akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;

int main()
{
ll h , w , a ;
cin >> h >> w >> a ;
ll b ;
cin >> b ;
rep(i,b){
  rep(j,a)cout << '1';
  rep(j,w-a)cout << '0';
  cout << endl;
}
rep(i,h-b){
  rep(j,a)cout << '0';
  rep(j,w-a)cout << '1';
  cout << endl;

}
return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN = 2 * 1e5 + 5;
int a[MAXN],b[MAXN];
const long long MOD = 1e9 + 7;
vector<pair<int, int> > v;
vector<pair<int, int> > cnts[4];
long long fac[MAXN], rfac[MAXN];
long long p2(long long a, long long p)
{
  if(p == 0)
    return 1ll;
  long long ans = p2(a , p/2);
  ans = (ans * ans) % MOD;
  if(p%2)
    ans = (ans * a) % MOD;
  return ans;
}
long long C(long long n , long long r)
{
  if(r > n) return 0;
  return (((fac[n] * rfac[n - r]) % MOD) * rfac[r]) % MOD;
}

int main()
{
  int n;
  cin >> n ;
  for(int i = 0;i < n;i ++)
  {
    cin >> a[i];
    v.push_back(make_pair(a[i], 1));
  }
  for(int i = 0;i < n;i ++)
  {
    cin >> b[i];
    v.push_back(make_pair(b[i], 2));
  }
  sort(v.begin(), v.end());

  int cnt1 = 0 , cnt2 = 0;
  long long ans = 1;


  for(int i = 0;i < (int)v.size();i ++)
  {
    if(cnt1 == 0 && cnt2 == 0)
    {
      if(v[i].second == 1) cnt1 ++;
      if(v[i].second == 2) cnt2 ++;
    }
    else if(cnt1 > 0 && v[i].second == 1)
      cnt1 ++;
    else if(cnt2 > 0 && v[i].second == 2)
      cnt2 ++;
    else if(cnt1 > 0)
    {
      ans = (ans * cnt1) % MOD;
      cnt1 --;
    }
    else if(cnt2 > 0)
    {
      ans = (ans * cnt2) % MOD;
      cnt2 --;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2932
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

#include<unistd.h>
struct Buffer{
    int idx;
    enum { chunk = 1 << 16 };
    char buf[chunk];
    Buffer(){ init(); }
    void init(){ idx = 0; read(0, buf, chunk); }
    void check(){ if(idx == chunk){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0, sign = 1;
        while(check(), notDigits[(int)buf[idx]]){ idx++; }
        if(check(), buf[idx] == '-'){ sign = -1; idx++; }
        while(check(), !notDigits[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        return sign * ret;
    }
};

string ans;
void out(int num){
    if(!num){
        // putchar('0');
        ans += '0';
        return;
    }
    char buf[16];
    int idx = 0;
    while(num){
        auto ret = div(num, 10);
        buf[idx] = ret.rem + '0';
        num = ret.quot;
        idx++;
    }
    for(int i = idx - 1; i >= 0; i--){
        // putchar(buf[i]);
        ans += buf[i];
    }
}

int main(){
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    Buffer buf;
    const int lim = 1e5;
    vector<char> prime(lim + 1, true);
    prime[0] = prime[1] = false;
    for(int i = 2; i <= lim; i++){
        if(prime[i]){
            for(int j = i + i; j <= lim; j += i){
                prime[j] = false;
            }
        }
    }
    vector<int> accs(lim + 1);
    for(int i = 1; i <= lim; i++){
        accs[i] = accs[i - 1] + (i & 1 && prime[i] && prime[(i + 1) / 2]);
    }
    // int q; cin >> q;
    int q = buf.next();
    // stringstream ss;
    for(int i = 0; i < q; i++){
        // int l, r;
        // cin >> l >> r;
        int l = buf.next(), r = buf.next();
        // cout << accs[r] - accs[l - 1] << '\n';
        // ss << accs[r] - accs[l - 1] << '\n';
        out(accs[r] - accs[l - 1]);
        // putchar('\n');
        ans += '\n';
    }
    // cout << ss.str();
    cout << ans;
}


Measured memory_bytes: 1668
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int n,k;
	char s[11],sp[11];
	char tmp;
	
	scanf("%d",&n);
	scanf("%s",&s);
	scanf("%d",&k);
	
	tmp = s[k-1];
	
	for(int i=0;i<n;i++){
		if(tmp != s[i]) sp[i] = '*';
		else sp[i] = s[i];
	}
	
	sp[n] = '\0';
	
	printf("%s\n",sp);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	 
	vector<vector<int>> denList;

	for (int i = 0; i < M; i++)
	{
		int conCnt;
		cin >> conCnt;

		vector<int> conList;
		for (int j = 0; j < conCnt; j++)
		{
			int con;
			cin >> con;
			conList.push_back(con-=1);	
		}

		denList.push_back(conList);
	}

	vector<int> p;
	for (int i = 0; i < M; i++)
	{
		int pIn;
		cin >> pIn;
		p.push_back(pIn);
	}

	int ans = 0;
	for (int i = 0; i < (1 << N); i++)
	{
		bool result = true;

		for (int j = 0; j < denList.size(); j++)
		{
			int cnt = 0;
			vector<int> cons =  denList[j];
			for (int n: cons)
			{
				if ((i >> n) & 1)
				{
					cnt++;
				}
			}

			if (cnt % 2 != p[j])
			{
				result = false;
			}
		}

		if (result)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
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;}

string s,t;
inline void solve(){
  IN2(s,t);
  sort(ALL(s));
  sort(RALL(t));
  OUT(s<t?"Yes":"No");
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    int n, m;
    cin >> n >> m;
    vector<int> A(n);
    copy_n(istream_iterator<int>(cin), n, A.begin());
    vector<int64_t> csum(n + 1);
    for (int i = 0; i < n; i++)
        csum[i + 1] = csum[i] + A[i];
    
    const double INF = 1e18;
    auto dp = vector<vector<double>>(n + 1, vector<double>(n + 1, -INF));
    dp[0][n] = 0;
    
    for (int i = 0; i < n; i++){
        for (int j = 0; j <= n; j++){
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + A[i]);
            for (int k = 1; k <= n; k++){
                if (j - k + 1 < 0)
                    continue;
                if (i + k > n)
                    continue;
                dp[i + k][j - k + 1] = max(dp[i + k][j - k + 1], dp[i][j] + double(csum[i + k] - csum[i]) / k);
            }
        }
    }

    double ans = 0;
    for (int i = 0; i <= m; i++)
        ans = max(ans, dp[n][i]);

    cout << ans << endl;
}


Measured memory_bytes: 4996
#n=int(input())
#n,k=map(int, input().split())
#a=[[0]*n for _ in range(3)]
n,we=map(int,input().split())
w=[0]*n
v=[0]*n
for i in range(n):
  w[i],v[i]=map(int,input().split())
dp=[[0]*(n+1) for _ in range(we+1)]
for i in range(1,we+1):
  for j in range(1,n+1):
    if(w[j-1]<=i):
    	dp[i][j]=max(v[j-1]+dp[i-w[j-1]][j-1],dp[i][j-1])
    else:
      dp[i][j]=dp[i][j-1]
print(dp[-1][-1])

Measured memory_bytes: 163240
require "prime"
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
ans=0
N.times do
    ans+=1 if Prime.prime?(gets.to_i)
end
puts ans


Measured memory_bytes: 7040
#include <iostream>

using namespace std;

int main(){
    int s;
    cin >> s;
    
    int h = s / (60 * 60);
    int m = s % (60 * 60) / 60;
    s = s % 60;
    
    cout << h << ":" << m << ":" << s << "\n";
    return 0;
}


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

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;

#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define int long long
#define sz(v) (int)v.size()
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define f(i,l,r) for(long long i=l;i<=r;i++)
#define rf(i,r,l) for(long long i=r;i>=l;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }


const int N=1e5+5,mod=1e9+7,bit=61;

template<typename T>
class dsu
{
	public:
		vector<T> par,sz;
		ll n;
		dsu(ll n_)
		{
			n=n_;
			par.resize(n+1);
			sz.resize(n+1);
			for(int i=0;i<=n;i++)
			{
				par[i]=i;
				sz[i]=1;
			}
		}
		T getp(T x)
		{
			while(par[x]!=x)
			{
				par[x]=par[par[x]];
				x=par[x];
			}
			return x;
		}
		void merge(T a,T b)
		{
			T p1=getp(a),p2=getp(b);
			if(p1==p2)
			{
				return;
			}
			if(sz[p2]>sz[p1])
			{
				swap(p1,p2);
			}
			par[p2]=p1;
			sz[p1]+=sz[p2];
			sz[p2]=0;
		}
};

signed main()
{
    fast;

    int t=1;
    //cin>>t;
    f(tc,1,t)
    {
        int n,m;
        cin>>n>>m;
        dsu<int> obj(n);
        f(i,1,m)
        {
            int u,v;
            cin>>u>>v;
            obj.merge(u,v);
        }
        set<int> ms;
        int ans=0;
        f(i,1,n)
        {
            ans=max(ans,obj.sz[i]);
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 6364
#include<iostream>
using namespace std;
int main () {
	int a, b, d;
	char o;
	cin >> a >> o >> b;
	while (o !='?') {
		if (o == '+') {
			d = a + b;
		} 
		else if (o == '-') {
			d = a - b;
		}
		else if (o == '*') {
			d = a * b;
		}
		else if ((o == '/') && (a > 0) && (b > 0)) {
			d = a / b;
		} 
		else if ((o == '/') && ((a == 0) || (b == 0))) {
			d = 0;
		}
		cout << d << endl;
		cin >> a >> o >> b;
	}
	return 0;
}


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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> X(N), Y(N);
    rep(i, N) {
        cin >> X[i];
        Y[i] = X[i];
    }
    sort(Y.begin(), Y.end());
    rep(i, N) {
        if (X[i] < Y[N / 2]) {
            cout << Y[N / 2] << "\n";
        } else {
            cout << Y[N / 2 - 1] << "\n";
        }
    }
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int d[7005];
struct did{
	int num,val;
}a[3005];
bool cmp(did x,did y){
	if(x.num==y.num) return x.val>y.val;
	return x.num<y.num;
}
int main(){
	int n,t,ans=0;
	cin>>n>>t;
	for(int i=1;i<=n;i++){
		cin>>a[i].num>>a[i].val;
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++){
		for(int j=t-1;j>=0;j--){
			d[j+a[i].num]=max(d[j+a[i].num],d[j]+a[i].val);
		}
	}
	for(int i=0;i<=3000;i++){
		ans=max(ans,d[t+i]);
	}
	cout<<ans<<endl;
}

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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#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 sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef long double ld;
const ll inf = (ll)1e18;
const int N = (int)2e5+77;
const ll mod = (ll)1e9+7;

int main() {
    fast;
    ll x, y, a = 0;
    cin >> x >> y;
    while (x <= y) x *= 2, a++;
    cout << a << endl;
    return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, x;
  std::cin >> n >> x;
  std::vector<int64_t> s(n);
  std::cin >> s;
  std::sort(s.begin(), s.end(), std::greater<int64_t>());

  constexpr int64_t mod = 1000000007;

  std::vector<int64_t> t1(100001, 0), t2(100001, 0);

  t1[x] = 1;

  for (int64_t i = 0; i < n; i++) {
    std::fill(t2.begin(), t2.end(), 0);
    for (int64_t j = 0; j < 100001; j++) {
      t2[j % s[i]] += t1[j] % mod;
      t2[j % s[i]] %= mod;
      t2[j] += t1[j] * (n - i - 1);
      t2[j] %= mod;
    }
    std::swap(t1, t2);
  }

  int64_t ans = 0;

  for (int64_t j = 0; j < 100001; j++) {
    ans += j * t1[j] % mod;
    ans %= mod;
  }

  std::cout << ans << std::endl;

  return 0;
}

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

int main() {
    int N; cin >> N;
    map<int64_t, int64_t> mp;
    for(int i = 0; i < N; ++i) {
        int a; cin >> a;
        mp[a]++;
    }
    int64_t ans = 0;
    for(auto &[key, val] : mp) ans += (key * val);
    int Q; cin >> Q;
    while(Q--) {
        int64_t b, c;
        cin >> b >> c;
        ans -= b * mp[b];
        ans += c * mp[b];
        mp[c] += mp[b];
        mp[b] = 0;
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 9520
{
  const run = (input: string) => {
    const split = input.trim().split("\n")
    const [x, n] = split[0].split(" ").map(v => parseInt(v))
    if (n === 0) return x
    const list = split[1].split(" ").map(v => parseInt(v));

    list.sort((a: number, b: number) => a - b);

    let result = 0
    let diff = x

    for (let i = 0; i < 100; i++) {
      if (list.every(v => v != i)) {
        const tmpDiff = Math.abs(x - i)
        if (diff > tmpDiff || (diff === tmpDiff && result > i)) {
          diff = tmpDiff
          result = i
        }
      }
    }

    const tmpDiff = Math.abs(x - 101)
    if (diff > tmpDiff) {
      return 101
    }

    return result
  }

  const Main = (input: string) => {
    console.log(run(input))
  };

  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}


Measured memory_bytes: 29652
#include <stdio.h>

int s[20];
int n = 0;

int
solve(int i, int x)
{
	if (x == 0)
		return 1;
	if (i >= n || x < 0)
		return 0;
	return solve(i + 1, x) | solve(i + 1, x - s[i]);
}

int
main(int argc, char **argv)
{
	int i, q, a;

	scanf("%d", &n);

	for (i = 0; i < n; i++)
		scanf("%d", s + i);

	scanf("%d", &q);

	for (i = 0; i < q; i++) {
		scanf("%d", &a);
		printf("%s\n", solve(-1, a) ? "yes" : "no");
	}

	return 0;
}



Measured memory_bytes: 2044
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const double PI=3.14159265358979323846;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vint a(n);
  map<int,int> count;
  rep(i,n){
    cin>>a[i];
    count[a[i]]++;
  }
  ll sum=0;
  for(auto x:count){
    if(x.first>x.second){
      sum+=x.second;
    }
    else{
      sum+=x.second-x.first;
    }
  }
  cout<<sum<<'\n';
  return(0);
}


Measured memory_bytes: 8196
// B - Not Found
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	string S; cin>>S;
	vector<bool> A('z'-'a'+1, false);
	rp(i, 0, S.size()) A[S[i]-'a'] = true;
	rp(i, 0, A.size()){
		if(!A[i]){
			printf("%c\n", i+'a');
			return 0;
		}
	}
	puts("None");
}

Measured memory_bytes: 512
N,M=map(int,input().split())
tree=[[] for _ in range(N)]
for _ in range(M):
    u,v=map(int,input().split())
    tree[u-1].append(v-1)
S,T=map(int,input().split())
s=S-1
t=T-1
ischecked=[[0]*3 for _ in range(N)]
ischecked[s][0]=1
ans=-1
q=[]
q.append([s,0])
while q:
    v,c=q.pop(0)
    if v==t and c%3==0:
        ans=c//3
        break
    for i in tree[v]:
        if ischecked[i][(c+1)%3]==0:
            q.append([i,c+1])
            ischecked[i][(c+1)%3]=1
print(ans)


Measured memory_bytes: 28208
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string O,E,ans="";
  cin >> O;
  cin >> E;
  for(int i=1;i<=O.size()+E.size();i++)
  {
    if(i%2!=0)
    {
      ans.push_back(O.at(i/2));
    }
    else{
      ans.push_back(E.at(i/2-1));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int h = scanner.nextInt();
        final int w = scanner.nextInt();
        final int[][] table = new int[h][w];

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                table[i][j] = scanner.nextInt();
            }
        }

        final List<String> answers = new ArrayList<>();

        for (int i = 0; i < h; i++) {
            if (i % 2 == 0) {
                for (int j = 0; j < w; j++) {
                    if (i == h - 1 && j == w - 1) {
                        break;
                    }

                    if (table[i][j] % 2 == 0) {
                        continue;
                    }

                    if (j == w - 1) {
                        table[i][j]--;
                        table[i + 1][j]++;
                        answers.add((i + 1) + " " + (j + 1) + " " + (i + 2) + " " + (j + 1));
                        continue;
                    }

                    table[i][j]--;
                    table[i][j + 1]++;
                    answers.add((i + 1) + " " + (j + 1) + " " + (i + 1) + " " + (j + 2));
                }
            } else {
                for (int j = w - 1; j >= 0; j--) {
                    if (i == h - 1 && j == 0) {
                        break;
                    }

                    if (table[i][j] % 2 == 0) {
                        continue;
                    }

                    if (j == 0) {
                        table[i][j]--;
                        table[i + 1][j]++;
                        answers.add((i + 1) + " " + (j + 1) + " " + (i + 2) + " " + (j + 1));
                        continue;
                    }

                    table[i][j]--;
                    table[i][j - 1]++;
                    answers.add((i + 1) + " " + (j + 1) + " " + (i + 1) + " " + j);
                }
            }
        }

        System.out.println(answers.size());
        for (String answer : answers) {
            System.out.println(answer);
        }
    }

    static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

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


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

int main(){
    int N;  cin >> N;
    vector<ll> A(N), B(N);
    for(int i=0; i<N; i++) cin >> A[i] >> B[i];

    ll ans = 0;
    for(int i=N-1; i>=0; i--){
        ll red = (A[i]+ans)%B[i];
        if(red != 0){
            ans += B[i] - red;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b,c,k = LI()
    if k % 2 == 0:
        return a-b
    return b-a



print(main())



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

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

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

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

using namespace std;

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

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

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

    // Actual program code starts here.
    int N, M, C, ret = 0;
    cin >> N >> M >> C;
    VEC(int) A(M), B(M);
    READVEC(B);
    FOR(i, 0, N) {
        READVEC(A);
        int tot = C;
        FOR(i, 0, M)
            tot += A[i] * B[i];
        if (tot > 0)
            ret++;
    }

    cout << ret << endl;
    return 0;
};


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int s[305][305];
long long t[90005];
int x[100000],y[100000];
int main() {
    int n,m,d;
    scanf("%d%d%d",&n,&m,&d);
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++) {
            scanf("%d",&s[i][j]);
            x[s[i][j]]=i;
            y[s[i][j]]=j;
        }
    for(int i=n*m; i>=1; i--) {
        int j=i+d;
        if(j<=n*m) {
            t[i]=abs(x[i]-x[j])+abs(y[i]-y[j]);
        }
    }
    for(int i=n*m; i>=1; i--) {
        int j=i+d;
        if(j<=n*m)
            t[i]+=t[j];
    }
    int q;
    scanf("%d",&q);
    while(q--) {
        int a,b;
        scanf("%d%d",&a,&b);
        printf("%lld\n",t[a]-t[b]);
    }
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
ll power(ll b,ll e,ll m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}

bool isPrime(ll n)
{
  if(n==1) return 0;
  for(ll i=2;i*i<=n;i++)
    if(n%i==0)
      return 0;
  return 1;
}

vi adj[100001];
ll vis[100001];

void dfs(ll node)
{
  vis[node]=1;
  for(ll child:adj[node])
  {
    if(!vis[child])
    {
      vis[child]=1;
      dfs(child);
    }
  }
}

void solve()
{
  ll n,m;
  cin>>n>>m;
  rep(i,0,m)
  {
    ll a,b;
    cin>>a>>b;
    adj[a].pb(b);
    adj[b].pb(a);
  }
  ll ans=0;
  rep(i,1,n+1)
  {
    if(!vis[i])
    {
      ans++;
      vis[i]=1;
      dfs(i);
    }
  }
  cout<<ans-1;
}

int main()
{
  ll tt=1;
  // cin>>tt;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
}

Measured memory_bytes: 10996
read a
read b
cnt=0
a1=`echo $a | cut -c 1`
a2=`echo $a | cut -c 2`
a3=`echo $a | cut -c 3`
b1=`echo $b | cut -c 1`
b2=`echo $b | cut -c 2`
b3=`echo $b | cut -c 3`


if [ $a1 = $b1 ];then
 cnt=$((cnt+1))
fi

if [ $a2 = $b2 ];then
 cnt=$((cnt+1))
fi

if [ $a3 = $b3 ];then
 cnt=$((cnt+1))
fi

echo $cnt

Measured memory_bytes: 816
from collections import deque

N = int(input())
A = list(map(int,input().split()))
if 0 in A:
    print(0)
    exit();

A = deque(A)

if N%2 == 1:
    ans_right = A.pop()
else:
    ans_right = 1

ans_left = 1

for i in range(N//2):
    right = A.pop()
    left = A.popleft()
    
    ans_right = ans_right * right
    ans_left = ans_left * left

    if ans_right > 10**18 or ans_left> 10**18 or ans_left*ans_right> 10**18:
        print(-1)
        exit()


else:
    print(ans_right*ans_left)


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

using namespace std ;

#define N  100010

int n , L , m ;
int a[ N ] , to[ N ] ;
int num , block , belong[ N ] ; 
int nxt[ N ] , val[ N ] ;

int find( int x ) {
    int l = x + 1 , r = n , ans = 0 ;
    while( l <= r ) {
        int mid = ( l + r ) >> 1 ;
        if( a[ mid ] - a[ x ] <= L ) l = mid + 1 , ans = mid ;
        else r = mid - 1 ;
    }
    return ans ;
}

int main() {
    scanf( "%d" , &n ) ;
    for( int i = 1 ; i <= n ; i ++ ) {
        scanf( "%d" , &a[ i ] ) ;
    }
    sort( a + 1 , a + n + 1 ) ;
    scanf( "%d%d" , &L , &m ) ;
    for( int i = 1 ; i < n ; i ++ ) {
        to[ i ] = find( i ) ;
    }
    to[ n ] = n + 1 ;
    block = sqrt( n ) ;
    num = n / block ;
    if( n % block ) num ++ ;
    for( int i = 1 ; i <= n ; i ++ ) {
        belong[ i ] = ( i - 1 ) / block + 1 ;
    }
    for( int i = 1 ; i < n ; i ++ ) {
        int t = i , sp = 0 ;
        while( belong[ t ] == belong[ i ] ) {
            t=to[ t ] ;
            sp ++ ;
        }
        val[ i ] = sp ;
        nxt[ i ] = t ;
        if( i >= block * ( num - 1 ) + 1 ) val[ i ] -- , nxt[ i ] -- ;
    }
    for( int i = 1 ; i <= m ; i ++ ) {
        int x , y  , ans = 0 ;
        scanf( "%d%d" , &x ,&y ) ;
        if( x > y )swap( x , y ) ;
        while( belong[ x ] < belong[ y ] ) {
            ans += val[ x ] ;
            x = nxt[ x ] ;
        }
        while( x < y ) {
            x = to[ x ] ;
            ans ++ ;    
        } 
        printf( "%d\n" , ans  ) ;
    }
    return 0 ;
} 


Measured memory_bytes: 2816
mod = 10**9+7

def comb(n, r):
  p, q = 1, 1
  for i in range(r):
    p = p * (n-i) % mod
    q = q * (i+1) % mod
  return p * pow(q, mod-2, mod) % mod

x, y = map(int, input().split())
m = abs(x - y)
n = (x + y) // 3
if (x + y) % 3 == 0 and n >= m:
  print(comb(n, (n - m) // 2))
else:
  print(0)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	long long a, b, c, ans = 0, d, e, f;
	cin >> a >> b >> c;
  if(a==1&&b==1&&c==1){
    cout<<"0"<<endl;
    return 0;
  }
	if (a == b&&b == c) {
		cout << "-1" << endl;
		return 0;
	}
	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
		d = (b + c) / 2;
		e = (a + c) / 2;
		f = (a + b) / 2;
		a = d;
		b = e;
		c = f;
		ans++;
	}
	cout << ans << endl;
}


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

int n;
vector<string> s;
string ans;

bool dfs(int a, int b, int c, int i) {
    if(i == n) {
        return true;
    }
    if(s[i] == "AB") {
        if(a > 0) {
            if(dfs(a - 1, b + 1, c, i + 1)) {
                ans = "B" + ans;
                return true;
            }
        }
        if(b > 0) {
            if(dfs(a + 1, b - 1, c, i + 1)) {
                ans = "A" + ans;
                return true;
            }
        }
    } else if(s[i] == "BC") {
        if(b > 0) {
            if(dfs(a, b - 1, c + 1, i + 1)) {
                ans = "C" + ans;
                return true;
            }
        }
        if(c > 0) {
            if(dfs(a, b + 1, c - 1, i + 1)) {
                ans = "B" + ans;
                return true;
            }
        }
    } else {
        if(a > 0) {
            if(dfs(a - 1, b, c + 1, i + 1)) {
                ans = "C" + ans;
                return true;
            }
        }
        if(c > 0) {
            if(dfs(a + 1, b, c - 1, i + 1)) {
                ans = "A" + ans;
                return true;
            }
        }
    }

    return false;
}

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

    s = vector<string>(n);
    for(int i = 0; i < n; i++) {
        cin >> s[i];
    }

    bool f = dfs(a, b, c, 0);
    if(f) {
        cout << "Yes" << endl;
        for(int i = 0; i < ans.length(); i++) {
            cout << ans[i] << endl;
        }
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 16092
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if (A == 0 || B == 0 || (A < 0 && B > 0)) {
      System.out.println("Zero");
    } else if ((A > 0 && B > 0) || ((B-A+1)%2 == 0)) {
      System.out.println("Positive");              
    } else {
      System.out.println("Negative");
    }
  }
}

Measured memory_bytes: 23380
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
 
const ll MOD = 1000000007;
 
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}
 
#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif


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

    ll n;

    cin >> n;
    vector<ll> ans(n,0);

    for(ll x=1; x*x<n; x++){
        for(ll y=1; y*y<n; y++){
            for(ll z=1; z*z<n; z++){
                ll a = x*x+y*y+z*z+x*y+y*z+z*x;
                if(a<=n){
                    ans[a-1]++;
                }
            }
        }
    }
    
    for(ll i=0;i<n; i++){
        cout << ans[i] << endl;
    }
 
    return 0;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 100000000000007LL
#define ll long long
using namespace std;
vector<int> nex[114514];
int col[114514];
int od[114514],ev[114514],act[114514];
signed main(){
	ll n,m;
	cin>>n>>m;
	vector<int> a,b,c;
	map< pair<ll,ll>, ll > mope;
	for(ll i=0;i<m;i++){
		ll x,y,z;
		cin>>x>>y>>z;
		a.pb(x);b.pb(y);c.pb(z);
		nex[x].pb(y);
		nex[y].pb(x);
		mope[ mp(x,y) ] = z;
		mope[ mp(y,x) ] = z;
	}
	for(int i=1;i<=n;i++){
		od[i] = LINF;
		ev[i] = LINF;
		act[i] = LINF;
	}
	bool nib = true;
	col[1]=1;
	queue<int> que;
	que.push(1);
	while(!que.empty()){
		int cur = que.front();que.pop();
		for(int i=0;i<nex[cur].size();i++){
			int nx = nex[cur][i];
			if( col[nx] == 0){
				col[nx] = 3 - col[cur];
				que.push(nx);
			}
			else if(col[cur] + col[nx] != 3){
				nib = false;
			}
		}
	}
	if(nib == false){
		ev[1] = 0;
		que.push(1);
		int stval=0;
		while(!que.empty()){
			int cur = que.front();que.pop();
			for(int i=0;i<nex[cur].size();i++){
				int nx = nex[cur][i];
				bool update = false;
				if( od[cur] != LINF && ev[nx] == LINF){
					ev[nx] = mope[mp(cur,nx)] - od[cur];
					update = true;
				}
				if( ev[cur] != LINF && od[nx] == LINF){
					od[nx] = mope[mp(cur,nx)] - ev[cur];
					update = true;
				}
				if(update)que.push(nx);
			}
			if( od[1] != LINF && ev[1] != LINF){
				stval = od[1]+ev[1];
				break;
			}
		}
		while(!que.empty()){que.pop();}
		if( abs(stval) % 2 == 1){
			cout<<0<<endl;
			return 0;
		}
		else{
			stval /= 2;
			act[1] = stval;
			que.push( 1 );
			while(!que.empty()){
				int cur = que.front();que.pop();
				for(int i=0;i<nex[cur].size();i++){
					int nx = nex[cur][i];
					if(act[nx] == LINF){
						act[nx] = mope[mp(cur,nx)]-act[cur];
						que.push( nx );
					}
				}
			}
			for(int i=1;i<=n;i++){
				if(act[i]<=0){
					cout<<0<<endl;
					return 0;
				}
			}
			for(int i=0;i<m;i++){
				if( act[a[i]]+act[b[i]] != c[i] ){
					cout<<0<<endl;
					return 0;
				}
			}
			cout<<1<<endl;
			return 0;
		}
	}
	else{ //nib
		act[1] = 0;
		que.push(1);
		while(!que.empty()){
			int cur = que.front();que.pop();
			for(int i=0;i<nex[cur].size();i++){
				int nx = nex[cur][i];
				int val = mope[mp(cur,nx)]-act[cur];
				if( act[nx] == LINF){
					act[nx] = val;
					que.push(nx);
				}
				else if( act[nx] != val ){
					cout<<0<<endl;
					return 0;
				}
			}
		}
		int mi = 1, ma = inf; // written on v1
		for(int i=1;i<=n;i++){
			if(col[i] == 1){
				mi = max( mi, 1 - act[i] );
			}
			else{
				ma = min( ma, act[i] - 1);
			}
		}
		cout<< max( 0LL , ma-mi+1 ) <<endl;
	}
	return 0;
}

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

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  ll ans=a[0];
  for(ll i=1;i<n;i++) {
    ans=gcd(ans,a[i]);
  }
  cout << ans << endl;
}

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

#define INF int(1e9)
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=300005;
int n,tot,sum;
int a[maxn];

bool check(int x){
	int cur=a[1];
	for(int i=2;i<=n;i+=2){
		if(cur>=x)cur=max(cur+a[i+1]-a[i],a[i+1]);
		else cur+=a[i+1]-a[i];
	}
	return cur>=x;
}

int main(){
	scanf("%d",&n);
	REP(i,n){
		scanf("%d",&a[i]);
		tot+=a[i];
		sum+=(i&1)?a[i]:-a[i];
	}
	if(!(n&1)){
		int sum1=(tot+sum)/2,sum2=(tot-sum)/2;
		printf("%d %d\n",max(sum1,sum2),min(sum1,sum2));
		return 0;
	}
	int l=0,r=tot+1;
	while(r-l>1){
		int mid=l+r>>1;
		if(check(mid))l=mid;
		else r=mid;
	}
	int sum1=max((tot+sum)/2,(tot-sum+2*l)/2),sum2=tot-sum1;
	printf("%d %d\n",sum1,sum2);
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>


using namespace std;


int main()
{
    int N;
    string S;

    cin >> N >> S;


    int x = 0;
    int len = S.length();
    int ans = 0;

    for( int i = 0; i < len; ++i ){
        if( S.c_str()[i] == 'I' ) ++x;
        else --x;
        if( ans < x ) ans = x;
    }


    cout << ans << endl;


    return 0;
}

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

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

    map<int, int> cnt;
    for(int i = 2; i <= n; ++i) {
        int ti = i;
        for(int j = 2; j * j <= ti; ++j) {
            if(ti % j != 0) continue;
            int c = 0;
            while(ti % j == 0) {
                c += 1;
                ti /= j;
            }
            cnt[j] += c;
        }
        if(ti > 1) {
            cnt[ti] += 1;
        }
    }

    int ans = 0;
    for(auto& p1 : cnt) {
        ans += p1.second >= 74;
        for(auto& p2 : cnt) {
            if(p1.first == p2.first) continue;
            ans += (p1.second >= 24 && p2.second >= 2);
            ans += (p1.second >= 14 && p2.second >= 4);
            for(auto& p3 : cnt) {
                if(p1.first == p3.first || p2.first == p3.first) continue;
                if(p2.first >= p3.first) continue;
                ans += p1.second >= 2 && p2.second >= 4 && p3.second >= 4;
            }
        }
    }

    cout << ans << endl;
}


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



int main() {

    string s; cin >> s;
    reverse(s.begin(), s.end());

    vector<string> x = {"dream","dreamer","erase","eraser"};
    for(int i = 0; i < 4; i++) reverse(x[i].begin(), x[i].end());

    while(s.size() != 0) {

        string tmp;
        tmp = s.substr(0,5);

        if(tmp == x[0]) {

            s.erase(0,5);
        
        } else if (tmp == x[2]) {

            s.erase(0,5);
        
        } else {

            tmp = s.substr(0,6);

            if(tmp == x[3]) {

                s.erase(0,6);         

            } else {
            
                tmp = s.substr(0,7);
            
                if(tmp == x[1]) {
            
                    s.erase(0,7);
            
                } else {
                    break;
                }
            }
        }
    }
    if(s.size() > 0) cout << "NO" << endl;
    else cout << "YES" << endl;

    return 0;
}





Measured memory_bytes: 3756
N = int(input())
pList = list(map(int, input().split()))

ans = 0
for i in range(1, N-1):
    if pList[i-1] < pList[i] < pList[i+1] or pList[i-1] > pList[i] > pList[i+1]:
        ans += 1

print(ans)

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

int main(){
  int N,b=0;
  cin>>N;
  for (int i=0;i<N;i++){
    char a;
    cin>>a;
    if (a=='Y'){
      b++;
    }
  }
  if (b>=1){
    cout<<"Four"<<endl;
  }
  else {
    cout<<"Three"<<endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	char c;
	int i, cnt[26] = {0};
	while((c = getchar()) != EOF){
		if((c >= 'A') && (c <= 'Z')){
			cnt[c - 'A']++;
		}
		if((c >= 'a') && (c <= 'z')){
			cnt[c - 'a']++;
		}
	}
	for(i = 0; i < 26; i++){
		printf("%c : %d\n",'a' + i, cnt[i]);
	}
	return 0;
}

Measured memory_bytes: 1760
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
    priority_queue<int> pq;
    string command;
    int x;
    
    while (cin >> command && command != "end") {
        if (command == "extract") {
            cout << pq.top() << endl;
            pq.pop();
        } else {
            cin >> x;
            pq.push(x);
        }
    }
}


Measured memory_bytes: 6920
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back
#define vs vector<string>

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll N;
    cin>>N;
    vl A(N);
    ll countfu=0;
    rep(i,N){
        cin>>A[i];
        if(A[i]<0) countfu++;
        A[i]=abs(A[i]);
    }
    sort(all(A));
    ll sum=0;
    if(countfu%2==0){
        rep(i,N) sum+=A[i];
        cout<<sum<<endl;
    }else{
        rep(i,N-1) sum+=A[i+1];
        cout<<sum-A[0]<<endl;
    }
}

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

int main() {
    int N;
    cin >>N;
    int count=0;
    vector<int>data(N);
    for (int i=1;i<=N;i++){
        cin >> data.at(i-1);
        if(data.at(i-1) != i){
            count++;
        }
    }
    if(count <=2)cout <<"YES"<<endl;
    else cout << "NO" <<endl;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ll INF = ll(1e18)+1;

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

    ll N,K;
    cin >> N >> K;

    vector<ll> warp(N);
    rep(i,N) cin >> warp[i];

    vector<ll> back_count_vec(N,-1);
    ll count = 0;
    ll start_count = 0;
    ll start_position = 0;
    ll position = 0;
    bool flag = true;
    back_count_vec[0] = 0;
    while (flag){
        count++;
        position = warp[position] - 1;
        if(back_count_vec[position] == -1){
            back_count_vec[position] = count;
        }
        else{
            start_count = back_count_vec[position];
            start_position = position;
            count -= start_count;
            flag = false;
        }
    }

    // cout << count << "\n";

    if(K < start_count){
        ll result = 0;
        rep(i,K){
            result = warp[result] - 1;
        }
        cout << result +1;
    }
    else{
        ll kai = (K - start_count) % count;
        ll result = start_position;
        rep(i,kai){
            result = warp[result] - 1;
        }
        cout << result +1;
    }
}

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

using namespace std;

int c[5][5],s;

int main()
{
    for (int i = 1; i <= 3; i++)
        for (int j = 1; j <= 3; j++)
        {
            cin >> c[i][j];
            s+=c[i][j];
        }
    if (s==3*(c[1][2]+c[2][3]+c[3][1])) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N >> K;
    REP(i, N) {
        cin >> H;
        if (H >= K)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636