akhauriyash/Code-Regression huggingface dataset:
// OURL: https://atcoder.jp/contests/abc136/tasks/abc136_b
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

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

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int ans = 0;
  RREP(i,1,n+1) {
    if (int(log10(i)) % 2 == 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

void Do(int N, int X){
  int i, D, c, L;
  D = 0;
  c = 1;
  for(i = 0;i < N;i++){
    scanf("%d", &L);
    D += L;
    if(D <= X) c++;
  }
  printf("%d\n", c);
}

int main(void){
  int N, X;
  scanf("%d %d", &N, &X);
  Do(N, X);
  return 0;
}


Measured memory_bytes: 128
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=1000*1007;
const ll inf=1e18;

int n, q;

set < pair <int,ll> > setel;

int main()
{
	scanf("%d%d", &n, &q);
	setel.insert({0, inf});
	setel.insert({n+1, 0});
	while(q--)
	{
		int a;
		ll b;
		scanf("%d%lld", &a, &b);
		auto it=setel.lower_bound({a, -1});
		setel.insert({a, (*it).second});
		while(b)
		{
			it=setel.lower_bound({a, -1});
			auto jt=it;
			jt--;
			if ((*it).second==(*jt).second)
			{
				setel.erase(jt);
				continue;
			}
			int dlu=(*it).first-(*jt).first;
			if (b<dlu)
			{
				setel.insert({(*jt).first+b, (*it).second+1});
				b=0;
				continue;
			}
			ll ile=min(b/dlu, (*jt).second-(*it).second);
			b-=dlu*ile;
			auto pam=(*it);
			setel.erase(pam);
			pam.second+=ile;
			setel.insert(pam);
		}
	}
	for (int i=1; i<=n; i++)
		printf("%lld\n", (*setel.lower_bound({i, -1})).second);
	return 0;
}


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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 200000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //int TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    ll n;
    cin >> n;
    vector<vector<ll> > a(n, vector<ll> (2));
    rep(i, 0, n)
        cin >> a[i][0] >> a[i][1];
    ll ma = max(a[0][0], a[0][1]), mi = min(a[0][0], a[0][1]);
    rep(i, 1, n)
    {
        ma = max(ma, max(a[i][0], a[i][1]));
        mi = min(mi, min(a[i][0], a[i][1]));
    }
    ll ans = big;
    vector<pair<ll, ll> > b(n * 2);
    rep(i, 0, n)
    {
        b[i * 2] = {a[i][0], i};
        b[i * 2 + 1] = {a[i][1], i};
    }
    sort(b.begin(), b.end());
    int cnt[n], curr = 0;
    fill(cnt, cnt + n, 0);
    for (int l = 0, r = -1; l < n * 2; l++)
    {
        while (curr < n)
        {
            if (r == n * 2 - 1)
                break;
            r++;
            cnt[b[r].se]++;
            if (cnt[b[r].se] == 1)
                curr++;
        }
        if (curr == n)
            ans = min(ans, (ma - mi) * (b[r].fi - b[l].fi));
        cnt[b[l].se]--;
        if (cnt[b[l].se] == 0)
            curr--;
    }
    ll t1 = ma, t2 = mi;
    rep(i, 0, n)
    {
        if (a[i][0] < a[i][1])
            swap(a[i][0], a[i][1]);
        t1 = min(t1, a[i][0]);
        t2 = max(t2, a[i][1]);
    }
    ans = min(ans, (ma - t1) * (t2 - mi));
    cout << ans << endl;
}


Measured memory_bytes: 18304
#include <iostream>
#include <cmath>
#include <vector>
#include <limits>
#include <algorithm>
using namespace std;

#define REP( i, n )	for( int (i) = 0; (i) < (n); i++ )

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

	vector<int> a(n);
	REP( i, n ) cin >> a[i];

	int count = 0;
	REP( i, n - 1 ) {
		for( int j = n - 1; j > i; j-- ) {
			if( a[j - 1] > a[j] ) {
				swap( a[j - 1], a[j] );
				count++;
			}
		}
	}

	REP( i, n - 1 ) cout << a[i] << " ";
	cout << a[n - 1] << endl << count << endl; 
}


Measured memory_bytes: 3084
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main() {
  int N;
  cin >> N;
  auto p = vectors(1001, 1001, 0LL);
  rep(i, N) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    p[a][b]++, p[c][d]++, p[a][d]--, p[c][b]--;
  }
  rep(i, 1001) loop(j, 1, 1001) p[i][j] += p[i][j - 1];
  rep(j, 1001) loop(i, 1, 1001) p[i][j] += p[i - 1][j];
  int ans = 0;
  rep(i, 1001) rep(j, 1001) cmax(ans, p[i][j]);
  cout << ans << endl;
}



Measured memory_bytes: 10788
#include <stdio.h>


int main(void)
{
    int stack[105], input, i;
    int topOfStack = 0;

    i = 0;
    while (scanf("%d", &input) == 1){
        
        switch (input)
        {
        case 0:
            topOfStack--;
            printf("%d\n", stack[topOfStack]);
            break;
        default:
            stack[topOfStack] = input;
            topOfStack++;
            break;
        }
        i++;
        //if(topOfStack == 0) break;
    }

    return (0);
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M,K;

template<int um> class UF {
	public:
	vector<int> par,rank,cnt;
	UF() {par=rank=vector<int>(um,0); cnt=vector<int>(um,1); for(int i=0;i<um;i++) par[i]=i;}
	void reinit() {int i; FOR(i,um) rank[i]=0,cnt[i]=1,par[i]=i;}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int count(int x) { return cnt[operator[](x)];}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		cnt[y]=cnt[x]=cnt[x]+cnt[y];
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};
UF<101010> uf;
vector<int> A[101010],B[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>K;
	FOR(i,M) {
		cin>>x>>y;
		uf(x-1,y-1);
		A[x-1].push_back(y-1);
		A[y-1].push_back(x-1);
	}
	FOR(i,K) {
		cin>>x>>y;
		B[x-1].push_back(y-1);
		B[y-1].push_back(x-1);
	}
	FOR(i,N) {
		int cnt=uf.count(i)-1-A[i].size();
		
		FORR(e,B[i]) if(uf[e]==uf[i]) cnt--;
		cout<<cnt<<" ";
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 13688
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int n1 = int(s.size());
  int n2 = int(t.size());

  int res = INT_MAX;
  for (int i = 0; i <= n1-n2; ++i) {
    int count = 0;
    for (int j = 0; j < n2; ++j) {
      count += s[i+j] != t[j];
    }
    // cout << count << endl;
    chmin(res, count);
  }

  cout << res << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n; cin >> n;
    vector<int>v(n);
    for(auto & e : v) cin >> e;
    cout << accumulate(all(v),0LL,[](int a, int b){return a+b;}) - *max_element(all(v)) + *max_element(all(v)) /2  << endl;
}




Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 21:15:44 2020

@author: naoki
"""

N = int(input())
L = list(map(int, input().split()))
count = 0 # 条件を満たす要素のカウント
L2 = sorted(L) # 小さい順に長さをソートする
# i + j > k and i > k - j 
if len(L2) <= 2: 
    count =  0
else:
    for i in range(len(L2)-2):
        for j in range(i+1,len(L2)-1):
            for k in range(j+1,len(L2)):
                if (int(L2[i]) + int(L2[j]) > int(L2[k])) and (int(L2[i]) > int(L2[k]) - int(L2[j])) and int(L2[i]) != int(L2[j]) and int(L2[j]) != int(L2[k]):
                    count+=1
print(count)

Measured memory_bytes: 9224
#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

ll ans = 1e+18+7;
ll N;

ll keta(ll x) {
	ll res = 0;
	while (x != 0) {
		x /= 10;
		res++;
	}
	return res;
}

ll calc(ll A, ll B) {
	return max(keta(A), keta(B));
}

void solve() {
	for (ll A = 1; A*A <= N; A++) {
		if (N % A != 0) continue;
		ans = min(ans, calc(A, N/A));
	}
	cout << ans << endl;
}

int main() {
	cin >> N;
	solve();
	return 0;
}




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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
using vvl = vector<vl>;
using pll = pair<ll,ll>;
using vb = vector<bool>;

const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;

#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define xx first
#define yy second

#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORD(i,a,b) for (int i=int(b)-1; i>=(a); i--)

#define rv(type,name,count) vector<type> name(count); FOR(_i,0,count) cin >> name[_i];
#define grid(type,name,c1,c2) vector<vector<type>> name(c1, vector<type>(c2)); FOR(_i,0,c1)FOR(_j,0,c2)cin >> name[_i][_j];
vvl adj;
vl best;

ll dfs(ll n) {
	if (best[n] != -1) return best[n];
	ll d = 0;
	for(ll nei : adj[n]) {
		d = max(d, 1 + dfs(nei));
		
	}
	return best[n] = d;
}
int main() {
	ll n, m;
	cin >> n >> m;
	adj = vvl(n);
	best = vl(n, -1);
	FOR(i,0,m) {
		ll x, y;
		cin >> x >> y;
		x--; y--;
		adj[x].pb(y);
	}
	ll res = 0;
	FOR(i,0,n) res = max(res, dfs(i));
	cout << res << endl;
}


Measured memory_bytes: 8576
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	LL X;
	cin >> N >> X;
	vector<LL> A(N);
	for(int i=0;i<N;++i){
		cin >> A[i];
	}
	/////
	vector< vector<LL> > dp(N,vector<LL>(N));
	for(int i=0;i<N;++i){
		dp[i][0] = A[i];
		for(int x=1;x<N;++x){
			dp[i][x] = min(dp[i][x-1],A[(i-x+N)%N] );
		}
	}

	LL ans = LINF;
	for(LL K=0;K<N;++K){//K回色変換を使う
		LL res = X*K;
		for(int i=0;i<N;++i){
			res += dp[i][K];
		}
		ans = min(ans,res);
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 31616
<?php

class CalculateSum
{
    public function getAnswer()
    {
        $n = trim(fgets(STDIN));
        $count = 0;

        for ($i = 0; $i < $n; $i++) {
            $num = (int) fgets(STDIN);

            if ($this->isPrime($num)) {
                $count++;
            }
        }

        echo $count . PHP_EOL;
    }
}

class CheckPrimeNumbers extends CalculateSum
{
    public function isPrime($num)
    {
        if ($num == 2) {
            return true;
        } elseif ( $num < 2 or $num % 2 == 0) {
            return false;
        } else {
            $start = 3;
            while ($start <= sqrt($num)) {
                if ($num % $start == 0) {
                    return false;
                }
                $start += 2;
            }
            return true;
        }
    }
}

$rate = new CheckPrimeNumbers();
$rate->getAnswer();



Measured memory_bytes: 9312
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPR(i,n) for(int i=n-1; i>=(int)(0); i--)
#define FOR(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define FORR(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); i--)
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()
//**関数リスト**//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) {
	ll keta = 1;
	while (F / 10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
ll gcd(ll x, ll y) {
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll isPrime(ll x) {
	ll i;
	if (x < 2) {
		return 0;
	}
	else if (x == 2) {
		return 1;
	}
	else if (x % 2 == 0) {
		return 0;
	}
	else {
		for (i = 3; i * i <= x; i += 2) {
			if (x % 1 == 0) {
				return 0;
			}
		}
		return 1;
	}
}
void eratos(vl isPrime) {
	//(注)isPrimeのサイズはN+1にする！実際にはmain内に配置して使用
	ll i, j;
	REP(i, isPrime.size()) {
		isPrime[i] = 1;
	}
	isPrime[0] = 0; isPrime[1] = 0;
	for (i = 2; i * i <= isPrime.size() - 1; i++) {
		if (isPrime[i] == 1) {
			j = i * 2;
			while (j <= isPrime.size() - 1) {
				isPrime[j] = 0;
				j = j + i;
			}
		}
	}
}
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
void bitSearch(ll n) {
	//実際にはコピーして中身を改変して使う
	ll i;
	REP(i, pow(2, n)) {
		ll p = i;
		REP(i, n) {
			cout << p % 2;
			p /= 2;
		}
		cout << endl;
	}
}

void bfs(ll now) {
	//中身は毎回書き換えて使用
	queue<ll> Q;
	Q.push(now);
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		//ll v=;
		//Q.push(v);
	}
}
//**定義場所**//
ll i, j, k, l, m, n;
ll N, M, K, H, W;
ll MOD = 1000000007;
ll ans = 0;
//***********//

int main() {
	ll N;
	cin >> N;
	vl A(N);
	vl B(N);
	for (i = 0; i < N; i++) {
		cin >> A[i];
		B[i] = A[i];
	}
	sort(B.begin(), B.end());
	reverse(B.begin(), B.end());
	for (i = 0; i < N; i++) {
		if (A[i] == B[0]) {
			cout << B[1] << endl;
		}
		else {
			cout << B[0] << endl;
		}
	}
}

Measured memory_bytes: 4736
function Main(input){
  var In = input.split('\n');
  
  var count = 0;
  
  for(var i = 0; i <= In[0]; i++){
    for (var j = 0; j <= In[1]; j++){
      for (var k = 0; k <= In[2]; k++){
        var total = (500 * i) + (100 * j) + (50 * k);
        
        if(total == In[3]){
          count = count + 1;
        }
      }
    }
  }
  
  console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21320
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int result = 0;

			for (int a = 1; a < n; a++) {
				for (int b = 1; a * b < n; b++) {
					result++;
				}
			}
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 35660
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VII;
typedef pair<int,int> PII;

bool comp(pair<ll,ll> a,pair<ll,ll> b) {
  return atan2(a.second, a.first)<atan2(b.second, b.first);
}

int main(){
  int N;
  cin>>N;
  vector<ll> X(N),Y(N);
  rep(i,N) cin>>X[i]>>Y[i];
  vector<pair<ll,ll>> P;
  rep(i,N) P.push_back(make_pair(X[i],Y[i]));
  sort(all(P),comp);
  ll ans=0,xs,ys;
  rep(i,N) rep(j,N){
    xs=0;
    ys=0;
    rep(k,(j+N-i)%N+1){
      xs+=P[(k+i)%N].first;
      ys+=P[(k+i)%N].second;
    }
    ans=max(ans,xs*xs+ys*ys);
  }
  printf("%.12f",sqrt(ans));
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin>>s;
int cnt=count(s.begin()+2,s.end()-1,'C');
bool isLower=true;
reps(i,s.size(),1){
    if(s[i]!='C'&&s[i]-'Z'<=0){
        isLower=false;
        break;
    }
}
if(s[0]=='A' && cnt==1 && isLower){
    cout<<"AC"<<endl;
}
else{
    cout<<"WA"<<endl;
}
//system("pause");
return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        int K = sc.nextInt();
        System.out.println(cnt(N, K));

    }

    private static long cnt(String N, int K){
        if(N.length() == 0){return 0;}
        if(N.charAt(0) == '0'){
            return cnt(N.substring(1), K);
        }
        if(K == 0){
            return 0;
        }
        if(K == 1){
            if(N.length() == 1){
                return (N.charAt(0)-'0');
            }else {
                return (N.length() - 1) * 9 + (N.charAt(0) - '0');
            }
        }
        if(N.length() < K){
            return 0;
        }
        long res=0;
        res = cnt(N.substring(1), K-1);
        res += (N.charAt(0)-'0'-1) * cnt(nines(N.length()-1), K-1);
        res += cnt(nines(N.length()-1), K);
        return res;
    }

    private static String nines(int k){
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<k;i++){
            sb.append('9');
        }
        return sb.toString();
    }
}


Measured memory_bytes: 30640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <string.h>
#include <stdio.h>
#include <queue>
#include <limits.h>
#include <stack>
#include <set>
#include <map>

#define P pair
#define MP make_pair

typedef long long int llint ;

using namespace std;

int main()
{
	llint x,y;
	cin>>x>>y;
	llint sol=0;
	while(x<=y)
	{
		sol++;
		x*=2;
	}
	cout<<sol;
    return 0;
}


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

int main(){
  string s;
  cin >> s;
 
  string w[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  int a;
  for(int i=0; i<7; i++){
    if(s==w[i]){
      a = 7 - i;
    }
  }
  
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int n, m, k = 0;
vvi e;
vi c, d;
V<bool> seen;

void dfs(int v) {
	seen[v] = true;
	d[v] = c[k];
	k++;
	for (auto x : e[v])if (!seen[x])dfs(x);
	return;
}

int main() {


	cin >> n;

	e.resize(n);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;a--;b--;
		e[a].emplace_back(b);
		e[b].emplace_back(a);
	}

	c.resize(n);
	rep(i, n)cin >> c[i];
	sort(all(c), greater<int>());
	
	ll m = 0;
	rep(i, n)m += c[i];
	m -= c[0];

	d.resize(n);
	seen.assign(n, false);
	dfs(0);
	
	cout << m << endl;
	rep(i, n) {
		cout << d[i];
		if (i != n - 1)cout << " ";
		else cout << endl;
	}	

}

Measured memory_bytes: 1280
a,b,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=min(a)+min(b)
for _ in range(m):
    x,y,c=map(int,input().split())
    x-=1
    y-=1
    ans=min(ans,a[x]+b[y]-c)

print(ans)

Measured memory_bytes: 72540
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0

for i in range(N - 1):
    ans = max(ans, sum(A[:i + 1]) + sum(B[i:]))
ans = max(ans, sum(A) + B[-1])

print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))
#define P 1000000007
long powP (long a, long b) {
  if (b == 1) return a;
  else if (b == 0) return 1;
  else if (b < 0) return powP(a, P + b - 1);
  else return (powP(a, b/2) * powP(a, b/2 + b%2)) % P;
}

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

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

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


int main() {
  int n; cin>>n;
  int cnt=0;
  int a,b;
  for (int i = 0; i < n; i++) {
    cin>>a>>b;
    if(a==b)cnt++; else cnt=0;
    if(cnt==3) {
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No";
}


/* きょむ〜 */


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

vi p;
vi q;

int main() {

    int N;
    Scd(N);
    p.resize(N);
    q.resize(N+1);
    Rep(i,N) Scd(p[i]), q[p[i]] = i;

    set<int> expi;
    expi.insert(-1);
    expi.insert(N);
    expi.insert(q[N]);

    ll ans = 0;
    for( ll i = N-1; i >= 1; i-- ){
        int from = q[i];
        int l = *(--expi.lower_bound( from ));
        int r = *(expi.upper_bound( from ));
        // printf ("[%d](%d,%d)", from,l,r);
        // hidari
        if( l != -1 ){
            int li = *(--expi.lower_bound( l ));
            ans -= i*(l-li)*(from-r);
        }
        // migi
        if( r != N ){
            int ri = *(expi.upper_bound( r ));
            ans -= i*(l-from)*(ri-r);
        }
        expi.insert(from);
    }

    printf ("%lld\n", ans );


    return 0;
}





Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << a << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {}

int main(void) {
  ll n,k;cin>>n>>k;
  ll res;
  ll cnt=n/k;
  res=n-k*cnt;
  res=min(res,abs(res-k));
  pr(res);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<vector>
using namespace std;
typedef complex < double > P;
typedef vector< P > G;
struct L:public vector< P >{ // L:線分
  L(const P& a,const P& b){push_back(a);push_back(b);}
};
const double EPS = 1e-8;
const double INF = 1e12;
double cross(const P& a,const P& b){
  return imag(conj(a) * b);
}
double dot(const P& a,const P& b){
  return real(conj(a) * b);
}
int ccw(P a,P b,P c){
  b -= a; c -= a;
  if(cross(b,c) > 0) return 1;
  if(cross(b,c) < 0) return -1;
  if(dot(b,c) < 0) return 2; // c--a--b
  if(norm(b) < norm(c)) return -2; // a--b--c
  return 0; // a--c--b
}
bool intersect(const L& s,const L& t){
  return ccw(s[0],s[1],t[0]) * ccw(s[0],s[1],t[1]) <= 0 &&
    ccw(t[0],t[1],s[0]) * ccw(t[0],t[1],s[1]) <= 0;
}
bool isconvex(const G& g){
  return intersect(L(g[0],g[2]),L(g[1],g[3]));
}
int main(){
  double x1,y1,x2,y2,x3,y3,x4,y4;
  char o;
  while(cin >> x1 >> o >> y1 >> o >> x2 >> o >> y2 >> o >> x3 >> o >> y3 >> o >> x4 >> o >> y4){
    G g(4);
    g[0] = P(x1,y1);
    g[1] = P(x2,y2);
    g[2] = P(x3,y3);
    g[3] = P(x4,y4);
    cout << (isconvex(g) ? "YES" : "NO") << endl;
  }
}

Measured memory_bytes: 1224
import sys

def caesar(c, n):
	cint = ord(c)
	return chr((cint+n-97)%26+97)

keyword = ['the', 'this', 'that']

for line in sys.stdin:
	slist = line.split()
	indx = 1
	while True:
		decodelist = []
		for i in range(0, len(slist)):
			word = ''
			for j in range(0, len(slist[i])):
				if slist[i][j] == '.': word = word+'.'
				else: word = word+caesar(slist[i][j], indx)
			decodelist.append(word)
		anotherlist = []
		for i in range(0, len(decodelist)):
			word = ''
			for j in range(0, len(decodelist[i])):
				if slist[i][j] == '.':
					anotherlist.append(word)
					word = ''
				else: word = word + decodelist[i][j]
			anotherlist.append(word)
		flag = False
		for i in range(0, 3):
			if keyword[i] in decodelist or keyword[i] in anotherlist:
				ans = decodelist[0]
				for j in range(1, len(decodelist)):
					ans = ans + ' ' + decodelist[j]
				print ans
				flag = True
				break
		if flag: break
		indx += 1


Measured memory_bytes: 4692
## for test
# a, b, c, d = 0, 75, 25, 100
# a, b, c, d = 0, 33, 66, 99
# a, b, c, d = 10, 90, 20, 80

## 考え方
# a, cの大きい方　～　b, dの小さい方　までがカウント対象

## for submit
a, b, c, d = map(int, input().split())

sec = min([b, d]) - max([a, c])
sec = sec if sec >= 0 else 0

print(str(sec))


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int A,B;
    char op;
    scanf("%d %c %d",&A,&op,&B);
    if(op=='+')
    printf("%d",A+B);
    else if(op=='-')
    printf("%d",A-B);
    return 0;
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  long long a[200000];
  for(int i = 0; i < n ; i++){
    cin >> a[i];
    a[i] -= i+1;
  }
  sort(a, a + n);
/*  for(int i = 0; i < n ; i++){
    cout << a[i] << " ";
  }
  cout << endl;
*/
  long long  ans = 0;
  if(n % 2){
    for(int i = 0; i < n; i++){
      ans += abs(a[i]-a[(n-1)/2]);
    }
  }
  else{
    long long s = 1e18;
    for(int i = a[(n-1)/2]; i <= a[(n-1)/2+1]; i++){
      long long t = 0;
      for(int j = 0; j < n; j++){
        t += abs(a[j]-i);
      }
      if(s > t) s = t;
    }
    ans = s;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
n, m = map(int, input().split())

student_points = list(map(lambda _: list(map(int, input().split())), range(n)))
check_points = list(map(lambda _: list(map(int, input().split())), range(m)))

for s_p in student_points:
    min_index = 0
    min_distance = abs(s_p[0] - check_points[0][0]) + abs(s_p[1] - check_points[0][1])
    for j, c_p in enumerate(check_points):
        d = abs(s_p[0] - check_points[j][0]) + abs(s_p[1] - check_points[j][1])
        if d < min_distance:
            min_distance = d
            min_index = j
    print(min_index + 1)


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using TP = tuple<int, int, int>;

void Main(){
    int n; cin >> n;
    vll a(n); 
    ll s = 0, tot = 0;
    rep(i, n) {
        cin >> a[i];
        if(i > 1) tot ^= a[i];
        else s += a[i];
    }
    
    // s = x + y, tot = x ^ y, d = x & y
    ll d = (s - tot) / 2;
    if( (s - tot) % 2 == 1 || d < 0 || d > a[0]){
        cout << -1 << endl;
        return;
    }
    
    int keta = 0;
    ll tot_cp = tot;
    while(tot_cp){
        tot_cp /= 2;
        keta++;
    }
    
    /*
    cout << "s = " << s << endl;
    cout << "tot = " << tot << endl;
    cout << "d = " << d << endl;
    cout << "keta = " << keta << endl;
    //*/

    ll x = d;
    rep3rev(i, keta, 1){
        ll now = 1LL << (i-1);
        if((d & now) && (tot & now)){
            cout << -1 << endl;
            return;
        }
        if(d & now) continue;
        if(!(tot & now)) continue;
        // cout << i << ": " << now << ", " << x << endl;
        if( a[0] > x + now){
            x += now;
        }
    }
    
    if(x == 0) cout << -1 << endl;
    else cout << a[0] - x << endl;    
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3648
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;



class Program
{
    public const int INF = 1 << 25;

    static void Main()
    {
		int[] high = new int[10];
		for (int i = 0; i < 10; i++) {
			high[i] = int.Parse(Console.ReadLine());
		}
		Array.Sort(high);
		Array.Reverse(high);
		for (int i = 0; i < 3; i++) {
			Console.WriteLine(high[i]);
		}
	}
}

Measured memory_bytes: 5752
#include <ciso646>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <vector>
#pragma GCC optimize ("O3")
#pragma GCC target("sse4.2")


class DisjointDataStructure {
public:
	DisjointDataStructure(int number_of_nodes) {
		par = std::vector<int>(number_of_nodes);
		std::iota(par.begin(), par.end(), 0);
		rank = std::vector<int>(number_of_nodes);
	}
	int root(int node) {
		if (par[node] == node)
		{
			return node;
		}
		else
		{
			return par[node] = root(par[node]);
		}
	}
	inline int inTheSameSet(int node1, int node2) {
		return root(node1) == root(node2);
	}
	void unite(int node1, int node2) {
		auto x = root(node1);
		auto y = root(node2);
		if (x == y)
		{
			return;
		}
		else if (rank[x] < rank[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (rank[x] == rank[y])
			{
				rank[x]++;
			}
		}
	}
private:
	std::vector<int> par;
	std::vector<int> rank;
};


int main() {
	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	int n, m;
	std::cin >> n >> m;
	std::vector<std::vector<int>> speakers(m, std::vector<int>());
	for (int i = 0; i < n; i++)
	{
		int k;
		std::cin >> k;
		for (int j = 0; j < k; j++)
		{
			int l;
			std::cin >> l;
			--l;
			speakers[l].push_back(i);
		}
	}
	DisjointDataStructure dds(n);
	for (const auto& lang_speakers : speakers)
	{
		for (int i = 0; i < (int)lang_speakers.size() - 1; i++)
		{
			dds.unite(lang_speakers[i], lang_speakers[i + 1]);
		}
	}
	for (int i = 1; i < n; i++)
	{
		if (not dds.inTheSameSet(0, i))
		{
			std::cout << "NO" << std::endl;
			return EXIT_SUCCESS;
		}
	}
	std::cout << "YES" << std::endl;
	return EXIT_SUCCESS;
}

Measured memory_bytes: 4608
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
using namespace std;
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a==4||a==6||a==9||a==11)
    {
        if(b==30)
            cout<<1<<endl;
        else
            cout<<0<<endl;
    }

    else if(a==2)
    {
        if(b==28)
            cout<<1<<endl;
        else
            cout<<0<<endl;
    }
    else
    {
        if(b==31)
            cout<<1<<endl;
        else
            cout<<0<<endl;

    }


    return 0;
}





Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;


int main() {
	//cout << fixed << setprecision(10);
	long long int n,m,a,b,c,d,x,h,w;
	cin >>a>>b ;
	cout << max(a,b)+max(max(a,b)-1,min(a,b));
	
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPS(i,n) for(int i=0; i<(n); i++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

void swap(int& a, int& b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

int main(int argc, char const *argv[])
{
  int A,B,C,X;
  cin >> A >> B >> C >> X;

  int ans = 0;
  REPS(i,A+1) {
    REPS(j,B+1) {
      REPS(k,C+1) {
        if((i*500 + j*100 + k*50) == X) ans++;
      }
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main
{
  public static void main (String[]args)
  {
    Scanner sc = new Scanner (System.in);
    String s = sc.next ();
    String result = "Yes";

    for (int i = 0; i < s.length (); i++)
      {
	if (s.charAt (i) == 'U' || s.charAt (i) == 'D')
	  {
	    continue;
	  }
	else
	  {
	    if (i % 2 == 0)
	      {
		if (s.charAt (i) == 'R')
		  {
		    continue;
		  }
		else
		  {
		    result = "No";
		    break;
		  }
	      }
	    else
	      {
		if (s.charAt (i) == 'L')
		  {
		    continue;
		  }
		else
		  {
		    result = "No";
		    break;
		  }
	      }

	  }
      }


    System.out.println (result);
  }
}

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

int main(){
    while(1){
        int n; cin>>n;
        if(n == 0) return 0;
        vector<char> c(100);
        for(int i=0; i<100; i++) cin>>c[i];

        vector<int> cnt(n, 0);

        int field = 0;
        for(int i=0; i<100; i++){
            cnt[i%n]++;
            if(c[i] == 'M'){
                continue;
            }
            else if(c[i] == 'S'){
                field += cnt[i%n];
                cnt[i%n] = 0;
            }
            else{
                cnt[i%n] += field;
                field = 0;
            }
        }

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

        for(int i=0; i<n; i++){
            cout << cnt[i] << " ";
        }

        cout << 100 - accumulate(cnt.begin(), cnt.end(), 0) << endl;
    }
}


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

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

    vector<P> pairs(n);
    for (int i = 0; i < n; i++) {
        pairs[i] = P(a[i], i+1);
    }

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

    for (int i = 0; i < n; i++) {
        cout << pairs[i].second;
        if (i < n-1) {
            cout << " ";
        } 
    }
    cout << endl;
    
    return 0;
}


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

using namespace std;

int n, t, k;
string s;

void solve() {
	cin >> k;
	cin >> s;
	if(s.length() <= k) cout << s;
	else{
		string b = s.substr(0, k);
		b = b+ "...";
		cout << b;
	}
}

int main(){
	t = 1;

	while(t--){
		solve();
	}
}

Measured memory_bytes: 3588
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

//最大値更新
const ll MAX_N=114514*2;
ll bit[MAX_N],n;
//1-indexed (i=0で抜けれるようにするため)
ll query(ll i){
    ll s=0;
    while(i>0){
        s=max(s,bit[i]);
        i-=i&-i;
    }
    return s;
}

void upd(ll i,ll x){
    while(i<=n){
        bit[i]=max(bit[i],x);
        i+=i&-i;
    }
}
int main(){
    cin>>n;
    vl h(n);
    rep(i,n){
        cin>>h[i];
    }
    vl a(n);
    rep(i,n)cin>>a[i];
    rep(i,n){
        upd(h[i],query(h[i])+a[i]);
    }
    cout<<query(n)<<endl;
}
    

Measured memory_bytes: 4992