akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#include <string> 
using namespace std;
const int N = 1000000;
int n, a[N];
void heapify(int i){
	int l = 2 * i + 1, r = l + 1;
	int pv = i;
	if(l < n && a[l] > a[pv]) pv = l;
	if(r < n && a[r] > a[pv]) pv = r;
	if(i != pv){
		swap(a[i], a[pv]);
		heapify(pv);
	}
}
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = n / 2 - 1; i >= 0; i--){
		heapify(i);
	}
	for(int i = 0; i < n; i++) cout << " " << a[i];
	cout << endl;
}
int main(void){
	solve();
	return 0;
}


Measured memory_bytes: 5052
#include <iostream>
int main()  {
  long long n, a, b;
  std::cin >> n >> a >> b;
  if ((b - a) % 2 == 0) {
    std::cout << (b - a) / 2;
  }
  else {
    std::cout << std::min(a, n - b + 1) + (b - a - 1) / 2;
  }
}

Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)1e9+7;
//}}}

ll modpow(ll a, ll b){
  if(b == 0) return 1;
  if(b % 2){
    return a * modpow(a, b - 1) % MOD;
  }else{
    ll half = b / 2;
    half = modpow(a, half);
    return half * half % MOD;
  }
}

ll modfact(ll n){
  ll res = 1;
  rep(i, n) res = res * (i + 1) % MOD;
  return res;
}

ll modcomb(ll n, ll r){
  ll res = 1;
  rep(i, r) res = res * (n - i) % MOD;
  return res * modpow(modfact(r), MOD - 2) % MOD;
}

ll modh(ll n, ll r){
  return modcomb(n + r - 1, r - 1);
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> v;
  ll ans = 1;
  rep(n, 2, 100000){
    if(M == 1) break;
    int num = 0;
    while(M % n == 0){
      M /= n;
      num++;
    }
    if(num){
      ans *= modh(num, N);
      ans %= MOD;
    }
  }
  if(M != 1){
    ans *= N;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,k;
  while(cin>>n>>k){
    if(n==0&&k==0) break;
    int s[n],ans=0,su=0;
    for(int i=0;i<n;i++) cin >> s[i];
    for(int i=0;i<k;i++) su += s[i];
    ans = su; 
    for(int i=k;i<n;i++){
      su += (s[i] - s[i-k]);
      if(ans<su) ans = su;
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

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

    int n, r;

    cin >> n >> r;

    if(n >= 10){
        cout << r << endl;
    }
    else{
        cout << r + 100*(10-n) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int main()
{
	long long  a,c;
	char b;
	scanf("%lld %c %lld",&a,&b,&c);
	if(b == '+')
	printf("%lld",a+c);
	else
	printf("%lld",a-c);
return 0;	
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=2*1e3+2;
vector<int> a[N];
int ans[N];
int d[N];
bool vis[N];
void bfs(int x)
{
	for(int i=0;i<N;i++) d[i]=0,vis[i]=false;
	queue<int> q;
	q.push(x);
	vis[x]=true;
	d[x]=0;
	while(q.size())
	{
		int o=q.front();
		q.pop();
		for(auto y:a[o])
		{
			if(!vis[y])
			{
				q.push(y);
				d[y]=d[o]+1;
				vis[y]=true;
			}
		}
	}
	for(int i=1;i<N;i++)
	{
		ans[d[i]]++;
	}
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	// freopen("out10.txt","w",stdout);
	#endif
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=1;i<n;i++)
	{
		a[i].pb(i+1);
		a[i+1].pb(i);
	}
	a[x].pb(y);
	a[y].pb(x);
	for(int i=1;i<=n;i++)
	{
		bfs(i);
	}
	for(int i=1;i<n;i++)
	{
		cout<<ans[i]/2<<"\n";
	}
}
// Don't be afraid to fail. Be afraid not to try.
// "Become grindian instead of greendian" - aryanc403
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <numeric>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> W(N);
  for(int i = 0; i < N; i++) cin >> W[i];
  int T[N-1];
  int sum = accumulate(W.begin(), W.end(), 0);
  T[0] = sum - 2 * W[0];
  for(int i = 1; i < N-1; i++){
    T[i] = T[i-1] - 2 * W[i];
  }
  int minT = abs(T[0]);
  for(int i = 0; i < N-1; i++){
    minT = min(minT, abs(T[i]));
  }
  cout << minT << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n, x;
  cin >> n >> x;
  vecll a(n, 0);
  REPe(e, a) cin >> e;
  ll ans = 0;
  REP(i, n - 1) {
    if (a[i] + a[i + 1] <= x) continue;
    ll k = a[i] + a[i + 1] - x;
    ans += k;
    if (a[i + 1] >= k) {
      a[i + 1] -= k;
    } else {
      a[i + 1] = 0;
      a[i] -= k - a[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long int  //comment for large arrays
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define INF 10000000000000001
#define all(x) (x).begin(),(x).end()
#define LB(v,x) (lower_bound(all(v),x) - v.begin()) 
#define UB(v,x) (upper_bound(all(v),x) - v.begin())
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vec(dt) vector<dt>
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v)) 
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || click to see test details "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(int i=s;i<n;i++)
#define print(v) for(auto it:v) cout<<it<<" "; cout<<endl 
using namespace std;




signed main()
{
	fastio(0);
	string s;
	cin>>s;
	int d;
	cin>>d;
	vec(int) v;
	v.pb(0);
	reverse(all(s));
	for(auto it:s) v.pb(it - '0');
	
	int dp[size(v)][d][2]; // dp[idx, sum%d, tight]
	init(dp,0);
	loop(i,0,10) dp[1][i%d][0] += 1;
	loop(i,0,v[1]+1) dp[1][i%d][1] += 1;

	loop(n,2,size(v))
	{
		loop(sum,0,d)
		{
			loop(i,0,10) dp[n][sum][0] = (dp[n][sum][0] + dp[n-1][(sum-i+ 10*d)%d][0])%mod;
			loop(i,0,v[n]+1) 
				if(i<v[n]) dp[n][sum][1] = (dp[n][sum][1] + dp[n-1][(sum-i+ 10*d)%d][0])%mod;
				else  dp[n][sum][1] = (dp[n][sum][1] + dp[n-1][(sum-i+ 10*d)%d][1])%mod;
		}
	}

	cout<<(dp[size(s)][0][1] - 1 + mod)%mod<<endl; // -1 to remove no. 000000000

	return 0;		
}


Measured memory_bytes: 16128
//Water Bottle
#include <iostream>
#include <math.h>
#include <iomanip>
#define pi 3.14159265358
using namespace std;
int main () {
	double a, b, x, y;		cin >> a >> b >> x;
	double v =  a * a * b / 2;
	if (v >= x) {
		y = (2 * x) / (a * b);
		std::cout << std::setprecision (20) << atan (b / y) * 180 / pi << endl;
	}
	if (v < x) {
		y = 2 * (b - (x / (a * a)));
		std::cout << std::setprecision (20) << atan (y / a) * 180 / pi << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    std::string s;
    std::cin >> s;
    for (int i = 0; i < s.size(); i += 2) { std::cout << s[i]; }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;

int main(){
	string s;
	cin >> s;
	for(int i = 1;i <= s.size();i++) printf("x");
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int d = n;
    if(n % 2 == 0){
        d++;
    }
    vector<P> vec;
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(i + j != d){
                vec.push_back(P(i, j));
            }
        }
    }
    cout << vec.size() << endl;
    REP(i,vec.size()){
        cout << vec[i].first << " " << vec[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 384
/**
 *   author:  prakhar17252
 *   created: 27.04.2019 18:26:26
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
#define int ll

#define pb emplace_back
#define push emplace
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define len(a) (int) a.size()
#define reset(a, val) memset(a, val, sizeof(a))
#define endl '\n'
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

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

const ll mod = (int) 1e9 + 7;
const ll inf = (ll) 2e18;
const ll ninf = (ll) -2e18;

ll power(ll x, ll y, ll mod = inf) {
    if (y == 0) return 1LL;
    if (y % 2) return ((x % mod) * power(x, y - 1, mod)) % mod;
    return power((x * x) % mod, y / 2, mod);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    time_t t1, t2;
    t1 = clock();

    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    //     freopen("error.txt", "w", stderr);
    // #endif

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

    cout << b * (t / a) << '\n';


    t2 = clock();
    #ifndef ONLINE_JUDGE
        cerr << endl << "time taken: " << (ld) (t2 - t1) / CLOCKS_PER_SEC << endl;
    #endif // ONLINE_JUDGE

    return 0;
}

Measured memory_bytes: 256
// 2020-07-24 01:34:17
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n;
  cin >> n;
  vector<vector<int> > a(n, vector<int>(n-1, -1));
  rep(i, n) {
    rep(j, n-1) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  ll ans = 0;
  vector<int> c(n, 0);
  while(1) {
    ans++;
    vector<int> m(n, 0);
    bool matched = false;
    rep(i, n) {
      if(m[i] || c[i] == n-1) continue;
      int b = a[i][c[i]];
      if(m[b] || c[b] == n-1) continue;
      if(a[b][c[b]] == i) {
        matched = true;
        m[i] = m[b] = true;
        c[i]++;
        c[b]++;
      }
    }
    if(!matched) {
      cout << -1 << '\n';
      return;
    }
    bool done = true;
    rep(i, n) {
      done &= (c[i] == n-1);
    }
    if(done) break;
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

int main(){
	int x,y;
	while(1){
		cin >> x >> y;
		if(!x) break;
		int dp[17][15] = {},field[17][15] = {};
		for(int i = 1;i <= y;i++){
			for(int j = 0;j < x;j++) cin >> field[i][j];
		}
		for(int i = 0;i < x;i++) dp[0][i] = 1;
		for(int i = 0;i <= y;i++){
			for(int j = 0;j < x;j++){
				if(field[i][j] == 1) continue;
				if(i == 0){
					if(field[i + 1][j] != 1) dp[i + 1][j] = dp[i][j];
				}
				else if(field[i][j] == 0){
					if(i != y){
						if(j >= 1 && field[i + 1][j - 1] == 0) dp[i + 1][j - 1] += dp[i][j];
						if(j <= x - 2 && field[i + 1][j + 1] == 0) dp[i + 1][j + 1] += dp[i][j];
					}
					if(field[i + 1][j] != 1) dp[i + 1][j] += dp[i][j];
				}else{
					if(field[min(i + 2,y + 1)][j] != 1) dp[min(i + 2,y + 1)][j] += dp[i][j];
				}
			}
		}
		int cnt = 0;
		for(int i = 0;i < x;i++) cnt += dp[y + 1][i];
		cout << cnt << endl;
	}
	return 0;
}

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

int main(){
  int i,n,m,ss[100]={};
  cin >> n;
  string s[100];
  for(i=0;i<n;i++){
    cin >> s[i];
    //int flag=0;
    for(int j=0;j<=i;j++){
      if(s[i]==s[j]){
        //cout << "sdf" <<endl;
        ss[j]++;
        //flag=1;
        break;
      }
    }
    //cout<< ss[i]<<endl;
    //if(flag==0)ss[i]++;
    //cout<< ss[i]<<endl;
  }
  cin >> m;
  for(i=0;i<m;i++){
    string t;
    cin >> t;
    for(int j=0;j<n;j++){
      if(t==s[j]){
        ss[j]--;
        break;
      }
    }
  }
  int ans=0;
  for(i=0;i<n;i++){
    if(ans<ss[i]) ans=ss[i];
  }
  if(ans<0) printf("0");
  else printf("%d",ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 2e5 + 5 ; 
const int inf = 1e9 + 7 ;
int n, m, cnt, num, dp[40], Pre[N] ; 
struct Node {
	int a, b ; 
} t[N], p[N], r[N] ;
bool cmp( Node x, Node y ) {
	return x.b < y.b ; 
} 
bool cmp2( Node x, Node y ) {
	return ( 1ll * x.b * y.a + y.a ) < ( 1ll * y.b * x.a + x.a ) ;
}
int check( int x ) {
	int l = 0, r = num, ans = 0 ; 
	while( l <= r ) {
		int mid = ( l + r ) >> 1 ; 
		if( Pre[mid] <= x ) ans = mid, l = mid + 1 ;
		else r = mid - 1 ;
	} return ans ; 
}
signed main()
{
	n = gi(), m = gi() ;
	rep( i, 1, n ) {
		t[i].a = gi(), t[i].b = gi() ; 
		if( t[i].a != 0 ) p[++ cnt] = t[i] ; 
		if( t[i].a == 0 ) r[++ num] = t[i] ; 
	}
	rep( j, 0, 32 ) dp[j] = m + 1 ; 
	sort( p + 1, p + cnt + 1, cmp2 ) ;
	sort( r + 1, r + num + 1, cmp ) ;
	dp[0] = 0 ; 
	for( re int i = 1; i <= cnt; ++ i ) {
		for( re int j = 32; j > 0; -- j ) {
			if( dp[j - 1] > m ) continue ; 	
			if( p[i].a * dp[j - 1] > m ) continue ; 
			dp[j] = min( ( dp[j - 1] + 1 ) * ( p[i].a + 1 ) + p[i].b, dp[j] ) ;
		}
	}
	for( re int i = 1; i <= num; ++ i ) Pre[i] = Pre[i - 1] + r[i].b + 1 ; 
	int Ans = 0 ;
	for( re int i = 0; i <= 32; ++ i ) {
		int ans = i, T = dp[i] ;
		if( T > m ) continue ; 
		ans = ans + check( m - dp[i] ) ;
		Ans = max( Ans, ans ) ;
	}
	printf("%lld\n", Ans ) ;
	return 0 ;
}

Measured memory_bytes: 9984
N = int(input())
A = [0] * N
XY = []

for i in range(N):
    tmp = []
    a = int(input())
    A[i] = a
    for j in range(a):
        tmp.append(list(map(int, input().split())))
    XY.append(tmp)

def counter(x):
    if x == 0:
        return 0
    else:
        return counter(x >> 1) + (x & 1)

ans = 0
for bits in range(1, 1 << N):
    ok = True
    for i in range(N):
        if not (bits & (1 << i)):
            continue
            
        for x, y in XY[i]:
            if ((bits >> (x - 1)) & 1) ^ y:
                ok = False
                
    if ok:
        ans = max(ans, counter(bits))
            
print(ans)


Measured memory_bytes: 50672
import sys

def check(r,g,b):
    return r<g and g<b

r,g,b=input().split()
r,g,b=int(r),int(g),int(b)

K=int(input())+1

#print(r,g,b,K)

for i in range(K):
    for j in range(K-i):
        for k in range(K-i-j):
            if check(r*2**(i),g*2**(j),b*2**(k)):
                print("Yes")
                sys.exit(0)
print("No")

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

const int MX = 1e6+10;
LL acc[MX];
LL ones[MX];
LL twos[MX];

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

  int N;
  cin >> N;
  VI xs(N+10, -1);
  REP(i,N){
    char c;
    cin >> c;
    if(c == 'D') xs[i] = 0;
    else if(c == 'M') xs[i] = 1;
    else if(c == 'C') xs[i] = 2;
  }

  REP(i,N+1){
    acc[i+1] = acc[i];
    ones[i+1] = ones[i];
    twos[i+1] = twos[i];
    if(xs[i] == 0){
    }
    else if(xs[i] == 1){
      ones[i+1]++;
    }
    else if(xs[i] == 2){
      twos[i+1]++;
      acc[i+1] += ones[i];
    }
  }

  int Q;
  cin >> Q;
  VI qs(Q);
  cin >> qs;

  for(int q: qs){
    LL ans = 0;
    for(int i=0;i<N;++i){
      if(xs[i] == 0){
        int r = min(N,i+q);
        ans += acc[r] - acc[i] - (twos[r] - twos[i]) * ones[i];
      }
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 27648
n = int(input())
l = []
for i in range(n):
    l.append(list(map(int,input().split())))

nums = [0,1,2]
dp = [[0]*3 for _ in range(n)]

# print(dp)
dp[0] = l[0]

for i in range(1,n):
    for jnow in range(3):
        for jpre in nums:
            if jpre != jnow:
                dp[i][jnow] = max(dp[i][jnow],dp[i-1][jpre]+l[i][jnow])
print(max(dp[n-1]))

Measured memory_bytes: 105008
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

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

  int32_t N;
  cin >> N;
  int32_t result = 1;
  int32_t p = 1;
  for (int32_t i = 0; i < 100; ++i) {
    if (p <= N) {
      result = p;
    } else {
      break;
    }
    p = p* 2;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> vec(H,vector<char>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  
  vector<int> dx = {0,1,0,-1};
  vector<int> dy = {1,0,-1,0};

  int ans = 0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){//始点の決定
      if(vec.at(i).at(j) == '#'){
        continue;
      }
      vector<vector<int>> dist(H,vector<int>(W));
      int INF = 100000;
      int ans_max = 0;
      for(int k=0; k<H; k++){
        for(int l=0; l<W; l++){
          dist.at(k).at(l) = INF;
        }
      }
      dist.at(i).at(j) = 0;
      pair<int,int> P;
      queue<pair<int,int>> Q;
      P = make_pair(i,j);
      Q.push(P);
      while(Q.size()){
        P = Q.front();
        Q.pop();
        for(int n=0; n<4; n++){
          int nx = P.first + dx.at(n); 
          int ny = P.second + dy.at(n);
          if(nx >= 0 && nx < H && ny >= 0 && ny < W){
            if(vec.at(nx).at(ny) != '#' && dist.at(nx).at(ny) == INF){
             dist.at(nx).at(ny) = dist.at(P.first).at(P.second) + 1;
             ans_max = max(ans_max,dist.at(nx).at(ny));
             pair<int,int> p = make_pair(nx,ny);
             Q.push(p);
            }
          }
        }
      }
      ans = max(ans_max,ans);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	char a;
	
	cin >> a;

	if (a == 'A')
	{
		cout << 'T' << endl;
	}
	else if (a == 'T')
	{
		cout << 'A' << endl;
	}
	else if(a == 'G')
	{
		cout << 'C' << endl;
	}
	else if (a == 'C')
	{
		cout << 'G' << endl;
	}

	
	return 0;
}


Measured memory_bytes: 256
//Robs Code
/***********HEADER***************/
#include<bits/stdc++.h>
/***********MACROS***************/
#define ll long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 10000007
#define mxval 1e9
#define grt [](auto x,auto y){return x>y;}
#define pii pair<ll,ll>
/*********VARIABLE****************/
using namespace std;
ll i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/***********MAIN******************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>k;
    string s;
    cin>>s;
    vector<ll> v(n+1);
    v[0]=0;
    for(i=0;i<n;i++){
        if(s[i]=='A'&&s[i+1]=='C'){
            v[i+1]=1;
        }
    }
    for(i=1;i<=n;i++)
        v[i]+=v[i-1];
    while(k--){
        cin>>i>>j;
        if(s[j-1]=='A'&&s[j]=='C'){
            cout<<(v[j]-v[i-1]-1)<<endl;
        }else cout<<(v[j]-v[i-1])<<endl;
    }
    return 0;
}
//.........

Measured memory_bytes: 1872
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
#define N 100010
map<int,int> odd;
map<int,int> even;
struct node
{
    int num;
    int per;
    node(int i1,int i2)
    {
        num=i1;
        per=i2;
    }
};
vector<node> Vo;
vector<node> Ve;
bool cmp(node &n1,node &n2)
{
    return n1.per>n2.per;
}
int n;
int v[N];
int main()
{   
    ios::sync_with_stdio(false);
    while(cin>>n)
    {
        odd.clear();
        even.clear();
        Vo.clear();
        Ve.clear();
        for(int i=1;i<=n;i++) 
        {
            cin>>v[i];
            if(i%2==0) even[v[i]]++;
            else odd[v[i]]++;
        }
        map<int,int>::iterator it;
        for(it=odd.begin();it!=odd.end();it++)
        {
            Vo.push_back(node(it->first,it->second));
        }
        for(it=even.begin();it!=even.end();it++)
        {
            Ve.push_back(node(it->first,it->second));
        }
        sort(Vo.begin(),Vo.end(),cmp);
        sort(Ve.begin(),Ve.end(),cmp);
        
        int opos=0;
        int epos=0;
        //cout<<"odd:"<<Vo[0].num<<" "<<Vo[0].per<<endl;
        //cout<<"even:"<<Ve[0].num<<" "<<Ve[0].per<<endl;
        if(Vo[0].num==Ve[0].num)
        {
            if(Vo[0].per>Ve[0].per)
            {
                epos++;
            }
            else if(Vo[0].per<Ve[0].per) opos++;
            else
            {
                if(Vo[1].per>Ve[1].per) opos=1;
                else epos=1;
            }
        }
        if(epos<Ve.size()&&opos<Vo.size()) cout<<n-Vo[opos].per-Ve[epos].per<<endl;
        else
        {
            cout<<n/2<<endl;
        }
    }
}

Measured memory_bytes: 6524
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	
		String s = sc.next();
	int number = 700;	
      // スペース区切りの整数の入力
		int flag = 0;
      for(int i=0;i<3;i++){
      if(s.charAt(i)=='o'){
        number=number+100;
      }}
		// 出力
    
		System.out.println(number);
	
      }
}

Measured memory_bytes: 21716
//============================================================================
// Name        : abc75c.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
int N, M;

void dfs(vector<vector<int>> &A, int node, map<int, int> &mp) {
	mp[node] = 1;

	for (int i = 0; i < N; ++i) {
		if(mp[i] == 1) continue;
		if(A[node][i] == 0)continue;
		dfs(A, i, mp);
	}
}

int main() {

	cin >> N >> M;

	vector<vector<int>> node(N);
	for(int i = 0; i < N; ++i){
		node[i].resize(N);
	}

	vector<int> a(M);
	vector<int> b(M);

	for (int i = 0; i < M; ++i) {
		cin >> a[i] >> b[i];
		--a[i];--b[i];
		node[a[i]][b[i]] = 1;
		node[b[i]][a[i]] = 1;
	}

	int count = 0;

	for(int i = 0; i < M; ++i){
		node[a[i]][b[i]] = node[b[i]][a[i]] = 0;
		map<int, int> mp;


		dfs(node, 0, mp);
		node[a[i]][b[i]] = node[b[i]][a[i]] = 1;

		for(int k = 0; k < N; ++k){
			if(mp[k] == 0){
				++count;
				break;
			}
		}
	}

	cout << count << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,d;
	cin >> n >> d;
	vector<vector<int>>x(n,vector<int>(d));
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++)
			cin >> x[i][j];
	}
	int c = 0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int s = 0;
			for(int k=0;k<d;k++)
				s+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			if((int)sqrt(s)*(int)sqrt(s) == s)
				c++;
		}
	}
	cout << c <<endl;	
}


Measured memory_bytes: 256
# AOJ 0004 Simultaneous Equation
# Python3 2018.6.9 bal4u

EPS = 0.0001
while True:
	try:
		a = list(map(float, input().split()))
		dd = a[0]*a[4]-a[3]*a[1]
		d1 = a[2]*a[4]-a[5]*a[1]
		d2 = a[0]*a[5]-a[3]*a[2]
		print("{0:.3f} {1:.3f}".format(d1/dd+EPS, d2/dd+EPS))
	except EOFError:
		break


Measured memory_bytes: 5584
n,m=map(int,input().split())
a={int(input()) for i in range(m)}

dp=[0]*(n+1)
dp[0]=1
if 1 in a:
      dp[1]=0
else:
      dp[1]=1

for i in range(2,len(dp)):
      if i in a:
            continue
      dp[i]=(dp[i-2]+dp[i-1])
      
print(dp[-1]%(10**9+7))


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

int main()
{
    int n;
    string a, b;

    cin >> n;
    
    int pa = 0, pb = 0;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        if (a > b) pa += 3;
        else if (a < b) pb += 3;
        else pa++, pb++;
    }
    cout << pa << " " << pb << endl;

    return 0;
}

Measured memory_bytes: 3180
#include<iostream>
#include<algorithm>
using namespace std;
int n,s,k,a[5001],dp[5001],vis=1;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]=min(a[i],k);
		s+=a[i];
		}
	sort(a+1,a+n+1);
	dp[0]=1;
	for(int i=n;i>=0;i--)
	{
		vis=1;
		for(int j=k-1;j>=k-s and j>=0;j--)
		{
			if(dp[j])vis=0;
			}
		if(vis)
		{
			cout<<i;
			break;
			}
		for(int j=k;j>=a[i];j--)
		{
			dp[j]|=dp[j-a[i]];
			}
		s-=a[i];
		}
	return 0;
	}

Measured memory_bytes: 256
/*
Anki:未済
作成日:
*/

#include <stdio.h>

int main()
{
    char a, b, c;

    scanf( "%c%c%c", &a, &b, &c );
    if( a == 'A' && b == 'B') printf( "Yes\n" );
    else if (a == 'B' && b == 'A') printf("Yes\n");
    else if (b == 'A' && c == 'B') printf("Yes\n");
    else if (b == 'B' && c == 'A') printf("Yes\n");
    else printf( "No\n" );
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

#define mk make_pair
#define pb push_back
#define sc(t) scanf("%d",&t)
#define sc3(t,u,v) scanf("%d %d %d",&t,&u,&v)
#define sc2(t,u) scanf("%d %d",&t,&u)
#define scL(t) scanf("%lld",&t)
#define scL3(t,u,v) scanf("%lld %lld %lld",&t,&u,&v)
#define scL2(t,u) scanf("%lld %lld",&t,&u)
#define mem(a,i) memset(a,i,sizeof a)
#define pcase(x,y) printf("Case %d: %d\n",x,y)
#define pcase2(x) printf("Case #%d:\n",x)
#define inf 1e18
#define sett(n) (mark[n>>5] |= (1<<(n&31)))
#define check(n) (mark[n>>5]&(1<<(n&31)))
#define endd printf("\n")

int main()
{
    int n,u,k,v,w,cas=1;
    sc2(n,k);
    for(int i=0;i<n;i++){
        sc(u);
    }
    int cnt = 1;
    n-=k;
    cnt+=ceil((double)n/(k-1));
    cout << cnt << endl;
    return 0;
}


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

int main()
{
    int i,j,res,d,m = 0x3f3f3f3f;
    int min[10010];
    char str[13];
    gets(str);
    d=strlen(str);

    for(i=0; i<d-2; i++)
    {
        res=(str[i]-'0')*100+(str[i+1]-'0')*10+(str[i+2]-'0');

        min[i] = abs(753-res);

    }
    for (i=0; i<d-2; i++)
    {
        if(m > min[i])
            m = min[i];
    }

    printf("%d",m);

    return 0;
}

Measured memory_bytes: 1556
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i <= i##_len; ++i)
#define rep3(i, l, r) for (int i = l, i##_len = (r); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = l, i##_len = (r); i <= i##_len; ++i)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef int64_t Int;
typedef long double Ld;

using namespace std;
template <class T>
using Graph = vector<vector<T>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 62;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

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

template <typename T>
inline T Gcd(T a, T b) {
    T c;
    while (b) {
        c = b;
        b = a % b;
        a = c;
    }
    return a;
}

Int Lcm(Int a, Int b) {
    if (a < b) {
        swap(a, b);
    }

    return a / Gcd(a, b) * b;
}

// 二分累乗法
template <typename T>
T modpow(T a, T n, T mod) {
    T ret = 1;

    if (mod == 1) {
        while (n > 0) {
            if (n & 1) {
                ret = ret * a;
            }
            a = a * a;
            n >>= 1;
        }
    } else {
        while (n > 0) {
            if (n & 1) {
                ret = ret * a % mod;
            }
            a = a * a % mod;
            n >>= 1;
        }
    }

    return ret;
}

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

    Int n;
    cin >> n;

    bool a = false, b = false, ans = false;
    for (Int i = 0; i < n; i++) {
        int da, db;
        cin >> da >> db;

        if (da == db) {
            if (a) {
                if (b) {
                    ans = true;
                    break;
                } else {
                    b = true;
                }
            } else {
                a = true;
            }
        } else {
            a = false;
            b = false;
            ans = false;
        }
    }

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

    return 0;
}


Measured memory_bytes: 3628
N, T = map(int, input().split(" "))
ans = (10000,-1)
for i in range(0,N):
    c, t = map(int, input().split(" "))
    if t <= T and ans[0] > c:
        ans = (c,t)

print(ans[0] if not ans[1] == -1 else "TLE")


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main()
{
	int x1, y1, x2, y2, x3, y3, x4, y4;

	cin >> x1;
	cin >> y1;


	cin >> x2;
	cin >> y2;



	x3 = x2 - (y2 - y1);
	y3 = y2 + (x2 - x1);

	x4 = x1 - (y2 - y1);
	y4 = y1 + (x2 - x1);

	cout << x3 <<" "<< y3<<" "<<x4 << " " << y4;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(1<=a&&a<=9&&1<=b&&b<=9){
    cout<<a*b<<endl;
    return 0;
  }
  cout<<-1<<endl;
  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;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;

int main(){
    int l;
    cin >> l;
    double a = l / 3.0, ans;
    ans = pow(a,3);
    printf("%.12f\n", ans);
    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int sum=0;
	string s;
	cin>>s;
	for(auto i:s)
	{
		sum+=(i-'0');
	}
	
	if(sum%9==0)cout<<"Yes";
	else cout<<"No";
	
	
}

Measured memory_bytes: 3720
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int N;
	cin>>N;
	
	int ans=1;
	while(ans<=N/2){
		ans*=2;
	}
	cout<<ans;
}

Measured memory_bytes: 256
n = int(input())
x, y = 0, 0
for _ in range(n):
  t, xnew, ynew = map(int, input().split())
  dist = abs(x - xnew) + abs(y - ynew)
  if dist > t or (dist - t) % 2 == 1:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3060
while 1:
    a, b, c, d, e = map(int, input().split())
    if a == b == c == d == e == 0:
        break
    na, nb, nc = map(int, input().split())
    if nc >= d:
        print(e * nc + b * nb + a * na)
        continue
    lst = [c] * nc + [b] * nb + [a] * na
    if na + nb + nc > d:
        print(min(sum(lst[:d]), e*d) + sum(lst[d:]))
    else:
        print(min(sum(lst), e*d))


Measured memory_bytes: 11708
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a <= 8 && b <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
long long cnt[20],num[20],n;
int main()
{
	cin>>s;
	n=s.size();
	cnt[0]=0;
	cnt[1]=s[0]-'0';
	num[0]=1;
	num[1]=1;
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<i;j++)
		{
			num[i]+=num[j];
			long long now=0;
			for(int k=j+1;k<=i;k++)
			{
				now=now*10+s[k-1]-'0';
			}
			cnt[i]+=(now*num[j]+cnt[j]);
		}
	}
	cout<<cnt[n]<<endl;
	return 0;
}

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

class Union_Find{
  vector<int> par; vector<int> rank; vector<int> num;
public:
  Union_Find(int n) {
    par = vector<int>(n); rank = vector<int>(n,0); num = vector<int>(n,1);
    rep(i,n) par[i] = i;
  }
  int find(int x) {
    if(par[x] == x) return x;
    else  return par[x] = find(par[x]);
  }
  int number(int x) {
    return num[find(x)];
  }
  void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) rank[x]++;
    par[y] = x;
    num[x] += num[y];
  } 
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main(){
  int n, m;
  cin >> n >> m;
  Union_Find uf(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf.unite(a,b);
  }
  int ans = 0;
  rep(i,n) ans = max(ans,uf.number(i));
  cout << ans << endl;
  return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long  
#define pb push_back

		   //       |----|       /\      |    |   -----   |
		   //       |   /       /  \     |    |     |     |
		   //       |--/       /----\    |----|     |     |
		   //       |   \     /      \   |    |     |     |
		   //       |    \   /        \  |    |   -----   -------

int n;
int r,g,b;
int cache[4][10000];
int dp(int pos,int taken)
{
	if(taken>n)
		return 0;
	if(pos==3)
		return taken==n;
	if(cache[pos][taken]!=-1)
		return cache[pos][taken];
	int ans=0;
	if(pos==0)
	{
		for(int i=0;i<=3002;i++)
			ans+=dp(pos+1,taken+r*i);
	}
	if(pos==1)
	{
		for(int i=0;i<=3002;i++)
			ans+=dp(pos+1,taken+g*i);
	}
	if(pos==2)
	{
		for(int i=0;i<=3002;i++)
			ans+=dp(pos+1,taken+b*i);
	}
	return cache[pos][taken]=ans;
}
int32_t main()
{
	IOS;
	cin>>r>>g>>b>>n;
	memset(cache,-1,sizeof(cache));
	cout<<dp(0,0);
}

Measured memory_bytes: 512
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<queue>
#include<map>

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double db;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mp make_pair
#define case_for(n) for(int i = 1 ; i <= n ; i ++) { cout<<"Case "<<i<<": "<<endl; solve();}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll power(ll a, ll b, ll p) { ll ans = 1; while (b) { if (b & 1) ans = ans * a % p; a = a * a % p, b /= 2; }return ans; }
int hw_check(string a, int l, int r) { int ans = r - l + 1; for (l, r; l < r; l++, r--)if (a[l] != a[r]) return 0; return ans; }
string movesubstr(string a, int l, int r) { string s = "";	for (int i = l; i <= r; i++) s.push_back(a[i]);	return s; }

ull mod = 212370440130137957ll;
int base = 233;
/*ull hashs(string a)
{
	ull ans = 0;
	for (int i = 0; i < a.size(); i++)
	{
		ans = ans * base + a[i];
	}
	return ans;
}*/

int main()
{
	std::ios::sync_with_stdio(false);
	//cin.tie(nullptr),cout.tie(0);
	cin.tie(0);
	string a, b;
	cin >> a >> b;
	for (int i = 0; i < a.size(); i++)
	{
		if (a[i] != b[i])
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}
/*

*/

Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>

const int MAXN = 1e5 + 5;

int n, m, u, v, s, t;
int dp[MAXN][3];

struct node {
    int nv, flag;
    node(int vv = 0, int ff = 0) {
        nv = vv;
        flag = ff;
    }
};

std::vector<int> con[MAXN];
std::queue<node> q;

void ins(int start, int end) {
    con[start].push_back(end);
}

void bfs() {
    dp[s][0] = 0;
    q.push(node(s, 0));
    while (!q.empty()) {
        int nv = q.front().nv, nf = q.front().flag;
        for (int i = 0; i < con[nv].size(); ++i) {
            int tv = con[nv][i];
            if (dp[tv][(nf + 1) % 3] == -1) {
                dp[tv][(nf + 1) % 3] = dp[nv][nf] + 1;
                q.push(node(tv, (nf + 1) % 3));
            }
        }
        q.pop();
    }
}

int main() {
    scanf("%d%d", &n, &m);
    while (m--) {
        scanf("%d%d", &u, &v);
        ins(u, v);
    }
    scanf("%d%d", &s, &t);
    memset(dp, -1, sizeof(dp));
    bfs();
    if (dp[t][0] == -1)
        printf("-1");
    else 
        printf("%d", dp[t][0] / 3);
    return 0;
}

Measured memory_bytes: 6912
#include <stdio.h>

int main() {
    int W,H,x,y,r=0;
    scanf("%d %d %d %d %d", &W,&H,&x,&y,&r);
    
   if ((x-r >= 0) && (x+r <= W) && (y-r >= 0) && (y+r <= H)){
       printf("Yes\n");
   }
   else{
        printf("No\n");
   }
    return 0;    
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ll                  long long int
#define ull                 unsigned long long int
#define ld                  long double
#define fi                  first
#define se                  second
#define pb                  push_back
#define pbb                 pop_back
#define mp                  make_pair
#define pii     	        pair<int,int>
#define all(x)              x.begin(), x.end()
#define uniq(x)             x.erase(unique(x.begin(),x.end()),x.end())
#define mem(array, value)   memset(array, value, sizeof(array))
#define lcm(a,b)            (abs(a)/gcd(a,b))*abs(b)
#define PI      	        2*acos(0.0)
#define INF     	        1e9
#define EPS     	        1e-8
#define line                cout << "\n==========\n"
#define fastRead 	        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet; 

const int N = 109;
const int W = 1e5+9;
int weight[N], value[N];
ll dp[N][W];
int n;

ll call(int i, int w)
{
    if (i == n){
        return 0;
    }
    if (dp[i][w] != -1){
        return dp[i][w];
    }
    ll profit1, profit2;
    profit1 = 0;
    if (w - weight[i] >= 0){
        profit1 = value[i] + call(i+1, w-weight[i]);
    }
    profit2 = call(i+1, w);
    return dp[i][w] = max(profit1, profit2);
}

int main ()
{
    #ifdef Lollipop
    //freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
    #endif
    int w;
    cin >> n >> w;
    for (int i = 0; i<n; i++){
        cin >> weight[i] >> value[i];
    }
    mem(dp, -1);
    cout << call(0, w) << endl;
    return 0;
}



Measured memory_bytes: 85376
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
  double x1, y1, x2, y2;
  scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);

  double dx = abs(x1 - x2);
  double dy = abs(y1 - y2);
  double dis = sqrt(dx * dx + dy * dy);

  printf("%f\n", dis);

  return 0;
}


Measured memory_bytes: 2680
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

type number struct{ a, b int }
type numbers []number

func (n numbers) Len() int           { return len(n) }
func (n numbers) Swap(i, j int)      { n[i], n[j] = n[j], n[i] }
func (n numbers) Less(i, j int) bool { return n[i].a < n[j].a }

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	var k int
	fmt.Fscan(r, &n)
	fmt.Fscan(r, &k)
	nums := numbers(make([]number, n))
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &nums[i].a)
		fmt.Fscan(r, &nums[i].b)
	}

	sort.Sort(nums)
	ans := 0
	for i := 0; i < n; i++ {
		if nums[i].b >= k {
			ans = nums[i].a
			break
		}
		k -= nums[i].b
	}

	fmt.Println(ans)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 3840
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt(),k=sc.nextInt(),x=sc.nextInt(),y=sc.nextInt();
			System.out.println(Math.min(n,k)*x+Math.max(n-k,0)*y);
		}
	}
}


Measured memory_bytes: 9428
#include <bits/stdc++.h>
#define N 1000001
using namespace std;
typedef pair <int,int> P;
int n,u,v,m,num[N];
P U[N],V[N];

void in(P a[]){
  for(int i=1;i<=n;i++)
    for(int j=1,b;j<=n;j++) cin>>b,a[b]=P(i,j);
}

int game(P A[],int B){
  int i,ta[501]={},yo[501]={},X[2]={},cnt=n!=1? 0:-3;
  
  for(i=0;cnt<B&&i<=m;i++){
    int y=A[num[i]].first,x=A[num[i]].second;
    if(x==0)continue;
    X[0]+=(x==y);
    X[1]+=(x+y==n+1);
    if(X[0]==n) X[0]++,cnt++;
    if(X[1]==n) X[1]++,cnt++;
    cnt+=(++ta[y]==n)+(++yo[x]==n);
  }
  return i;
}

int main(){
  cin>>n>>u>>v>>m;
  in(U),in(V);
  for(int i=0;i<m;i++) cin>>num[i];
  int Uscore=game(U,u),Vscore=game(V,v);
  
  if(Uscore!=Vscore)cout<<(Uscore<Vscore ? "USAGI":"NEKO")<<endl;
  else cout<<"DRAW"<<endl;
  return 0;
}

Measured memory_bytes: 17544
#include <stdio.h>

int main(void)
{
	int a[4][13];
	int c, b, ab;
	char d;
		
	for(c = 0; c < 13; c++){
		a[0][c] = c + 1;
		a[1][c] = c + 1;
		a[2][c] = c + 1;
		a[3][c] = c + 1;
	}
	
		
		
    
	
	scanf("%d", &b);
	
	for(c = 0; c < b; c++){
		scanf("%s %d", &d, &ab);
		if(d == 'S'){
			a[0][ab-1] = 0;
		}
		if(d == 'H'){
			a[1][ab-1] = 0;
		}
		if(d == 'C'){
			a[2][ab-1] = 0;
		}
		if(d == 'D'){
			a[3][ab-1] = 0;
		}
	}
	
	for(c = 0; c < 13; c++){
		if(a[0][c] != 0){
			printf("S %d\n", a[0][c]);
		}
	}
	for(c = 0; c < 13; c++){
		if(a[1][c] != 0){
			printf("H %d\n", a[1][c]);
		}
	}
	for(c = 0; c < 13; c++){
		if(a[2][c] != 0){
			printf("C %d\n", a[2][c]);
		}
	}
	for(c = 0; c < 13; c++){
		if(a[3][c] != 0){
			printf("D %d\n", a[3][c]);
		}
	}
	
	
	
	
	
	
	return (0);
}

Measured memory_bytes: 596