akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
class mint {
	long long x;
public:
	mint(long long 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 {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= 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 {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

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 * b / gcd(a, b);
};
//fixed << setprecision(2)

//小文字=大文字+32
int main() {
	ll n,d;
	ll ans= 0;
	double  tmp;
	cin >> n>>d;
	vector<double>x(n), y(n);
	rep(i, n)cin >> x[i] >> y[i];
	rep(i, n) {
		tmp = pow(x[i] * x[i] + y[i] * y[i], 0.5);
		if (tmp <= d) {
			ans++;
		}
	}
	cout << ans;
}
	



Measured memory_bytes: 6488
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n;
vll a;
lli ans = 0;

template<class T>
class bit : public vector<T> {
private:
    lli n;
public:
    bit():vector<T>(){}
    bit(lli n):vector<T>(n+1,0){
        this->n = n;
    }
    T sum(lli i){
        T s = 0;
        for(;i > 0;i -= i & -i) s += this->at(i);
        return s;
    }
    void add(lli i,T x){
        for(;i <= n;i += i & -i) this->at(i) += x;
    }
};
bit<lli> b;
map<lli,lli> m;

int main(){
    cin >> n;
    a = vll(n);
    b = bit<lli> (n);
    for(lli i = 0;i < n;i++) cin >> a[i];
    for(lli i = 0;i < n;i++) m[a[i]] = 0;
    lli i = 1;
    for(auto itr = m.begin();itr != m.end();itr++) itr->second = i++;
    for(lli i = 0;i < n;i++){
        b.add(m[a[i]],1);
        ans += b.sum(n) - b.sum(m[a[i]]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18412
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define vi vector<int>
#define Sort(v) sort(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;


int main(){
    int n;
    cin >> n;
    
    int maxn = -1000000 , minn=1000000;
    long long sum=0;
    rep(i,n){
        int a; cin >> a;
        
        sum += a;
        maxn = max(maxn,a);
        minn = min(minn,a);
    }
    
    cout << minn << " " << maxn << " " <<sum << endl;
}








Measured memory_bytes: 3128
/***************************************** START OF TEMPLATE *********************************************/

#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  newl           cout<<"\n";
#define  f              first
#define  s              second
#define  pb             push_back
#define  mp             make_pair
#define  sym(s)         s="#"+s+"#";   
#define  all(x)         (x).begin(),(x).end()
#define  alll(x, n)     x+1, x+n+1
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  mset1d(a,n,v)  foo(i,0,n+5)a[i]=v;
#define  mset2d(a,n,m,v)foo(i,0,n+5)foo(j,0,m+5)a[i][j]=v;
#define  INP(a,n)       foo(i,1,n) cin>>a[i];
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}    
#define  debm(a)        for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  debp(a,n)      foo(i,1,n)cout<<"{"<<a[i].f<<","<<a[i].s<<"}, ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b<<" ";newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<" ";newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ld   PI    =  3.14159265358979323846; 
const ll   MOD   =  1e+9+7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  1e+6+8;

vll adj[N]; ll vis[N];
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll test_cases = 1; randomINIT;

/************************************************************************************** *******************/
/***************************************** VARIABLE DECLARATIONS *****************************************/
ll n, k, a[N], dp[N];


/***************************************** FUNCTION IMPLEMENTATIONS **************************************/


/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc){
    ll res=0;
    cin>>n>>k;
    foo(i,1,n)cin>>a[i];
    sort(alll(a,n));
    foo(i,1,k)res+=a[i];
    cout<<res;
    
}

int main(){
    SPEED;

    //cin>>test_cases;
    foo(i,1,test_cases){
        MAIN(i);
    }
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s, t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  string ans = "";
  string tmp = "";
  for(int i = 0; i <= n-m; i++) {
    bool flag = true;
    for(int j = 0; j < m; j++) {
      if(s[i+j] != t[j] && s[i+j] != '?') flag = false;
    }
    if(flag) {
      if(ans == "") ans = tmp + t + s.substr(i+m);
      else chmin(ans, tmp + t + s.substr(i+m));
    }
    tmp += s[i];
  }
  if(ans == "") cout << "UNRESTORABLE" << endl;
  else {
    for(int i = 0; i < n; i++) cout << (ans[i] == '?' ? 'a' : ans[i]);
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
#define TSUKASA_DIARY_S_TEMPLATE
// define
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) int((a).size())
#define cauto const auto
// typedef
typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;
template< typename T > using Matrix = Vec< Vec< T > >;
template< typename T > using USet = unordered_set< T >;
template< typename T, class C > using MyUSet = unordered_set< T, C >;
template< typename T, typename F > using UMap = unordered_map< T, F >;
template< typename T, typename F, class C > using MyUMap = unordered_map< T, F, C >;
// hash
class PiiHash { public: size_t operator () (const pii& p) const { return (p.first << 16) | p.second; } };
// popcount
inline int POPCNT(int x) { return __builtin_popcount(x); }
inline int POPCNT(lint x) { return __builtin_popcount(x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
const Double EPS = 1e-9;
const Double PI = acos(-1);
// inrange
template< typename T >
inline bool in_range(T v, T mi, T mx) { return mi <= v && v < mx; }
template< typename T >
inline bool in_range(T x, T y, T W, T H) { return in_range(x,0,W) && in_range(y,0,H); }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
template< typename T > inline void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > inline void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > inline void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > inline void maxUpdate(T& a, T b) { a = max(a, b); }
// converter
template< typename F, typename T >
inline void convert(F& from, T& to) {
	stringstream ss;
	ss << from; ss >> to;
}


int H, W;
string str[55][55];

void solve() {
	for_(i,0,H) for_(j,0,W) {
		if (str[i][j] == "snuke") {
			cout << char('A' + j) << i + 1 << endl;
		}
	}
}

int main() {
	cin >> H >> W;
	for_(i,0,H) for_(j,0,W) cin >> str[i][j];
	solve();
}






Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict
H, W = map(int, input().split())
M = []
for i in range(H):
    M.append(list(input()))


def getMaxDistantPoint(Sx, Sy):
    BIG = 10**16

    def bigcost():
        return BIG
    costs = defaultdict(bigcost)
    costs[(Sx, Sy)] = 0
    current = [(Sx, Sy)]
    visited = set()
    while len(current) > 0:
        next = []
        for v in current:
            c = costs[v]
            if v[0] > 0 and M[v[1]][v[0]-1] == ".":
                coord = (v[0]-1, v[1])
                if coord not in visited:
                    visited.add(coord)
                    next.append(coord)
                    costs[coord] = min(c+1, costs[coord])
            if v[0] < W-1 and M[v[1]][v[0]+1] == ".":
                coord = (v[0]+1, v[1])
                if coord not in visited:
                    visited.add(coord)
                    next.append(coord)
                    costs[coord] = min(c+1, costs[coord])
            if v[1] < H-1 and M[v[1]+1][v[0]] == ".":
                coord = (v[0], v[1]+1)
                if coord not in visited:
                    visited.add(coord)
                    next.append(coord)
                    costs[coord] = min(c+1, costs[coord])
            if v[1] > 0 and M[v[1]-1][v[0]] == ".":
                coord = (v[0], v[1]-1)
                if coord not in visited:
                    visited.add(coord)
                    next.append(coord)
                    costs[coord] = min(c+1, costs[coord])
        current = next
    maxCost = 0
    maxCoord = None
    for c in costs:
        if costs[c] != BIG:
            if costs[c] > maxCost:
                maxCoord = c
                maxCost = costs[c]
    return (maxCoord, maxCost)


result = 0
for Sx in range(W):
    for Sy in range(H):
        if M[Sy][Sx] == '.':
            result = max(result, getMaxDistantPoint(Sx, Sy)[1])
print(result)


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

struct Comp {
	bool operator() (pair<int, ll> a, pair<int, ll> b) {
		return a.second > b.second;
	}
};

int sx, sy, gx, gy;
int lx, ly;
bool box[300][300];

ll dist[300][300][6];
bool done[300][300][6];

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

ll solve()
{
	rep(i, 0, ly*2 + 1) rep(j, 0, lx*2 + 1) rep(t, 0, 6) dist[i][j][t] = INF;
	rep(i, 0, ly*2 + 1) rep(j, 0, lx*2 + 1) rep(t, 0, 6) done[i][j][t] = false;

	priority_queue<pair<int, ll>, vector<pair<int, ll> >, Comp> que;
	que.push(make_pair(sy * 1000000 + sx * 1000, 0));
	dist[sy][sx][0] = 0;

	while (!que.empty())
	{
		auto q = que.top(); que.pop();

		int y = q.first / 1000000;
		int x = (q.first % 1000000) / 1000;
		int t = q.first % 1000;

		if (y == gy && x == gx) return q.second;

		if (done[y][x][t]) continue;
		done[y][x][t] = false;

		int type = (x - lx + 1000) % 2;

		rep(i, 0, 7)
		{
			int yy = y + dy[type][i];
			int xx = x + dx[type][i];

			if (yy < 0 || 2*ly < yy) continue;
			if (xx < 0 || 2*lx < xx) continue;
			if (box[yy][xx]) continue;

			ll nc = q.second;
			int tmp = abs((x - lx) * (y - ly) * t) % 6;
			if (i != tmp) nc++;

			int tt = (t + 1) % 6;

			if (nc < dist[yy][xx][tt])
			{
				dist[yy][xx][tt] = nc;
				que.push(make_pair(yy * 1000000 + xx * 1000 + tt, nc));
			}
		}
	}

	return -1;

}

int bx[1010];
int by[1010];

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

	while (cin >> sx >> sy >> gx >> gy)
	{
		int n; cin >> n;
		rep(i, 0, n) cin >> bx[i] >> by[i];

		cin >> lx >> ly;

		sx += lx; sy += ly; gx += lx; gy += ly;

		rep(i, 0, 300) rep(j, 0, 300) box[i][j] = false;
		rep(i, 0, n) box[by[i] + ly][bx[i] + lx] = true;

		cout << solve() << endl;
	}
}

Measured memory_bytes: 6380
#include <cstdio>
int main(){
	int n,m=0,a,b;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		a=i;b=0;
		while(a>0){
			a/=10;
			b++;
		}
		if(b%2==1)	m++;
	}
	printf("%d",m);
	return 0;
}

Measured memory_bytes: 128
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double lb;

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


int main() {
    ll A,B;
    cin >> A >> B;

    rep(i,2000){
        if(i*8/100 == A && i*10/100 == B){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}



Measured memory_bytes: 3596
import math

def lcm(a, b):
    return (a*b)//math.gcd(a, b)

a, b, c, d = map(int, input().split())
e = lcm(c, d)

total = b - (a - 1)
cc = b//c - (a-1)//c
dd = b//d - (a-1)//d
ee = b//e - (a-1)//e

ans = total - cc - dd + ee
print(ans)


Measured memory_bytes: 9152
/**
 *   created: 09 August 2019  11:55:44
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================
vector< vi > adj;
vi comp,vis;

int dfs(int node){
	// trace1(node);
	vis[node] = 1;
	// comp[node] = 1;
	int res = 1;
	for(int x : adj[node]){
		if(!vis[x])
			res += dfs(x);
	}
	return res;
}

int main()
{
	optimizeIO();
	int tt=1;
	// cin>>tt;
	while(tt--){
		int k,x;
		cin>>k>>x;
		rep(i,max((int)-1e6, x-k+1), x)
			cout<<i<<" ";
		rep(i,x,min(1000001, x+k))
			cout<<i<<" ";
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>

using namespace std;

int main()
{
    char ch[101];

    char sub[101];

    cin>>ch>>sub;

    int lenth1=strlen(ch);
    int lenth2=strlen(sub);

    bool flag=false;
    for(int i=0;i<lenth1;i++)
    {
        int j;
        for(j=0;j<lenth2;j++)
        {
            if(ch[(i+j)%lenth1]!=sub[j])
            {
                break;
            }
        }
        if(j==lenth2)
        {
            flag=true;
            break;
        }
    }

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


    return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
#define SORTD(s) sort((s).rbegin(),(s).rend())

int gcd(int a, int b) {
    if (!b) return a;
    return gcd(b, a % b);
}

int main() {
	ll a,b,c,d,sum;
  
  	cin>>a>>b>>c>>d;
  
  	sum +=b/c-(a-1)/c;//b以下ｃの約数の数を取って、a以下のcの約数を引く
  	sum +=b/d-(a-1)/d;//c以下の
  	int e=gcd(c,d);//最大公約数
  	sum-=b/(c*d/e)-(a-1)/(c*d/e);//最大公約数は2重に足されてるから片方引く//a以下のやつは既に2回ひかれてるから改めてひかないように-から-する
  	cout<<b-a+1-sum<<endl;//ｂ以下でa以下じゃなくて約数じゃないやつを出す
  

}

Measured memory_bytes: 3480
#include <iostream>

using namespace std;

const int MAXN = 1e3 + 10;
bool grid[MAXN][MAXN];
int dp[MAXN][MAXN];

const int MOD = 1e9 + 7;

int main()
{
    int h, w;
    cin >> h >> w;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char a;
            cin >> a;

            if (a == '.')
                grid[i][j] = 1;
            else
                grid[i][j] = 0;
        }
    }

    bool isWall = false;
    for (int i = h-1; i >= 0; i--) {
        if (!grid[i][w-1])
            isWall = true;

        if (!isWall)
            dp[i][w-1] = 1;
        else
            dp[i][w-1] = 0;
    }

    isWall = false;
    for (int j = w-1; j >= 0; j--) {
        if (!grid[h-1][j])
            isWall = true;

        if (!isWall)
            dp[h-1][j] = 1;
        else
            dp[h-1][j] = 0;
    }

    for (int i = h-2; i >= 0; i--) {
        for (int j = w-2; j >= 0; j--) {
            if (grid[i][j]) {
                dp[i][j] = (dp[i+1][j]) % MOD + (dp[i][j+1]) % MOD;
                dp[i][j] = dp[i][j] % MOD;
            } else
                dp[i][j] = 0;
        }
    }

    cout << dp[0][0];
    return 0;
}

Measured memory_bytes: 5248
object Main extends App {
  val n = scala.io.StdIn.readLine.toInt
  val list = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  val map = list.groupBy(identity).mapValues(_.length).toMap
  var delete_count = 0
  var checked = Map[Int, Boolean]()

  list.foreach({e =>
    if (checked.isDefinedAt(e)) {
    } else {
      if (map(e) > e) {
        delete_count += map(e) - e
      }

      if (map(e) < e) {
        delete_count += map(e)
      }

      checked += (e -> true)
    }
  })
  println(delete_count)
}


Measured memory_bytes: 113072
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var k = next();
  var n = next();
  var a = nexts(n);
  a.push(a[0]+k);
  var ans = k;
  for(var i = 0; i < n; i++){
    var t = a[i]+k-a[i+1];
    if(t < ans)ans = t;
  }
  return ans;
}

Measured memory_bytes: 51204
def calc_a_order arr
  a_order = [[], [], [], [], [], [], [], [], []]
  arr.each do |v|
    a_order[v[1].to_i - 1].push(v[0])
  end
  a_order
end

len = gets.to_i
arr = gets.split(' ')
o = calc_a_order arr

arr1 = arr.dup
0.upto(len-2) do |i|
  (len-1).downto(i+1) do |j|
    arr1[j], arr1[j-1] = arr1[j-1], arr1[j] if arr1[j][1].to_i <  arr1[j-1][1].to_i
  end
end
puts arr1.join(' ')

o1 = calc_a_order arr1
puts (o == o1) ? 'Stable' : 'Not Stable'

arr2 = arr.dup
0.upto(len-2) do |i|
  minj = i
  (i+1).upto(len-1) do |j|
    minj = j if arr2[minj][1].to_i > arr2[j][1].to_i
  end
  arr2[i], arr2[minj] = arr2[minj], arr2[i]
end
puts arr2.join(' ')

o2 = calc_a_order arr2
puts (o == o2) ? 'Stable' : 'Not stable'


Measured memory_bytes: 6876
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define inv(i, a, b)        for (int i = (int)(a); i >= (int)(b); i--)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl                endl

using namespace std;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int x, unsigned int y) {                                                    //return x^y in order(log(y))
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class DDoubleDots {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N, M;
    cin >> N >> M;
    vector<int> ans(N, 0);
    deque<int> pos = {0};
    vector<vector<int>> road(N);
    rep(i, M) {
      int A, B;
      cin >> A >> B;
      road[A - 1].emplace_back(B - 1);
      road[B - 1].emplace_back(A - 1);
    }
    while (pos.size()) {
      int k = pos[0];
      pos.pop_front();
      rep(i, road[k].size()) {
        if (ans[road[k][i]] == 0) {
          ans[road[k][i]] = k + 1;
          pos.emplace_back(road[k][i]);
        }
      }
    }
    cout << "Yes" << Endl;
    rep(i, ans.size() - 1) {
      cout << ans[i + 1] << endl;
    }
  }
};


signed main() {
  DDoubleDots solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

string S;
priority_queue<int> Q;

int main() {
	int b;
	while (true) {
		cin >> S;
		if (S[0] == 'i') {
			cin >> b;
			Q.push(b);
		}
		if (S[1] == 'x') {
			cout << Q.top() << endl;
			Q.pop();

		}
		if (S[2] == 'd') {
			break;
		}
	}
	return 0;
}

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

int main(){
    int cnt = 0;
    string s;
    std::cin >> s;
    for (int i = 0; i < s.length(); ++i)
    {
        if (s.substr(i,1) == "1") cnt++;
    }
    std::cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 256
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [a, b, x] = stdin.split('\n')[0].split(' ').map(Number)

let res = 'YES'
if(x > a){
  res = x <= a+b ? 'YES' : 'NO'
} else if (x < a){
  res = 'NO'
}

console.log(res)

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define all(c) (c).begin(), (c).end()
const int INF = 1e9 + 1;
const ll LINF = 1e18 + 1;
const ll MOD = 1e9 + 7;

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

  int h, w;
  cin >> h >> w;

  const int MAX = 10000;
  vector<vector<P>> table(h, vector<P>(w));
  vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(MAX * 2 + 1, false)));
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> table[i][j].first;
    }
  }

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> table[i][j].second;
    }
  }
  int f = table[0][0].first - table[0][0].second;
  dp[0][0][MAX + f] = true;
  dp[0][0][MAX - f] = true;

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      int now = table[i][j].first - table[i][j].second;
      for (int k = 0; k <= MAX * 2; ++k) {
        bool f = false;
        if (i > 0 && dp[i - 1][j][k]) f = true;
        if (j > 0 && dp[i][j - 1][k]) f = true;
        if (!f) continue;
        if (now + k <= 2 * MAX && now + k >= 0) dp[i][j][now + k] = true;
        if (-now + k <= 2 * MAX && -now + k >= 0) dp[i][j][-now + k] = true;
      }
    }
  }
  int ans = INF;
  for (int i = -MAX; i <= MAX; ++i) {
    if (dp[h - 1][w - 1][MAX + i]) ans = min(abs(i), ans);
  }

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


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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 1e5 + 5;


int a[N];

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

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

    int cnt = 0;
    int tot = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        tot += a[i];
    }

    for (int i = 0; i < n; i++) {
        if (a[i] >= (tot + 4*m - 1) / (4*m))
            cnt++;
    }

    cout << (cnt >= m ? "Yes" : "No") << endl;

    return 0;
%>

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

using namespace std;

//#define PRAGMA 448
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#ifdef LUCARIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif

typedef int intt;
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define int long long
#define pb push_back
#define bs binary_search
#define up upper_bound
#define fs first 
#define sd second 
#define mp make_pair    
#define endl "\n"

#define fore(i,a,b) for(ll i = a; i < b; i++)
#define rfore(i, a, b) for(ll i = a - 1; i >= b; i--)
#define forev(a,b) fore(i,0,b)cout<<a[i]<<" "; 
#define ing(g,u,v)  g[u].pb(v); g[v].pb(u);
#define ingp(g,u,v,c) (g[u].pb({v,c});g[v].pb({u,c});)
#define mm(a,b) memset(a , b , sizeof a) 
#define ALL(a) a.begin(),a.end() 
#define SZ(n) ((ll) (n).size())
#define sfind(s,t) (s.find(t) != string::npos)

#define infll (ll)1e15
#define infi  (int)(1e9+1)
#define PI 3.14159265359 
#define mod (ll)(1e9+7)
#define eps  1e-6

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


int n,m,k;
string s,t;
bool c[3001][3001];
int dp[4001][4001];
pii a[1001];

int solve(int i,int j){
    if(i == n || j == m)return 0;
    int &r = dp[i][j];
    if(~r)return r;
    return r = max({solve(i+1,j+1)+c[i][j],solve(i+1,j), solve(i,j+1)});
}


int32_t main(int32_t argc, char const *argv[]){
    FIN;

    cin>>s>>t;n=SZ(s);m=SZ(t);
    fore(i,0,n){
        fore(j,0,m){
            c[i][j] = s[i]==t[j];
        }
    }
    mm(dp,-1);
    string r;
    int mini = solve(0,0);
    int i =0,j=0;
    while(i < n+1 && j < m+1){
        if(c[i][j]){
            r+=s[i];
            i++;j++;
        }else if(dp[i+1][j] > dp[i][j+1] ){
            i++;
        }else{
            j++;
        }
    }

    if(SZ(r)== 0){
        cout<<" ";
    }else{
        cout<<r;
    }


    return 0;
}



















Measured memory_bytes: 134400
#include <stdio.h>

int main(void) {

  int array[3];
  int i, j;

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

  for(i = 0; i < 3; i++)
    for(j = 0; j < 3; j++)
      if(array[i] < array[j]) {
        int temp = array[i];
        array[i] = array[j];
        array[j] = temp;
      }

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

  return 0;

}

Measured memory_bytes: 596
# さっきWAして答えみて再度アタック
# （ちなみに問題自体憶えてないけど昔やったことあってそんときゃACしてたので退化してるね 向いてないね やめたほうがいいね）
n, m = map(int, input().split())
p = list(map(lambda x: int(x) - 1, input().split()))
par = [i for i in range(n)]


def root(x):
    # while x != par[x]:
    #     par[x] = root(par[x])
    # return par[x]
    # なぜか上記の書き方が駄目だった
    if x == par[x]:
        return x
    y = root(par[x])
    par[x] = y
    return y


def union(a, b):
    if a > b:
        a, b = b, a
    ra, rb = root(a), root(b)
    if ra != rb:
        par[ra] = rb


for _ in range(m):
    x, y = map(lambda x: int(x) - 1, input().split())
    union(x, y)

ans = 0
for i in range(n):
    ra, rb = root(i), root(p[i])
    if ra == rb:
        ans += 1
print(ans)


Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 998244353;
#define all(V) V.begin(),V.end()

int main() {
	ll N;
	cin >> N;
	string S;
	cin >> S;
	vector<vector<ll>> Fc(3, vector<ll>(3 * N, 0)), Sc = Fc;
	vector<ll> Ans(3 * N);

	ll po = N - 1;
	for (int i = 0;i < 3 * N;i++) {
		if (i == 0) {
			Ans[0] = N;
			if (S[i] == 'R')
				Fc[0][0] = 1;
			if (S[i] == 'G')
				Fc[1][0] = 1;
			if (S[i] == 'B')
				Fc[2][0] = 1;
			continue;
		}

		Fc[0][i] = Fc[0][i - 1];
		Fc[1][i] = Fc[1][i - 1];
		Fc[2][i] = Fc[2][i - 1];

		Sc[0][i] = Sc[0][i - 1];
		Sc[1][i] = Sc[1][i - 1];
		Sc[2][i] = Sc[2][i - 1];

		if (S[i] == 'R') {
			if (Sc[0][i] > 0) {
				Ans[i] = Sc[0][i];
				Sc[0][i]--;
			}
			else if (Fc[1][i] > 0) {
				Ans[i] = Fc[1][i];
				Fc[1][i]--;
				Sc[2][i]++;
			}
			else if (Fc[2][i] > 0) {
				Ans[i] = Fc[2][i];
				Fc[2][i]--;
				Sc[1][i]++;
			}
			else {
				Ans[i] = po;
				po--;
				Fc[0][i]++;
			}
		}

		if (S[i] == 'G') {
			if (Sc[1][i] > 0) {
				Ans[i] = Sc[1][i];
				Sc[1][i]--;
			}
			else if (Fc[0][i] > 0) {
				Ans[i] = Fc[0][i];
				Fc[0][i]--;
				Sc[2][i]++;
			}
			else if (Fc[2][i] > 0) {
				Ans[i] = Fc[2][i];
				Fc[2][i]--;
				Sc[0][i]++;
			}
			else {
				Ans[i] = po;
				po--;
				Fc[1][i]++;
			}
		}

		if (S[i] == 'B') {
			if (Sc[2][i] > 0) {
				Ans[i] = Sc[2][i];
				Sc[2][i]--;
			}
			else if (Fc[1][i] > 0) {
				Ans[i] = Fc[1][i];
				Fc[1][i]--;
				Sc[0][i]++;
			}
			else if (Fc[0][i] > 0) {
				Ans[i] = Fc[0][i];
				Fc[0][i]--;
				Sc[1][i]++;
			}
			else {
				Ans[i] = po;
				po--;
				Fc[2][i]++;
			}
		}
	}

	//cout << Ans[0] << " ";
	for (int i = 1;i < 3 * N;i++) {
		//cout << Ans[i] << " ";
		Ans[i] *= Ans[i - 1];
		Ans[i] %= MOD;
	}
	cout << Ans[3 * N - 1] << endl;
	return 0;
}

Measured memory_bytes: 16988
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define LIM 1000007
#define ll long long
using namespace std;
int main() {
  // 97;
  string s;
  cin >> s;
  int v[26];
  for (int i = 0; i < 26; i++) {
    v[i] = 0;
  }
  for (char c : s) {
    v[(int)c - 97]++;
  }
  for (int i = 0; i < 26; i++) {
    if (v[i] % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
main=do
 [n,a,b]<-map read.words<$>getLine
 getLine>>=putStr.unlines.f a b
f a b[]=[]
f a b(c:s)
 |c=='a'&&a>0="Yes":f(a-1)b s
 |c=='a'&&a==0&&b>0="Yes":f a(b-1)s
 |c=='a'="No":f a b s
 |c=='b'&&b>0="Yes":f a(b-1)s
 |c=='b'="No":f a b s
 |c=='c'="No":f a b s

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

using namespace std;
typedef long long ll;

int main() {
	ll N, W;
  	ll w, v;
  
	cin>>N>>W;
	vector<vector<ll> > table(N, vector<ll>(W+1, 0));
	
  	cin>>w>>v;
  	for(int j = 1 ; j <= W ; j++) {
      	if(j>=w)
	      	table[0][j] = v;
    }
  	
  	for(int i = 1;i<N;i++) {
  		cin>>w>>v;
      
      	for(int curcap = 1 ; curcap <= W ; curcap++) {
        	if(w <= curcap) {
              	// max of taking vs not taking this item
            	table[i][curcap] = max(v + table[i-1][curcap-w],
                                       table[i-1][curcap]);
            }
          	else {
              	// can not take this item
              	table[i][curcap] = table[i-1][curcap];
            }
        }
    }
  
  	cout<<table[N-1][W];
  	return 0;
}

Measured memory_bytes: 79488
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    for(int i = 60; i >= 0; i--){
        int cnt = 0;
        rep(j,n){
            if(a[j]>>i&1) cnt++;
        }
        if(cnt&1){
            rep(j,n){
                a[j] &= ~(1ll<<i);
            }
            ans += 1ll<<i;
        }
    }
    

    int rank = 0;
    for(int i = 60; i >= 0; i--){
        int j = rank;
        for(; j < n; j++){
            if(a[j]>>i&1){
                swap(a[rank],a[j]);
                break;
            }
        }
        if(j == n) continue;
        rep(k,n){
            if(k == rank) continue;
            if(a[k]>>i&1){
                a[k] ^= a[rank];
            }
        }
        rank++;
    }
    ll ans2 = 0;
    rep(i,rank) ans2 ^= a[i];
    ans2 *= 2;
    cout << ans+ans2 << endl;
}



Measured memory_bytes: 3988
import decimal,math
# from decimal import Decimal as co
from collections import Counter,defaultdict
from fractions import gcd
from bisect import bisect_right,bisect_left
decimal.getcontext().prec = 10
import sys
sys.setrecursionlimit(1000000)
# co=decimal.Decimal
n=int(raw_input())
p = map(float,raw_input().split())
dp = [[(0.0)]*(n+1) for i in range(n+1)]
dp[0][0]=(1.0)
for i in range(1,n+1):
	for j in range(0,i+1):
		if(j==0):
			dp[i][j]=dp[i-1][j]*(1-(p[i-1]))
		else:
			dp[i][j]=dp[i-1][j]*(1-(p[i-1]))+dp[i-1][j-1]*(p[i-1])
ans=(0.0)
for j in range(n/2+1,n+1):
	ans=ans+dp[n][j]
print ans				
			


Measured memory_bytes: 104088
import heapq
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

N, M = list(map(int, sys.stdin.readline().split()))
VU = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]
S, T = list(map(int, sys.stdin.readline().split()))

#: :type: list of (list of int)
graph = [[] for _ in range(N * 3 + 1)]
for v, u in VU:
    graph[v].append(u + N)
    graph[v + N].append(u + N * 2)
    graph[v + N * 2].append(u)

heap = [(0, S)]
dist = [INF] * (N * 3 + 1)
ans = -1
while heap:
    d, v = heapq.heappop(heap)
    if v == T and d % 3 == 0:
        ans = int(d // 3)
        break
    for u in graph[v]:
        if d + 1 < dist[u]:
            dist[u] = d + 1
            heapq.heappush(heap, (d + 1, u))
print(ans)


Measured memory_bytes: 76408
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, I;
  cin >> N >> I;
  ll ans = N - I + 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    clock_t start = clock();

    ll d; cin>>d;
    vl cs(26); cin>>cs;
    vvl ss(d, vl(26)); cin>>ss;

    std::random_device rnd;
    std::mt19937 mt(rnd());
    std::uniform_int_distribution<> rd(0, d - 1);
    std::uniform_int_distribution<> rq(0, 25);

    ll ans = 0;
    vvl last(26);
    rep(i, 26) last[i].push_back(-1);
    vl ts;
    rep(i, d) {
        ll q = rq(mt);
        ts.push_back(q);
        ans += ss[i][q];
        last[q].push_back(i);
        rep(j, 26) {
            ans -= cs[j] * (i - last[j].back());
        }
    }
    rep(i, 26) last[i].push_back(d);

    clock_t end = clock();
    while (static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0 < 1900.0) {
        ll e = rd(mt);
        ll q = rq(mt);
        while (ts[e] == q) {
            e = rd(mt);
            q = rq(mt);
        }
        ll temp = ans;
        ll p = ts[e];
        auto pit = lower_bound(rng(last[p]), e);
        temp -= cs[p] * (pit - (pit - 1)) * ((pit + 1) - pit + 1);
        auto qit = lower_bound(rng(last[q]), e);
        temp += cs[q] * (e - *(qit - 1)) * (*qit - e + 1);
        temp += ss[e][q] - ss[e][p];
        if (temp > ans) {
            ans = temp;
            last[p].erase(pit);
            last[q].push_back(e);
            sort(rng(last[q]));
            ts[e] = q;
        }
        end = clock();
    }
    rep(i, d) cout<<ts[i] + 1<<endl;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long int
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define N 100009
#define mod 1000000007
#define med 998244353
#define debug cout<<"There There\n";
#define debug1(x) cout<<"\nValue is "<<x<<endl
#define debug2(x,y) cout<<"\nValue is "<<x<<" "<<y<<endl
#define debug3(x,y,z) cout<<"\nValue is "<<x<<" "<<y<<" "<<z<<endl  
#define pr pair<int,int>
#define mx INT_MAX
#define lmx LONG_MAX
#define err return 0
#define cn continue
#define bre break

int n;
int x,y,z;
vector<int> v[N];
int color[N];
bool visited[N];
map<pr,int> mp;

void dfs(int a,int b,int c)
{
	color[a] = c;
	for(auto i:v[a])
	{
		if(i==b)
		{
			continue;
		}
		int see = mp[{a,i}];
		if(see%2==0)
		{
			dfs(i,a,c);
		}
		else
		{
			dfs(i,a,1-c);
		}
		
	}
}

int32_t main()
{
	IOS;
	cin>>n;
	memset(visited,0,sizeof(visited));
	for(int i=0;i<n-1;i++)
	{
		cin>>x>>y>>z;
		v[x].pb(y);
		v[y].pb(x);
		mp[{x,y}] = z;
		mp[{y,x}] = z;
	}
	dfs(1,-1,0);
	for(int i=0;i<n;i++)
	{
		cout<<color[i+1]<<endl;
	}
}	


Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int i = 2;
  for(; i <= N; i *= 2){
    
  }
  if(N == 1)cout << 1 << endl;
  else cout << i / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define fo(i,a,n) for(int i=a;i<n;i++)
#define ll long long int
#define li long int
using namespace std;
vector<int> h(100005);
vector<int> dp(100005);
int n,k;
int cost(int ind)
{
    if(ind==n-1)
        return 0;
    if(dp[ind]==-1)
    {
        int ans=INT_MAX;
        for(int i=1;i<=k&&(ind+i<n);i++)
        {
            ans=min(ans,cost(ind+i)+abs(h[ind]-h[ind+i]));
        }
        dp[ind]=ans;
    }
    return dp[ind];
}
int main()
{
    cin>>n>>k;
    memset(&dp[0],-1,sizeof(dp[0])*100005);
    f(i,n)
        cin>>h[i];
    cout<<cost(0);
}


Measured memory_bytes: 10348
#include<iostream>
using namespace std;
int main(){
  long long i=1,k,c=0;
  cin>>k;
  while(i<=k){
    c=(c*10)+7;
    c=c%k;
    if(c==0){
      cout<<i;
      return 0;
    }
    i++;
  }
  cout<<"-1";
}

Measured memory_bytes: 3604
#include <iostream>
#include <stdio.h>
using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPD(i, n) for(ll i=(ll)(n)-1; i>=0; i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=b; i++)
#define INF 100000000000000

//変数定義
int L;

double answer;

int code(){
    answer = (double)L*L*L/27;
    return 0;
}

int main(){
    cin >> L;
    code();
    printf("%.12f\n", answer);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])cout << "Bad" << endl;
	else cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==min(a,min(b,c)))cout << max(b,c)-a << endl;
    else if(b==min(a,min(b,c)))cout << max(a,c)-b << endl;
    else if(c==min(a,min(b,c)))cout << max(a,b)-c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    char s[105];
    int n,i,count=0;
    scanf("%d", &n);
    scanf("%s", s);
   for(i=0;i<n/2;i++)
   {
       if(s[i]!=s[n/2+i])
       {
           count=1;
       }
   }
    if(count==0&&n%2==0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    h = LI()
    m = h[0]-1
    for i in h[1:]:
        if m > i:
            print("No")
            return
        m = max(m,i-1)
    print("Yes")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 58224
#include <stdio.h>
int main(void){
	int a,op,b,c,d,e,f;
	for(;;){
		scanf("%d %s %d",&a,&op,&b);
		if(op == '+'){
			c=a+b;
			printf("%d\n",c);
		}else if(op == '-'){
			d=a-b;
			printf("%d\n",d);
		}else if(op == '*'){
			e=a*b;
			printf("%d\n",e);
		}else if(op == '/'){
			f=a/b;
			printf("%d\n",f);
		}else if(op == '?'){
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#!/usr/bin/env python3
import sys


def solve(M: int, D: int):
    count = 0
    for m in range(1, M+1):
        for d in range(1, D+1):
            d_1 = d % 10
            d_10 = d // 10
            if d_1 >= 2 and d_10 >= 2 and d_1*d_10 == m:
                count += 1
    print(count)
    return


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

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>


int main(){
	int N;
	if(scanf("%d",&N)==1);

	int X[N];
	for(int i=0;i<N;i++){
		if(scanf("%d",&X[i])==1);

	}


	int num=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			for(int k=0;k<N;k++){
				if(i<j && i<k && j<k){
					if(X[i]!=X[j]&&X[j]!=X[k]&&X[i]!=X[k]){
						int max=X[i];
						int i_max = i;
						if(max<X[j]){
							max=X[j];
							i_max=j;
						}
						if(max<X[k]){
							max=X[k];
							i_max=k;
						}
			
						int sum=X[i]+X[j]+X[k];	
						if(max<sum-X[i_max]){
							// printf("%d%d%d\n",i+1,j+1,k+1);
							num++;
						}
					}

				}
			}
		}
	}
	printf("%d\n",num );


	return 0;

}


Measured memory_bytes: 1736
package main

import (
	"fmt"
)

func fillSlice(x []int, y int) {
	for i := range x {
		x[i] = y
	}
}

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	x := make([]int, 26)
	y := make([]int, 26)
	fillSlice(x, -1)
	fillSlice(y, -1)

	ok := true
	for i := 0; i < len(s); i++ {
		si := int(s[i]) - 97
		ti := int(t[i]) - 97
		if x[si] < 0 {
			x[si] = ti
		}
		if y[ti] < 0 {
			y[ti] = si
		}
		if (x[si] != ti) || (y[ti] != si) {
			ok = false
			break
		}
	}

	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 2176
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np

n, k = map(int, input().split())
memo = np.zeros(100010, dtype=np.int)

for i in range(n):
    a, b = map(int, input().split())
    memo[a] += b

s = 0
for i in range(len(memo)):
    s += memo[i]
    if k <= s:
        print(i)
        exit()

Measured memory_bytes: 20908
#include<bits/stdc++.h>
using namespace std;
int g[5][5];
int main()
{
    for (int i = 0; i < 3; ++i) {
        int a,b;
        cin >> a >> b;
        g[a][b]  = g[b][a] = 1;
    }
    vector<int> v{1,2,3,4};
    do {
        bool ok = true;
        for (int i = 0; i <= 2; ++i)
            ok = ok && g[v[i]][v[i+1]];
        if (ok) {
            cout << "YES\n";
            return 0;
        }
    } while (next_permutation(begin(v),end(v)));
    cout << "NO\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" = "<<x<<endl;

int main() {
  int n;
  cin>>n;
  long long ans=1;
  bool x=true;
  bool zero=false;
  for (int i=0;i<n;i++) {
	long long a;
    cin>>a;
    if (a!=0&&ans>((long long)1e18)/a) {
	  x=false;
    }
    ans*=a;
    if (a==0) 
    	zero=true;
  }
  if (x || zero==true)
    cout<<ans<<endl;
  else cout<<-1<<endl;
}




Measured memory_bytes: 3568