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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  map<int,P<int,int>> pos;
  for(int i = 0; i < 9; ++i){
    int n; cin >> n;
    pos.insert({n,{i/3,i%3}});
  }
  bool open[3][3] = {};
  int n; cin >> n;
  for(int i = 0; i < n; ++i){
    int x; cin >> x;
    if(pos.count(x))open[pos[x].first][pos[x].second] = 1;
  }
  bool f = false;
  for(int i = 0; i < 3; ++i){
    bool g = true;
    for(int j = 0; j < 3; ++j){
      g &= open[i][j];
    }
    f |= g;
  }
  for(int i = 0; i < 3; ++i){
    bool g = true;
    for(int j = 0; j < 3; ++j){
      g &= open[j][i];
    }
    f |= g;
  }  
  {
    bool g = true;
    for(int j = 0; j < 3; ++j){
      g &= open[j][j];
    }
    f |= g;
  }
  {
    bool g = true;
    for(int j = 0; j < 3; ++j){
      g &= open[2-j][j];
    }
    f |= g;
  }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e18;
using namespace std;
typedef long long ll;
int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll diff = abs(a - b) - 1;
  if (diff % 2 == 0) {
    cout << "Borys" << endl;
  } else {
    cout << "Alice" << endl;
  }
  return 0;
}


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



int main(){
    ll n,k;cin>>n>>k;
    ll an=0;
    for(ll i=k;i<=n+1;i++){
        ll beg=i*(i+1)/2-i;
        ll end=n*(n+1)/2-(n-i)*(n-i+1)/2;
        an+=end-beg+1;
        an%=(ll)(1e9+7);
    }
    cout<<an<<endl;
}
    









Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main(){
  string str;
  cin >> str;
  if ( str[0] != 'A' ){
    cout << "WA" << endl;
    return 0;
  }
  
  int cnum = 0;
  for ( int i = 2; i < str.size() - 1; i++ ){
    if ( str[i] == 'C' ) cnum++;
  }
  
  if ( cnum != 1 ){
    cout << "WA" << endl;
    return 0;
  }
  int count = 0;
  for( int i = 0; i < str.size(); i++ ){
    if ( isupper( str[i] ) ){
      count++;
    }
  }
  
  if ( count != 2 ){
    cout << "WA" << endl;
  }else{
    cout << "AC" << endl;
  }
}

Measured memory_bytes: 256
/**    epsileer 01 September 2019  17:37:04  **/    
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<LL,LL> PII;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define TEST int t = 1; while(t--) solve()

void solve(){
    int a,b; cin>>a>>b;
    int ans = 1;
    b -= a;
    ans += ceil((LD)b/(a-1));
    cout<<ans;
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); TEST;
return 0;
}

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

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n = 0;
	cin >> n;
	vector <int> v(n);
	for(int i = 1; i<n;i++){
		int x;
		cin >> x;
		++v[--x];
		
	}
	for(int i =0; i<n;i++){
		cout << v[i] << '\n';
	}
}

Measured memory_bytes: 3988
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=1000005;
int n,i,j,k,a[N],cnt,tot;
char s[N];
int Abs(int a)
{
	return a>0?a:-a;
}
int C(int n,int m)
{
	return (m|n)==n;
	if(n%2<m%2)
		return 0;
	if(n==0)
		return 1;
	return C(n/2,m/2);
}
int main()
{
	scanf("%d%s",&n,s+1);
	for(i=1;i<n;++i)
		a[i]=Abs(s[i]-s[i+1]);
	--n;
	for(i=1;i<=n;++i)
		if(a[i]==1)
			break;
	if(i<=n)
	{
		k=1;
		for(i=1;i<=n;++i)
			if(a[i]==2)
				a[i]=0;
	}
	else
	{
		k=2;
		for(i=1;i<=n;++i)
			if(a[i]==2)
				a[i]=1;
	}
	j=0;
	for(i=1;i<=n;++i)
		j=(j+1ll*C(n-1,i-1)*a[i])%2;
	printf("%d",j*k);
	return 0;
}


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

signed main(void)
{
	int n, x, cnt;
	cin >> n >> x;
	vector<int> m(n);
	cnt = 0;	
	rep(i, n)
	{
		cin >> m.at(i);
		x -= m.at(i);
		cnt++;
	}
	sort(m.begin(), m.end());
	cnt += x / m[0];
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <chrono> 
using namespace std::chrono;
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_mset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fr(i,a,b) for (ll i=(a); i<(b);++i)
#define frr(i,a,b) for(ll i=(a-1);i>=(b);--i)
#define vi vector<ll>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define F first
#define S second
#define pii pair<ll,ll> 
#define rev(a) reverse(a.begin(),a.end())
#define srt(a,k) sort(a,a+k,greater<ll>())
#define rsrt(a) sort(a.begin(),a.end(),greater<ll>())
#define sz(a) (ll)a.size()
//#define endl "\n"
#define po(a,b) (ll)(pow(a,b)+0.5)
#define double long double
#define print(a) for(auto x:a)cout<<x<<" ";cout<<endl;
#define setbits(a) __builtin_popcount(a)
const ll M=1e9+7;
const ll MX=1e6+1;

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

  int tt=1;
  //cin>>tt;
  while(tt--)
  {
     string s;
     cin>>s;
     int cnt=(s[0]=='R')+(s[1]=='R')+(s[2]=='R');
     if(cnt<=1 || cnt==3)cout<<cnt;
     else 
     {
       if(s[1]=='S')cout<<1;
       else cout<<2;
     }

  }
}



Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main () {
 int N, M, X;
 cin >> N >> M >> X;
 int p, q;
 p = 0;
 q = 0;

 for ( int i =0 ; i < M ; i ++) {
  int cost;
  cin >> cost;
  if ( cost > X ) {
   p++;
  }
  else {
   q++;
  }
 }
 if ( p > q ) {
 cout <<  q << endl;
 }
 else {
 cout << p << endl;
}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int n;
long long a,min=1000000,max=-1000000,sum=0;
cin>>n;
for(int i=0;i<n;i++){
cin>>a;
if(a<min)min=a;
if(a>max)max=a;
sum+=a;
}
cout<<min<<" "<<max<<" "<<sum<<endl;
return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int N;
ll a[410];
ll dp[410][410];
ll memo[410][410];

ll sum(int l, int r)
{
  if(memo[l][r] > 0) return memo[l][r];
  ll res = 0;
  if(l == 0){
    rep(i, r+1) res += a[i];
    return memo[l][r] = res;
  }
  else return memo[l][r] = sum(0, r) - sum(0, l-1);
}

ll rec(int l, int r)
{
  if(dp[l][r] > 0) return dp[l][r];
  if(l == r) return 0;

  ll res = INF;
  REP(m, l, r) chmin(res, rec(l, m) + rec(m+1, r) + sum(l, r));

  return dp[l][r] = res;
}


int main(){
  cin >> N;
  rep(i, N) cin >> a[i];
  
  cout << rec(0, N-1) << endl;

  return 0;
}


Measured memory_bytes: 2816
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int N=200005;
typedef long long ll;
const ll mod=924844033;

int n,hd[N],to[N*2],pr[N*2],tot,sz[N];
void addedge(int u,int v) {to[++tot]=v;pr[tot]=hd[u];hd[u]=tot;}
void dfs(int u,int fa) 
{
	sz[u]=1;
	for (int i=hd[u];i;i=pr[i]) if (to[i]!=fa) dfs(to[i],u),sz[u]+=sz[to[i]];
}



int jc[N],ny[N],ans[N];
int C(int n,int m) 
{
	if (n<m) return 0;
	return (ll)jc[n]*ny[m]%mod*ny[n-m]%mod;
}
int power_mod(int a,int b) 
{
	int ans=1;
	while (b) 
	{
		if (b&1) ans=(ll)ans*a%mod;
		a=(ll)a*a%mod;
		b>>=1;
	}
	return ans;
}
void MOD(int &x) {if (x>=mod) x-=mod;}
int om[N*4],on[N*4],rev[N*4],len;
void init(int n)
{
	int l=0;len=1;while (len<n) len<<=1,l++;
	int g=power_mod(5,(mod-1)/len),inv=power_mod(g,mod-2);
	for (int i=0;i<len;i++) 
	{
		om[i]= i==0 ? 1:(ll)om[i-1]*g%mod;
		on[i]= i==0 ? 1:(ll)on[i-1]*inv%mod;
		rev[i]=(rev[i>>1]>>1)|((i&1)<<l-1);
	}
}
void ntt(int *a,int *om,int n) 
{
	for (int i=0;i<n;i++) if (rev[i]>i) swap(a[i],a[rev[i]]);
	for (int len=2;len<=n;len<<=1) 
		for (int m=len/2,i=0;i<n;i+=len)
			for (int t,j=0;j<m;j++) 
			{
				t=(ll)a[i+j+m]*om[n/len*j]%mod;
				MOD(a[i+j+m]=a[i+j]-t+mod);
				MOD(a[i+j]+=t);
			}
}
void dft(int *a) {ntt(a,om,len);}
void idft(int *a) 
{
	ntt(a,on,len);
	int inv=power_mod(len,mod-2);
	for (int i=0;i<len;i++) a[i]=(ll)a[i]*inv%mod;
}
int c[N*4],d[N*4];


int main()
{
	scanf("%d",&n);
	for (int u,v,i=1;i<n;i++) 
	{
		scanf("%d%d",&u,&v);
		addedge(u,v);
		addedge(v,u);
	}
	dfs(1,0);
	
	//for (int i=1;i<=n;i++) printf("sz[%d]=%d\n",i,sz[i]);
	
	jc[0]=jc[1]=ny[0]=ny[1]=1;
	for (int i=2;i<=n;i++) jc[i]=(ll)jc[i-1]*i%mod,ny[i]=(mod-mod/i)*ny[mod%i]%mod;
	for (int i=2;i<=n;i++) ny[i]=(ll)ny[i-1]*ny[i]%mod;
	
	
	init(n*2+1);	
	for (int i=2;i<=n;i++) c[sz[i]]++;
	for (int i=2;i<=n;i++) c[n-sz[i]]++; 
	for (int i=n;i>=0;i--) d[i]=ny[n-i],c[i]=(ll)c[i]*jc[i]%mod;
	//for (int i=0;i<len;i++) printf("i=%d d=%d c=%d\n",i,d[i],c[i]);
	dft(c),dft(d);
	for (int i=0;i<len;i++) d[i]=(ll)d[i]*c[i]%mod;
	idft(d);
	for (int i=n+1;i<=n*2;i++) ans[i-n]=d[i];//printf("ans[%d]=%d\n",i-n,ans[i-n]);
	
	
	
	for (int i=1;i<=n;i++) 
	printf("%lld\n",(( (ll)n*C(n,i)-(ll)ans[i]*ny[i] )%mod+mod)%mod   );
//	system("pause");
	return 0;
}

Measured memory_bytes: 32640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    stack<int> st[n];
    for(int i = 0; i < q; i++)
    {
        int v, t, x;
        cin >> v;
        if(v == 0)
        {
            cin >> t >> x;
            st[t].push(x);
        }
        else if(v == 1)
        {
            cin >> t;
            if(st[t].size() != 0) cout << st[t].top() << "\n";
        }
        else if(v == 2)
        {
            cin >> t;
            if(st[t].size() != 0) st[t].pop();
        }
    }
    return 0;
}




Measured memory_bytes: 4180
function Main(input) {
    input = input.split("\n");
    var n = parseInt(input[0], 10);
    var h = input[1].split(' ');
    h = h.map(str => parseInt(str, 10));
    var mov = 0;
    var movHigh = 0;
    for(var i = 0; i < n-1; i++){
        if(h[i] >= h[i+1]){
            mov++;
        }else{
            movHigh = Math.max(movHigh,mov);
            mov = 0;
        }
    }
    movHigh = Math.max(movHigh,mov);
	console.log(movHigh);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int main(){
	long long w,h,x,y,r;
	
	cin>>w>>h>>x>>y>>r;
	
	if(x+r<=w && x-r>=0 && y-r>=0 && y+r<=h) cout<<"Yes\n";
		else cout<<"No\n";
			      
	return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    int w, h; cin >> h >> w;
    vector<string> HW(h);
    rep(i, h) cin >> HW[i];
    rep(i, h) cout << HW[i] << endl << HW[i] << endl;
    // rep(i, h) cout << HW[i] << endl;
    return 0;
}

Measured memory_bytes: 768
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-10;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  vector<int> v(5);
  rep(i, 5) cin >> v[i];
  rep(i, 5)
  {
    if (v[i] == 0)
    {
      cout << i + 1 << endl;
      return;
    }
  }
}

int main()
{
  init_main();

  solve();

  return 0;
}


Measured memory_bytes: 3616
#!/usr/bin/env python3
import sys
# sys.setrecursionlimit(10000000)
INF = 1<<32
# import numpy as np

MOD = 1000000007  # type: int

def solve(n: int, a: int, b: int):
    def combination_with_mod(n, r, mod=10**9+7):
        n1, r = n+1, min(r, n-r)
        numer = denom = 1
        for i in range(1, r+1):
            numer = numer * (n1-i) % mod
            denom = denom * i % mod
        return numer * pow(denom, mod-2, mod) % mod

    def power_func(a,n,p):
        bi=str(format(n,"b"))#2進表現に
        res=1
        for i in range(len(bi)):
            res=(res*res) %p
            if bi[i]=="1":
                res=(res*a) %p
        return res

    ans = 0
    ans = power_func(2, n, MOD)

    ans = ans-combination_with_mod(n, a)-combination_with_mod(n, b)-combination_with_mod(n, 0)
    if ans < 0:
        print((MOD+ans)%MOD)
    else:
        print(ans%MOD)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(n, a, b)

if __name__ == '__main__':
    main()


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

int main(){
    int Q;
    string str_x, str_y;
    int memo[1001][1001];
    cin >> Q;
    
    for(int q = 0;q < Q;q++){
        cin >> str_x >> str_y;
        
        for(unsigned int i = 0;i < str_x.size();i++){
            for(unsigned int j = 0;j < str_y.size();j++){
                if(str_x.at(i) == str_y.at(j)){
                    memo[i+1][j+1] = memo[i][j] + 1;
                }else{
                    memo[i+1][j+1] = max(memo[i][j+1], memo[i+1][j]);
                }
            }
        }
        
        printf("%d\n", memo[str_x.size()][str_y.size()]);
    }
    
    return 0;
}

Measured memory_bytes: 7108
n = int(input())
ls = list(map(int,input().split()))
di = [0]*(n+1)
ls = [0] + ls + [0]
for i in range(n+1):
    di[i] = abs(ls[i+1] - ls[i])
mx = sum(di)
for j in range(1,n+1):
    print(mx-di[j-1]-di[j]+abs(ls[j+1]-ls[j-1]))

Measured memory_bytes: 57708
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int height = scan.nextInt();
		int width = scan.nextInt();
		
		while(height != 0 || height != 0)
		{
			for(int i = 0;i < height;i++)
			{
				for(int j = 0;j < width;j++)
				{
					if(i % 2 == 0)
					{
						if(j % 2 == 0){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}else{
						if(j % 2 == 0){
							System.out.print(".");
						}else{
							System.out.print("#");
						}System.out.print("");
					}
				}
				System.out.println("");
			}
			System.out.println("");
			height = scan.nextInt();
			width = scan.nextInt();
		}
	}
}

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

using namespace std;

int bubbleSort(vector<int> &v) {
  int tot = 0;
  for (int i = 0, n = v.size(); i < n; i++) {
    bool isSorted = true;
    for (int j = n - 1; j > i; j--) {
      if (v[j] < v[j - 1]) {
        isSorted = false;
        swap(v[j], v[j - 1]);
        ++tot;
      }
    }
    if (isSorted) break;
  }
  return tot;
}

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int &i : v) cin >> i;
  int t = bubbleSort(v);
  cout << v[0];
  for (int i = 1; i < n; i++) {
    cout << " " << v[i];
  }
  cout << endl << t << endl;
  return 0;
}



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

int main () {
  int  N ;
  cin >> N ;
  int ans = 0 ;
  for(int i = 1 ; i <= 1+N ; i++ ){
    for(int j = 2 ; j <= 2+N ; j++ ){
      int pre = pow(i,j) ;
      if( pre <= N ) ans = max(ans,pre) ;
      else break ;
    }
  }
  cout << ans << endl ;
}


Measured memory_bytes: 256
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

string s;
int temp, ans;
bool sol;

int main(){
    ios::sync_with_stdio(0);
    cin >> s;
    s.pop_back();
    ans = 0;
    while(true){
        ans++;
        //cout << "NOW ON " << s << "\n";
        if(s.length()%2){
            s.pop_back();
            continue;
        }

        int temp = (int)s.length()/2;
        sol = true;
        forn(i,temp){
            if(s[i] != s[i+temp]){
                sol = false;
                break;
            }
        }

        if(sol){
            break;
        }else{
            s.pop_back();
        }
    }

    cout << s.length() << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std ;
int main( void )
{
	short w ,h ;
	cin >> h >> w ;
	short ans[ h ][ w + 1 ] = { 0 } ;
	char c[ h + 1 ][ w + 1 ] ;
	for( short i = 0 ; i < h ; i++ )
	{
		for( short j = 0 ; j < w ; j++ )
		{
			cin >> c[ i ][ j ] ;
		}
		short k = 0 ;
		for( ; k < w && c[ i ][ k ] == '.' ; k++ )
		{
			ans[ i ][ k ]-- ;
		}
		short p ;
		for( short j = k ; j < w ; j++ )
		{
			if( c[ i ][ j ] == 'c' )
			{
				p = j ;
				ans[ i ][ j ] = 0 ;
			}
			else
			{
				ans[ i ][ j ] = j - p ;
			}
		}
	}
	for( short i = 0 ; i < h ; i++ )
	{
		for( short j = 0 ; j < w ; j++ )
		{
			if( j == 0 )
			{
				cout << ans[ i ][ j ] ;
			}
			else
			{
				j < w - 1 ? cout << " " << ans[ i ][ j ] : cout << " " << ans[ i ][ j ] ;
			}
		}
		cout << endl ;
	}
	return 0 ;
}

Measured memory_bytes: 3116
n = int(input())
A = list(map(int, input().split()))
plan = [0] + A + [0]
cost = sum([abs(plan[i] - plan[i - 1]) for i in range(1, len(plan))])

for i in range(1, n + 1):
    diff = (abs(plan[i - 1] - plan[i]) + abs(plan[i] - plan[i + 1])) - abs(plan[i - 1] - plan[i + 1])
    print(cost - diff)

Measured memory_bytes: 14048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;

int main(){
    ll i,j;
    ll n;
    cin>>n;
    ll b[n+1];
    for(i=1;i<=n;i++){
        cin>>b[i];
    }
    vector<ll> v;
    for(i=n;i>0;i--){
        for(j=i;j>0;j--){
            if(b[j]==j){
                v.pb(j);
                for(ll k=j;k<i;k++){
                    b[k]=b[k+1];
                }
                break;
            }
            if(j==1) {
                cout<<-1<<endl;
                return 0;
            }

        }
    }
    reverse(v.begin(),v.end());
    for(i=0;i<v.size();i++) cout<<v[i]<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.lang.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int x = scanner.nextInt();
        if (x >= a && x < a + b) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        } 
    }
}


Measured memory_bytes: 22100
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
ans=[[]for i in range(h)]
t=0
tmp=0
for i in range(n):
    for j in range(a[i]):
        if tmp!=w:
            ans[t].append(i+1)
            tmp+=1
            if tmp==w:
                tmp=0
                t+=1
flg=True
for i in range(h):
    if flg:
        print(*ans[i])
        flg=False
    elif flg==False:
        print(*ans[i][::-1])
        flg=True

Measured memory_bytes: 9548
def div(num):
  ret=[]
  for i in range(1,int(num**0.5)+1):
    if num%i==0:
      ret.append(i)
      ret.append(num//i)
  return ret

n=int(input())
arr=sorted(div(n))
l=len(arr)
ans=10**10
for i in range(l):
  t1=arr[i]
  t2=n//t1
  ans=min(ans,max(len(str(t1)),len(str(t2))))
print(ans)

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

int main(void){
  char S[3];
  cin >> S;
  if(S[0] == S[1] || S[1] == S[2] || S[0] == S[2])
    cout << "No" << "\n";
  else
    cout << "Yes" << "\n";
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include<utility>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<cfloat>
#include<functional>
#include<string>
#include<numeric>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<cctype>
#include<iterator>
#include <stdio.h>
#include <string.h>
#include <sstream>
// #include <bits/stdc++.h>
//#include<conio.h>
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define MEGA_MIND ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define M_PI 3.14159265358979323846
#define mod 1000000007
#define endl "\n"
using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;


const int N = 5e5 + 5, inf = 9e9;



int main()
{
	MEGA_MIND

		string s, t, ans;
	cin >> s >> t;
	int m = s.size(), n = t.size();
	vector<vector<int>>dp(m + 1, vector<int>(n + 1));
	for (int i = 0; i <= m; i++)
	{
		for (int j = 0; j <= n; j++)
		{
			if (i == 0 || j == 0)
				dp[i][j] = 0;
			else if (s[i - 1] == t[j - 1])
				dp[i][j] = dp[i - 1][j - 1] + 1;
			else
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	} 
	int index = dp[m][n];
 
	int i = m, j = n;
	while (i > 0 && j > 0)
	{
		if (s[i - 1] == t[j - 1])
		{
			ans.push_back(s[i - 1]);
			i--;
			j--; 
			index--; 
		}

		else if (dp[i - 1][j] > dp[i][j - 1])
			i--;
		else
			j--;
	}

	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 35584
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  string S;
  cin >> S;
  if (S[0] == 'R') {
    if (S[1] == 'S') {
      cout << 1 << endl;
      return 0;
    }
    if (S[2] == 'S') {
      cout << 2 << endl;
      return 0;
    }
    cout << 3 << endl;
    return 0;
  } else {
    if (S[1] == 'R') {
      if (S[2] == 'R') {
        cout << 2 << endl;
        return 0;
      }
      cout << 1 << endl;
      return 0;
    }
    if (S[2] == 'R') {
      cout << 1 << endl;
      return 0;
    }
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
s = list(input())
flag = 0
if s[0] != "A" or s[2:len(s)-1].count("C") != 1:
    flag = 1
else:
    s = s[1:]
    s.remove("C")
    s = "".join(s)
    if not s.islower():
        flag = 1
print("AC") if flag == 0 else print("WA")


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

int main() {
	int w,h,x,y,r;
	cin >> w >> h >> x >> y >> r;
	bool isIncluded = true;
	if(x-r < 0 || x+r > w){
		isIncluded = false;
	}else if(y-r < 0 || y+r > h){
		isIncluded = false;
	}
	if(isIncluded){
		cout << "Yes";
	}else{
		cout << "No";
	}
	cout << "\n";
	return 0;
}


Measured memory_bytes: 3060
//ALDS1_4B
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int A[1000000],n;

int main(){
 cin>>n;
 for(int i=0;i<n;i++){
  scanf("%d",&A[i]);
 }
 int q,k,sum=0;
 cin>>q;
 for(int i=0;i<q;i++){
  scanf("%d",&k);
  if(*lower_bound(A,A+n,k)==k) sum++;
 }
 cout<<sum<<endl;
 return 0;
}

Measured memory_bytes: 1632
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>



const int N=2e5+10;
int n,m,c;
vector<int>adj[N];
bool vst[N];




void dfs(int u)
{
	vst[u]=1;
	for(int i=0,v;i<adj[u].size();i++)
	{
		v=adj[u][i];
		if(vst[v])continue;
		dfs(v);
	}
}






void solve()
{
	cin>>n>>m;
	for(int i=1,k,l;i<=n;i++)
	{
		cin>>k;
		for(int j=1;j<=k;j++)
		{
			cin>>l;
			adj[i].pb(l+n);
			adj[l+n].pb(i);
		}
	}
	for(int i=1;i<=n+m;i++)vst[i]=0;
	dfs(1);
	c=0;
	for(int i=1;i<=n;i++)c+=vst[i];
	if(c==n)cout<<"YES\n";
	else cout<<"NO\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 8704
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

int vis[15][15],n,m,foo=1;
string a[15];
int dfs(int i,int j)
{
	if(i<0||i>n-1||j<0||j>m-1)
	return 0;
	if(a[i][j]=='.')return 0;
	if(vis[i][j]==1)return 0;
	vis[i][j]=1;
	int cc=dfs(i+1,j);
	cc+=dfs(i,j+1);
	if(cc==2)foo=0;
	return 1;
}

int main()
{ios_base::sync_with_stdio(false);
cin>>n>>m;

rep(i,0,n-1)cin>>a[i];
if(a[0][0]=='.'||a[n-1][m-1]=='.')
{
	ol("Impossible");
	return 0;
}
dfs(0,0);
if(vis[n-1][m-1]&&foo)
{
	rep(i,0,n-1)rep(j,0,m-1)
	{
		if(a[i][j]=='#'&&vis[i][j]==0)
		foo=0;
	}
	if(foo)ol("Possible");
	else ol("Impossible");
}
else ol("Impossible");

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll h,w;

bool in(ll y, ll x){
    return 0<=y && y<h && 0<=x && x<w;
}

int main(){
    cin >> h >> w;
    ll dy[4] = {0, 1, 0, -1};
    ll dx[4] = {1, 0, -1, 0};
    char s[h][w];
    rep(i,h) rep(j,w) cin >> s[i][j];
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='.') continue;
            bool flag = false;
            rep(k,4){
                if(in(i+dy[k],j+dx[k])){
                    if(s[i+dy[k]][j+dx[k]]=='#') flag = true;
                }
            }
            if(!flag){
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


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



int main() {
	int n, m, x;
	cin >> n >> m >> x;

	int a = 0, b = 0;

	vector<int> v(m);
	REP(i, m) {
		cin >> v[i];
	}

	REP(i, m) {
		if (v[i] <= x) {
			a++;
		}
		if (v[i] >= x) {
			b++;
		}
	}

	cout << min(a, b) << endl;


	return 0;
}



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

typedef long double ld;

int main(){
    ld a, b, c, A, B, C;
    cin >> a >> b >> c;
    A = sqrtl(a), B = sqrtl(b), C = sqrtl(c);
    if(A + B  + 1e-14 < C)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int k,x;
    cin>>k>>x;
    if(k*500>=x)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	int n;
	string s, t;
	cin >> n >> s >> t;

	vl dp(n + 1), cm(26);

	dp[0] = 1;
	cm[s[0] - 'a'] = 1;

	Rep(i, n) {
		dp[i] = cm[t[i] - 'a'];
		cm[s[i] - 'a'] = (cm[s[i] - 'a'] + dp[i]) % mod;
	}

	cout << dp[n - 1] << endl;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  rep(i,n) {
    cout << "x";
  }
  cout << endl;
}


Measured memory_bytes: 3608
// problem: "https://atcoder.jp/contests/abc157/tasks/abc157_d"

#include<bits/stdc++.h>
#define Pair pair<int,int>

using namespace std;

int Parent(int p,vector<int>&P)
{
    while(P[p] != -1)
        p = P[p];

    return p;
}

int DFS(int i,vector<int>G[],int n,vector<int>&S)
{
    int j,c;
    c = 1;
    for(j=0;j!=G[i].size();j++)
    {
        if(S[G[i][j]] == -1)
        {
            S[G[i][j]] = 0;
            c += DFS(G[i][j],G,n,S);
        }
    }

    return c;
}

void setS(int i,vector<int>G[],int n,vector<int>&S,int p)
{
    int j;
    for(j=0;j!=G[i].size();j++)
    {
        if(S[G[i][j]] != p)
        {
            S[G[i][j]] = p;
            setS(G[i][j],G,n,S,p);
        }
    }
}

void countFriends(vector<int>G[],int n,vector<Pair>&F,int m,vector<Pair>&B,int k)
{
    vector<int>S(n+1,-1);
    int i;
    for(i=1;i!=n+1;i++)
    {
        if(S[i] == -1)
        {
            S[i] = 0;
            S[i] = DFS(i,G,n,S);      // define
            setS(i,G,n,S,S[i]);
        }
    }

    vector<int>P(n+1,-1);
    for(i=0;i!=m;i++)
    {
        int p1,p2;
        p1 = Parent(F[i].first,P);      // define
        p2 = Parent(F[i].second,P);     // define

        if(p1 != p2)
            P[max(p2,p1)] = min(p1,p2);
    }

    vector<int>Block(n+1,0);
    for(i=0;i!=k;i++)
    {
        if(Parent(B[i].first,P) == Parent(B[i].second,P))
        {
            Block[B[i].first]++;
            Block[B[i].second]++;
        }
    }

    // test
    // for(i=1;i!=n+1;i++)
    //     cout<<S[i]<<' ';
    //
    // cout<<'\n';
    // for(i=1;i!=n+1;i++)
    //     cout<<P[i]<<' ';
    //
    // cout<<'\n';
    // for(i=1;i!=n+1;i++)
    //     cout<<Block[i]<<' ';
    //
    // cout<<'\n';

    for(i=1;i!=n+1;i++)
        cout<<S[i]-1-Block[i]-(int)G[i].size()<<' ';

}

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

    int n,m,k;
    cin>>n>>m>>k;

    vector<int>G[n+1];
    vector<Pair>F;
    int i;
    for(i=0;i!=m;i++)
    {
        int x,y;
        cin>>x>>y;

        G[x].push_back(y);
        G[y].push_back(x);

        F.push_back(Pair(min(x,y),max(x,y)));
    }

    sort(F.begin(),F.end());

    vector<Pair>B;
    for(i=0;i!=k;i++)
    {
        int x,y;
        cin>>x>>y;

        B.push_back(Pair(x,y));
    }

    countFriends(G,n,F,m,B,k);      // define

    return 0;
}


Measured memory_bytes: 10352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
bool used[26];
int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int l = max(A, C);
	int r = min(B, D);
	if (l > r) cout << 0 << endl;
	else cout << r - l << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  int N,K; cin>>N>>K;
  int n[N+1] = {0};
  int d = 0;
  int a;
  REP(i,N){
    cin >> a;
    if(n[a]==0){d++;}
    n[a]++;
  }
  int r = 0;
  if(d>K){
    sort(n,n+N+1);
    for(int i=1;i<=N;i++){
      if(n[i]>0){
        r += n[i];
        --d;
        if(d==K){break;}
      }
    }
  }
  cout << r;
}

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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h, a;
  cin >> h >> a;
  cout << (h + a - 1) / a << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    vector<int> d(n);
    rep(i, n) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());

    vector<int> t(n+1);
    rep(i, n) {
        if(i%2 == 0) {
            t[i] = d[i];
        }
        else {
            t[i] = 24 - d[i];
        }
    }

    int ans = 30;
    rep(i, n) {
        for(int j = i+1; j <= n; j++) {
            int x = abs(t[i] - t[j]);
            int y = min(x, 24-x);
            ans = min(ans, y);
        }
    }

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

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

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

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

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
class Digit
   def initialize(digit, str1, str2)
	  @digit = digit
	  @flag = 0
	  if (str1.length > digit) || (str2.length > digit)
		 @flag = nil
		 puts "overflow"
	  end
	  @array1, @array2, @ans = [],[],[]
	  @digit.times {|i| @array1.push(str1[i-@digit].to_i); @array2.push(str2[i-@digit].to_i)}
	  (@digit+1).times {@ans.push(0)}
   end
   attr_reader :array1, :array2, :ans
   def plus
	  if @flag
		 (1..@digit).each do |i|
			sum = @array1[-i] + @array2[-i]
			if @ans[-i] + sum > 9
			   @ans[-i] = @ans[-i] + sum - 10
			   @ans[-i-1] = 1
			else
			   @ans[-i] = @ans[-i] + sum
			end
		 end
		 if @ans[0] != 0
			puts "overflow"
			@flag = nil
		 end
	  end
   end
   def puts_ans
	  if @flag
		 index = 0
		 while @ans[index] == 0
			index += 1
		 end
		 (index..(@digit+1)).each {|each| print @ans[each].to_s}
		 print "\n"
	  end
   end
end

num = gets.to_i
num.times do
   str1 = gets
   str1.slice!(-1)
   str2 = gets
   str2.slice!(-1)
   if (str1 == "0") && (str2 == "0")
	  puts "0"
   else
	  d = Digit.new(80, str1, str2)
	  d.plus
	  d.puts_ans
   end
end

Measured memory_bytes: 6128
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/30/2019 11:03:37 PM
*************************************************************************/
//#pragma GCC optimize(2)
//#pragma GCC diagnostic error "-std=c++11"
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#include <numeric>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define MP(x,y) make_pair(x,y)
#define ll long long
#define ull unsigned long long
#ifdef WindCry1
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#endif
#define lowbit(x) x&(-x)
#define ls x<<1
#define rs x<<1|1
using namespace std;
template<typename T> inline T MIN(const T &a,const T &b) {return a<b?a:b;}
template<typename T> inline T MAX(const T &a,const T &b) {return a>b?a:b;}
template<typename T,typename ...Args> inline T MIN(const T &a,const T &b,Args ...args) {return MIN(MIN(a,b),args...);}
template<typename T,typename ...Args> inline T MAX(const T &a,const T &b,Args ...args) {return MAX(MAX(a,b),args...);}
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
int cnt[200010];
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifdef WindCry1
	freopen("C:/Users/LENOVO/Desktop/in.txt","r",stdin);
#endif
	int n;cin>>n;
	for(int i=1,t;i<n;i++) cin>>t,cnt[t]++;
	for(int i=1;i<=n;i++) cout<<cnt[i]<<endl;
	return 0;
}



Measured memory_bytes: 4356
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long n;
  cin >> n;
  long long num;
  for(int i=sqrt(n);i>0;i--){
    if(n%i==0){
      num=i;
      break;
    }
  }
  long long x=n/num;
  long long ans=(x-1)+(num-1);
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    N,M = map(int, input().split())
    H = list(map(int, input().split()))
    H.insert(0,0)
    A = [0] * (M)
    B = [0] * (M)
    TOP = [0] * len(H)
    cnt = 0

    for index in range(M):
        A[index],B[index] = map(int, input().split())

    for jn in range(M):
        if H[A[jn]] <= H[B[jn]]:
            TOP[A[jn]] = 1
        if H[B[jn]] <= H[A[jn]]:
            TOP[B[jn]] = 1

    cnt = TOP.count(0) -1

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21732
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

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

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  if (abs(a - c) <= d) {
    COUT("Yes");
    return 0;
  }

  if (abs(a - b) <= d && abs(c - b) <= d) {
    COUT("Yes");
    return 0;
  }
  COUT("No");
  return 0;
}

Measured memory_bytes: 3600
import math
a,b,x=map(int,input().split())
PI=3.14159265
if x>=a*a*b/2:
    ans=math.atan(2*(a*a*b-x)/(a**3))*180/PI
else:
    ans=math.atan(a*b*b/(2*x))*180/PI
print(ans)


Measured memory_bytes: 38384