akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef priority_queue<ll, vl> decendingQueue;              //降順
typedef priority_queue<ll, vl, greater<ll>> ascendingQueue; //昇順
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 9 * 1e18;
const ll MOD = 1e9 + 7;

ll calc(long long N, long long C, std::vector<long long> &x,
        std::vector<long long> &v) {
  vl leftAccVMinusX(N + 1);
  leftAccVMinusX[1] = v[0] - x[0];
  rep(i, 2, N + 1) {
    leftAccVMinusX[i] = leftAccVMinusX[i - 1] + v[i - 1] - x[i - 1] + x[i - 2];
  }

  vl rightAccVMinusX(N + 1);
  rightAccVMinusX[1] = v[N - 1] - 2 * (C - x[N - 1]);
  rep(i, 2, N + 1) {
    rightAccVMinusX[i] = rightAccVMinusX[i - 1] + v[N - i] -
                         2 * (C - x[N - i]) + 2 * (C - x[N + 1 - i]);
  }

  vl maxAccVMinusX(N + 1);
  rep(i, 1, N + 1) {
    maxAccVMinusX[i] = max(maxAccVMinusX[i - 1], leftAccVMinusX[i]);
  }

  ll ret = 0;
  rep(i, 0, N + 1) {
    ll tmp = rightAccVMinusX[i] + maxAccVMinusX[N - i];
    ret = max(ret, tmp);
  }
  return ret;
}

void solve(long long N, long long C, std::vector<long long> x,
           std::vector<long long> v) {
  ll rightFirst = calc(N, C, x, v);

  reverse(all(v));
  vl xrev(N);
  rep(i, 0, N) { xrev[i] = C - x[N - i - 1]; }
  ll leftFirst = calc(N, C, xrev, v);

  print(max(rightFirst, leftFirst));
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long C;
  scanf("%lld", &C);
  std::vector<long long> x(N);
  std::vector<long long> v(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &x[i]);
    scanf("%lld", &v[i]);
  }
  solve(N, C, std::move(x), std::move(v));
  return 0;
}


Measured memory_bytes: 4944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll ans[10][10];
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		cin>>ans[i][j];
	}
	ll n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		for(int j=0;j<3;j++)
		{
			for(int k=0;k<3;k++)
			{
				if(ans[j][k]==t)
				{
					ans[j][k]=-1;
				}
			}
		}
	}
	bool f=false;
	if(ans[0][0]==-1&&ans[0][1]==-1&&ans[0][2]==-1)
	f=true;
	if(ans[1][0]==-1&&ans[1][1]==-1&&ans[1][2]==-1)
	f=true;
	if(ans[2][0]==-1&&ans[2][1]==-1&&ans[2][2]==-1)
	f=true;
	if(ans[0][0]==-1&&ans[1][0]==-1&&ans[2][0]==-1)
	f=true;
	if(ans[0][1]==-1&&ans[1][1]==-1&&ans[2][1]==-1)
	f=true;
	if(ans[0][2]==-1&&ans[1][2]==-1&&ans[2][2]==-1)
	f=true;
	if(ans[0][0]==-1&&ans[1][1]==-1&&ans[2][2]==-1)
	f=true;
	if(ans[0][2]==-1&&ans[1][1]==-1&&ans[2][0]==-1)
	f=true;
	if(f)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<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 ll long long

int main() {
  string s;
  cin >> s;
  string Ss,sS;
  int q;
  cin>>q;
  int rev =0;
  rep(i,q){
    int t;
    cin >> t;
    if(t==1){
      rev++;
      continue;
    }
    int f;
    cin >> f;
    string c;
    cin >> c;
    if(rev%2==1){
      if(f==2) Ss = c + Ss;
      else sS = sS + c;
      continue;
    }
    if(f==1) Ss = c + Ss;
    else sS = sS + c;
  }
  s = Ss + s + sS;
  if(rev%2==1) reverse(s.begin(),s.end());
  cout << s;
}



Measured memory_bytes: 1512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int a,b;
	cin>>a>>b;


	if(a>9||b>9)cout<<"-1"<<endl;
	else cout<<a*b<<endl;

	return 0;

}


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

int main() {
    int n;
    cin>>n;
    long long a[n];
    long long x=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        x ^= a[i];
    }
    for(int i=0;i<n;i++)
        cout<<(x^a[i])<<" ";
    cout<<endl;
	return 0;
}


Measured memory_bytes: 5108
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    vector<vector<int>> f(3,vector<int>(3,0)),res(3,vector<int>(3,0));
    rep(i,3)rep(j,3)cin >> f[i][j];
    int n;cin >> n;
    auto check = [&](int x){
        rep(i,3)rep(j,3){
            if(f[i][j] == x){
                res[i][j] = 1;
                return true;
            }
        }
        return false;
    };
    rep(i,n){
        int x;cin >> x;
        check(x);
    }
    // trace(res);
    rep(i,3){
        bool ok = true;
        rep(j,3){
            if(!res[i][j])ok = false;
        }
        if(ok){
            cout << "Yes" << endl;
            return 0;
        }
    }
    rep(j,3){
        bool ok = true;
        rep(i,3){
            if(!res[i][j])ok = false;
        }
        if(ok){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(res[0][0] &&res[1][1] &&res[2][2]){
        cout << "Yes" << endl;
        return 0;
    }
    if(res[0][2] &&res[1][1] &&res[2][0]){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3588
n = int(input())
a = [int(i) for i in input().split()]
print(" ".join(map(str,a)))
for i in range(1,n):
    v = a[i]
    j = i-1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = v
    print(" ".join(map(str,a)))


Measured memory_bytes: 5604
#include <iostream>
#include <math.h>

using namespace std;

int main(){
  int N,D;
  int X[11][11];
  int dist[11][11] = {{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}};
  int ans = 0;

  cin >> N >> D;
  for(int i = 1;i <= N;i++){
    for(int j = 1;j <= D;j++){
      cin >> X[i][j];
    }
  }
  
  for(int i = 1;i <= N-1;i++){
    for(int j = i+1;j <= N;j++){
      for(int k = 1;k <= D;k++){
        //でばっぐ
        /*cout << "i = " << i << endl;
        cout << "j = " << j << endl;
        cout << "k = " << k << endl;
        cout << "X[i][k] - X[j][k] = " << X[i][k] - X[j][k] << endl;
        cout << "(X[i][k] - X[j][k]) * (X[i][k] - X[j][k]) = " << (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]) << endl;*/
        //でばっぐ終わり
        dist[i][j] += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      }
    }
  }
  
  for(int i = 1;i <= N-1;i++){
    for(int j = i+1;j <= N;j++){
      for(int k = 1;k <= 640;k++){
        if(dist[i][j] / k == k && dist[i][j] % k == 0)
        ans ++;
      }
      
    }
  }
  //でばっぐ
  /*cout << "N = " << N << endl;
  cout << "D = " << D << endl;
  for(int i = 1;i <= N;i++){
    for(int j = 1;j <= D;j++){
      cout << "X[" << i << "][" << j <<"]" << X[i][j] << endl;
    }
  }
  for(int i = 1;i <= N-1;i++){
    for(int j = i+1;j <= N;j++){
      cout << "dist[" << i << "," << j<< "]"<< dist[i][j] << endl;
    }
  }
  */
  cout << ans;
  
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 03.02.2018 17:19:54       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n), b(n);
  long long sum_a = 0, sum_b = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    sum_a += a[i];
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
    sum_b += b[i];
  }
  if (sum_a > sum_b) {
    puts("No");
    return 0;
  }
  long long ops = sum_b - sum_a;
  long long need = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] < b[i]) {
      long long diff = b[i] - a[i];
      need += (diff + 1) / 2;
    }
  }
  if (need <= ops) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifdef LOCAL
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define debug(x) ;
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

template< class T >
struct Matrix{
  vector<vector<T> > val;

  Matrix(int n): val(n, vector<T>(n)) {}

  int height() const { return (int)val.size(); }
  int width() const { return (int)val[0].size(); }

  Matrix operator * (const Matrix& B) {
    int n = height();
    Matrix result(n);

    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
        for(int k=0;k<n;k++)
          (result[i][k] += val[i][j] * B[j][k]) %= mod;

    return result;
  }

  const vector<T>& operator[] (const int i) const {
    return val[i];
  }

  vector<T>& operator [] (const int i) {
    return val[i];
  }
};

Matrix<ll> power(Matrix<ll> k, ll n){
  if(n==0) return 1;
  if(n==1) return k;

  auto res = power(k, n/2);

  res = res * res;

  if(n % 2)
    res = k * res;

  return res;
}



int main(){
  int n;
  ll k;

  scanf("%d%lld", &n, &k);

  Matrix<ll> mat(n);

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      scanf("%lld", &mat[i][j]);
    }
  }

  auto res = power(mat, k);

  ll ans = 0;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      ans = (ans + res[i][j]) % mod;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1536
def swap(i,j):
  X=A[i]
  A[i]=A[j]
  A[j]=X

N,M=map(int,input().split())
A=list()
for i in range(N):
  A.append(int(input()))
for i in range(M):
  for j in range(N-1):
    if A[j]%(i+1)>A[j+1]%(i+1):
      swap(j,j+1)
for i in range(N):
  print(A[i])


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define fi first 
#define se second
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
// ミント
const int mod = 1e9+7 ;
//998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}   ;
 
mint modpow(ll a,ll b){
 if(b==0) return 1 ;
 mint c= modpow(a,b/2) ;
 if(b%2==1) return c*c*a ;
 else return c*c ;
}

mint komb(ll n,ll m){
  mint x=1 ;mint y=1 ;
  rep(i,m){
    x*= n-i ;
    y*= i+1 ;
  }
  return x/y ;
}

 
 map<ll,ll> factor(ll n){  //素因数とオーダーをマップで管理
  map <ll,ll> ord ;  
  for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int res=0;
            while(n%i==0){
                n/=i;
                res++;
            }
            ord[i]=res;
        }
    }
   if(n!=1) ord[n]++;
   return ord ;
 }

int main(){
  ll n,m ; cin>>n >> m ;
  
  map<ll,ll> mp= factor(m) ;
  mint ans= 1 ;
  combination c(2000000) ;
  for(auto u : mp){
    mint a = c(u.se+n-1,u.se) ;
    ans = ans * a ;
  }
  cout<<ans<<endl ;
    return 0;
  }
   

Measured memory_bytes: 34416
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> 	pii;
typedef long long 		ll;
typedef vector<int> 	vi;
#define PI 				3.14159265
#define int				long long
#define f 				first
#define s 				second
#define mtup 			make_tuple
#define nl 				'\n'
#define FLASH 			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define maxheap 		priority_queue<ll>
#define minheap 		priority_queue<ll,vector<ll> ,greater<ll>>
const ll inf = 1e18 + 1;
const int mod = 1e9 + 7;
const int maxn = 3e5;
ll modpow(ll a,ll b,int mod = inf) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) {return __gcd(a,b);}
int dp[1111][1111], n, m; char grid[1111][1111];

int solv(int i, int j){
	if (i == n and j == m) return dp[i][j] = 1;
	if (dp[i][j] != -1) return dp[i][j];
	int sum = 0;
	if (j + 1 <= m) if (grid[i][j + 1] == '.') sum += solv(i, j + 1);
	if (i + 1 <= n) if (grid[i + 1][j] == '.') sum += solv(i + 1, j);
	return dp[i][j] = sum % mod;
}

signed main(){
	FLASH
	cin >> n >> m;
	memset(dp, -1, sizeof(dp));
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			cin>>grid[i][j];
	cout<<solv(1,1);


	return 0;
}


Measured memory_bytes: 11008
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

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

    vector<int> nums(4);
    rep(i, 4) nums[i] = n[i] - '0';

    map<int, char> chars;
    chars[-1] = '-';
    chars[1] = '+';

    bool flag = true;
    for(int i = -1; i <= 1 && flag; i++){
        for(int j = -1; j <= 1 && flag; j++){
            for(int k = -1; k <= 1 && flag; k++){
                if(i != 0 && j != 0 && k != 0 && nums[0] + nums[1]*i + nums[2]*j + nums[3]*k == 7){
                    cout << nums[0] << chars[i] << nums[1] << chars[j] << nums[2] << chars[k] << nums[3] << "=7" << endl;
                    flag = false;
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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;
	}
}

// 二項係数計算
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int n, m;
int a[114514];
int dp[114514];
signed main() {
	cin >> n >> m;
	rep(i, m)cin >> a[i];
	rep(i, n + 1)dp[i] = inf;
	rep(i, m)dp[a[i] - 1] = 0;
	if (dp[0] != 0)dp[0] = 1;
	if (dp[1] != 0)dp[1] = dp[0] + 1;
	for (int i = 2; i < n; i++) {
		if (dp[i] != 0) {
			dp[i] = dp[i - 1] + dp[i - 2];
			dp[i] %= mod;
		}
	}
	cout << dp[n - 1] << endl;
	ggr
}


Measured memory_bytes: 1792
import collections
n = int(input())
k = []
result=[]
for i in range(n):
    a = input()
    k.append(a)
ans = collections.Counter(k)
for i in range(1,n):
    if k[i-1][-1] == k[i][0] and ans.most_common()[0][1] == 1:
        result.append("1")
    else:
        result.append("0")
aim = collections.Counter(result)
if aim.most_common()[0][1] != n-1 or aim.most_common()[0][0] =='0':
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3444
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
  class Program
  {
    static void Main(string[] args)
    {
      

      string line = Console.ReadLine();
      string[] abc = line.Split(' ');
      int red = Int32.Parse(abc[0]);
      int green = Int32.Parse(abc[1]);
      int blue = Int32.Parse(abc[2]);
      line = Console.ReadLine();
      int k = Int32.Parse(line);

      for (int i = 0; i < k; ++i) {
        if (green <= red) {
          green *= 2;
        }
        else if (blue <= green) {
          blue *= 2;
        }
      }

      if (green > red && blue > green) Console.Write("Yes");
      else Console.Write("No");
      int a = 0;
    }
  }
	class list{
		public int juni;
		public int old;
		public list(int juni, int old){
			this.juni = juni;
			this.old = old;
		}
	}
}


Measured memory_bytes: 27500
#include<stdio.h>
int main(void)
{
  int paid,price;
  char str[16];
  
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&paid);
  
  price = paid * 100 / 108;
  
  if(price*108/100 == paid)
  {
    printf("%d",price);
  }else if((price+1)*108/100 == paid)
  {
    printf("%d",price+1);
  }else
  {
    puts(":(");
  }
  
  return 0;
}

Measured memory_bytes: 128
n = int(input())
cnt = 0
mcnt = 0
ans = 1
temp = 0

for i in range(2, n + 1):
    temp = i
    while i%2 == 0:
        i //= 2
        cnt += 1
    if cnt > mcnt:
        mcnt = cnt
        ans = temp
    cnt = 0

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define M 10000007;
typedef pair<int,int> P;
int main(void)
{
	priority_queue<P,vector<P>,greater<P> > que;
	int q;
	int n,m;
	int s;
	int a,b;
	int c,d,e;
	int i,j;
	int leng[101];
	int ri[101][101];
	while(1){
		cin>>n>>m;
		if(n==0&&m==0) break;
		
		//隣接行列 初期化
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++) ri[i][j]=M;
		}
		
		for(i=0;i<m;i++){
			cin>>s;
			
			//ダイクストラ法
			if(s==0){
				for(j=1;j<=n;j++) leng[j]=M;
				cin>>a>>b;
				leng[a]=0; que.push(P(0,a));
				while(!que.empty()){
					P q=que.top(); que.pop();
					if(leng[q.second]<q.first) continue;
					for(j=1;j<=n;j++){
						if(leng[j]>q.first+ri[q.second][j]){
							leng[j]=q.first+ri[q.second][j];
							que.push(P(leng[j],j));
						}
					}
				}
				if(leng[b]==10000007) cout<<-1<<endl;
				else cout<<leng[b]<<endl;
			}
			
			//隣接行列
			else{
				cin>>c>>d>>e;
				if(ri[c][d]>e){
					ri[c][d]=e;
					ri[d][c]=e;
				}
				/*for(i=1;i<=n;i++){
					for(j=1;j<=n;j++) cout<<ri[i][j]<<" ";
					cout<<endl;
				}
				cout<<endl;*/
			}
			
		}
	}
	return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>

int main(void){
  int i, temp, sort[3];

  scanf("%d %d %d", &sort[0], &sort[1], &sort[2]);

  while(sort[0] > sort[1] || sort[1] > sort[2]){
  for(i=0;i<2;i++){
    if(sort[i] > sort[i+1]){
      temp = sort[i];
      sort[i] = sort[i+1];
      sort[i+1] = temp;
    }
  }
  }

  printf("%d %d %d\n", sort[0], sort[1], sort[2]);

  return 0;
}



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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;




int make(int mask, vector<string> g) {
    int n = g.size();
    int m = g[0].size();
    for (int bit=0; bit<n; bit++) {
	if (mask>>bit&1) {
	    for (int j=0; j<m; j++) {
		g[bit][j]='x';
	    }
	}
    }
    for (int bit=n; bit<n+m; bit++) {
	if (mask>>bit&1) {
	    for (int i=0; i<n; i++) {
		g[i][bit-n]='x';
	    }
	}
    }

    int res = 0;
    for (int i=0; i<n; i++) {
	for (int j=0; j<m; j++) {
	    res += (g[i][j]=='#');
	}
    }
    return res;
}

int n,m,k;
vector<string> g;

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

    cin>>n>>m>>k;
    g.resize(n);
    for (int i=0; i<n; i++) {
	cin>>g[i];
    }

    int ans = 0;

    for (int mask=0; mask<(1<<(n+m)); mask++) {
	int cnt = make(mask, g);
	ans += (cnt==k);
    }

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


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int gcd(int x,int y){
    return y ? gcd(y,x%y) : x;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    if(s[0]=='S'&&s[1]=='U')cout << 7;
    else if(s[0]=='M')cout << 6;
    else if(s[0]=='T'&&s[1]=='U')cout<<5;
    else if(s[0]=='W')cout<<4;
    else if(s[0]=='T'&&s[1]=='H')cout<<3;
    else if(s[0]=='F')cout<<2;
    else cout<<1;
    
}


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

int vis[20][20];
int c[10];
int k;
int f;

void dfs(int t)
{
    if(t == 8-k && f==0)
    {
        f=1;
        for(int i=0; i<8; i++)
        {
            for(int j=0; j<8; j++)
            {
                    if(c[i]==j)
                        printf("Q");
                    else
                        printf(".");
            }
            printf("\n");
        }
        return;
    }
    if(f==0)
    {
        for(int i=0; i<8; i++)
        {
            if(c[i] == -1)
            {
                for(int j=0; j<8; j++)
                {
                    if(vis[0][j] == 0 && vis[1][i+j]==0 && vis[2][j-i+8]==0)
                    {
                        vis[0][j] = vis[1][i+j]=vis[2][j-i+8] = 1;
                        c[i]=j;
                        dfs(t+1);
                        vis[0][j] = vis[1][i+j]=vis[2][j-i+8] = 0;
                        c[i] = -1;
                    }
                }
            }
        }
    }

}

int main()
{

    memset(c,-1,sizeof(c));
    int x,y;
    scanf("%d",&k);
    for(int i=0; i<k; i++)
    {
        scanf("%d %d",&x,&y);
        c[x] = y;
        vis[0][y] = 1;
        vis[1][x+y]=1;
        vis[2][y-x+8]=1;
    }
    f=0;
    dfs(0);
}



Measured memory_bytes: 2692
def pair(n,count):
    l=[];su=0
    for i in range(0,len(n),2):
        sub=list()
        sub.append(n[i:i+2])
        su=su+sub[0][0]
        l.append(sub)
    return(su)
        
def ip11(): return int(input())
def ip22(): return [int(_) for _ in input().split()]
        

def main():
    ip1=ip11()
    ip2=ip22()
    ip2.sort()
    print(pair(ip2,ip1))
    return
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

public class program{
    public static void Main(){
        var ab = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var a = ab[0];
        var b = ab[1];
        Console.WriteLine("{0} {1}", a*b, 2*(a+b));
    }
}



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

using namespace std;
long long int a[110],b[110],dp[110][110][330];
int main()
{
    int n,m;
    cin >> n >> m;
    for(int i=1;i<=n;i++)
    {
        cin >> a[i] >> b[i];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            for(int k=0;k<=3*j;k++){
                dp[i+1][j][k] = max(dp[i+1][j][k],dp[i][j][k]);
              
                dp[i+1][j+1][k+a[i]-a[1]] = max(dp[i+1][j+1][k+a[i]-a[1]],dp[i][j][k] + b[i]);
            }
        }
    }
    long long int  ans = 0;
  
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=3*i;j++){
            long long int w = a[1]*i + j;
            if(w <= m)
                ans = max(ans,dp[n+1][i][j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 29056
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    int ans = 0, min_a = INF, max_a = 0, min_b = INF;
    rep(i, 0, n) {
        int a, b;
        cin >> a >> b;
        max_a = max(max_a, a);
        min_a = min(min_a, a);
        min_b = min(min_b, b);
    }
    ans = (max_a-min_a+1) + (min_a-1) + min_b;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
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;
}

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll n;
cin>>n;
ll a,b;
cin>>a>>b;
cout<<min(n*a,b)<<endl;
}









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

input=sys.stdin.readline      

n, q = map(int, input().split())

lv =[[] for _ in range(n)]
ans=[0] * (n)

def dfs(v,p=-1):
    for u in lv[v]:
        if u == p: continue
        ans[u] += ans[v]
        dfs(u,v)

for _ in range(n-1):
    a,b = map(int,input().split())
    lv[a-1].append(b-1)
    lv[b-1].append(a-1)

for _ in range(q):
    p,x = map(int,input().split())
    ans[p-1] += x

dfs(0)

print(*ans)
# for i in ans:print(i)

Measured memory_bytes: 268468
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

vector<int> yaku(int n) {
  vector<int> result;
  for(int i=1; i*i<=n; i++) {
    if (i*i==n) result.push_back(i);
    else if (n%i==0) { result.push_back(i); result.push_back(n/i); }
  }
  sort(result.begin(),result.end());
  return result;
}

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

  vector<int> y = yaku(M);
  int pos = (upper_bound(y.begin(), y.end(), M/N)-y.begin()) - 1;
  int result = y[pos];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<numeric>
#include<math.h>
#include<deque>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string s;
    cin >> s;
    int q;
    cin >> q;
    bool rev = false;
    deque<char> deq;
    rep(i, s.size()) {
        deq.push_back(s[i]);
    }
    rep(i, q) {
        int t;
        cin >> t;
        if ( t == 1 ) rev = !rev;
        if ( t == 2 ) {
            int f;
            char c;
            cin >> f >> c;
            if ( !rev && f == 1 || rev && f == 2 ) deq.push_front(c);
            if ( !rev && f == 2 || rev && f == 1 ) deq.push_back(c); 
        }
    }
    int n = deq.size();
    rep(i, n) {
        if ( rev ) {
            cout << deq.back();
            deq.pop_back();
        }
        else {
            cout << deq.front();
            deq.pop_front();
        }
    }
    return 0;
}


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

int main()
{
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<char>> cake(H, vector<char>(W));
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin >> cake[i][j];
    }
  }
  vector<vector<int>> ans(H, vector<int>(W));
  int cnt = 1;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (cake[i][j] == '#')
      {
        ans[i][j] = cnt;
        cnt++;
      }
    }
  }
  for (int i = 0; i < H; i++)
  {
    for (int j = 1; j < W; j++)
    {
      if (ans[i][j] == 0)
      {
        ans[i][j] = ans[i][j - 1];
      }
    }
  }
  for (int i = 0; i < H; i++)
  {
    for (int j = W - 2; j >= 0; j--)
    {
      if (ans[i][j] == 0)
      {
        ans[i][j] = ans[i][j + 1];
      }
    }
  }
  for (int i = 1; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (ans[i][j] == 0)
      {
        ans[i][j] = ans[i - 1][j];
      }
    }
  }
  for (int i = H - 2; i >= 0; i--)
  {
    for (int j = 0; j < W; j++)
    {
      if (ans[i][j] == 0)
      {
        ans[i][j] = ans[i + 1][j];
      }
    }
  }
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cout << ans[i][j] << " ";
    }
    cout << endl;
    cout << endl;
  }
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		long ans = 0;
		int sum = 0;
		int r = 0;
		for (int l = 0; l < n; l++) {
			while (r < n) {
				if (sum + a[r] == (sum ^ a[r])) {
					sum += a[r];
					r++;
				} else {
					break;
				}
			}
			ans += r - l;
			sum -= a[l];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 65796
def gcd(x,y):
  if y == 0:
    return x
  else:
    return gcd(y,x%y)

N,K = map(int,input().split())
A = list(map(int,input().split()))

GCD = A[0]
for i in range(1,N):
    GCD = gcd(GCD,A[i])
    
MAX = max(A)

if MAX >= K and (MAX-K)%GCD == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 14252
// In the Name of Allah. Ya Ali!
#include<bits/stdc++.h>
typedef long long ll;
const ll MAX_N = 1e5+5;
const ll MOD = 1e9+7;
using namespace std;

vector<int> g[MAX_N];
int dp[MAX_N];
int d[MAX_N];
int n,m;

int main()
{
    cin >> n >> m;
    for(int i = 0;i<m;++i)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        g[v].push_back(u);
        d[u]++;
    }
    set<int> st;
    for(int i = 1;i<=n;++i)
    {
        if (!d[i])
            st.insert(i);
    }
    while(st.size())
    {
        int v = *st.begin();
        st.erase(v);
        for(auto x:g[v])
        {
            dp[x] = max(dp[x],dp[v]+1);
            d[x]--;
            if (!d[x])
                st.insert(x);
        }
    }
    int ans = 0;
    for(int i = 1;i<=n;++i)
        ans = max(ans,dp[i]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	int n;
	cin >> n;
	using P = pair<double,double>;
	vector<P> xy;
	for(int i=0;i<n;i++)
	{
		double x,y;
		cin >> x >> y;
		xy.emplace_back(x,y);
	}
	sort(xy.begin(),xy.end());

	double sum = 0;
	do
	{
		for(int i = 0;i<n-1;i++)
		{
			double X = (xy[i].first-xy[i+1].first);
			double Y = (xy[i].second-xy[i+1].second);
			sum += sqrt(X*X+Y*Y);
		}
		//cout<<sum<<endl;
	}while (next_permutation(xy.begin(),xy.end()));
	double a=1;
	for(int i = 1;i<=n;i++)
	{
		a*=i;
	}
	printf("%.10lf\n",sum/a);
	
	return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll n, d, a;cin >> n >> d >> a;
	vector<P> v(n);
	REP(i, n)cin >> v[i].FI >> v[i].SE;

	sort(ALL(v));
	queue<P> q;
	ll now_power = 0;
	ll ans = 0;

	REP(i, n){
		while(!q.empty() && q.front().FI <= v[i].FI){
			auto power = q.front().SE;q.pop();
			now_power -= power;
		}
		ll cou = max(0LL, ((v[i].SE - now_power) + a - 1) / a);
		ans += cou;
		now_power += cou * a;
		q.push(MP(v[i].FI + 2 * d + 1, cou * a));
		//cout << v[i].FI << " " << v[i].SE << " " << ans << " " << now_power << endl;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6656
// ALDS1_1_A: Insertion Sort

use std::str::FromStr;

fn trace(a: &Vec<i64>, n: usize) {
    for _i in 0..n {
        if _i > 0 {
            print!(" ");
        }
        print!("{}", a[_i]);
    }
    println!("");
}

fn insert_sort(a: &mut Vec<i64>, n: usize) {
    for _i in 1..n {
        let v = a[_i];
        let mut j = _i;
        while j > 0 && a[j - 1] > v {
            a[j] = a[j - 1];
            j -= 1;
        }
        a[j] = v;
        trace(a, n);
    }
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let n: usize = it.next().unwrap();

    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.split_whitespace().map(|n| i64::from_str(n).unwrap());
    let mut a: Vec<i64> = Vec::new();
    while let Some(v) = it.next() {
        a.push(v);
    }

    trace(&a, n);
    insert_sort(&mut a, n);
}


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

using namespace std;

int main() {

    int n;
    int r, t;

    cin >> n;

    for(int i = 0; i < n; ++i) {
        cin >> r >> t;
        if(r % 100 == 0 && t % 30 == 0) {
            cout << 5 * (t / 30) + r / 100 << endl;
        } else if(r % 100 == 0 && t % 30 != 0) {
            int t0 = t / 30;
            int t1 = t0 + 1;
            cout << t0 * 5 + r / 100 << " ";
            cout << t1 * 5 + r / 100 << endl;
        } else if(r % 100 != 0 && t % 30 == 0) {
            int r0 = r / 100;
            int r1 = r0 + 1;
            cout << t / 30 * 5 + r0 << " ";
            cout << t / 30 * 5 + r1 << endl;
        } else {
            int t0 = t / 30;
            int t1 = t0 + 1;
            int r0 = r / 100;
            int r1 = r0 + 1;
            cout << 5 * t0 + r0 << " ";
            cout << 5 * t0 + r1 << " ";
            cout << 5 * t1 + r0 << " ";
            cout << 5 * t1 + r1 << endl;
        }
    }

}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%lld", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
ll h[200005];
bool cmp(ll a,ll b){
        return a>b;
}
int main(){
        int n,k;
        while(~getII(n,k)){
                F(i,0,n) getI(h[i]);
                sort(h,h+n,cmp);
                ll ans=0;
                F(i,k,n) ans+=h[i];
                printf("%lld\n",ans);
        }
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//pow(x,n) == x^n
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

string s,t;
cin >> s >> t;

cout << t << s << endl;





//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;



int main(){
    INIT;
    long double W, H, x, y;
    cin >> W >> H >> x >> y;
    if((x == 0 && y == 0) || (x == W && y ==0) || (x == 0 && y == H) || (x == W && y == H)) {
        cout << std::setprecision(12) << ((W*H)/2);
        cout << " " << 0;
        return 0;
    } 
    int ok = 0;
    if(W/2 == x && H/2 == y) ok = 1;
    cout << std::setprecision(12) << ((W*H)/2);
    cout << " " << ok;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define max_n 100
int N;
int H[100001];
int main() {
	cin >> N;
	rep(i,N)
	{
		cin >> H[i];
	}
	int ans = 0;
	int now = 0;
	int nowhigh = 0;
	rep(i,N)
	{
		if (nowhigh >= H[i]) {
			now++; nowhigh = H[i];
		}
		else{
			if (ans < now)ans = now;
			now = 0;
			nowhigh = H[i];
		}
	}
	if (ans < now)ans = now;
	cout << ans <<endl;
	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) int(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 998244353 //1000000007
#define inf 1000000007
#define ll long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 100010

template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}

int pow(int a,int b){
	cerr<<a<<" "<<b<<"\n";
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}

int a[102];
int main(){
    //cout<<setprecision(9)<<fixed;
    srand(time(NULL));
    int T,ca=0,m=0,k,i,j,n,K;
	scanf("%d",&n);
	rep(i,0,n)scanf("%d",&a[i]);
	int ans=0;
	rep(i,0,n){
		j=i;
		while(j<n&&a[j]==a[i])j++;
		k=j-i;
		ans+=k/2;
		i=j-1;
	}
	printf("%d\n",ans);
}	



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

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

int main()
{
	int n; cin>>n;
	map<string,int> anko;
	rep(i,n){
		string s; cin>>s;
		anko[s]++;
	}
	
	//回数を数える
	int max=0;
	for(auto& x:anko){
		int a=x.second;
		if(a>max) max=a;
	}
	for(auto it=anko.begin();it!=anko.end();++it){
		if(it->second==max) cout<<it->first<<endl;
	}
	return 0;
}

Measured memory_bytes: 25216