akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n;
long long arr[300010],sum,sum_1,sum1[300010],sum2[300010],sum3[300010],sum4[300010];
multiset<long long> s1,s2,s3,s4;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=3*n;i++)
    {
        cin>>arr[i];
        if(i<=n)
        {
            s1.insert(arr[i]);
            s2.insert(-arr[i]);
            sum+=arr[i];
            sum_1+=arr[i];
            sum1[i]=sum;
            sum2[i]=sum_1;
        }
    }
    multiset<long long>::iterator it1,it2;
    for(int i=n+1;i<=2*n;i++)
    {
        //cout<<i<<" "<<arr[i]<<" "<<*s1.begin()<<"\n";
        it1=s1.lower_bound(arr[i]);
        it2=s2.lower_bound(-arr[i]);
        if(it1!=s1.begin())
        {
            sum-=(*s1.begin());
            sum+=arr[i];
            s1.erase(s1.begin());
            s1.insert(arr[i]);
            //cout<<i<<" "<<sum1[i]<<"\n";
        }
            sum1[i]=sum;
        if(it2!=s2.begin())
        {
            sum_1+=(*s2.begin());
            sum_1+=arr[i];
            s2.erase(s2.begin());
            s2.insert(-arr[i]);
        }
            sum2[i]=sum_1;
    }
    sum=sum_1=0;
    for(int i=3*n;i>=2*n+1;i--)
    {
        if(i>=2*n+1)
        {
            s3.insert(arr[i]);
            s4.insert(-arr[i]);
            sum+=arr[i];
            sum_1+=arr[i];
            sum3[i]=sum;
            sum4[i]=sum_1;

        }
    }
    for(int i=2*n;i>=n+1;i--)
    {
        it1=s3.lower_bound(arr[i]);
        it2=s4.lower_bound(-arr[i]);
        //cout<<*it1<<" " <<*it2<<"\n";
        if(it1!=s3.begin())
        {
            sum-=(*s3.begin());
            sum+=arr[i];
            s3.erase(s3.begin());
            s3.insert(arr[i]);
        }
            sum3[i]=sum;
        if(it2!=s4.begin())
        {
            sum_1+=(*s4.begin());
            sum_1+=arr[i];
            s4.erase(s4.begin());
            s4.insert(-arr[i]);
        }
            sum4[i]=sum_1;
        //cout<<i<<" "<<sum4[i]<<"\n";
    }
    //cout<<"\n";
    long long mx=-1e18;
    for(int i=n;i<=2*n;i++)
    {
        //cout<<sum1[i]<<" "<<sum4[i+1]<<"\n";
        mx=max(mx,max(sum1[i]-sum4[i+1],sum2[i]-sum3[i+1]));
    }
    cout<<mx;
    return 0;
}


Measured memory_bytes: 29952
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N, X, T;
	cin >> N >> X >> T;
	
	cout << T*(((N-1)/X)+1) << endl;
}


Measured memory_bytes: 3620
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>
#include <numeric>

#define FOR(i, s, e) for(long i = s; i < e; ++i)

using namespace std;

template <typename T>
using TABLE = vector<vector<T>>;

using LONG = long long;
using LVEC = vector<long long>;

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;


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

    vector<bool> passed(N + 1, false);
    vector<bool> valid(N, false);
    LONG P;

    passed[0] = true;

    FOR(i, 0, N){
        cin >> P;

        if(passed[P-1]){
            valid[P-1] = true;
        }

        passed[P] = true;
    }

    LONG longest = 0;
    LONG count = 1;

    FOR(i, 1, N){
        if(valid[i]){
            ++count;
        }
        else{
            if(count > longest){
                longest = count;
            }
            count = 1;
        }
    }

    longest = max(longest, count);

    cout << N - longest;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int>> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define ri(a) scanf("%d", &a)
#define rii(a,b) scanf("%d %d", &a, &b)
#define riii(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define rl(a) scanf("%lld", &a)
#define rll(a,b) scanf("%lld %lld", &a, &b)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second

const int INF = 0x3f3f3f3f;
const ll LLINF = 1e18;
const int maxN = 1e5; // CAMBIAR ESTE

// GJNM

int main(){
	int n,k;
	rii(n,k);
	priority_queue<int> pq;
	FOR(i,0,n){
		int aux;
		ri(aux);
		if ( pq.size() < k )
			pq.push(aux);
		else{
			if ( pq.top() > aux ){
				pq.pop();
				pq.push(aux);
			}
		}
	}
	int tot = 0;
	while(!pq.empty()){
		tot += pq.top();
		pq.pop();
	}
	printf("%d\n", tot);
	return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
//using Graph = vector<vector<int>>;


const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
ll gcd(ll a,ll b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
ll lcm(ll a,ll b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}









int main() {
 ll n;
 cin >> n;
 ll a[n+1];
 rep (i,n){
   cin >> a[i];
 }
 ll ans = 0;
 rep (i,n-1){
   if (a[i+1]-a[i]<=0){
     ans += abs(a[i+1]-a[i]);
     a[i+1] = a[i];
   }
 }
 cout << ans << endl;
}


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

using namespace std;

int main(void)
{
  int a,b,c,d;

  cin>>a>>b>>c>>d;

  while(1)
  {
    c-=b;
    a-=d;

    if(c<=0)
    {
      cout<<"Yes"<<endl;
      break;
    }

    if(a<=0)
    {
      cout<<"No"<<endl;
      break;
    }
  }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
string s,t;
int N;
int main(){
	cin >> N;
	cin >> s;
	cin >> t;
	for(int i=0;i<N;i++){
		bool flag = true;
		for(int j=0;j<N-i;j++){
			if(s[i+j]!=t[j]){
				flag = false;
				break;
			}
		}
		if(flag){
			cout << 2*N-(N-i) << endl;
			return 0;
		}
	}
	cout << 2*N << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int w = sc.nextInt();

        if (s > w) {
            System.out.println("safe");
        } else {
            System.out.println("unsafe");
        }

        sc.close();
    }
}


Measured memory_bytes: 35564
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
using namespace std;


int prime[101];
int n;

int func(int k)
{
	int tot = 0;
	for (int i = 1; i <= n; i++)
		if (prime[i] >= k - 1)tot++;
	return tot;
}

int main()
{
	
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int r = i;
		for (int j = 2; j*j <= r; j++) {
			while (r%j == 0) {
				prime[j]++;
				r /= j;
			}
		}
		if (r > 1)prime[r]++;
	}
	int ans = 0;
	ans += func(75) + func(25)*(func(3) - 1) + func(15)*(func(5) - 1) + func(5)*(func(5) - 1)*(func(3) - 2) / 2;
	cout << ans;
	
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
//#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

int dp[5005][5005];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, ans = 0;
  string S;
  cin >> N >> S;

  for (int i = N - 1; i >= 0; i--) {
    for (int j = i + 1; j < N; j++) {
      if (S[i] == S[j]) {
        dp[i][j] = dp[i + 1][j + 1] + 1;
        ans = max(ans, min(dp[i][j], j - i));
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 96768
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1000000007, INF = 1e9;

int main()
{
    int n, k;
    cin >> n >> k;
    if(n >= 10){
        cout << k << endl;
    }
    else{
        cout << k+(100*(10-n)) << endl;
    }
    system("pause");
}

Measured memory_bytes: 504
#include <iostream>
#include <cstdint>

using namespace std;

template<typename T>
class BinTree {
private:
    struct Node {
        T val;
        Node *parent;
        Node *left;
        Node *right;
    };

    Node *root;

    void inner_print_inorder(Node *x) {
        if (x == NULL) return;

        inner_print_inorder(x->left);
        cout << " " << x->val;
        inner_print_inorder(x->right);

        return;
    }

    void inner_print_preorder(Node *x) {
        if (x == NULL) return;

        cout << " " << x->val;
        inner_print_preorder(x->left);
        inner_print_preorder(x->right);

        return;
    }

public:
    BinTree() {
        root = NULL;
    }

    void insert(T val) {
        Node *z = new Node;
        z->val = val;
        z->parent = NULL;
        z->left = NULL;
        z->right = NULL;

        Node *y = NULL;
        Node *x = root;
        while (x != NULL) {
            y = x;
            if (val < x->val) {
                x = x->left;
            } else {
                x = x->right;
            }
        }
        z->parent = y;

        if (y == NULL) {
            root = z;
        } else if (z->val < y->val) {
            y->left = z;
        } else {
            y->right = z;
        }
    }

    void print_inorder() {
        inner_print_inorder(root);
        cout << endl;
    }

    void print_preorder() {
        inner_print_preorder(root);
        cout << endl;
    }
};

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

    BinTree<int32_t> bt;
    for (int32_t i = 0; i < n; i++) {
        string command;
        cin >> command;

        if (command == "insert") {
            int32_t val;
            cin >> val;
            bt.insert(val);
        } else if (command == "print") {
            bt.print_inorder();
            bt.print_preorder();
        }
    }

    return 0;
}

Measured memory_bytes: 26584
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N = 0;
  int digit,d = 0;
  
  cin >> N;
  
  for (int i = 1 ; i < 100000000; i *= 10) {
    if (i > N)
      break;
    d += N % (10 * i) / i;
    }
  if (N / d * d == N){
  cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  ll n,a,b;
  cin>>n>>a>>b;
  if(a>b or (n==1 and a!=b)){
    cout<<0<<endl;
  }
  else{
    cout<<a+b*(n-1)-(a*(n-1)+b)+1<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(i, e) cerr << #i << ' ' << i << e
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
#else
#define DE(...) 0
void debug(...) {}
#endif
const int maxn = 300010, p = 1e9+7;
ll dp[maxn];
void add(ll &v, ll val) {
	v += val - p;
	v += (v>>63) & p;
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int s;
	cin >> s;
	dp[0] = 1;
	for (int i = 0;i <= s;++i) {
		for (int j = i+3;j <= s;++j)
			add(dp[j], dp[i]);
	}
	cout << dp[s] << '\n';
}



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

int main(){
    ll A,B,C,K;
    cin>>A>>B>>C>>K;
    ll ma=max(max(A,B),C);
    ll ans=A+B+C-ma;
    rep(i,0,K){
        ma*=2;
    }
    ans+=ma;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  string s; cin >> s;
  int n = sz(s);

  ll ans = 0;
  Vll v(1);
  rep(i, n) {
    if (s[i] == 'A') ++v.back();
    else if (s.substr(i, 2) == "BC") {
      v.push_back(0);
      ++i;
    }
    else {
      int k = sz(v);
      rep(j, k) ans += v[j] * (k-1-j);
      v.clear();
      v.push_back(0);
    }
  }

  int k = sz(v);
  rep(j, k) ans += v[j] * (k-1-j);

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4304
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL gcd(LL n,LL m){
  if (n < m)
  {
    return gcd(m, n);
  }
  if(m==0){
    return n;
  }
  return gcd(m, n % m);
}

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

  int T;
  cin >> T;
  REP(heoge,T){
    LL A, B, C, D;
    cin >> A >> B >> C >> D;

    {
    LL ok = 0;
    LL ng = A / B + 1;

    while(abs(ok-ng)>1){
      LL mid = (ok + ng) / 2;
      if(A-mid*B>C){
        ok = mid;
      }
      else
      {
        ng = mid;
      }
    }

    A = A-ok*B;
    }

    if(A-B<0){
      cout << "No" << endl;
      continue;
    }
    if(-B+D<0){
      cout << "No" << endl;
      continue;
    }

    LL g = gcd(D, B);

    {
      LL ok = 0;
      LL ng = A / g + 1;

      while (abs(ok - ng) > 1)
      {
        LL mid = (ok + ng) / 2;
        if (A - mid * g > C)
        {
          ok = mid;
        }
        else
        {
          ng = mid;
        }
      }

      A = A - ok * g;
    }

    if(A-B>=0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }


  }
}

/*

A-g-g-g-g>C

37hon

9hon kau

12hon tuika




*/


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

void run (void) {
  i32 a, b;
  scanf ("%" SCNi32 "%" SCNi32, &a, &b);
  if (a == b) {
    printf ("%" PRIi32 "\n", 2 * a);
  } else {
    i32 x = a > b ? a : b;
    printf ("%" PRIi32 "\n", 2 * x - 1);
  }
}

int main (void) {
  run ();
  return 0;
}

Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;
use std::cmp::{max, min};

fn read<T: FromStr> () -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let mut A: Vec<usize> = vec![0; N+2];
    let mut B: Vec<usize> = vec![0; N+1];

    for i in 0..(N+1) {
        A[i] = read();
    }

    for i in 0..N {
        B[i] = read();
    }

    let mut ans = 0;
    for i in 0..N {
        let killed = std::cmp::min(A[i], B[i]);
        ans += killed;
        B[i] -= killed;

        let killed = std::cmp::min(A[i+1], B[i]);
        A[i+1] -= killed;
        ans += killed;
    }
    println!("{}", ans);
}



Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s1,s2;cin>>s1>>s2;
    reverse(s2.begin(),s2.end());
    bool key=true;
    for(int i=0;i<3;i++){
        if(s1[i]!=s2[i]){
            key = false;
        }
    }
    if(key){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}

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

int a,b,c,d,e;//KはくまでX円でNはくする

int main(){

	cin>>a>>b>>c>>d>>e;
	if(a==0)	cout<< 1<<endl;
	if(b==0)	cout<< 2<<endl;
	if(c==0)	cout<< 3<<endl;
	if(d==0)	cout<< 4<<endl;
	if(e==0)	cout<< 5<<endl;

	return 0;

	}

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

int main() {
    int N;

    cin >> N;
    int tmp;
    int flg = 0;
    for (int i = 1; i <= N; i++){
        for (int j = 0; j < 26; j++){
            for (int k = 0; k < 16; k++){
                tmp = 4 * j + 7 * k;
                if (tmp == N){
                    flg = 1;
                }
            }
        }
    }

    string ans;
    if (flg){
        ans = "Yes";
    } else{
        ans = "No";
    }

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

Measured memory_bytes: 888
#include <cstdio>
#include <iostream>
#include <vector>
#include <ctype.h>
#include <algorithm>
#define mp make_pair
#define fir first
#define sec second

using namespace std;

typedef long long LL;
typedef pair<LL, LL> pll;

const int MAXN = 2e5 + 7;
const int MOD = 1000000007 ; 

inline int read() {
	int res = 0, flag = 1; char in = getchar();
	while(!isdigit(in)) { if(in == '-') flag = -1; in = getchar(); }
	while(isdigit(in)) { res = (res << 1) + (res << 3) + in - '0'; in = getchar(); }
	return res * flag;
}

inline void chkmax(int &a, int b) { if(a < b) a = b; }
inline void chkmin(int &a, int b) { if(a > b) a = b; }

inline LL fpm(int x, int y) {
	LL res = 1;
	while(y) {
		if(y & 1) res = 1ll * res * x % MOD;
		x = 1ll * x * x % MOD;
		y >>= 1;
	}
	return res;
}

vector<int> G[MAXN];
vector<pll> dp[MAXN];

int n, fa[MAXN];
int lc[MAXN], id[MAXN], tot;
int dep[MAXN], cnt[MAXN];
LL zro[MAXN], all[MAXN], one[MAXN];
LL ans;

void dfs(int u) {
	int son = n + 1;
	int len = G[u].size();
	for(int i = 0; i < len; ++i) {
		int v = G[u][i];
		dfs(v);
		if(lc[v] > lc[son]) son = v;
	}
	if(son != n + 1) id[u] = id[son], lc[u] = lc[son] + 1;
	else id[u] = ++tot;

	dp[id[u]].push_back(mp(1ll, 1ll));
	if (G[u].size() == 1) return ;

	for(int i = 0; i <= lc[u]; ++i)
		all[i] = zro[i] = 1, one[i] = 0;
	
	for(int t = 0; t < len; ++t) {
		int v = G[u][t];
		for(int i = 0; i <= lc[v]; ++i) {
			int cur = lc[son] - lc[v] + i;
			pll st = dp[id[v]][i];
			(all[cur] *= (st.fir + st.sec) % MOD) %= MOD;
			(zro[cur] *= st.fir) %= MOD;
		}
	}

	for(int t = 0; t < len; ++t) {
		int v = G[u][t];
		for(int i = 0; i <= lc[v]; ++i) {
			int cur = lc[son] - lc[v] + i;
			pll st = dp[id[v]][i];
			(one[cur] += zro[cur] * fpm(st.fir, MOD - 2) % MOD 
				* st.sec % MOD) %= MOD;
		}
	}
	for(int i = 0; i < lc[u]; ++i) {
		dp[id[u]][i].fir = (all[i] - one[i] + MOD) % MOD;
		dp[id[u]][i].sec = one[i];
	}
}

inline void solve() {
	n = read();
	for(int i = 1; i <= n; ++i) {
		G[fa[i] = read()].push_back(i);
		dep[i] = dep[fa[i]] + 1;
		++cnt[dep[i]];
	}
	lc[n + 1] = -MAXN;
	++cnt[0];
	dfs(0);
	for(int i = 0; i <= lc[0]; ++i) {
		pll st = dp[id[0]][i];
		(ans += st.sec * fpm(2, n + 1 - cnt[lc[0] - i]) % MOD) %= MOD;
	}
	cout << ans << endl;
}

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


Measured memory_bytes: 52724
#include <iostream>
#include <algorithm>
#include<functional>
#include<stdio.h>
#include<stdlib.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
int main() {
	int n;
	float sum = 0;
	cin >> n;
	float a[120];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		sum = sum + float(1 / a[i]);
	}
	cout << float(1 / sum);
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll H;
  cin >> H;
  ll cnt = 0;
  while (H >= 1) {
    H = H / 2;
    cnt++;
  }
  ll ans = pow((ll)(2),cnt) - 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main () {
	long long int N;
	long long int sum=0;
	scanf("%lld",&N);
	for(int i=1;i<=N;i++) {
		if(i%15==0) {
		continue;
		} else if(i%5==0) {
		continue;
		} else if(i%3==0) {
		continue;
		}
	sum+=i;
}
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 1728
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
            for (int j = Math.max(i - k, 0); j <= i - 1; j++) {
                dp[i] = Math.min(dp[i], dp[j] + Math.abs(h[i] - h[j]));
            }
        }
        System.out.println(dp[n - 1]);
    }

}


Measured memory_bytes: 59656
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;
int f(int b, int n){
    if(n<b)return n;
    int ans=f(b,n/b)+n%b;
    return ans;
}

int32_t main(){
	ios::sync_with_stdio(false);
    int n, s;
    cin>>n>>s;
    // for(int i=2;i<=100;i++){
    //     cout<<i<<" "<<f(i,n)<<"\n";
    // }
    
    if(s>n){
        cout<<-1<<"\n";
            return 0;
    }
    if(s==n){
        cout<<(n+1)<<"\n";
            return 0;
    }
  
    for(int i=2;i*i<=n;i++){

        if(f(i,n)==s){
            cout<<i<<"\n";
            return 0;
        }
    }
    int res=-1;
    for(int i=1;i*i<=(n-s);i++){
        if((n-s)%i==0){
            if(f(i+1,n)==s){
                // cout<<(i+1)<<"\n";
                // return 0;
                // res=min(res,i+1);
                if(res==-1 || res>(i+1)){
                    res=i+1;
                }
            }
            if(f(((n-s)/i)+1,n)==s){
                // cout<<(((n-s)/i)+1)<<"\n";
                // return 0;
                // res=min(res,((n-s)/i)+1);
                if(res==-1 || res>((n-s)/i)+1){
                    res=((n-s)/i)+1;
                }  
            }
        }
        
    }
  
    cout<<res<<"\n";


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
string a[110];
int n,l;
int main()
{
    cin>>n>>l;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++)cout<<a[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

def dp(now) :
    if int(now) > N :
        return 0
    count = 0
    if all(x in now for x in ['7', '5', '3']) :
        count += 1
    for x in ['7', '5', '3'] :
        count += dp(now + x)
    return count

ans = dp('0')
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<set>
using ll =  long long;

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

using namespace std;

int main(){

    string s;
    cin >> s;
    int cnt=0;
    rep(i,s.size()){
        if(s[i]=='1')
            cnt+=1;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(b==1) return a;else if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    LL(n,x,m);
    ll ans=0;
    if(n<=10000000){
    for(int i=0;i<n;i++){
        ans+=x;
        x=(x*x)%m;
    }
    out(ans);
    }else{
        vector<ll> syuuki;
        umap<ll,ll> Map;
        ll cycle,T,kaisuu,made;
        for(int i=0;i<n;i++){
            if(!Map.count(x)){
                syuuki.push_back(x);
                Map[x]=i;
                x=(x*x)%m;
            }else{
                cycle=x;
                break;
            }
        }
        ll start=Map[cycle];
        n-=start;
        for(int i=0;i<start;i++){
            ans+=syuuki[i];
        }
        T=syuuki.size()-Map[cycle];
        kaisuu=n/T;
        made=n%T+start;
        for(int i=start;i<syuuki.size();i++){
            ans+=((i<made)+kaisuu)*syuuki[i];
        }
        out(ans);
    }
}

Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
int n, num[100007], f[100007];
vector<int>e[100007];
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int dfs(int w, int fa)
{
	if (e[w].size() == 1)
	{
		f[w] = num[w];
		return 0;
	}
	long long tot = 0, mx = 0;
	for (int i = e[w].size() - 1; i >= 0; i--)
		if (e[w][i] != fa)
		{
			dfs(e[w][i], w);
			tot += f[e[w][i]];
			mx = max(mx, 1LL * f[e[w][i]]);
		}
	f[w] = min(tot / 2, tot - mx);
	if (tot < num[w]) { cout << "NO" << endl; exit(0); }
	if (tot - f[w] > num[w]) { cout << "NO" << endl; exit(0); }
	f[w] = tot - (tot - num[w]) * 2;
	return 0;
}
int main()
{
	n = read();
	for (int i = 1; i <= n; i++)
		num[i] = read();
	for (int i = 1; i < n; i++)
	{
		int a = read(), b = read();
		e[a].push_back(b);
		e[b].push_back(a);
	}
	if (n == 2)
	{
		if (num[1] == num[2])cout << "YES" << endl;
		else cout << "NO" << endl;
		return 0;
	}
	for (int i = 1; i <= n; i++)
		if (e[i].size() > 1)
		{
			dfs(i, 0);
			if (f[i])cout << "NO" << endl;
			else cout << "YES" << endl;
			break;
		}
	return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol n; cin >> n;
    //int k; cin >> k;
    vector<int> a(n);
    REP(i, n)
    {
        cin >> a[i];
    }
    REP(i, n)
    {
        if(i % 2 == 0 && a[i]%2 == 1)
            result++;
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(void) {
	int k, cnt=0;
	scanf("%d", &k);
	for (int i=0;i<=k;i++) {
		for (int j=i+1;j<k;j++) {
			if ((i%2==0&&j%2==1)||(i%2==1&&j%2==0)) {
				cnt++;
			}
		}
	}
	printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  string s;
  cin >> s;
  ll n=s.size();
  if(n==2) cout << s << endl;
  else {
    reverse(s.begin(),s.end());
    cout << s << endl;
  }
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}
int main()
{
    int A, N;
    cin >> N;
    cin >> A;

    cout << N * N - A << endl;

}

Measured memory_bytes: 256
//ラウンドロビンスケジューリング
using System;
using System.Collections.Generic;

namespace tst
{
    class Program
    {
        public static void Main()
        {
            //命令数
            int n = int.Parse(Console.ReadLine());
            //編集用リスト
            LinkedList<string> dt = new LinkedList<string>();
            //deleteをfirst-lastするときの目印
            int last = 0;
            for (int i = 0; i < n; i++)
            {
                //入力読み込み
                string text = Console.ReadLine();
                string[] C = text.Split(' ');
                string command = C[0];
                //コマンドによる条件分岐
                switch (command)
                {
                    case "insert":
                        dt.AddFirst(C[1]);
                        break;
                    case "delete":
                        dt.Remove(C[1]);
                        break;
                    case "deleteFirst":
                        dt.RemoveFirst();
                        break;
                    case "deleteLast":
                        dt.RemoveLast();
                        break;
                }
            }
            //linkedlistの列挙操作
            Console.WriteLine(string.Join(" ", dt));
     
        }

    }
}


Measured memory_bytes: 123704
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	for (int i = 0; i < n; i++)
		cin >> p[i];
	
	sort(p.begin(), p.end());
	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += p[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3612
def p_fact(n):
  m=n
  i=2
  a=[]
  while n>1:
    if i>m**.5:
      a+=[n]
      break
    if n%i==0:
      n//=i
      a+=[i]
    else:i+=1
  return a
a=p_fact(int(input()))
d={}
for i in a:
  if d.get(i):d[i]+=1
  else:d[i]=1
ans=0
for i in d:
  j=1
  while d[i]-j>=0:
    ans+=1
    d[i]-=j
    j+=1
print(ans)

Measured memory_bytes: 64116
h, w, k = map(int, input().split())
dp = [0] * w
mod = 10 ** 9 + 7

dp[0] = 1
for i in range(h):
    next = [0] * w
    for bit in range(1 << w - 1):
        ok = True
        for j in range(w - 2):
            if bit >> j & 1 and bit >> j + 1 & 1:
                ok = False
        if ok:
            moved = [False] * w
            for j in range(w):
                if bit >> j & 1:
                    next[j + 1] += dp[j]
                    next[j] += dp[j + 1]
                    moved[j] = moved[j + 1] = True
                elif not moved[j]:
                    next[j] += dp[j]
    dp = next
print(dp[k - 1] % mod)


Measured memory_bytes: 9128
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>

using namespace std;

int main(void)
{
	string S;
	int count;

	cin >> S;

	// 01010... と 10101...のどちらの方が近いかを
	count = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '0') {
			if (i % 2 != 0) {
				count++;
			}
		}
		else {
			if (i % 2 != 1) {
				count++;
			}
		}
	}

	if (count >= S.size() / 2.0) {
		count = S.size() - count;
	}

	cout << count << endl;
	

	return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python3

n = int(input())
s = input()
k = int(input())

S = []
for i in s:
    S.append(i)

ta = S[k-1]
    
for i in range(n):
    if S[i] == ta:
        print(S[i],end = "")

    else:
        print("*",end = "")
        


Measured memory_bytes: 3060
#include <iostream>
#include<vector>
#include <stdlib.h>
using namespace std;

int chmin(int a,int b)
{
    int mi=min(a,b);
    return mi;
}



int main(void){
    // Your code here!
    int N;  cin>>N;
    
    vector<int> h(N);
    for(int i=0;i<N;i++)    cin>>h[i];
    vector<int> cost(N,2147483647);  //全部のコストをinfで初期化
    
    cost[0]=0;  //スタート地点のコストは0
    cost[1]=abs(h[0]-h[1]);   //1番目の最小コストは確定してる
    
    for(int i=2;i<N;i++)
    {
        cost[i]=chmin(cost[i],cost[i-1]+abs(h[i]-h[i-1]));
        cost[i]=chmin(cost[i],cost[i-2]+abs(h[i]-h[i-2]));
    }
    
    cout<<cost[N-1];
    
    
    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		HashMap<Integer, ArrayList<Integer>> es = new HashMap<>();
		char[] s = new char[n+1];
		int[] degA = new int[n+1];
		int[] degB = new int[n+1];
		String str = sc.next();
		for(int i=1; i<=n; i++) es.put(i, new ArrayList<>());
		for(int i=1; i<=n; i++) {
			s[i] = str.charAt(i-1);
		}
		for(int _i=0; _i<m; _i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			es.get(a).add(b);
			es.get(b).add(a);
			if(s[a]=='A') {
				degA[b]++;
			} else {
				degB[b]++;
			}
			if(s[b]=='A') {
				degA[a]++;
			} else {
				degB[a]++;
			}
		}
		ArrayDeque<Integer> q = new ArrayDeque<>();
		boolean[] removed = new boolean[n+1];
		for(int i=1; i<=n; i++) {
			if(degA[i]<1||degB[i]<1) {
				q.add(i);
				removed[i] = true;
			}
		}
		while(!q.isEmpty()) {
			int v = q.poll();
			for(int next : es.get(v)) {
				if(s[v]=='A') {
					degA[next]--;
				} else {
					degB[next]--;
				}
				if(degA[next]<1||degB[next]<1) {
					if(!removed[next]) {
						q.add(next);
						removed[next] = true;
					}
				}
			}
		}
		for(int i=1; i<=n; i++) {
			if(!removed[i]) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
 	}

	static void printArray(int[] a) {
		int n=a.length;
		for(int i=0; i<n; i++) {
			if(i==0) System.out.print(a[i]);
			else System.out.print(" "+a[i]);
		}
		System.out.println();
	}

	static class MyScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public MyScanner(InputStream s) 
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next() throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
			
		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 99716
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

void b_countABC(void) {
	int n;
	string s;
	cin >> n >> s;
	int cnt = 0;
	string target = "ABC";
	for (int i = 0; i < n - 2; i++) {
		string sub = s.substr(i, 3);
		if (sub == target) cnt++;
	}

	cout << cnt << endl;
}

int main()
{
    b_countABC();

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int m1 = 0, i1 = 0;
    rep(i,n) {
        cin >> a[i];
        if (max(m1,a[i]) != m1) {
            i1 = i;
            m1 = a[i];
        }
    }
    a[i1] = 0;
    int m2 = 0;
    rep(i,n) {
        m2 = max(m2,a[i]);
    }
    rep(i,n) {
        if (i == i1) cout << m2 << endl;
        else cout << m1 << endl;
    }
    return 0;
}



Measured memory_bytes: 3972
def warshall_floyd(V, E):
    INF = 10 ** 9
    d = [[0 for _ in range(V + 1)]] + [[0] + [INF for j in range(V)] for i in range(V)]
    for i in range(V + 1):
        d[i][i] = 0
    for i, j in E:
        d[i][j] = 1
        d[j][i] = 1
    for k in range(1, V + 1):
        for i in range(1, V):
            for j in range(i, V + 1):
                dk = d[i][k] + d[k][j]
                if d[i][j] > dk:
                    d[i][j] = dk
                    d[j][i] = dk
    return d


h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
n = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            n += 1
            s[i][j] = n
        else:
            s[i][j] = 0


E = []
for i in range(h):
    for j in range(w):
        p = s[i][j]
        if p > 0:
            if j < w - 1:
                p1 = s[i][j + 1]
                if p1 > 0:
                    E.append([p, p1])
            if i < h - 1:
                p2 = s[i + 1][j]
                if p2 > 0:
                    E.append([p, p2])

ans = 0
INF = 10 ** 9
D = warshall_floyd(n, E)
ans = max(list(map(max, D)))
print(ans)


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

using namespace std;

typedef long long ll;
const int MAX = 100005;
const int MOD = 1000000007;

#define F first
#define S second


void solve()
{
	ll a,b,c,d,e;
	cin>>a>>b>>c>>d;
	a--;
	e=c*d/__gcd(c,d);
	ll x=a/c+a/d-a/e;
	ll y=b/c+b/d-b/e;
	ll ans=b-a-(y-x);
	cout<<ans<<endl;
	return;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 256
mod = 10**9+7
fac = [1, 1]
finv = [1, 1]
inv = [0, 1]


def init(n):
    for i in range(2, n + 1):
        fac.append(fac[-1] * i % mod)
        inv.append(-inv[mod % i] * (mod // i) % mod)
        finv.append(finv[-1] * inv[-1] % mod)


def com(n, k, mod):
    if n < 0 or k < 0 or n < k:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


X, Y = map(int, input().split())

if not (X+Y) % 3 == 0:
    print(0)
else:
    n = (Y - 2 * X) // -3
    m = X - (2 * n)
    if n < 0 or m < 0:
        print(0)
    else:
        init(n + m)
        print(com(n + m, n, mod))


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

int main(){
    int s,w;
    cin >> s >> w;
    if(w>=s) cout << "unsafe" << endl;
    else cout << "safe" << endl; 
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<stdlib.h> 
#include<cstring>
#include<map>
#include<list>
#include<stdio.h>
#include<cmath>
#include<iomanip>
#include<bitset>
#include<vector>
#include<time.h>
#include<algorithm> 
#include<queue>
#include<set>
#include<deque>
#define mod 1e9+7
#define inf 1e18 
typedef long long ll;
typedef long double ld;
using namespace std;
typedef list<ll> li;
typedef list<ll>::iterator lt;
li sh_r;
ll N,s;
vector<li>a;
bool dfs(ll step,ll x,ll f){
	if(x>N)cout<<f<<" "<<x<<endl;
	if(x==N){
	  s=step;
	  return true;
    }
	for(lt it=a[x].begin();it!=a[x].end();it++){
		if(*it==f)continue;
		if(dfs(step+1,*it,x)){
			sh_r.push_back(x);
			return true;
		}
	}
	return false;
}
ll num(ll x,ll f){
	ll n=1;
	for(lt it=a[x].begin();it!=a[x].end();it++){
		if(*it==f)continue;
		n+=num(*it,x);
	}
	return n;
}
int main(){	
    cin>>N;
    a.resize(N+10);
    for(ll K=1;K<N;K++){
    	ll x,y;
    	scanf("%lld%lld",&x,&y);
    	a[x].push_back(y);
    	a[y].push_back(x);
	}
	dfs(0,1,-1);
	s--;
	ll F=1,S=N;
	if(N!=2){
		ll j=s/2;
		for(lt it=sh_r.begin();it!=sh_r.end();it++){
			j--;
			if(j==0)S=*it;
			if(j==-1){
				F=*it;
				break;
			}
		}
	}
	ll Fen=num(F,S);
	ll Snu=num(S,F);
	if(Fen>Snu)printf("Fennec");
	else printf("Snuke");
	return 0;
}

Measured memory_bytes: 17536