akhauriyash/Code-Regression huggingface dataset:
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,x,y,ans=0,res=0;

int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>x>>y;
		ans+=y;
		res+=x*y;
	}
	ans--;
	if(res%9==0) ans+=res/9-1;
	else ans+=res/9;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
//#include <math.h>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include<stdio.h>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main(){
    int n, k;
    cin >>n>>k;
    vector<int> p(n);
    rep(i,n){
        cin >>p[i];
    }
    
    sort(p.begin(),p.end());//昇順ソート

    int ans=0;
    
    rep(i,k){
        ans += p[i];
    }
    
    cout<< ans <<endl;

}


Measured memory_bytes: 3640
#include<stdio.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#define swap(a,b) ((*a!=*b)&&(*a+=*b,*b=*a-*b,*a-=*b))
typedef long long LL;
typedef unsigned long long ULL;
const long long LLMIN=(1LL<<63);
int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void Sort(ULL *from,ULL *to,ULL bit)
{
  if(!bit||to<from+1)return;
  ULL *left=from,*right=to-1;
  for(;;)
  {
    while(left<right&&!(*left&bit))left++;
    while(left<right&&(*right&bit))right--;
    if(left>=right)break;
    swap(left,right);
  }
  if(!(bit&*left)&&left<to)left++;
  bit>>=1;
  Sort(from,left,bit);
  Sort(left,to,bit);
}
static inline void Radix(LL *array,const int len)
{
  ULL *x=(ULL*)array;
  rep(i,len)x[i]^=LLMIN;
  Sort(x,x+len,LLMIN);
  rep(i,len)x[i]^=LLMIN;
}
int main(void)
{
  LL N=IN(),K=IN(),P[1000]={0},i=0,sum=0;
  while(i<N){P[i++]=IN();}
  Radix(P,N);i=0;
  while(i<K){sum+=P[i++];}
  return printf("%lld\n",sum),0;
}

Measured memory_bytes: 1608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    int r, D, x;
    cin >> r >> D >> x;
    for (int i = 0; i < 10; ++i) { 
        x = r*x - D;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i)
static const ll INFTY = (1 << 30);
ll N, M;
void func()
{
    cin >> N;
    pair<ll, ll> lf[N];
    ll tmp1, tmp2;
    ll ans(N);
    rep(i, 0, N)
    {
        cin >> tmp1 >> tmp2;
        lf[i] = make_pair(tmp1 + tmp2, tmp1 - tmp2);
    }
    sort(&lf[0], &lf[N]);
    ll i = 0;
    while (i < N)
    {
        ll j = 1;
        while (lf[i].first > lf[i + j].second)
        {
            --ans;
            ++j;
        }
        i += j;
    }
    cout << ans << endl;
}
int main()
{
    func();
}

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

int main(){

    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for(int i = 0; i < H; i++) cin >> s[i];

    bool ans = true;

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(s[i][j] == '.') continue;
            bool iso = true;
            if(0 <= i - 1 && (s[i][j] == '#' && s[i - 1][j] == '#')) iso = false;
            if(i + 1 < H && (s[i][j] == '#' && s[i + 1][j] == '#')) iso = false;
            if(0 <= j - 1 && (s[i][j] == '#' && s[i][j - 1] == '#')) iso = false;
            if(j + 1 < W && (s[i][j] == '#' && s[i][j + 1] == '#')) iso = false;
            if(iso) ans = false;
        }
    }

    int num = 0;
    for(int i = 0; i < H; i++) num += count(s[i].begin(), s[i].end(), '#');
    if(ans || num == 1) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
//#include<cstring>
//#include<map>
using namespace std;
struct knife
{
	int ai;
	bool f;
}m[2000018];
inline int read()
{
    int p=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9'){p=p*10+c-'0';c=getchar();}
    return f*p;}
int N,H,ans;
bool cmp(knife x,knife y)
{
	return x.ai>y.ai; 
}
int main()
{
	N=read();H=read();
	for(int i=1;i<=N;i++)
	   {m[i].ai=read();
	   	m[i+N].ai=read();
	    m[i+N].f=true;}
	sort(m+1,m+1+N*2,cmp);
	int ans=0;   
	for(int i=1;i<=2*N;i++) 
	   {if(m[i].f)    
		  {ans++;
		   H-=m[i].ai;}
	    else{int u=H%m[i].ai;
		     ans+=H/m[i].ai;
	         if(u)ans++;
		  	 H=-1;}
	      if(H<=0){cout<<ans;return 0;}
	   }
}

Measured memory_bytes: 1792
def main():
    A, B, C = map(int, input().split())
    if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
        print(0)
    else:
        ans = min(A*B, B*C, C*A)
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include <iostream>

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

using namespace std;

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

	int a = 100000;
	rep(i,N)
	{
		a = (105 * a / 100 + 999) / 1000 * 1000;
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
queue<pair<int,long long> > q;
int n,qu,k;
vector<pair<int,long long> > ga[100100];
int a,b;
long long c;
long long dist[100100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>a>>b>>c;
		ga[a].push_back(make_pair(b,c));
		ga[b].push_back(make_pair(a,c));
		dist[i]=1e18;
	}
	cin>>qu>>k;
	memset(dist,63,sizeof(dist));
	q.push(make_pair(k,0LL));
	dist[k]=0LL;
	while(!q.empty()){
		int x=q.front().first;
		long long di=q.front().second;
		q.pop();
		if(di!=dist[x])
			continue;
		for(int i=0;i<ga[x].size();i++){
			int y=ga[x][i].first;
			long long cst=ga[x][i].second;
			if(dist[y]>di+cst){
				dist[y]=di+cst;
				q.push(make_pair(y,dist[y]));
			}
		}
	}
	while(qu--){
		cin>>a>>b;
		cout<<dist[a]+dist[b]<<endl;
	}
	return 0;
}



Measured memory_bytes: 11008
function f()
    N = parse(Int, chomp(readline()))
    A = parse(Int, chomp(readline()))
    B = parse(Int, chomp(readline()))
    C = parse(Int, chomp(readline()))
    D = parse(Int, chomp(readline()))
    E = parse(Int, chomp(readline()))

    if N <= A && N <= B && N <= C && N <= D && N <= E
        print("5")
    else
        tmp = N / findmin([A, B, C, D, E])[1] + 4
        @printf("%15d", ceil(tmp))
    end

end
f()

Measured memory_bytes: 164044
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
#include<set>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007LL;
const ll INF=1000000000;
const int MAX=100001;
struct edge{int to,cost;};
typedef pair<int,int> P;
int main(){
    string s;
    cin>>s;
    int sl=s.length();
    int a=0;int b=0;int c=0;
    for(int i=0;i<sl;i++){
        if(s[i]=='a'){
            a++;
        }else if(s[i]=='b'){
            b++;
        }else{
            c++;
        }
    }
    int ma=max(a,max(b,c));
    int mi=min(a,min(b,c));
    if(ma-mi<2){
        if(mi>0){
            cout<<"YES"<<endl;
        }else{
            if(ma==1){
                cout<<"YES"<<endl;
            }else{
                cout<<"NO"<<endl;
            }
        }
    }else{
        cout<<"NO"<<endl;
    }
    getchar();
    getchar();
}

                           


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using pii = pair<int,int>;

int main(){
  ll n; cin>>n;
  ll a[n+1],b[n+1],c[n+1];
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  ll count=0;
  ll count_b[n];
  a[n] = b[n] = c[n] = 1000000007;
  /*rep(i,n){
    ll x_c = lower_bound(c,c+n+1,b[n-1-i]+1)-c;
    if(i==0)count_b[n-1-i]=n-x_c;
    else count_b[n-1-i]=count_b[n-i]+n-x_c;
  }
  for(auto x : a){
    ll x_b = lower_bound(b,b+n+1,x+1)-b;
    count+=count_b[x_b];
  }*/
  for (int i = 0; i < n; i++) count += 1ll * (lower_bound(a, a + n + 1, b[i]) - a) * (n - (upper_bound(c, c + n + 1, b[i]) - c));
  cout<<count<<endl;
}


Measured memory_bytes: 5980
#include <iostream>
#include <vector>
using namespace std;


struct Node {
	vector<size_t> edges;
	size_t xsum = 0;
	size_t count = 0;
};

void count_up(vector<Node>& nodes, size_t i, size_t n) {
	nodes[i].count = nodes[i].xsum + n;
	for (size_t j: nodes[i].edges) {
		count_up(nodes, j, nodes[i].count);
	}
}

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

	vector<Node> nodes(n);
	for (size_t i = 0; i < n - 1; ++i) {
		size_t a, b;
		cin >> a >> b;
		nodes[a - 1].edges.push_back(b - 1);
	}

	for (size_t i = 0; i < q; ++i) {
		size_t p, x;
		cin >> p >> x;
		nodes[p - 1].xsum += x;
	}

	count_up(nodes, 0, 0);

	for (Node const& node: nodes) {
		cout << ' ' << node.count;
	}
	cout << endl;
}

Measured memory_bytes: 25856
#include <iostream>
#include <set>
#include <algorithm>

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

using namespace std;

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

int h, w, n;
vector<P> v;
set<P> c;
int ans[10];

void srch(int x, int y){
	if(c.find(P(x, y)) != c.end()){
		return;
	}
	int s = 0;
	for(int i = -1; i <= 1; ++i){
		for(int j = -1; j <= 1; ++j){
			if(binary_search(v.begin(), v.end(), P(x + i, y + j))){
				++s;
			}
		}
	}
	++ans[s];
	c.insert(P(x, y));
}

int main(){
	cin >> h >> w >> n;
	rep(i, n){
		int a, b;
		cin >> a >> b;
		v.push_back(P(a, b));
	}
	sort(v.begin(), v.end());
	rep(k, n){
		for(int i = -1; i <= 1; ++i){
			for(int j = -1; j <= 1; ++j){
				int x = v[k].first + i;
				int y = v[k].second + j;
				if(1 <= x - 1 && x + 1 <= h && 1 <= y - 1 && y + 1 <= w){
					srch(x, y);
				}
			}
		}
	}
	ll s = 0;
	rep(i, 9){
		s += ans[i + 1];
	}
	cout << ll(h - 2) * (w - 2) - s << endl;
	rep(i, 9){
		cout << ans[i + 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 43252
#include <bits/stdc++.h>
#define _boost ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define fi first
#define se second
#define clz __builtin_clz
#define clzll __builtin_clzll
#define bp __builtin_popcount
#define _unique(x) sort((x).begin(),(x).end()),(x).erase(unique((x).begin(), (x).end()),(x.end()))
#define all(x) (x).begin(),(x).end()
#define _rand(i,j) uniform_int_distribution<int>(i, j)(rng___)
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;
template < typename _T, typename _T2> string to_string(pair<_T,_T2> x) {return "<"+to_string(x.fi)+", "+to_string(x.se)+">";}
template < typename _T> string to_string(vector<_T> vec) {string s="[ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]=']';s[s.size()-2]=' '; return s;}
template < typename _T> string to_string(set<_T> vec) {string s="{ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T, typename _T2> string to_string(map<_T,_T2> vec) {string s="{ "; for(auto el:vec)s+="mp["+to_string(el.fi)+"]= "+to_string(el.se)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T > inline void _DBG(const char *s, _T x){cerr << s << " = " << to_string(x) << "\n";}
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a){while(*s != ',') cerr << *s++;cerr << " = " << to_string(x) << "\n";_DBG(s + 1, a...);}
#ifdef LOCAL
#define _print(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define _print(...) ;//cout<<2;//(__VA_ARGS__)
#endif
mt19937 rng___(chrono::steady_clock::now().time_since_epoch().count());


const LL MOD = 998244353;//1e9+7;
const LL LLINF = 1e18+7;
const int N=1e5+8;

vector<vector<int>> G(N);
int best[N];
int indeg[N];
vector<int> vers;
int main()
{
    _boost;
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        G[x].push_back(y);
        indeg[y]++;
    }
    for(int i=1;i<=n;i++)if(indeg[i]==0)vers.push_back(i);
    int maxi=0;
    while(!vers.empty())
    {
        int cur=vers.back();
        vers.pop_back();
        for(int u:G[cur])
        {
            if(--indeg[u]==0)vers.push_back(u);
            best[u]=max(best[u],best[cur]+1);
            maxi=max(maxi,best[u]);
        }
    }
    cout<<maxi;
}




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

int64_t gcd( int64_t a, int64_t b ) {
	return b ? gcd( b, a%b ) : a;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	int64_t result = 1;

	for( int i = 0; i < N; ++i ) {
		int64_t x;
		cin >> x;

		result = lcm( result, x );
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
n,x=map(int,input().split())

a=list(map(int,input().split()))

a.sort()

count=0
 
if x<a[0]:
    print(0)
    exit()


for i in range(n):
    if x>=a[i]:
        x-=a[i]
        count+=1
    else:
        print(count)
        exit()

if x>0:
    print(count-1)
else:
    print(count)

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

const int mod = 998244353;

template<int m = mod>
inline int qpow(int e, int x) {
	int r = 1;
	for (; x; x >>= 1, e = 1LL * e * e % m)
		if (x & 1) r = 1LL * r * e % m;
	return r;
}

int n, m;
int fac[1000005], inv[1000005];

inline int C(int n, int m) {
	if (n < 0 || m < 0 || n < m) return 0;
	return 1LL * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main() {
	scanf("%d%d", &n, &m);
	if (n < m) swap(n, m);
	int tot = n + m;
	fac[0] = 1;
	for (int i = 1; i <= tot; ++i)
		fac[i] = 1LL * fac[i - 1] * i % mod;
	inv[tot] = qpow(fac[tot], mod - 2);
	for (int i = tot; i; --i)
		inv[i - 1] = 1LL * inv[i] * i % mod;
	int sum = 0;
	for (int i = 1; i <= m; ++i)
		(sum += 1LL * C(i * 2, i) * C(n + m - i * 2, n - i) % mod) %= mod;
	printf("%d\n", (1LL * sum * inv[2] % mod * inv[n + m] % mod * fac[n] % mod * fac[m] % mod + n) % mod);
}

Measured memory_bytes: 8064
from sys import stdin
from collections import Counter

lines = stdin.readlines()

N, K, Q = map(int, lines[0].split())
ans = [0] * N
A = Counter([int(i) - 1 for i in lines[1:]])
for k in A.keys():
    ans[k] += A[k]
print("\n".join(["Yes" if Q < K + a
                 else "No" for a in ans]))


Measured memory_bytes: 18940
#include<iostream>
#include<utility>
#include<algorithm>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    pair<long int, long int> p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i].first >> p[i].second;
    }
    sort(p, p + n);
    long int ans = 0;
    long int num = 0;
    for(int i = 0; true; i++){
        if (num + p[i].second < m) {
            ans += p[i].first * p[i].second;
            num += p[i].second;
        }else{
            ans += p[i].first * (m - num);
            break;
        }        
    }
    cout << ans << '\n';
    
}

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

int g[15][15] ;

int main() {
  int N ;
  cin >> N ;
  int ans = 0 ;
  int sum = 0 ;
  rep(i,N) rep(j,N) g[i][j] = -1 ;
  rep(i,N){
    int A ;
    cin >> A ;
	rep(j,A){
      int x , y ;
      cin >> x >> y ;
      x-- ;
      g[i][x] = y ;
    }
  }
  rep(i,1<<N){
    sum = 0 ;
	vector<int> V(N) ;
    rep(j,N) if(i>>j&1) V.at(j) = 1 ;
    bool ok = true ;
    rep(j,N){
      if( V.at(j) != 1 ) continue ;
      rep(k,N){
        if( g[j][k] == -1 )continue ;
        if( g[j][k] != V.at(k) )ok = false ;
      }
    }
    if(ok) rep(i,N) sum += V.at(i) ;
    ans = max(sum,ans) ;
  }
  cout << ans << endl ;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> p_i;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)

#define repv(v, values) for (auto v : values)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0LL)
#define srt(vec) sort(vec_all(vec))
#define rev(vec) reverse(vec_all(vec))
#define revsrt(vec) \
    srt(vec);       \
    rev(vec)

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

template <typename T, typename S>
void dump_dic(map<T, S> dic)
{
    for (auto v : dic)
    {
        cout << v.first << ": " << v.second << endl;
    }
}

// --- notice ---
// intの和はllにしろ

int main()
{
    int n;
    cin >> n;
    map<string, ll> cnt;
    string tmp;
    rep(i, n) {
        cin >> tmp;
        srt(tmp);
        cnt[tmp]++;
    }

    ll ans = 0;
    repv(v, cnt) {
        if (v.second > 1) {
            ans += (v.second * (v.second - 1) / 2);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define long long long
using namespace std;
const long M = 1e5+1, LINF = 1e18 + 1;

int n, W, w[101], v[101];
long dp[M], ans;
int main() {
  cin >> n >> W;
  for(int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }
  fill(dp+1, dp+M, LINF);
  dp[0] = 0;
  for(int i = 0; i < n; i++) {
    for(int j = M-1; j >= v[i]; j--) {
      dp[j] = min(dp[j - v[i]] + w[i], dp[j]);
    }
  }
  for(int j = M-1; j >= 0; j--) if(dp[j] <= W) {
    cout << j << endl;
    break;
  }
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scan = new Scanner(System.in);

		long x = scan.nextLong();

		long deposit = 100L;
		int i =0;

		while(deposit < x) {
			deposit *= 1.01;
			i++;
		}
			System.out.println(i);

			scan.close();

	}

}


Measured memory_bytes: 27044
/*
 * Click `Run` to execute the snippet below!
 */
 
import java.io.*;
import java.util.*;

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline. 
 */

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int W = sc.nextInt(), B = sc.nextInt();
    char ans[][] = new char[105][105];
    for(int i = 0; i<=49; i++){
      for(int j = 0; j<100; j++){
        ans[i][j] = '#';
      }
    }
    for(int i = 50; i<=99; i++){
      for(int j = 0; j<100; j++){
        ans[i][j] = '.'; 
      }
    }
    W--;
    B--;
    for(int i = 0; i<=49; i++){
      for(int j = 0; j<100; j++){
        if(i%2 == 0 && j%2 == 0 && W > 0){
          ans[i][j] = '.';
          W--;
        }
      }
    }
    for(int i = 99; i>=50; i--){
      for(int j = 0; j<100; j++){
        if(i%2 == 1 && j%2 == 0 && B > 0){
          ans[i][j] = '#';
          B--;
        }
      }
    }
    System.out.println(100 + " " + 100);
    for(int i = 0; i<100; i++){
      for(int j = 0; j<100; j++){
        System.out.print(ans[i][j]); 
      }
      System.out.println();
    }
  }
}


Measured memory_bytes: 39228
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   string S,T;
   cin >> S >> T;
   int size =S.size();
   if(S==T.substr(0,size)){
      cout << "Yes" << endl;
   }
   else{
      cout << "No" << endl;
   }


   return 0;
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(){
  int n,m,i,l,r,max,min;
  cin >> n >> m;max = n;min = 0;
  for (i=0;i<m;i++){
    cin >> l >> r;
    if (min < l) min = l;
    if (max > r) max = r;
  }
  cout << ((min > max) ? 0:max-min+1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll N=2e5+5;
const ll MOD=1e9+7;
const ld pi=3.14159265359;
const ll INF=(1LL<<60);
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()

ll n,a[3][3],x,vis[3][3],r[3],c[3],ans;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	REP(i,3)REP(j,3)cin>>a[i][j];
	cin>>n;
	while(n--){
		cin>>x;
		REP(i,3)REP(j,3)if(!vis[i][j]&&a[i][j]==x)r[i]++,c[j]++,vis[i][j]=1;
	}
	if(vis[0][0]&&vis[1][1]&&vis[2][2])ans=1;
	if(vis[2][0]&&vis[1][1]&&vis[0][2])ans=1;
	REP(i,3)if(r[i]==3||c[i]==3)ans=1;
	cout<<(ans?"Yes\n":"No\n");
	return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int  N, K;
    cin >> N >> K;
    vector<ll> enemies;
    rep(i,N){
        ll h;
        cin >> h;
        enemies.push_back(h);
    }
    sort(enemies.begin(), enemies.end(), greater<ll>());
    ll sum = 0;
    if(N <= K) cout << 0 << endl;
    else{
//        sum = accumulate(enemies.begin() + K, enemies.end(),0);
//        cout << sum << endl;
        for(int i = K; i < N ; i++){
            sum += enemies[i];
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 2420
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        String curr;
        TreeMap<String,Integer> hm=new TreeMap<>();
        int currMax = 0;
        for (int i = 0; i < n; i++){
            curr = sc.nextLine();
            if(!hm.containsKey(curr)){
                hm.put(curr,1);
            } else{
                hm.put(curr, hm.get(curr)+1);
            }
            if(hm.get(curr)>=currMax)
                currMax = hm.get(curr);
        }
        for(Map.Entry e:hm.	entrySet()){
            if((int)e.getValue()==currMax)
                System.out.println(e.getKey());

        }




    }
}


Measured memory_bytes: 179404
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        Scanner sc = new Scanner(System.in);
        // 要素数nを読み込み、配列にn個の整数を読み込む
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        // 以下で配列aの中身を逆順に表示しよう
        // 改行なしで表示する時は System.out.print(表示する値) を使おう
        // 改行だけを表示する時は System.out.println() を使おう
        for(int j=a.length-1;j>0;j--){
            System.out.print(a[j] + " ");
        }
        System.out.print(a[0]);
        System.out.println();
        sc.close();
    }
}


Measured memory_bytes: 26224
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}
 
	private void solve() {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B = sc.next();
		String C = sc.next();
		System.out.println("A" + B.charAt(0) + "C");
	}
 
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> bool chmax(T &a,T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int n,m,ans=0;
    cin>>n>>m;
    Vi a(n,0),dp(n+1);
    REP(i,0,m){
        int t;
        cin>>t;
        a[t]++;
    }
    dp[0]=1;
    if(a[1]==0) dp[1]=1;
    REP(i,2,n+1){
        dp[i]=(dp[i-1]+dp[i-2])%MOD;
        if(a[i]==1) dp[i]=0;
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll n, tmp;
	std::cin >> n;
	map<ll, ll> e, o;
	rep(i, 0, n) {
		std::cin >> tmp;
		if (i % 2 == 0) {
			e[tmp]++;
		}
		else {
			o[tmp]++;
		}
	}

	ll maxE = 0, memE, secondE = 0;
	for (auto itr = e.begin(); itr != e.end(); itr++) {
		if (itr->second > maxE) {
			secondE = maxE;
			maxE = itr->second;
			memE = itr->first;
		}
		else if (itr->second > secondE) {
			secondE = itr->second;
		}
	}

	ll maxO = 0, memO, secondO = 0;
	for (auto itr = o.begin(); itr != o.end(); itr++) {
		if (itr->second > maxO) {
			secondO = maxO;
			maxO = itr->second;
			memO = itr->first;
		}
		else if (itr->second > secondO) {
			secondO = itr->second;
		}
	}

	if (memO == memE) {
		if (maxO + secondE < maxE + secondO) {
			maxO = secondO;
		}
		else {
			maxE = secondE;
		}
	}

	outn(n - maxE - maxO);

	return 0;
}


Measured memory_bytes: 6528
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

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

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << " " << max(0, a + b - n) << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>  
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 
ll mpow(ll a, ll b){
	if(b >= (MOD-1)) b %= (MOD-1);
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}
 
ll mpow(ll a, ll b, ll p){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2,p);
	t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}
 
ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}
 
ll range(ll l, ll r){
	return l + rand()%(r-l+1);
}
 
ll rev(ll v){
	return mpow(v,MOD-2);
}

void solve(){
	ll n,m;
	cin >> n >> m;
	bool a[n][m];
	forn(i,n){
		forn(j,m){
			char c;
			cin >> c;
			if(c=='.') a[i][j]=1;
			else a[i][j]=0;
		}
	}
	ll dp[n][m];
	forn(i,n) forn(j,m) dp[i][j]=INF;
	rforn(i,n-1){
		rforn(j,m-1){
			if(i==n-1 && j==m-1){
				if(a[i][j]==0) dp[i][j]=1;
				else dp[i][j]=0;
			}
			if(a[i][j]==1){
				if(i+1<n) dp[i][j]=min(dp[i][j],dp[i+1][j]);
				if(j+1<m) dp[i][j]=min(dp[i][j],dp[i][j+1]);
			}
			else{
				if(i+1<n && a[i+1][j]==0) dp[i][j]=min(dp[i][j],dp[i+1][j]);
				else if(i+1<n && a[i+1][j]==1) dp[i][j]=min(dp[i][j],dp[i+1][j]+1);
				if(j+1<m  && a[i][j+1]==0) dp[i][j]=min(dp[i][j],dp[i][j+1]);
				else if(j+1<m  && a[i][j+1]==1) dp[i][j]=min(dp[i][j],dp[i][j+1]+1);
			}
		}
	}
	cout << dp[0][0] << ln;
}
 
int main()
{
	fast_cin();
    ll t=1;
    // cin>>t;
    forn(i,t) {
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,n)  for(ll i=0;i<n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef pair<int,int> pii;
const ll INF = 1e10L;
int main()
{
	IOS;
	//int t; cin>>t;
	//ll M=pow(10,9)+7;
	int t=1;
	while(t)
	{
		ll n,w; cin>>n>>w;
		vector<ll> weight(n),value(n);
		ll sum_value=0;
		for(int i=0;i<n;i++)
		{
			cin>>weight[i]>>value[i];
			sum_value+=value[i];
		}
		vector<ll> dp(sum_value+1,INF);
		dp[0]=0;
		for(ll item=0;item<n;item++)
		{
			for(ll value_already=sum_value-value[item];value_already>=0;value_already--)
			{
				dp[value_already+value[item]]=min(dp[value_already+value[item]],dp[value_already]+weight[item]);
			}
		}
		ll ans=0;
		for(ll i=0;i<=sum_value;i++)
		{
			if(dp[i]<=w)
			{
				ans=max(ans,i);
			}
		}
		cout<<ans;
		t--;
	}
	return 0;
}

Measured memory_bytes: 3960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

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

void solve() {
  int n;
  cin >> n;
  rep3(x, 1, n / 100 + 1) {
    int n2 = n - x * 100;
    if (x * 5 >= n2) {
      cout << 1 << endl;
      return;
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def f(x):
    cnt = 0
    while x%2 == 0:
        cnt += 1
        x //= 2
    return cnt
def lcm(x,y):
    return x*y//math.gcd(x,y)

n,m = inpl()
a = inpl()
a = list(set(a))
c = list(set([f(x) for x in a]))
if len(c) != 1:
    print(0)
    quit()
c = c[0]
x = 1
for i in range(len(a)):
    x = lcm(a[i]//2, x)
# print(x)
print((m+x)//(2*x))

Measured memory_bytes: 91300
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.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>;
 
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
typedef long long int ll;
typedef long double ld;

const ll N = 2e5 + 9;
// const ll m = 1e9 + 7;
const ll INF = 1e14;
const ll mod =1e9+7;
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define pld pair<ld,ld>
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    freopen("error.txt", "w", stderr); 
    #endif      
    int T = 1;
    // cin>>t;
    while(T--){
        string s;cin>>s;
        int ans = 0;
        for(int i = 0;i<(int)s.size();i++){
            ans+=s[i]-'0';
            ans%=9;
        }
        if(ans){
            cout<<"No\n";
        }
        else{
            cout<<"Yes\n";
        }
        
    }
}

Measured memory_bytes: 3788
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;
template<typename T> using VP = vector<pair<T, T>>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = INT64_MAX >> 1;
const int INF = INT_MAX >> 1;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

signed main()
{
	string T;
	cin >> T;
	RBF(t, T) {
		if (t == '?') {
			t = 'D';
		}
	}
	col(T);
	return 0;
}


Measured memory_bytes: 3788
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a,b,c,s=0,s1=0,s2=0,s3=0,q;
	while(cin>>a>>b>>c)
	{
		if(a<b)
		{
			q=a;a=b;b=q;
		}
		if(a<c)
		{
			q=a;a=c;c=q;
		}
		if(a>=b+c)break;
		else
		{
			s++;
			if((a*a)==(b*b)+(c*c))s1++;
			else if((a*a)<(b*b)+(c*c))s2++;
			else if((a*a)>(b*b)+(c*c))s3++;
		}
	}
	cout<<s<<" "<<s1<<" "<<s2<<" "<<s3<<endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, k, l, p, q, r, s;
pii pr[200000];

// ゴミみたいな実装
//----------------↓UnionFind↓----------------

int para[200000], ranka[200000];
int parb[200000], rankb[200000];

void init(int n) {
	for (int i=0; i<n; i++) {
		para[i] = parb[i] = i;
		ranka[i] = rankb[i] = 0;
	}
}

int finda(int x) {
	if (para[x]==x) return x;
	else return para[x] = finda(para[x]);
}

int findb(int x) {
	if (parb[x]==x) return x;
	else return parb[x] = findb(parb[x]);
}

void unitea(int x, int y) {
	x = finda(x);
	y = finda(y);
	if (x==y) return;
	
	if (ranka[x]<ranka[y]) para[x] = y;
	else {
		para[y] = x;
		if (ranka[x]==ranka[y]) ranka[x]++;
	}
}

void uniteb(int x, int y) {
	x = findb(x);
	y = findb(y);
	if (x==y) return;
	
	if (rankb[x]<rankb[y]) parb[x] = y;
	else {
		parb[y] = x;
		if (rankb[x]==rankb[y]) rankb[x]++;
	}
}

bool samea(int x, int y) {
	return finda(x) == finda(y);
}

bool sameb(int x, int y) {
	return findb(x) == findb(y);
}

//----------------↑UnionFind↑----------------

int main() {
	cin >> n >> k >> l;
	init(n);
	rep(i,k) {
		cin >> p >> q;
		unitea(p-1, q-1);
	}
	rep(i,l) {
		cin >> r >> s;
		uniteb(r-1, s-1);
	}
	
	rep(i,n) pr[i] = mp(finda(i), findb(i));
	sort(pr, pr+n);
	rep(i,n) {
		pii sa = mp(finda(i), findb(i));
		cout << upper_bound(pr, pr+n, sa) - lower_bound(pr, pr+n, sa) << (i==n-1 ? '\n' : ' ');
	}
}

Measured memory_bytes: 5376
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String S = sc.next();
        String[] s = S.split("");
        int[] e = new int[N];
        int[] w = new int[N];
        int esum = 0;
        int wsum = 0;
        
        if(s[0].equals("W")) {
            w[0] = 1;
            wsum++;
        }else {
            e[0] = 1;
            esum++;
        }
        
        for(int i=1; i<N; i++) {
            if(s[i].equals("W")) {
                w[i] = w[i-1]+1;
                e[i] = e[i-1];
                wsum++;
            }else {
                e[i] = e[i-1]+1;
                w[i] = w[i-1];
                esum++;
            }
        }
        
        int[] count = new int[N];
        count[0] = esum-e[0];
        for(int i=1; i<N; i++) {
            count[i] = w[i-1] + (esum - e[i]);
        }
        Arrays.sort(count);
        System.out.println(count[0]);
    }
}


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

int main(){
  int n,k;
  cin>>n>>k;
  int a[n+1];
  for(int i=1;i<=n;i++)  cin>>a[i];
  int dp[n+1];
  dp[1] = 0;
  for(int i=2;i<=n;i++){
    int j = i-1;
    dp[i] = INT_MAX;
    while(j>=1 && j>=i-k){
      dp[i] = min((abs(a[i]-a[j])+dp[j]),dp[i]);
      j--;
    }
  }
  cout<<dp[n]<<endl;
}


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

string s;
string::const_iterator it;

int memo[3] = {0};

int solve();
int calc();
int fact();
int num();
void consume(char x, char y);

int main() {
  while(1) {
    cin >> s;
    if(s == ".") break;
    cout << solve() << endl;
  }
  return 0;
}

int solve() {
  int ans = 0;
  for(int i = 0; i < 3; ++i)
    for(int j = 0; j < 3; ++j)
      for(int k = 0; k < 3; ++k) {
        memo[0] = i;
        memo[1] = j;
        memo[2] = k;
        it = s.begin();
        if(fact() == 2) ++ans;
      }
  return ans;
}

int calc() {
  int ans = fact();
  while(it != s.end()) {
    int now = 0;
    bool option = 0;
    if(*it == '+')
      option = 1;
    else if(*it == '*')
      option = 0;
    else
      break;
    ++it;
    now = fact();
    if(option) {
      if(now == 2 || ans == 2)
        ans = 2;
      else
        ans = (now + ans) > 0;
    }
    else {
      if(now == 0 || ans == 0)
        ans = 0;
      else
        ans = 1 + (now * ans == 4);
    }
  }
  return ans;
}

int fact() {
  int ans = 0;
  if(*it == '(') {
    ++it;
    ans = calc();
    ++it;
  }
  else if(*it == '-') {
    ++it;
    ans = 2 - fact();
  }
  else
    ans = num();
  return ans;
}

int num() {
  int ans = 0;
  if(isdigit(*it))
    ans = *it - '0';
  else
    ans = memo[*it - 'P'];
  ++it;
  return ans;
}

void consume(char x, char y) {
  if(*it >= x && *it <= y)
    ++it;
  else {
    cerr << "error" << endl;
    cerr << *it << " " << x << " " << y << endl;
    while(it != s.end()) cerr << *it++;
    cerr << endl;
  }
}


Measured memory_bytes: 3192
def main():
    N = int(input())
    x = []
    ans = 0
    for i in range(N):
        x.append(list(map(str, input().split(' '))))
    for i in range(N):
        if x[i][1] == 'BTC':
            ans = ans + (float(x[i][0])*380000)
        else:
            ans += float(x[i][0])
    print(ans)
main()



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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N;
vector<ll> B;

signed main()
{
    cin >> N;
    B.resize(N);
    REP(i, N) { cin >> B[i]; }

    vector<ll> ans;
    REP(i, N) {
        bool isFind = false;
        for(int j = B.size() - 1; j >= 0; --j) {
            if(j + 1 == B[j]) {
                ans.push_back(B[j]);
                B.erase(B.begin() + j);
                isFind = true;
                break;
            }
        }
        if(!isFind) {
            printf("-1\n");
            return 0;
        }
    }
    reverse(ans.begin(), ans.end());
    REP(i, N) {
        printf("%lld\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 256
import scala.collection.mutable
import scala.io.StdIn._

object Main extends App {
  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val edges = Array.tabulate(m){_ ⇒
    val Array(a, b, c, d) = readLine.trim.split(' ').map(_.toInt)
    Edge(a, b, c, d)
  }
  if (m == n - 1) {
    println(0.0)
  }else {
    var min = 0.0
    var max = Double.MaxValue / 2
    while (min + 0.000000001 < max) {
      val mid = (min + max) / 2
      if (canMake(edges, mid)) max = mid
      else min = mid
    }
    println("%.10f".format(min))
  }
  def canMake(edges: Array[Edge], target: Double): Boolean = {
    if (edges.length == n - 1) true
    else {
      val union = new UnionFind(n)
      var unuseLength = 0.0
      var unuseJob = 0.0
      for (Edge(a, b, c, d) ← edges.sortBy(e ⇒ e.d - e.c * target)(Ordering.Double.reverse)) {
        if (union.isSame(a, b)) {
          unuseLength += c
          unuseJob += d
        }else {
          union.merge(a, b)
        }
      }
      (unuseJob / unuseLength) <= target
    }
  }
}
case class Edge(a: Int, b: Int, c: Int, d: Int)
class UnionFind(val size: Int) {
  private val parent = Array.fill(size){-1}
  def find(a: Int): Int = {
    if (parent(a) >= 0) {
      parent(a) = find(parent(a))
      parent(a)
    }else a
  }
  def isSame(a: Int, b: Int): Boolean = find(a) == find(b)
  def merge(a: Int, b: Int): Unit = {
    val ar = find(a)
    val br = find(b)
    if (ar != br) {
      if (parent(ar) < parent(br)) {
        parent(ar) += parent(br)
        parent(br) = ar
      }else {
        parent(br) += parent(ar)
        parent(ar) = br
      }
    }
  }
}


Measured memory_bytes: 238488
#include <stdio.h>
#include <limits.h>

void mergeSort(int *, int, int);
void merge(int *, int, int, int);

int count = 0;

int main(){
  int S[500000], n, i;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d", &S[i]);

  mergeSort(S, 0, n);

  for(i=0; i<n-1; i++) printf("%d ", S[i]);
  printf("%d\n%d\n", S[i], count);
  
  return 0;
}

void mergeSort(int *A, int left, int right){
  int mid;
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

void merge(int *A, int left, int mid, int right){
  int n1, n2, L[250001], R[250001], i, j, k;

  n1 = mid - left;
  n2 = right - mid;

  for(i=0; i<n1; i++) L[i] = A[left + i];
  for(i=0; i<n2; i++) R[i] = A[mid + i];
  L[n1] = 1000000001;
  R[n2] = 1000000001;
  i = 0;
  j = 0;

  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
    count++;
  }
}

Measured memory_bytes: 4504