akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }


ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * x % mod;
            x = x * x % mod;
            n >>= 1;
    }
    return res;
}

void solve() {
    string s;
    cin >> s;
    int N = s.size();
    vector<ll> accA(N + 1), accC(N + 1), accH(N + 1);
    for (int i = 0; i < N; i++) {
        accA[i + 1] = accA[i] + (s[i] == 'A');
        accH[i + 1] = accH[i] + (s[i] == '?');
        accC[i + 1] = accC[i] + (s[i] == 'C');
    }
    ll ans = 0;
    const int mod = 1000000007;
    for(int j = 1; j < N - 1; j++) {
        if (s[j] != 'B' && s[j] != '?') continue;
        ll cntA = accA[j];
        ll cntC = accC[N] - accC[j + 1];
        ll cntHl = accH[j];
        ll cntHr = accH[N] - accH[j + 1];
        ll l = ((cntA * mod_pow(3, cntHl, mod)) % mod + (cntHl * mod_pow(3, cntHl - 1, mod)) % mod) % mod;
        ll r = ((cntC * mod_pow(3, cntHr, mod)) % mod + (cntHr * mod_pow(3, cntHr - 1, mod)) % mod) % mod;
        ans += l * r % mod;
        ans %= mod;
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 2896
#define _GLIBCXX_DEBUG
#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()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;


int main(){
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  ll x = min(a, min(b, min(c, min(d, e))));
  ll ans = (n-1) / x + 5;
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

vector<vector<int>>dp(30,vector<int>(50010,0));

signed main(){
  int N;cin>>N;
  vector<int> ans;
  REP(i,0,N){
    string S,T;cin>>S>>T;
    int s_size=S.size(),t_size=T.size();
    vector<vector<int>> dp(t_size+2,vector<int>(s_size+2));
    REP(i,1,t_size+1)REP(j,1,s_size+1){
      if(S.at(j-1)==T.at(i-1)){
        dp[i][j]=max(dp[i-1][j-1]+1,dp[i-1][j]);
      }
      else{
        dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
      }
    }
    // debug(dp)
    ans.push_back(dp[t_size][s_size]);
  }
  each(a,ans){
    print(a)
  }

}



Measured memory_bytes: 22404
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    cout << setprecision(15) << (double)(n - n / 2) / n << '\n';
    return 0;
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';
constexpr int INF = 1e9;

bool judge(const vector<int>& v, int x) {
    for (int y : v) {
        if (y < x) return false;
    }
    return true;
}

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

    int n, m, x;
    cin >> n >> m >> x;

    vector<int> c(n);
    vector< vector<int> > a(n, vector<int>(m));

    for (int i = 0; i < n; i++) {
        cin >> c[i];

        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    int ans = INF;
    for (int i = 0; i < (1 << n); i++) {
        vector<int> v(m, 0);
        int sum = 0;
        for (int j = 0; j < n; j++) {
            if (i >> j & 1) {
                sum += c[j];
                for (int k = 0; k < m; k++) {
                    v[k] += a[j][k];
                }
            }
        }
        
        if (judge(v, x)) ans = min(ans, sum);
    }

    cout << (ans >= INF ? -1 : ans) << newl;
    return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>
#include <string.h>

#define BUF_SIZE 10000
#define ARRAY_SIZE 1000

void print_array(int array[], int size){
  int i;

  for(i = 0; i < size; i++){
    if(i > 0) printf(" ");
    printf("%d", array[i]);
  }

  printf("\n");
  return;
}

void insersion_sort(int array[], int size)
{
  int i, j, v;

  for(i = 1; i < size; i++){
    v = array[i];
    j = i - 1;
    while((j >= 0) && (array[j] > v)){
      array[j+1] = array[j];
      j--;
    }
    array[j+1] = v;
    print_array(array, size);
  }

  return ;
}

int main(void)
{
  char buf[BUF_SIZE];
  char *ptr;
  int input_size;
  int array[ARRAY_SIZE];
  int i;

  fgets(buf, BUF_SIZE, stdin);
  sscanf(buf, "%d", &input_size);

  fgets(buf, BUF_SIZE, stdin);
  ptr = strtok(buf, " ");

  for(i = 0; i < input_size; i++){
    sscanf(ptr, "%d", &array[i]);
    ptr = strtok(NULL, " ");
  }

  print_array(array, input_size);
  insersion_sort(array, input_size);

  return 0;
}

Measured memory_bytes: 620
import math

def C(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

(N, K) = input().split()
N = int(N)
K = int(K)

for i in range(1, K+1):
    if N - K + 1 < i:
        A = 0
    else:
        A = C(N - K + 1, i) * C(K - 1, i - 1) % 1000000007
    print(A)


Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int MOD = 1e9 + 7;

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

vector<ll> d_S(100010, 1e18), d_G(100010, 1e18); // 頂点sからの最短距離
vector<vector<P>> S(100010), G(100010); // 頂点の行き先firstとコストsecond

//0-index
void dijkstra_S(int s) { //sから
	priority_queue<P, vector<P>, greater<P>> que;
	d_S[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d_S[v] < p.first) continue;
		for (int i = 0; i < S[v].size(); i++) {
			int e = S[v][i].first;
			if (d_S[e] > d_S[v] + S[v][i].second) {
				d_S[e] = d_S[v] + S[v][i].second;
				que.push(P(d_S[e], e));
			}
		}
	}
}

void dijkstra_G(int s) { //tから
	priority_queue<P, vector<P>, greater<P>> que;
	d_G[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d_G[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); i++) {
			int e = G[v][i].first;
			if (d_G[e] > d_G[v] + G[v][i].second) {
				d_G[e] = d_G[v] + G[v][i].second;
				que.push(P(d_G[e], e));
			}
		}
	}
}

int main() {
	int n, m, s, t; cin >> n >> m >> s >> t;
	int u, v, a, b;
	for (int i = 0; i < m; i++) {
		cin >> u >> v >> a >> b;
		u--, v--;
		S[u].push_back(P(v, a)); //円
		S[v].push_back(P(u, a));
		G[u].push_back(P(v, b)); //スヌーク
		G[v].push_back(P(u, b)); 
	}

	dijkstra_S(s-1);
	dijkstra_G(t-1);

	vector<ll> ans(n, 1e15);
	ll MIN = 1e18;
	for (int i = n - 1; i >= 0; i--) {
		MIN = min(MIN, d_S[i] + d_G[i]);
		ans[i] -= MIN;
	}
	for (int i = 0; i < n; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 19140
#include <stdio.h>
#define N 100

void swapper(int *a, int *b) {
    int tmp;

    tmp = *a;
    *a = *b;
    *b = tmp;
}

void printlist(int A[N], int n) {
    int i;

    for (i = 0; i < n; i++) {
        if (i == n - 1) {
            printf("%d\n", A[i]);
        } else {
            printf("%d ", A[i]);
        }
    }
}

int main(void) {
    int i;
    int n, flag = 1, A[N], count = 0;

    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);

    while (flag) {
        flag = 0;
        for (i = n - 1; i >= 1; i--) {
            if (A[i] < A[i - 1]) {
                swapper(&A[i], &A[i - 1]);
                flag = 1;
                count++;
            }
        }
    }
    printlist(A, n);
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define pb push_back
#define Ceil(a,b)              ((a)+(b)-1)/(b)
#define MrGAFs                 file();
#define rep(i,limits)          for(int i = 0;i<(limits);++i)
#define allr(v)                ((v).rbegin()), ((v).rend())
#define all(v)                 ((v).begin()), ((v).end())
#define endl                   "\n"
#define sz(v)	               ((int)((v).size()))
#define dep(x)		       cout << #x << " = " << x << endl ;
#define rt(v)                  return cout<<v,0;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int oo = INT_MAX;
const ll OO = LLONG_MAX;
using namespace std;
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dx1[] = { -1, 1, 0, 0 };
int dy1[] = { 0, 0, -1, 1 };

	//classes
        void file (){
      #ifndef ONLINE_JUDGE 
         freopen ("in.txt", "r", stdin);
   //     x = freopen ("out.txt", "w", stdout);
      #else
#endif
  ios_base::sync_with_stdio (false);
  cout.tie (NULL);
  cin.tie (NULL);
}
  /******Functions*********/
  
  /******Main Function*********/
int main (){
  MrGAFs
   int n , k ; 
  cin >> n >> k ;
   map <int , bool> mp ;
while ( k-- ) {
int num ;
cin >> num ;
while(num -- ){
	int nm ;
	cin >> nm;
mp[nm] =true;
}
}
  cout << n- mp.size() ;

}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int n,k; cin >>n>>k;
    vector<int> l(n); REP(i,n) cin >> l[i];

    sort(l.begin(), l.end(), greater<int>());

    int res = 0;
    for (int i = 0; i < k; i++) {
        res += l[i];
    }

    cout << res << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

ll N,X;

ll get(ll a, ll b) {
    ll t = (b-1)/a;
    if (t != 0) return 2*a*t+get(a,b-t*a);
    if (a == b) return a;
    return get(b,a);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> X;
    cout << N+get(X,N-X);
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	string S; cin >> S;
	S[3] = '8';
	cout << S << endl;


	return 0;

}


Measured memory_bytes: 256
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    V = string_to_int(inputs[0])
    N = len(V)
    V.sort(reverse=True)

    ret = V.pop()
    for v in reversed(V):
        ret = (ret + v) / 2
    return ret


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


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

int main() {
	int input,s1,s2,s3,answer;
    cin >> input;
    s1 = input / 100;
    s2 = (input % 100) / 10;
    s3 = (input % 100) % 10;
    answer = s1 + s2 + s3;
    cout << answer << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n;
	cin >> n;
	vector<int> a(n);
	vector<vector<int>> x(n),y(n);
	REP(i, n) {
		cin >> a[i];
		x[i].resize(a[i]);
		y[i].resize(a[i]);
		REP(j, a[i]) {
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}
	int t = 1 << n;
	int res = 0;
	REP(i, t) {
		int k = i;
		vector<int> tr(n, -1);
		int temp = 0;
		REP(j, n) {
			if (k % 2 == 1) {
				tr[j] = 1;
				temp++;
			} else {
				tr[j] = 0;
			}
			k /= 2;
		}
		k = i;
		bool flag = true;
		REP(j, n) {
			if (tr[j] == 1) {
				REP(k, a[j]) {
					if (tr[x[j][k]] != y[j][k]) {
						flag = false;
						break;
					}
				}
			}
		}
		if (flag) {
			chmax(res, temp);
		}
	}
	put(res);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int D[45];

int fibonach(int a){
  if (a==1 ||a==0){
    return D[a]=1;
  }
  if(D[a]!=-1){
    return D[a];
  }
  return D[a]=fibonach(a-1)+fibonach(a-2);
}

int main(){
  int i,j,k,n;


  for(i=0; i < 45 ;i++){
    D[i]=-1;

  }

  scanf("%d",&n);

  printf("%d",fibonach(n));
  printf("\n");
  return 0;
}




Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    string s;
    cin>>s;
    int x=1;
    rep(i,s.size()){
        if(i%2==0&&s[i]=='L') x=0;
        if(i%2==1&&s[i]=='R') x=0;
    }
    if(x) cout<<"Yes";
    else cout<<"No";
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

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

int dp[110][110][4]; // 0->UU 1->UR 2->RR 3->RU
int h,w;
const int MOD=1e5;

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

	while(true) {
	cin>>h>>w;
	if(h==0&&w==0) break;
	REP(i,h) dp[i][0][2]=1;
	REP(i,w) dp[0][i][0]=1;
	FOR(i,1,h) {
		FOR(j,1,w) {
			dp[i][j][0]=(dp[i][j-1][0]+dp[i][j-1][3])%MOD;
			dp[i][j][1]=dp[i-1][j][0];
			dp[i][j][2]=(dp[i-1][j][1]+dp[i-1][j][2])%MOD;
			dp[i][j][3]=dp[i][j-1][2];
		}
	}
	h--,w--;
	cout<<(dp[h][w][0]+dp[h][w][1]+dp[h][w][2]+dp[h][w][3])%MOD<<endl;
	}

	return 0;
}



Measured memory_bytes: 3208
using namespace std;
#include<string>
#include<cmath>
#include<list>
#include <map>
#include <unordered_map>
#include <set>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ml map<ll,ll>
#define pb push_back
#define mp make_pair
#define ppl pair<ll,ll>
#define F first
#define S second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
#define PI 3.141592654
const ll N = 1e9 + 7;
#include<iterator>
#define EPSILON numeric_limits<double>::epsilon()


vector<bool> visited;
vector<set<ll>> v;

void dfs(ll pnt, ll &c) {
	if (!visited[pnt]) {
		visited[pnt] = true;
		c++;
	}
	for (auto it : v[pnt]) {
		if (!visited[it])dfs(it, c);
	}
}




void solve() {
	ll n, m, ma = 0; cin >> n >> m;
	v.assign(n, set<ll>());
	visited.assign(n, false);
	ll a, b;
	fr(i, 0, m) {
		cin >> a >> b;
		v[a - 1].insert(b - 1);
		v[b - 1].insert(a - 1);
	}
	fr(i, 0, n) {
		ll c = 0;
		dfs(i, c);
		ma = max(ma, c);
	}
	cout << ma;
}






int main() {
	fio;
#ifndef ONLINE_JUDGE
	// for getting input
	freopen("input.txt", "r", stdin);
	//for writing output
	freopen("jout.txt", "w", stdout);
#endif

	ll t;
	if (1)
		t = 1;
	else
		cin >> t;
	while (t--) {
		//cout << "Case #" << h << ": ";
		solve();
		//h++;
		cout << '\n';
	}
	return 0;
}






Measured memory_bytes: 40524
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
using pii = pair<int,int>;
using ll = long long;

struct UnionFind
{
    vector<int> uni;

    UnionFind(int n): uni(n+1, -1) {}
    int root(int x) { return (uni[x] < 0 ? x : uni[x]=root(uni[x])); }
    bool same(int x, int y) { return (root(x) == root(y)); }
    bool unite(int x, int y)
    {
        x=root(x);  y=root(y);
        if (x == y) return (false);

        if (uni[y] < uni[x]) swap(x, y);
        uni[x] += uni[y];
        uni[y] = x;

        return (true);
    }
};

struct Edge
{
    int prev, to, cost;
    Edge() {}
    Edge(int a, int b, int c): prev(a), to(b), cost(c) {}
    bool operator < (const Edge &r) const {
        return cost < r.cost;
    }
};

int kruskal(Edge a[], int N)
{
    int sum = 0;
    UnionFind uf(N);

    sort(a, a+N);

    rep(i, N) {
        if (uf.unite(a[i].prev, a[i].to)) {
            sum += a[i].cost;
        }
    }

    return sum;
}

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

    int V, E;
    Edge a[100001];

    cin >> V >> E;

    rep(i, E) {
        int s ,t, c;
        cin >> s >> t >> c;
        a[i] = Edge(s, t, c);
    }

    outl(kruskal(a, E));
}




Measured memory_bytes: 4392
// Copyright 2020 yaito3014
#include <iostream>
#include <vector>
int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int K;
  cin >> K;
  string S;
  cin >> S;
  const int N = K + S.length();
  constexpr int kMod = 1000000007;
  auto modpow = [&](long long a, int b) {
  	long long r = 1;
  	for (; b > 0; b /= 2) {
  		if (b % 2) r = r * a % kMod;
  		a = a * a % kMod;
  	}
  	return r;
  };
  auto inv = [&](int a) { return modpow(a, kMod - 2); };
  vector<long long> fact(N + 1, 1);
  for (int i = 0; i < N; ++i) fact[i + 1] = fact[i] * (i + 1) % kMod;
  auto c = [&](int n, int r){
  	return fact[n] * inv(fact[n-r] * fact[r] % kMod) % kMod;
  };
  int ans = 0;
  for (int i = 0; i <= K; ++i) {
  	ans += modpow(26, i) * c(N-i-1, N-K-1) % kMod * modpow(25, K-i) % kMod;
  	ans %= kMod;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 19528
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define fast_io ios::sync_with_stdio(false);cin.tie(NULL);
#define input freopen("Test.txt","r",stdin)
#define output freopen("Output.txt","w",stdout);
#define what_is(x) cout<<#x<<" is "<<x<<endl;
#define F(i,a,b) for(int i = a; i < b; i++)
#define MAX(a,b,c) max(a,max(b,c))
#define MIN(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define inf 1000000000
const double pi = 3.141592653589793238460;
#define debug false
#define MAXN 100010
#define mod 1000000007

void solve()
{
	int n; cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	int cnt = 0;
	int c = 1;
	for(int i=0;i<n;i++)
	{
		if(arr[i]==c)
		{
			cnt++;
			c++;
		}
	}
	if(cnt==0)
		cout<<"-1"<<"\n";
	else cout<<(n-cnt)<<"\n";
	
}

int main()
{
     // input; // output; // if(debug){watch_is();}
    fast_io;
    solve();   
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

int main(){
    int n, d; cin >> n >> d;
    int r=n%(d*2+1);
    int ans=n/(d*2+1)+(r ? 1 : 0);
    cout << ans << endl;
    return 0;
}



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

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(a) (a).begin(),(a).end()
#define CHMIN(a, b) a = min((a),(b))
#define CHMAX(a, b) a = max((a),(b))
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main() {
    string n;
    cin >> n;
    auto ans = n[0] == n[2] ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool mp[100][100];
int w,h;

int dfs(int y,int x){
  int dx[]={0,0,1,-1};
  int dy[]={1,-1,0,0};
  
  int res=0;  
  for(int i=0;i<4;i++){
    int nx=x+dx[i],ny=y+dy[i];
    if(nx<0||ny<0||nx>=w||ny>=h||!mp[ny][nx])continue;
    mp[ny][nx]=0;
    res=max(res,dfs(ny,nx));
    mp[ny][nx]=1;
  }
  return res+1;
}

int main(){
  
  while(cin>>w,w){
    cin>>h;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++) cin>>mp[i][j];

    int ans=0;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	if(mp[i][j]) {
	  mp[i][j]=0;
	  ans=max(ans,dfs(i,j));
	  mp[i][j]=1;
	}
    cout <<ans<<endl;

  }
  return 0;
}

Measured memory_bytes: 1168
import collections
n,k = map(int,input().split())
a = list(map(int,input().split()))

a_cnt = collections.Counter(a)
#print(a_cnt)
a_sort = sorted(a_cnt.values(),reverse=True)
#print(a_sort)
#print(a_sort[k:])
print(sum(a_sort[k:]))


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

int main(){

    int num=0,a;
    std::vector<int> x;
    
    for(;;){
        cin >> a;
        if(a != 0){
            x.push_back(a);
            num++;
        }else{
            break;
        }
    }

    for(int i=0;i<num;i++){
        cout << "Case " << i+1 << ": " << x[i] << endl;
    }

}


Measured memory_bytes: 3268
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		c,i,j,k,n,m,x,y;
	char	a,b;
	string	A,B,ans;

	cin >> a >> b;

	for(i=0;i<b-'0';i++) A += a;
	for(i=0;i<a-'0';i++) B += b;

	ans = min(A,B);

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int X[101];

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

    for (int i=0;i<N;i++) {
        cin >> X[i];
    }
    int ans = 0;
    int tmp = 0;

    for (int i=0;i<N;i++) {
        tmp += X[i];
    }
    tmp = (int) ((double) tmp / N + 0.5);

    for (int i=0;i<N;i++) {
        ans += (X[i] - tmp)*(X[i] - tmp);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N;
        cin >> N;
        vector<ll> A(N);
        vector<ll> nibeki(N);
        map<ll, ll> cnt;
        rep(i, 0, N) {
            cin >> A[i];
            cnt[A[i]]++;
        }

        sort(all(A));
        for (int i = 0; i < N; ++i) {
            int sh = 0;
            for (; 1ll << sh <= A[i]; ++sh);
            nibeki[i] = 1ll << sh;
        }


        ll ans = 0ll;
        for (int i = N - 1; i >= 0; --i) {
            ll target = nibeki[i] - A[i];
            if (A[i] == target) {
                ll tmp = cnt[A[i]] / 2;
                cnt[A[i]] -= tmp * 2;
                ans += tmp;
            } else if (cnt[A[i]] > 0 && cnt[target] > 0) {
                cnt[A[i]]--;
                cnt[target]--;
                ans++;
            }
        }
        cout << ans << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 28920
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;
using ll = long long int;

// 行列ライブラリ
// Verified: TopCoder SRM 704 Div.2 (ModEquationEasy)
// 行列の積 と 累乗(繰り返し二乗法)

// Matrix Library Begin (C++11)

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

template <typename T>
void init_mat(Matrix<T> &A, int h, int w) {
    A.resize(h, vector<T>(w, 0));
}

template <typename T>
Matrix<T> calc_mat(Matrix<T> A, Matrix<T> B) {
    Matrix<T> C(A.size(), vector<T>(B[0].size()));
    for(int i=0; i<A.size(); i++) {
        for(int k=0; k<B.size(); k++) {
            for(int j=0; j<B[0].size(); j++) {
                C[i][j] += A[i][k] * B[k][j]; // modなし
                // C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD; // modあり
            }
        }
    }
    return C;
}

template <typename T>
Matrix<T> mat_pow(Matrix<T> A, ll n) {
    Matrix<T> B(A.size(), vector<T>(A.size()));
    for(int i=0; i<A.size(); i++) B[i][i] = 1;
    while(n > 0) {
        if(n & 1) B = calc_mat(B, A);
        A = calc_mat(A, A);
        n >>= 1;
    }
    return B;
}

// Matrix Library End

long double dp[30][150];

int main() {
    long long int N, M;
    while(1) {
        cin >> N >> M;
        if(N + M == 0) break;

        fill(dp[0], dp[30], 0.0);
        dp[0][0] = 1;

        for(int i=0; i<N; i++) {
            for(int j=0; j<=6*N; j++) {
                for(int k=1; k<=6; k++) {
                    if(j + k <= 120) dp[i+1][j+k] += dp[i][j] / 6.0;
                }
            }
        }

        long double e = 3.5 * N;
        ll X = (ll)floor(e);
        M--;

        while(M > 0) {
            Matrix<long double> mat;
            init_mat(mat, 2, 2);

            long double A = 1, B = 0;
            for(int i=X+1; i<=6*N; i++) {
                A -= dp[N][i];
                B += dp[N][i] * i;
            }

            mat[0] = {A, B};
            mat[1] = {0, 1};

            ll lb = 0, ub = M;
            while(ub - lb > 1) {
                ll mid = (ub + lb) / 2;
                Matrix<long double> P = mat_pow(mat, mid);

                double tmp = P[0][0] * e + P[0][1];
                if(X + 1 < tmp) ub = mid;
                else lb = mid;
            }

            Matrix<long double> P = mat_pow(mat, ub);
            e = P[0][0] * e + P[0][1];

            M -= ub;
            X = (ll)floor(e);
        }
        printf("%.12Lf\n", e);
    }
    return 0;
}


Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string c;
    cin>>c;// Your code here!
    
          if(c == "a"){
        cout<<"b"<<endl;}
     else if(c == "b"){
        cout<<"c"<<endl;
    } else if(c == "c"){
        cout<<"d"<<endl;
    } else if(c == "d"){
        cout<<"e"<<endl;
    } else if(c == "e"){
        cout<<"f"<<endl;
    } else if(c == "f"){
        cout<<"g"<<endl;
    } else if(c == "g"){
        cout<<"h"<<endl;
    } else if(c == "h"){
        cout<<"i"<<endl;
    } else if(c == "i"){
        cout<<"j"<<endl;
    } else if(c == "j"){
        cout<<"k"<<endl;
    } else if(c == "k"){
        cout<<"l"<<endl;
    } else if(c == "l"){
        cout<<"m"<<endl;
    } else if(c == "m"){
        cout<<"n"<<endl;
    } else if(c == "n"){
        cout<<"o"<<endl;
    } else if(c == "o"){
        cout<<"p"<<endl;
    } else if(c == "p"){
        cout<<"q"<<endl;
    } else if(c == "q"){
        cout<<"r"<<endl;
    } else if(c == "r"){
        cout<<"s"<<endl;
    } else if(c == "s"){
        cout<<"t"<<endl;
    } else if(c == "t"){
        cout<<"u"<<endl;
    } else if(c == "u"){
        cout<<"v"<<endl;
    } else if(c == "v"){
        cout<<"w"<<endl;
    } else if(c == "w"){
        cout<<"x"<<endl;
    } else if(c == "x"){
        cout<<"y"<<endl;
    } else if(c == "y"){
        cout<<"z"<<endl;
    } 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String o, e;
		o = sc.next();
		e = sc.next();
		sc.close();
		
		StringBuilder ans = new StringBuilder();
		
		int n = Math.max(o.length(),  e.length());
		
		for(int i = 0; i < n; ++i) {
			ans.append(o.charAt(i));
			if(i < e.length())
			ans.append(e.charAt(i));
		}
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 22868
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main(void){
    int n,a,b;
    cin  >> n >> a >> b;
    cout << min(a,b) << " " << max(0,min(b-(n-a),a-(n-b))) << endl;
    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    unsigned long long int N;
    unsigned long long int A;
    unsigned long long int B;

    cin >> N >> A >> B;

    cout << N / (A+B) * A + min(A, N % (A+B)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,m,q,a[50],b[50],c[50],d[50];
    cin>>n>>m>>q;
    for(int i=0;i<q;i++)
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    int arr[10]={};
    int ans=0;
    while(true){
        int sum=0;
        for(int i=0;i<q;i++)
            if(arr[b[i]-1]-arr[a[i]-1]==c[i])
                sum+=d[i];
        ans=max(ans,sum);
        for(int i=n-1;i>=0;i--){
            if(arr[i]!=m-1){
                arr[i]++;
                for(int j=i+1;j<n;j++)
                    arr[j]=arr[i];
                break;
            }else if(i==0){
                cout<<ans<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0;i < n; i++){
    cin >> p[i];
  }

  int flg = 0;
  for (int i = 0; i < n; i++){
    if (p[i] != i+1)
      flg++;
  }

  if (flg <= 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
import math
nn=int(math.sqrt(n))+1
a=[0]*(100*n)
for x in range(1,nn+1):
    for y in range(1,nn+1):
        for z in range(1,nn+1):
            a[(x+y+z)**2-x*y-x*z-y*z]+=1
for i in range(1,n+1):
    print(a[i])

Measured memory_bytes: 16780
//FIRST THINK THEN CODE.

  #include <bits/stdc++.h>


  using namespace std;

  typedef long long ll;

  #define rep(i,a,b) for(ll i=a;i<b;++i)
  #define rrep(i,a,b) for(ll i=a;i>b;--i)
  #define FOR(i,n)  for(ll i=0;i<n;i++)
  #define vi vector<int>
  #define vl vector<ll>
  #define ld long double
  #define vld vector<ld>
  #define vvi vector<vector<int>>
  #define vvl vector<vector<long long>>
  #define vvld vector<vector<ld>>
  #define pii pair<int,int>
  #define pll pair<long,long>
  #define vpii vector<pii>
  #define vpll vector<pll>
  #define ff first
  #define ss second
  #define pb push_back
  #define pf push_front
  #define mp make_pair
  #define lb lower_bound
  #define ub upper_bound
  #define bs binary_search
  #define d1(x) cout<<(x)<<endl
  #define d2(x,y) cout<<(x)<<" "<<(y)<<endl
  #define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
  #define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
  #define PI 3.1415926535897932384626433832795
  #define fix(f,n) fixed<<setprecision(n)<<f
  #define all(x) x.begin(),x.end()
  #define rev(p) reverse(p.begin(),p.end());
  #define endl "\n"
  #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  #define popcount(x) __builtin_popcountll(x)
  #define sz(x) ((ll)x.size())
  const ll M=1000000007;
  const ll MM=998244353;
  ll begtime = clock();
  #define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
  //#define _Find_next 
  //#define _Find_first 



  ll newmod(ll a,ll b)
  {
  return ((a%b)+b)%b;
  }


  ll powM(ll a,ll b,ll m )
  { 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
  if(b&1)ans=ans*a%m;
  a=a*a%m;
  b>>=1;
  }

  return ans;
  }



  ll poww(ll a,ll b)
  { 

  ll ans=1;
  while(b)
  {
  if(b&1)ans=ans*a;
  a=a*a;
  b>>=1;
  }

  return ans;

  }

  template<typename T,typename F>
  void chmax( T &a,F b){
  if(b>a)a=b;
  }

  template<typename T,typename F>
  void chmin( T &a,F b){
  if(b<a)a=b;
  }

string tostring(ll x){
  stringstream sss;
  sss<<x;
  string ans=sss.str();
  return ans;
}


  const ll N=1e3+5;



  int main()
  { 

ll n,k;
cin>>n>>k;

vpll a(n);

ll s=0;

FOR(i,n){
  cin>>a[i].ff;
  cin>>a[i].ss;
}
sort(all(a));
FOR(i,n){
  s+=a[i].ss;
  if(s>=k){
    cout<<a[i].ff;
    return 0;
  }
}

  return 0;

  }

Measured memory_bytes: 4896
#include <iostream>
#include <algorithm>

using namespace std;
#define SIZE 100000

int main() {
    long long int i,j,k,N,M,K,Q,d;
  //  long long int A[100][100];
    long long int H[SIZE],A[SIZE],B[SIZE];
    long T[SIZE];
    long long sol;

   cin >> N >> M;
   for (i=0;i<N;i++) {
      cin >> H[i];
      T[i] = 1;
   }

   for (i=0;i<M;i++) {
     cin >> A[i] >> B[i];
     if (H[A[i]-1] >= H[B[i]-1]) {
       T[B[i]-1] = 0;
     }
     if (H[B[i]-1] >= H[A[i]-1]) {
       T[A[i]-1] = 0;
     }
   }

   sol = 0;
   for (i=0;i<N;i++)
    if (T[i]==1)
      sol++;


    cout << sol << endl;


  return 0;
}


Measured memory_bytes: 6748
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){

  int N,A,B,C,D;
  cin>>N>>A>>B>>C>>D;
  string S;
  cin>>S;
  bool flag1=0;
  for(int i=A-1;i<=max(C,D)-2;i++){
  
    if(S[i]=='#'&&S[i+1]=='#'){
    
      cout<<"No";
      return 0;
    }
  }
  if(C>D){
  
    for(int i=B-2;i<=D-2;i++){
    
      if(S[i]=='.'&&S[i+1]=='.'&&S[i+2]=='.')flag1=1;
    }
    if(flag1==0)cout<<"No";
    else cout<<"Yes";
  }
  else cout<<"Yes";
  return 0;
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;

const string DMC = "DMC";

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll count[n+1][3];
    for(int j=0;j<3;j++) count[0][j] = 0;
    for(int i=0;i<n;i++) {
        for(int j=0;j<3;j++) {
            if(s[i] == DMC[j]) {
                count[i+1][j] = count[i][j] + 1;
            }else {
                count[i+1][j] = count[i][j];
            }
        }
    }

    int k,q;
    ll ans;
    cin >> q;
    for(int i=0;i<q;i++) {
        cin >> k;

        ll mc[n+1];
        fill(mc, mc+n+1, 0);
        for(int j=1;j<=n;j++) {
            if(s[j-1] == 'C') mc[j] += count[j][1];
        }
        for(int j=1;j<=n;j++) mc[j] += mc[j-1];

        ans = 0LL;
        for(int j=1;j<=n;j++) {
            if(s[j-1] != 'D') continue;
            ans += (mc[min(n,j+k-1)] - mc[j-1]) - count[j-1][1] * (count[min(n,j+k-1)][2] - count[j-1][2]);
        }
        cout << ans << endl;
    }


}


Measured memory_bytes: 32644
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
typedef pair<double,long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n,cnt=0;
	cin >> n;
	vector<ll>p(n),pp;
	rep(i, n) {
		cin >> p[i];
		pp.push_back(i+1);
	}
	for (ll i = 0; i < n; i++) {
		if (p[i] == pp[i]) {
			if (i == n - 1) {
				swap(p[i], p[i - 1]);
				cnt++;
			}
			else {
				swap(p[i], p[i + 1]);
				cnt++;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 2168
MOD = 1e9 + 7

n, m = map(int, input().split())
a = [False] * (n+1)
for i in range(m):
    b = int(input())
    a[b] = True

dp = [0] * (n+1)
dp[0] = 1
for i in range(1, n+1):
    if a[i]:
        continue
    if i > 1:
        dp[i] = (dp[i-1] + dp[i-2]) % MOD
    else:
        dp[i] = dp[i-1]

print(int(dp[n]))


Measured memory_bytes: 6900
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
    a.sort();
    let mut d: std::collections::VecDeque<_> = a.into_iter().collect();
    let mut ans = 0;
    for k in (1..31).rev() {
        let mut s = std::collections::VecDeque::new();
        let mut t = std::collections::VecDeque::new();
        while d.len() >= 2 {
            let a = d.pop_front().unwrap();
            let b = d.pop_back().unwrap();
            if a + b == (1 << k) {
                ans += 1;
            } else if a + b > (1 << k) {
                t.push_front(b);
                d.push_front(a);
            } else {
                s.push_back(a);
                d.push_back(b);
            }
        }
        while let Some(a) = d.pop_front() {
            s.push_back(a);
        }
        d.append(&mut s);
        d.append(&mut t);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 12536
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

int main() {
  char C;
  cin >> C;
  cout << (char)(C + 1) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i, h, n, sum=0;
  scanf("%d %d",&h,&n);
  int a[n];
  for(i=0;i<n;i++) {
    scanf("%d",&a[i]);
    sum+=a[i];
  }
  puts(sum<h?"No":"Yes");
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

template<class Ty>
using passive_queue = priority_queue<Ty, vector<Ty>, greater<Ty>>;

struct Problem {

	void Solve() {
		UL N; cin >> N;
		UL M; cin >> M;
		vector<UL> A(M); rep(i, M) cin >> A[i];
		UL S[10] = { 0,2,5,5,4,5,6,3,7,6 };
		pair<UL, UL> G = { 0,0 };
		rep(i, M) {
			pair<UL, UL> B = { 10 - S[A[i]], A[i] };
			G = max(G, B);
		}
		G.first = 10 - G.first;
		UL Sz = min(G.first * 7 + (N % G.first), N);
		vector<UL> dp(Sz + 1, -1);
		dp[Sz] = 0;
		for (UL j = Sz; j != -1; j--) {
			rep(i, M) {
				if (j + S[A[i]] > Sz) continue;
				if (dp[j + S[A[i]]] == -1) continue;
				if (dp[j] == -1) dp[j] = 0;
				dp[j] = max(dp[j], dp[j + S[A[i]]] * 10 + A[i]);
			}
		}
		string Z = to_string(dp[0]);
		rep(i, Z.size()) if (Z[i] - '0' >= G.second) cout << Z[i];
		rep(i, (N - Sz) / G.first) cout << G.second;
		rep(i, Z.size()) if (Z[i] - '0' < G.second) cout << Z[i];
		cout << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
s = gets.chomp.split("").map
s = s.sort do |a,b|
  a <=> b
end
s.uniq!

alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
26.times do |i|
  if s[i] != alpha[i] then
    puts alpha[i]
    exit
  end
end

puts "None"

Measured memory_bytes: 10104
#include <iostream>
#include <algorithm>

using namespace std;;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] + a[1] == a[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

class Sieve
{
private:
    int n;
    vector<int> f, primes;
public:
    Sieve(int n = 1) :n(n), f(n + 1)
    {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i * i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool IsPrime(int x) { return f[x] == x; }
    vector<int> PrimeList(int x)
    {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<pair<ll, int>> PrimeFrequency(int x)
    {
        vector<int> fl = PrimeList(x);
        if (fl.size() == 0) return {};
        vector<pair<ll, int>> res(1, pair<ll, int>(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            }
            else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
    vector<pair<ll, int>> PrimeFrequencySelf(ll x)
    {
        vector<pair<ll, int>> res;
        for (int p : primes) {
            int y = 0;
            while (x % p == 0) x /= p, ++y;
            if (y != 0) res.emplace_back(p, y);
        }
        if (x != 1) res.emplace_back(x, 1);
        return res;
    }
};

int main()
{
    int n;
    cin >> n;
    Sieve sieve(n);
    ll ans = 1;
    for (ll i = 2; i <= n; i++) {
        vector<pair<ll, int>> pf = sieve.PrimeFrequency(i);
        ll sum = 1;
        for (const auto& item : pf) sum *= (item.second + 1);
        ans += sum * i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 46504
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    c1=STR()
    c2=STR()
    if c1[0]==c2[2] and c1[1]==c2[1] and c1[2]==c2[0]:
        print('YES')
    else:
        print('NO')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064