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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int NUM_BITS = 60;

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

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

  int64 xor_all = 0;
  for (int64 x : xs) {
    xor_all ^= x;
  }

  for (int i = 0; i < n; i++) {
    xs[i] &= ~xor_all;
  }

  if (DEBUG) {
    cout << "xor_all: " << xor_all << endl;
    for (int i = 0; i < n; i++) {
      cout << "i: " << i << " " << xs[i] << endl;
    }
  }

  int c = 0;
  for (int b = NUM_BITS - 1; b >= 0; b--) {
    int pivot_i = -1;
    for (int i = c; i < n; i++) {
      if (xs[i] & (1L << b)) {
        pivot_i = i;
        break;
      }
    }

    if (pivot_i < 0) continue;

    if (DEBUG) {
      cout << "b: " << b << endl;
      cout << xs[pivot_i] << endl;
    }

    swap(xs[pivot_i], xs[c]);

    for (int i = 0; i < n; i++) {
      if (i == c) continue;
      if (xs[i] & (1L << b)) {
        xs[i] ^= xs[c];
      }
    }

    c++;

    if (DEBUG) {
      cout << "xor_all: " << xor_all << endl;
      for (int i = 0; i < n; i++) {
        cout << "i: " << i << " " << xs[i] << endl;
      }
    }
  }

  if (DEBUG) {
    cout << "xor_all: " << xor_all << endl;
    for (int i = 0; i < n; i++) {
      cout << "i: " << i << " " << xs[i] << endl;
    }
  }

  int64 xor_all_2 = 0;
  for (int i = 0; i < n; i++) {
    xor_all_2 ^= xs[i];
  }
  cout << xor_all + xor_all_2 * 2 << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

typedef vector<int> vi;

void ff(vi e[], int x, bool v[]) {
    v[x] = true;
    for (int y : e[x]) {
        if (!v[y]) {
            ff(e, y, v);
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    vi e[n];
    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        x--, y--;
        e[x].push_back(y);
        e[y].push_back(x);
    }

    bool v[n];
    memset(v, 0, sizeof(v));
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (!v[i]) {
            ans++;
            ff(e, i, v);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10496
#include<bits/stdc++.h>
#define ll long long
#define f   first
#define s   second
#define pb          push_back
#define mod         1000000007
#define hell        998244353
#define inf         1000000000000000000LL
using namespace std;
ll n,k,m;
//ll dp[15][1005];
ll dp[100005];
vector<ll> adj[100005];
void dfs(ll V,ll par)
{
    for(auto x:adj[V])
        {   if(par==x) continue;
            dp[x]=max(dp[x],dp[V]+1);dfs(x,V);}
}
void solve()
{   ll W;
    cin>>n>>m;
    //vector<ll> adj[n+1];
    vector<ll> deg(n+1);
    for(int i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        adj[x].pb(y);
        //adj[y].pb(x);
        deg[y]++;
    }
    queue<ll> q;
    for(int i=1;i<=n;i++)
        if(deg[i]==0) q.push(i);
            
    ll dis[n+1];
    memset(dis,0,sizeof(dis));
    while(!q.empty())
    {
        ll x=q.front();
        q.pop();
        for(auto y:adj[x])
        {
            dis[y]=max(dis[y],dis[x]+1);
            deg[y]--;
            if(deg[y]==0) q.push(y);
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++) ans=max(ans,dis[i]);
        cout<<ans;
}

int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
        solve();

}

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

int main() {
    char a,b;
    cin >> a >> b;
    if (a<=b) for (int i=0; i<b-'0'; i++) cout << a;
    else if (b<a) for (int i=0; i<a-'0'; i++) cout << b;
}

Measured memory_bytes: 256
memo = [[None for i in range(50)] for j in range(50)]
def opt(n,k): # exponents must be >= k
	if n < k:
		return 0
	else:
		if memo[n][k]==None:
			memo[n][k] = max(1+opt(n-k,k+1),opt(n,k+1))
		return memo[n][k]

def prime_factorize(n):
	pf = {}
	d = 2
	orig_n = n
	while d*d <= orig_n:
		while n%d==0:
			pf[d] = pf.get(d,0)+1
			n //= d
		d += 1

	if n > 1:
		pf[n] = 1
	return pf 

print(sum([opt(e,1) for e in prime_factorize(int(input())).values()]))

Measured memory_bytes: 9136
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;cin>>s;
    for(int i=0;i<s.length();i++)
        cout<<'x';
    cout<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------








Measured memory_bytes: 256
#include<iostream>
#include<queue>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long llong;

//priority_queue.
int main(){
	int n,m;
	cin>>n>>m;
	
	priority_queue<int> q;
	REP(i,n){
		int a;
		cin>>a;
		q.push(a);
	}
	
	REP(i,m){
		int tmp=q.top();
		q.pop();
		q.push(tmp/2);
	}
	
	llong sum=0;
	while(!q.empty()){
		sum+=q.top();
		q.pop();
	}
	
	cout<<sum<<endl;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)

typedef pair<int, int> P;



int main() {
    int n; cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];

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

    if(check >= 3) cout << "NO" << endl;
    else cout << "YES" << endl;

    return 0;

}

/**
7
1 5 3 4 2 7 6

7
1 5 3 4 2 6 7

7
4 5 3 1 2 6 7
**/

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, d;
    cin >> n >> d;

    bool f[33] {};

    int cnt = 0;

    for (int i = 1 + d; i <= n; i += 1 + d+d) {
        for (int j = i - d; j <= i + d; ++j) {
            f[j] = true;
        }
        ++cnt;
    }
    if (!f[n]) ++cnt;

    cout << cnt << endl;

    return 0;
}

// vim: set foldmethod=marker :


Measured memory_bytes: 256
#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, q;
  string s;
  cin >> n >> s >> q;
  vector<set<int>> is(26);
  rep(i,n) is[s[i]-'a'].insert(i);
  rep(qi,q) {
    int ty;
    cin >> ty;
    if (ty == 1) {
      int i; char c;
      cin >> i >> c;
      --i;
      is[s[i]-'a'].erase(i);
      s[i] = c;
      is[s[i]-'a'].insert(i);
    } else {
      int l, r;
      cin >> l >> r;
      --l;
      int ans = 0;
      rep(i,26) {
        auto it = is[i].lower_bound(l);
        if (it != is[i].end() && *it < r) ++ans;
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}

Measured memory_bytes: 24196
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
 
int main() {

    int k;
    cin >> k;

    int l;
    if(k%7== 0) l = 9*k/7;
    else    l = 9*k; 
    int mod = 10%l;
    if(l%2 == 0 || l%5 == 0) {
        cout<<-1<<endl;
        return 0;
    }
    else {
        if(k == 7||k == 1) {
            cout<<1<<endl;
            return 0;
        }
        repi(i,1,10000000) {
            if(mod*10%l == 1) {
                cout<<i+1<<endl;
                return 0;
            }
            else {
                mod = mod*10%l;
            }
        }
    }

 return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int age,yen;
	scanf ("%d %d",&age,&yen);
	
	if (age<=12&&age>=6){
		printf ("%d",yen/2);
	}
	else if (age<6){
		printf ("0\n");
	}
	else{
		printf ("%d\n",yen);
	}
	
	return 0;	
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep2(i, s, n) for(ll i = s; i < n; i++)
using namespace std;

const ll mod = 2019;
int main(){
  ll L, R;
  cin >> L >> R;
  if (R - L >= 2019) cout << 0 << endl;
  else{
    ll ans = mod;
    rep2(i, L, R)rep2(j, i+1, R+1){
      ans = min(ans, i * j % mod);
    }
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>

void swap(int *x, int *y) {
	int temp = *x;
	*x = *y;
	*y = temp;
}

int main() {
	int a, b, c, temp;
	std::cin >> a >> b >> c;

	if (a > b) {
		swap(&a, &b);
	}
	if (b > c) {
		swap(&b, &c);
	}
	if (a > b) {
		swap(&a, &b);
	}

	std::cout << a << " " << b << " " << c << std::endl;

	return 0;
}


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

#define For(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define Rep(i,n) For(i,0,n)
#define dbg(x) cout<<#x"="<<x<<endl

#define MAX_N 300+1
#define MAX_W 1000+1

int N;
int w[MAX_N];
int dp[MAX_N][MAX_N];

int main(int argc, char const *argv[])
{
	while(1){
		scanf("%d", &N);
		if(N == 0) break;
		Rep(i,N){
			scanf("%d", &w[i]);
		}
		Rep(i,MAX_N)Rep(j,MAX_N) dp[i][j] = 0;
		Rep(l,N){
			for(int s = 0, e = l; e < N; s++,e++){
				For(i,s,e){
					dp[s][e] = max(dp[s][e], dp[s][i]+dp[i+1][e]);
				}
				if((e-s-1)%2 == 0 && (e-s-1)/2 == dp[s+1][e-1] && abs(w[e]-w[s]) <= 1) dp[s][e] = max(dp[s][e], dp[s+1][e-1]+1);
			}
		}
		printf("%d\n", dp[0][N-1]*2);
	}
	return 0;
}

Measured memory_bytes: 3484
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int main(){
  lint N,A,B;cin>>N>>A>>B;
  lint mn=A*(N-1)+B,mx=B*(N-1)+A;
  cout<<max(0ll,mx-mn+1)<<endl;
  return 0;
}





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

int main(){
    int a,b,c,d;    cin>>a>>b>>c>>d;
    int sum=0;
    a>b?sum+=b:sum+=a;    c>d?sum+=d:sum+=c;
    cout<<sum<<endl;
}


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

int main() {
  int ans = 0;
  string a;
  cin >> a;
  int i=0;
  while(i<a.length()){
    ans += a[i]-'0';
    i++;
  }
  if(ans%9==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

bool f(P l,P r){
    int a = l.second - l.first;
    int b = r.second - r.first;
    if(a > 0 && b <= 0){
        return true;
    }
    if(a <= 0 && b > 0){
        return false;
    }
    if(a > 0 && b > 0){
        return l.first < r.first;
    }if(a < 0 && b < 0){
        return l.second > r.second;
    }
}

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    vector<P> lr(n);
    rep(i,n){
        int l = 0;
        int r = 0;
        rep(j,s[i].size()){
            if(s[i][j] == '('){
                ++r;
            }else{
                if(r > 0) --r;
                else ++l;
            }
        }
        lr[i].first = l;
        lr[i].second = r;
    }

    sort(lr.begin(),lr.end(),f);
    if(lr[0].first!=0){
        cout << "No" << endl;
        return 0;
    }
    int r = 0;
    rep(i,n){
        if(r < lr[i].first){
            cout << "No" << endl;
            return 0;
        }
        r -= lr[i].first;
        r += lr[i].second;
    }
    cout << (r==0?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 42212
#include <stdio.h>

int
main(int arg, char *argv[])
{
  char s[20];
  scanf("%s", s);
  for(int i = 0; i < 19; i++){
    if(s[i] != ',')printf("%c", s[i]);
    else printf(" ");
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>

using namespace std;

int main(){
	int N;
	cin >> N;
	int x[10];
	int y[10];
	double z[10];
	
	for(int i=0; i<N; i++){
		cin >> x[i] >> y[i];
	}
	
	int hoge=0;
	int chage=0;
	double sum=0;
	
	for(int i=0; i<N-1; i++){
		for(int k=i+1; k<N; k++){
			hoge=x[i]-x[k];
			chage=y[i]-y[k];
			sum=sum+sqrt(hoge*hoge+chage*chage);
		}
	}
	double ans = (double)2*sum/N;
	
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int N, Q;
string S;

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

	cin >> N;
	cin >> S;
	cin >> Q;

	int K;
	rep(i, 0, Q)
	{
		cin >> K;
		int dc = 0, mc = 0, dmc = 0;
		int res = 0;
		rep(j, 0, N)
		{
			if (j >= K)
			{
				if (S[j - K] == 'D')
				{
					dc--;
					dmc -= mc;
				}
				if (S[j - K] == 'M')
				{
					mc--;
				}
			}
			if (S[j] == 'D')
			{
				dc++;
			}
			if (S[j] == 'M')
			{
				mc++;
				dmc += dc;
			}
			if (S[j] == 'C')
			{
				res += dmc;
			}
		}

		cout << res << endl;
	}

	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		//		new Main().solveC();
		new Main().solveC2();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			if (numN % 2 == 0) {
				System.out.println(numN);
			} else {
				System.out.println(numN * 2);
			}

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			int[] wk = new int[numN];

			for (int i = 0; i < wk.length; i++) {
				wk[i] = scanner.nextInt();
			}
			Arrays.sort(wk);

			System.out.println(wk[wk.length - 1] - wk[0]);

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private int getCry(int b, int currentI, int maxI, int[] wk) {
		if (currentI == maxI) {
			return 0;
		}

		return getCry(b, currentI + 1, maxI, wk) + Math.abs(wk[currentI] - (b + currentI + 1));
	}

	private void solveC2() {
		Scanner sc = new Scanner(System.in);
		int numN = sc.nextInt();
		int[] wk = new int[numN];
		for (int i = 0; i < numN; i++) {
			wk[i] = sc.nextInt() - (i + 1);
		}
		sc.close();
		Arrays.sort(wk);
		int med = numN % 2 == 0 ? numN / 2 - 1 : numN / 2;
		int b = wk[med];
		long ans = 0;
		for (int a : wk) {
			ans += Math.abs(a - b);
		}

		System.out.println(ans);
	}

	/**
	 * ⅰ)abs(xi-a)の総和(aとの距離の総和)を最小にするのは中央値で、
	 * ⅱ)(xi-a)^2の総和を最小にするのは平均値
	 */
	private void solveC() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			int[] wk = new int[numN];
			for (int i = 0; i < numN; i++) {
				wk[i] = scanner.nextInt() - (i + 1);
			}
			Arrays.sort(wk);

			//			int b = 0;
			//			if (numN % 2 == 0) {
			//				b = wk[(numN / 2) - 1];
			//			} else {
			//				b = wk[numN / 2];
			//			}

			int med = numN % 2 == 0 ? numN / 2 - 1 : numN / 2;
			int b = wk[med];

			int res = 0;

			for (int a : wk) {
				res += Math.abs(a - b);
			}
			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

#define rep(n) for(long long i=0;i<n;i++)
#define repp(j, n) for(long long j=0;j<n;j++)
#define reppp(i, m, n) for(long long 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;

int main() {
    ll n,m, p, y;
    cin >> n >> m;
    vector<Pll> v[n+1];
    rep(m) {
        cin >> p >> y;
        v[p].emplace_back(y, i);
    }
    rep(n) sort(all(v[i+1]));

    vector<ll> ans(m, 0);
    reppp(i, 1, n+1) {
        repp(j, v[i].size()) {
            ans[v[i][j].second] = i*1000000LL + j+1LL;
        }
    }

    rep(m) {
        printf("%012lld\n", ans[i]);
    }
}


Measured memory_bytes: 7680
def nPr(n,r,mod):
    if r==0: return 1
    if r==1: return n
    ans=1
    for i in range(r):
        ans=(n-i)*ans%mod
    return ans%mod
    
n,m=map(int,input().split())

mod=10**9+7
dog=nPr(n,n,mod)
mon=nPr(m,m,mod)

if abs(n-m)>1:
    print(0)
elif abs(n-m)==1:
    print(dog*mon%mod)
else:
    print(dog*mon*2%mod)

Measured memory_bytes: 3064
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, m;
	ll a,b,n;
	cin>>a>>b>>n;
	ll val;
	x=n;
	if(n<b)
	{	
		val=(a*x)/b;
	}
	else{
		x=b-1;
		val=(a*x)/b-a*(x/b);
	}
	
	cout<<val;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10640
n, x = map(int, input().split())
if 2<=x<=2*(n-1):
  print('Yes')
else:
  print('No')
  exit()
  
if x == n:
  for i in range(1, 2*n):
    print(i)
elif x < n:
  for i in range(n, x, -1):
    print(i)
  for i in range(1, x+1):
    print(i)
  for i in range(n+1, 2*n):
    print(i)
else:
  for i in range(1, n):
    print(i)
  for i in range(x, 2*n):
    print(i)
  for i in range(x-1, n-1, -1):
    print(i)


Measured memory_bytes: 9284
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char c;
	int i,Zjh111111=0;
	for(int i=1;i<=4;i++)
	 {
	 	c=getchar();
	 	Zjh111111+=(c=='2')?1:0;
	 }
	 cout<<Zjh111111<<endl;
	 return 0;
}

Measured memory_bytes: 256
S = list(input())
S.reverse()

D = [['m','a','e','r','d'],['r','e','m','a','e','r','d'],['e','s','a','r','e'],['r','e','s','a','r','e']]
can = True

while len(S) != 0:
    can2 = False
    for i in range(4):
        d = D[i]
        if S[:len(d)] == d:
            can2 = True
            for j in range(len(d)):
                S.pop(0)
            break
    if can2 == False:
        can = False
        break

if can == True:
    print('YES')
elif can == False:
    print('NO')

Measured memory_bytes: 9876
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	string s;
	getline(cin,s);
	int a1=0,a2=s.size()-1;
	while(s[a1]!='A') a1++;
	while(s[a2]!='Z') a2--;
	cout<<a2-a1+1; 
	return 0;
}

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

class Main{




	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);			//文字の入力
		int h = sc.nextInt();
		int w = sc.nextInt();

		long ans = 1000000000;
		long[] one = new long[3];
		long[] two = new long[3];


		for(long i = 1;i <= h;i++){
			long score = 0;

			long a = i*w;
			long b = 0;
			long c = 0;

			one[0] = a;

			b = (h-i)*(w/2);
			c = (h-i)*(w-w/2);
			one[1] = b;
			one[2] = c;

			Arrays.sort(one);

			two[0] = a;

			long bb = 0;
			long cc = 0;
			bb = (h-i)/2*w;
			cc = (h-i-(h-i)/2)*w;

			two[1] = bb;
			two[2] = cc;

			Arrays.sort(two);

			
			

			score = Math.min(one[2]-one[0],two[2]-two[0]);
			ans = Math.min(ans,score);

		}
		
		int x = h;
		h = w;
		w = x;
		
		for(long i = 1;i <= h;i++){
			long score = 0;

			long a = i*w;
			long b = 0;
			long c = 0;

			one[0] = a;

			b = (h-i)*(w/2);
			c = (h-i)*(w-w/2);
			one[1] = b;
			one[2] = c;

			Arrays.sort(one);

			two[0] = a;

			long bb = 0;
			long cc = 0;
			bb = (h-i)/2*w;
			cc = (h-i-(h-i)/2)*w;

			two[1] = bb;
			two[2] = cc;

			Arrays.sort(two);

			
			score = Math.min(one[2]-one[0],two[2]-two[0]);
			ans = Math.min(ans,score);

		}
		
		System.out.println(ans);






	}

}



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

_LL dp[2004][2004];

int main()
{
    _LL n;
    cin >> n;
    pair<_LL, _LL> *a = new pair<_LL, _LL>[n];
    rep(i, n)
    {
        cin >> a[i].first;
        a[i].second = i;
    } 
    sort(a, a + n, greater<pair<_LL, _LL>>());
    dp[0][0] = 0;
    _LL best = 0;
    rep(i, n)
    {
        int xy = i + 1;
//        cout << i << ":" << a[i].first << "," << a[i].second << endl;
        rep(x, xy + 1)
        {
            _LL y = xy - x;
            dp[x][y] = 0;
            if( x > 0 ) dp[x][y] = max(dp[x][y], dp[x - 1][y] + a[i].first * abs( a[i].second - x + 1));
            if( y > 0 ) dp[x][y] = max(dp[x][y], dp[x][y - 1] + a[i].first * abs( n - y - a[i].second)); 
//            cout << x << "," << y << ":" << dp[x][y] << endl;
            best = max(best, dp[x][y]);
        }
    }
    cout << best << endl;
    delete a;
}

Measured memory_bytes: 26264
#include<iostream>
#include<string>
#include<algorithm>
#include <cstdlib>
 
int main()
{
	int a,b,c,d,ansa,ansb;
	std::cin >> a >> b >> c >> d;;

	if (a > b) {
		ansa = b;
	}
	else {
		ansa = a;
	}
	if (c > d) {
		ansb = d;
	}
	else {
		ansb = c;
	}
	std::cout <<ansa+ansb;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1


#ifndef ONLINE_JUDGE
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
						 stringstream _ss(_s); \
						 istream_iterator<string> _it(_ss); \
						 err(_it, args); }
#else
#define error(args...)		42
#endif


void err(istream_iterator<string> it) { cerr << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "; ";
	err(++it, args...);
}


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
#endif
}


int32_t main()
{
	c_p_c();

	int ans;

	for (int i = 0; i < 5; ++i)
	{
		int a; cin>>a;

		if(a==0)
			ans = i+1;
	}

	cout << ans;
	
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
ll n;
ll t=0;
ll a[110];
ll res=1e18;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++) cin >>a[i];
	sort(a,a+n);
	for (int i=a[0];i<=a[n-1];i++)
	{
		ll r=0;
		for (int j=0;j<n;j++) r+=abs(i-a[j])*abs(i-a[j]);
		res=min(res,r);
	} 
	cout <<res;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>


using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から
#define REP(i,N) for(int j=i;j<N;j++) //iから

typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

#define MOD ((ll)1e+9 + 7)




//cout<<fixed<<setprecision(10);
int main(){
    ll N;
    cin>>N;
    ll t=1,e=1,n=1;
    rep(i,N){
        t*=10;
        n*=9;
        e*=8;
        t%=MOD;
        n%=MOD;
        e%=MOD;
    }
    N=(2*MOD+t+e-2*n)%MOD;
    cout<<N<<endl;

    return 0;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll divMod(ll a, ll b)
{
    return mulMod(a, powMod(b, MOD - 2));
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long X, long long Y)
{
    if ((X + Y) % 3 != 0)
    {
        cout << 0 << endl;
        return;
    }
    else
    {
        ll cnt = (X + Y) / 3;
        X -= cnt;
        Y -= cnt;

        if (X < 0 || Y < 0)
        {
            cout << 0 << endl;
            return;
        }
        else
        {
            ll ans = 1;
            for (int i = 1; i <= X + Y; i++)
            {
                ans = mulMod(ans, i);
            }

            for (int i = 1; i <= X; i++)
            {
                ans = divMod(ans, i);
            }
            for (int i = 1; i <= Y; i++)
            {
                ans = divMod(ans, i);
            }

            cout << ans << endl;
        }
    }
}

int main()
{
    long long X;
    scanf("%lld", &X);
    long long Y;
    scanf("%lld", &Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <memory>
#include <numeric>

#include <array>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cstring>
#include <ostream>
#include <type_traits>
#include <utility>
#include <chrono>
#include <random>

#ifdef ONLINE_JUDGE
#pragma GCC optimize ("O2")
#pragma GCC target ("avx,avx2")
#endif

using namespace std;

using u64 = uint64_t;
using i64 = int64_t;
using u32 = uint32_t;
using vi = vector<int>;
using vi64 = vector<i64>;

#define seq(i,a,b) for (int i = (a); i < (b); ++i)
#define rev(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define dbg(x) {cerr << #x << ": " << x << endl;}

// Find sum [l,r)
// add or set on pos
template <typename T>
class SumSegment
{
   public:
    SumSegment(int n)
    {
        len = 1;
        while (len < n) len <<= 1;
        data.resize(n + len);
    }

    T sum(int l, int r)
    {
        T summa = 0;
        for (l += len, r += len; l < r; l >>= 1, r >>= 1) {
            if ((l % 2) == 1) summa += data[l++];
            if ((r % 2) == 1) summa += data[--r];
        }
        return summa;
    }

    void add(int pos, T value)
    {
        for (pos += len; pos > 0; pos >>= 1) {
            data[pos] += value;
        }
    }

    void set(int pos, T value)
    {
        value -= data[pos + len];
        add(pos, value);
    }

   private:
    int len;
    vector<T> data;
};

int main(int argc, char *argv[])
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  vector<SumSegment<int>> S;
    
  int n; cin >> n;
  seq (i, 0, 'z' - 'a' + 1) {
    S.push_back(SumSegment<int>(n));
  }

  string s; cin >> s;
  seq(i,0,n) {
    S[s[i]-'a'].add(i,1);
  }

  int q; cin >> q;
  seq(_,0,q) {
    int t; cin >> t;
    if (t == 1) {
      int i; char c; cin >> i >> c;
      --i;
      int oc = s[i];
      s[i] = c;
      S[oc - 'a'].add(i, -1);
      S[c - 'a'].add(i, 1);
    } else {
      int l,r; cin >> l >> r;
      --l; --r;
      int res = 0;
      seq (i, 0, 'z' - 'a' + 1) {
        res += !!(S[i].sum(l, r+1));
      }
      cout << res << "\n";
    }
  }
}


Measured memory_bytes: 105236
from collections import defaultdict


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)


N, M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.union(a, b)

c = defaultdict(int)
for i in range(N):
    c[uf.find(i)] += 1

print(max(c.values()))


Measured memory_bytes: 101068
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[19];
    for(int i=0;i<19;i++)
        cin>>s[i];
    s[5] =' ';
    s[13] =' ';
    for(int i=0;i<19;i++)
        cout<<s[i];
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{
   ll n; cin>>n;
  ll add = 1;
  ll ans = 0 ;
   while(n)
   {
        n/=2;
        ans+=add;
        add*=2;
   }
    cout<<ans<<endl;
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vll red(a), green(b), white(c);
  vrep(red) cin >> i;
  vrep(green) cin >> i;
  vrep(white) cin >> i;

  sort(all(red), greater<ll>());
  sort(all(green), greater<ll>());
  priority_queue<ll> eat;
  rep(i, 0, x) eat.push(red.at(i));
  rep(i, 0, y) eat.push(green.at(i));
  rep(i, 0, c) eat.push(white.at(i));
  
  ll ans =0;
  rep(i, 0, x + y){
    ans += eat.top();
    eat.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 8816
using System;

class Marge
{
    private int count;
    public int counting
    {
        get {
            return count;
        }
        set {
            this.count += value;
        }
    }
    public void merge(ref int[] a, int left, int mid, int right) {
        int n1 = mid - left;
        int n2 = right - mid;
        int[] l = new int[n1+1];
        int[] r = new int[n2+1];
        for(int i1 = 0; i1 < n1; i1++) {
            l[i1] = a[left + i1];
        }
        for(int i2 = 0; i2 < n2; i2++) {
            r[i2] = a[mid + i2];
        }
        l[n1] = int.MaxValue;
        r[n2] = int.MaxValue;
        int i = 0;
        int j = 0;
        int k;
        for (k = left; k < right; k++) {
            if (l[i] <= r[j]) {
                a[k] = l[i];
                i++;
            } else {
                a[k] = r[j];
                j++;
            }
            this.counting = 1;
        }
    }
    public void MergeSort(ref int[] a, int left, int right) {
        if (left + 1 < right) {
            int mid = (left + right) / 2;
            MergeSort(ref a, left, mid);
            MergeSort(ref a, mid, right);
            merge(ref a, left, mid, right);
        }
    }
}

class B
{
    public static void Main() {
        int n = int.Parse(Console.ReadLine());
        int[] a = new int[n];
        string[] input = Console.ReadLine().Split(' ');
        for(int i = 0; i < n; i++) {
            a[i] = int.Parse(input[i]);
        }
        Marge marge = new Marge();
        marge.MergeSort(ref a, 0, a.Length);
        int c=0;
        foreach(int d in a) {
            if (c > 0) {
                Console.Write(' ');
            }
            Console.Write(d);
            c++;
        }
        Console.WriteLine();
        Console.WriteLine(marge.counting);
    }
}


Measured memory_bytes: 77424
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var Array(a, b, c) = Array.fill(3)(sc.nextInt()).sorted
  var ans = 0
  ans += c - b
  val d = c - (a + (c - b))
  ans += (if (d % 2 == 0) d / 2 else (d / 2) + 2)
  println(ans)
}


Measured memory_bytes: 55528
#include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
using namespace std;

int main()
{
  int n;
  string t,h;
  cin>>n;
  int t_score=0,h_score=0;
  for(int i=0;i<n;i++){
    cin>>t>>h;
    if(t==h){
      t_score++;
      h_score++;
    }
    else if(t>h){
      t_score+=3;
    }
    else
      h_score+=3;
  }

  cout<<t_score<<" "<<h_score<<endl;
  return 0;
}                 



Measured memory_bytes: 3208
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

const COMMAX int64 = 2000001
const MOD int64 = 1000000007

var fac [COMMAX]int64
var finv [COMMAX]int64
var inv [COMMAX]int64

// テーブル作成
func COMinit() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := int64(2); i < COMMAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

// 二項係数nCk
func COM(n, k int64) int64 {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func modPow(a, n, mod int) int {
	ret := 1
	for n > 0 {
		if n&1 == 1 {
			ret = (ret * a) % mod
		}
		a = (a * a) % mod
		n >>= 1
	}
	return ret
}

func modInv(a, mod int) int {
	b := mod
	u, v := 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		u -= t * v
		a, b = b, a
		u, v = v, u
	}
	u %= mod
	if u < 0 {
		u += mod
	}
	return u
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	COMinit()

	k, s := nextInt(), next()
	n := len(s)

	ans := int64(0)
	pow := int64(modPow(25, k, int(MOD)))
	for x := 0; x <= k; x++ {
		add := (COM(int64(n+k-x-1), int64(n-1)) * pow) % MOD
		ans += add
		ans %= MOD

		pow *= int64(26 * modInv(25, int(MOD)))
		pow %= MOD
	}

	puts(ans)
}


Measured memory_bytes: 52276
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define mod 1000000007LL
#define F first
#define S second
#define speed ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
int main()
{
	speed;
	int n;
	cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;i++)cin>>v[i];
	bool ans=true;
	int maxi=v[0];
	for(int i=1;i<n;i++)
	{
		if(v[i]<maxi-1)ans=false;
		maxi=max(maxi,v[i]);
	}
	if(ans)cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Feb 16 21:00:34 JST 2020
 **/

const Int INF = 1e18;
using pii = pair<Int, Int>;
signed main() {
    Int n, m;
    cin >> n >> m;
    vector<pii> ps(n + 2, {INF, 0});
    ps[n] = {-INF, 0};
    REP(i, n) cin >> ps[i].first >> ps[i].second;
    sort(ps.begin(), ps.end());
    struct Edge {
        Int to, idx;
    };
    vector<vector<Edge>> g(n + 1);
    REP(i, m) {
        Int l, r;
        cin >> l >> r;
        Int u = lower_bound(ps.begin(), ps.end(), pii(l, -1)) - ps.begin() - 1;
        Int v = lower_bound(ps.begin(), ps.end(), pii(r, INF)) - ps.begin() - 1;
        g[u].push_back({v, i});
        g[v].push_back({u, i});
    }
    vector<Int> color(n + 1);
    REP(i, n + 1) { color[i] = ps[i].second != ps[i + 1].second; }
    vector<bool> visited(n + 1);
    vector<Int> ans;
    auto dfs = [&](auto f, Int v, Int prv) -> void {
        if (visited[v]) return;
        visited[v] = true;
        for (Edge p : g[v]) {
            if (p.to == prv || visited[p.to]) continue;
            f(f, p.to, v);
            if (color[p.to]) {
                color[p.to] = 0;
                color[v] = !color[v];
                ans.push_back(p.idx);
            }
        }
    };
    REP(i, n + 1) {
        dfs(dfs, i, -1);
        if (color[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    sort(ans.begin(), ans.end());
    cout << ans.size() << endl;
    for (Int x : ans) cout << x + 1 << " ";
    cout << endl;
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    ll a,b,c;
    cin>>a>>b>>c;

    if(a%2==0 ||b%2==0 ||c%2==0)ans=0;
    else ans = min(b*c,min(a*c,a*b));

    cout<<ans<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=1;i<=1000;i++){
        if(i*a%b==c){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

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

int main()
{
	string a,b,c="";
	long n;
    cin >> a >> b;
    c=a+b;
    n=atol(c.c_str());
    if(sqrt(n)==int(sqrt(n))) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main()
{
  int h,n ;
  cin >> h >> n ;
  int a[n];
  
  int total=0;
   for(int i=0; i<n; i++){
     cin >> a[i];
     total+=a[i];
 }
  
  if(h<=total)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;    
  
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int N;
	cin >> N;
	vector<int>a(N);
	for (int i = 0; i < N; i++)cin >> a[i];
	
	int ans = 0;
	for (int i = 1; i < N; i++) {
		if (a[i] == a[i - 1]) {
			ans++;
			a[i] = -1;
		}
	}
	puts(ans);

	
	return 0;
}

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

/*
fact_time(x,prime): how many times x! can be devided by prime
fact_time(x,prime) = x/prime + fact_time(x/prime,prime)
*/

int64_t fact_time(int64_t x, int prime) {
	if (x == 0) return 0;

	return x/prime + fact_time(x/prime, prime);
}

int main() {
	int64_t N;
	cin >> N;
	int64_t cnt = 0, dum = N;

	if (N % 2 == 0) { // N!!=(2**N)*N! (N:even)
		cnt = fact_time(N/2, 5);
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256