akhauriyash/Code-Regression huggingface dataset:
/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___ 
           __|__|
          |  |___       */
#include <bits/stdc++.h>
using namespace std;
 
 
//---------------------------------------------------MACROS----------------------------------------------------------
#define ll long long
#define ld long double
#define beg(i ,n) for(ll i=0;i<n;i++)
#define beg1(i ,n) for(ll i=1;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back 
#define mp make_pair
#define nl "\n" 
#define sp " "
#define vec(v , n) vector<ll> v(n)
#define all(x) x.begin() , x.end()
#define pii pair<int , int>
#define pll pair<ll , ll>
#define mii map<int , int>
#define mll map<ll , ll>
#define msi map<string , int>
#define mci map<char , int>
#define f1 first
#define f2 second

//---------------------------------------------------GLOBAL----------------------------------------------------------
const ll MOD2 = 998244353 ;
const ll MOD = 1e9 + 7 ;
const ll MAX = 1e5 + 7 ;
const ll inf = 1e18L + 5 ;
const double pi = 3.14159265358979323846 ;
ll fpow(ll n , ll m ){ll res=1 ;while(m>0){if(m&1){res*=n ;}m/=2 ;n*=n ;}return res;}

//---------------------------------------------------FUNCTIONS-------------------------------------------------------

const ll nax = 1e5 + 5 ;

void solve(){
	ll n ;
	cin >> n ;
	ll odd = (n+1)/2 ;
	cout << (double)odd/n ;
}

//---------------------------------------------------DRIVER----------------------------------------------------------
int main()
{
    fast ;
    int t=1 ;
    // cin >> t ;
    while(t--){
        solve() ;
    }
    return 0;
}   

Measured memory_bytes: 256
n = int(input())
w = input()
w_list = w.split(" ")

for i in range(len(w_list)):
    w_list[i] = int(w_list[i])

cnt = 1e9

for i in range(len(w_list)):
    g1 = w_list[:i]
    g2 = w_list[i:len(w_list)]
    cnt = min(cnt, abs(sum(g1) - sum(g2)))

print (cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin>>x;
    if(x>=30)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return(0);
}

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

vector<int> dp[55][55];
bool used[55][55];

int N;
vector<int> D[55];
int solve(){
  memset(used,0,sizeof(used));
  for(int i=0;i<N;i++){
    used[0][i] = true;
    for(int j=0;j<=30;j++) dp[j][i].clear();
    dp[0][i].push_back(i);
  }
  int res = -1;
  for(int i=0;i<=30;i++){
    // cout << "day = " << i << endl; 
    for(int j=0;j<N;j++){
      if ( !used[i][j] ) continue;
      vector<int> v = dp[i][j];
      bool f=false;
      for(int k=0;k<(int)D[i+1].size();k++){
	if( D[i+1][k] == j ) f = true;
      }
      if(f){
	for(int k=0;k<(int)D[i+1].size();k++){
	  vector<int> r = dp[i][D[i+1][k]];
	  v.insert(v.end(),r.begin(),r.end());
	}
	sort(v.begin(),v.end());
	v.erase( unique(v.begin(),v.end()) ,v.end() );
      }
      //      cout << v.size() <<" flag : " << f << endl;
      if ( v.size() == N ){
	res = i+1; goto JUMP;
      }
      used[i+1][j] = true;
      dp[i+1][j] = v;
    }
  }
 JUMP:
  return res;
}


int main(){
  while( cin >> N && N ){
    for(int i=0;i<=30;i++) D[i].clear();
    for(int i=0;i<N;i++){
      int f;
      cin >> f;
      for(int j=0;j<f;j++){
	int t;
	cin >> t;
	D[t].push_back(i);
      }
    }
    cout << solve() << endl;
  }
}

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

typedef long long ll;
using namespace std;

int main(void) {
  int N, K;
  cin >> N >> K;
  vector<int> hp;
  for (int i = 0; i < N; i++)
  {
    int h; cin >> h;
    hp.push_back(h);
  }
  sort(hp.begin(), hp.end(), greater<int>());
  
  ll ans = 0;
  if (N > K) {
    for (int i = K; i < N; i++) {
      ans += hp[i];
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(void) {
	int k, i;
	string s;
	cin >> s >> k;
	for (i = 0; i < s.size() - 1; i++) {
		if (s[i] != 'a' && k >= 'z' - s[i] + 1) {
			k -= 'z' - s[i] + 1;
			s[i] = 'a';
		}
	}
	k %= 26;
	if (s[i] + k > 'z') {
		k -= 'z' - s[i] + 1;
		s[i] = 'a' + k;
	}
	else
		s[i] += k;
	cout << s << "\n";
	return 0;
}

Measured memory_bytes: 512
private class UnionFind(n: Int) {

    private val par = IntArray(n) { -1 }

    fun find(x: Int): Int {
        if (par[x] < 0) {
            return x
        }
        par[x] = find(par[x])
        return par[x]
    }

    fun unite(x: Int, y: Int) {
        val x1 = find(x)
        val y1 = find(y)
        if (x1 == y1) return

        val (x2, y2) = if (par[x1] > par[y1]) {
            y1 to x1
        } else {
            x1 to y1
        }

        par[x2] += par[y2]
        par[y2] = x2
    }

    fun same(x: Int, y: Int): Boolean {
        return find(x) == find(y)
    }

    fun size(x: Int): Int {
        return -par[find(x)]
    }

}

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val p = readLine()!!.split(' ').map { it.toInt() }

    val uf = UnionFind(n + 1)

    repeat(m) {
        val (x, y) = readLine()!!.split(' ').map { it.toInt() }
        uf.unite(x, y)
    }

    println(p.filter { uf.same(it, p[it - 1]) }.count())
}


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

int main()
{
    int N, H, W;
    cin >> N >> H >> W;
    cout << (N-H+1)*(N-W+1) << endl;
    return 0;
}

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

int main( )
{
    int n, i, j, k;
    string s;
    cin >> n >> s;
    for (i = 0; i < (int) s.size( ); i++)
        cout << char((s[i] - 'A' + n) % 26 + 'A');
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
using LL = long long;

const int N = 1e5 + 10;

struct Node {
    int w, t;

    bool operator<(const Node &b) const {
        return w > b.w;
    }
} a[N];

int fa[N];

void init(int n) {
    for (int i = 0; i <= n; ++i) fa[i] = i;
}

int find(int x) {
    return fa[x] == x ? x : fa[x] = find(fa[x]);
}

int main() {
#ifdef _LOCAL
    freopen("sample.in", "r", stdin);
#endif
    int n, m;
    scanf("%d%d", &n, &m);
    int Max = 0, tot = 0;
    for (int i = 1; i <= n; ++i) {
        int t, w;
        scanf("%d%d", &t, &w);
        t = m - t + 1;
        if (t >= 1) a[++tot] = {w, t};
        if (a[tot].t > Max) Max = a[tot].t;
    }
    n = tot;
    init(Max);
    sort(a + 1, a + n + 1);
    LL ans = 0;
    for (int i = 1; i <= n; ++i) {
        int pos = find(fa[a[i].t]);
        if (pos > 0) {
            fa[pos] = find(fa[pos] - 1);
            // printf("[%d,%d]\n", m - a[i].t + 1, a[i].w);
            ans += a[i].w;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main(){
    ll N;
    cin >> N;
    deque<string> dq;
    dq.push_back("");
    ll ans = 0;
    while(!dq.empty()){
        string nums = dq.front();
        dq.pop_front();
        if(nums.size()<10){
            dq.push_back(nums+'3');
            dq.push_back(nums+'5');
            dq.push_back(nums+'7');
        }
        if(nums.find("3")==string::npos ||
           nums.find("5")==string::npos ||
           nums.find("7")==string::npos){
            continue;
        }else{
            ll num = stoll(nums);
            if(num<=N){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void){
    int n,q;
    cin >> n >> q;
    vector<vector<int>> G(n,vector<int>());
    for(int i=0;i<n-1;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> query(n,0);
    for(int i=0;i<q;i++){
        int p,x;
        cin >> p >> x;
        p--;
        query[p] += x;
    }

    vector<ll> ans(n,-1);
    queue<int> Q;
    Q.push(0);
    while(!Q.empty()){
        int pos = Q.front(); Q.pop();
        ans[pos] = query[pos];
        for(int i=0;i<G[pos].size();i++){
            if(ans[G[pos][i]]!=-1) continue;
            query[G[pos][i]] += query[pos];
            Q.push(G[pos][i]);
        }
    }

    for(int i=0;i<n;i++){
        if(i!=n-1) cout << ans[i] << " ";
        else cout << ans[i] << endl; 
    }
}

Measured memory_bytes: 17140
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <bitset>
using namespace std;

int main(){
	vector <string> Name;
	map <string, int> Relation;
	int k, i, j, n, N, border;
	cin >> N >> border;
	for (k = 0; k < N; k++){
		cin >> n;
		Name.clear();
		string name;
		for (i = 0; i < n; i++){
			cin >> name;
			Name.push_back(name);
		}
		for (i = 0; i < n - 1; i++){
			for (j = i + 1; j < n; j++){
				if (Name[i] > Name[j]) Relation[Name[j] + " " + Name[i]]++;
				else Relation[Name[i] + " " + Name[j]]++;
			}
		}
	}
	{
		int count = 0;
		for (auto r : Relation){
			if (r.second >= border) count++;
		}
		cout << count << endl;
		for (auto r : Relation){
			if (r.second >= border) cout << r.first << endl;
		}
	}
	return 0;
}


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


#define Seg_Max_N (1<<20) 


using Value = int;
const Value ini = 0;
struct segtree {
	int N;
	vector<Value>dat;

	segtree() {}
	segtree(int n) :dat(2 * Seg_Max_N) {
		N = 1;
		while (N < n) N *= 2;
		for (int i = 0; i < 2 * N - 1; i++) {
			dat[i] = ini;
		}
	}
	Value connect(const Value&l, const Value&r) {
		return l + r;

	}
	// update k th element
	void update(int k, Value a) {
		k += N - 1;
		dat[k] = a;

		while (k > 0) {
			k = (k - 1) / 2;
			const Value al(dat[k * 2 + 1]);
			const Value ar(dat[k * 2 + 2]);
			dat[k] = connect(al, ar);
		}
	}
	// min [a, b)
	Value  query(int a, int b) { return query(a, b, 0, 0, N); }
	Value  query(int a, int b, int k, int l, int r) {
		if (r <= a or b <= l) return ini;
		if (a <= l and r <= b) return dat[k];
		const int m = (l + r) / 2;
		const Value al(query(a, b, k * 2 + 1, l, m));
		const Value ar(query(a, b, k * 2 + 2, m, r));
		return connect(al, ar);
	}
};

struct query {
	int command;
	long long int a;
	long long int b;
};

template<typename T> struct Compress {
	map<T, int>mp;
	map<int, T>revmp;

	Compress(vector<T>vs) {
		setmp(vs);
	}

	Compress() :mp(), revmp() {

	}
	void setmp(vector<T>vs) {
		sort(vs.begin(), vs.end());
		vs.erase(unique(vs.begin(), vs.end()), vs.end());
		for (int i = 0; i < static_cast<int>(vs.size()); ++i) {
			mp[vs[i]] = i;
			revmp[i] = vs[i];
		}
	}

};

int main() {
	int N, C; cin >> N >> C;
	vector<query>qs;
	Compress<pair<long long int, int>>cp;
	{
		
		vector<pair<long long int, int>>vs;
		for (int i = 0; i < N; ++i) {
			vs.push_back(make_pair(0, -i));
		}
		vector<long long int>v(N);
		for (int i = 0; i < C; ++i) {
			int command; cin >> command;
			if (command) {
				int m; cin >> m;
				qs.push_back(query{ command,m,-1 });
			}
			else {
				int t, p; cin >> t >> p;
				t--;
				v[t] += p;
				vs.push_back(make_pair(v[t], -t));
				qs.push_back(query{ command,t,p });
			}
		}
		cp.setmp(vs);
	}
	segtree seg(N+C+10);
	vector<long long int >scores(N);
	for (int i = 0; i < N; ++i) {
		seg.update(cp.mp[make_pair(0, -i)], 1);
	}
	for (int i = 0; i < C; ++i) {
		auto query(qs[i]);
		const int command(query.command);
		if (command == 0) {
			const long long int t(query.a);
			const int p(query.b);
			seg.update(cp.mp[make_pair(scores[t], -t)], 0);
			seg.update(cp.mp[make_pair(scores[t] + p,-t)], 1);
			scores[t] += p;
		}
		else {
			const long long int m(query.a);

			int amin = 0;
			int amax = 3e5;
			while (amin + 1 != amax) {
				int amid((amin + amax) / 2);
				int num = seg.query(0, amid);
				if (num >= N-m+1)amax = amid;
				else amin = amid;
			}
			auto p(cp.revmp[amin]);
			cout << -p.second+1 << " " << p.first << endl;

		}
	}
	
	return 0;
}

Measured memory_bytes: 42448
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

class Dice
{
private:
    int top_, bottom_, north_, south_, east_, west_;

    void rollingN()
    {
        int tmp = top_;
        top_    = south_;
        south_  = bottom_;
        bottom_ = north_;
        north_  = tmp; //top_;

    }
    void rollingS()
    {
        int tmp = top_;
        top_    = north_;
        north_  = bottom_;
        bottom_ = south_;
        south_  = tmp; //top_;

    }
    void rollingE()
    {
        int tmp = top_;
        top_    = west_;
        west_   = bottom_;
        bottom_ = east_;
        east_   = tmp; //top_;

    }
    void rollingW()
    {
        int tmp = top_;
        top_    = east_;
        east_   = bottom_;
        bottom_ = west_;
        west_   = tmp; //top_;

    }

public:
    Dice(const vector<int> &nums)
    {
        top_    = nums[0];
        bottom_ = nums[5];
        north_  = nums[4];
        south_  = nums[1];
        east_   = nums[2];
        west_   = nums[3];;
    }

    int getTop() const { return top_; }

    void exeOreder(const string &order)
    {
        size_t N = order.size();
        for(size_t i = 0; i < N; i++)
        {
            switch(order[i])
            {
            case 'N':
                rollingN();
                break;

            case 'S':
                rollingS();
                break;

            case 'E':
                rollingE();
                break;

            case 'W':
                rollingW();
                break;
            default:
                cout << "Error" << endl;
                break;

            }

        }

    }





};


int main()
{
    const int kNumDiceFaces = 6;
    vector<int> nums;
    nums.resize(kNumDiceFaces, 0);

    for(int i = 0; i < kNumDiceFaces; i++)
    {
        cin >> nums[i];
    }
    string order;
    cin >> order;

    Dice dice(nums);
    dice.exeOreder(order);
    cout << dice.getTop() << endl;

    return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    ll h;cin>>h;
    ll cnt=0;
    while(h>1){
        h/=2;
        cnt++;
    }
    ll ans=1;
    repi(i,1,cnt+1){
        ans+=pow(2,i);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
list<int> L;
stack<int> S;
queue<int> Q;
deque<int> dq;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=100000;
static const int NMAX=50;
static const int MMAX=50;
ll X;
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>X;
    
    ll l=0ll,r=1e5;
    while(r-l>1){
        ll m=(l+r)/2; //r=l+1の時m=l
        if(m*(m+1)>2*X)r=m;
        else l=m;
    }
    
    if(l*(l+1)==2*X)cout<<l<<"\n";
    else cout<<r<<"\n";
    
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

double rad(const double d) { return d * M_PI / 180.0; }

int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  const double hour_angle = static_cast<double>(30 * h) + 0.5 * m;
  const double min_angle = 6 * m;
  const double angle = abs(hour_angle - min_angle);
  const double c2 = a * a + b * b - 2 * a * b * cos(rad(angle));
  const double ans = sqrt(c2);
  printf("%.10f\n", ans);

  return 0;
}


Measured memory_bytes: 4128
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <math.h>
#include <assert.h>

using namespace std;

#define x first
#define y second
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define all(x) x.begin(),x.end()
#define SZ(x) int(x.size())
#define rep(i, a, b) for(int i = a; i < b; i++)
#define per(i, a, b) for(int i = b-1; i >= a; i--)
#define DBG(x) cerr << (#x) << "=" << x << "\n";
#define ll long long
#define inf 1000000007
#define mod 1000000007
#define N 200005

template<typename U, typename V> void Min(U &a, const V & b){if(a > b)a = b;}
template<typename U, typename V> void Max(U &a, const V & b){if(a < b)a = b;}
template<typename U, typename V> void add(U &a, const V & b){a = (a + b) % mod;}
template<typename U> U gcd(U a, U b){
    if(a == 0)return b;
    if(b == 0)return a;
    if(a >= b)return gcd(a % b, b);
    else return gcd(a, b % a);
}
int pow(int a, int b){
    int ans = 1;
    while(b){
        if(b & 1)ans = 1LL * ans * a % mod;
        a = 1LL * a * a % mod;
        b >>= 1;
    }
    return ans;
}
int pow(int a, int b, int c){
    int ans = 1;
    while(b){
        if(b & 1)ans = 1LL * ans * a % c;
        a = 1LL * a * a % c;
        b >>= 1;
    }
    return ans;
}

int a[N];
int main(){
  int T, i, j, k, ca = 0, m, K, n;
  scanf("%d%d%d%d", &n, &m, &K, &T);
  rep(i, 0, n)scanf("%d", &a[i]);
  sort(a, a+n);
  int x = n-T;
  while (x > 0 && a[x-1] == a[x])x--;
  int l = 0, r = x-1;
  while(l <= r){
    int t = (l + r) >> 1;
    int w = a[t] + m; 
    int rem = K - t - 1, y = t+1, res = T;
    per(i, t+1, n){
      if (a[i] > w){
        res--;
        rem--;
      }
      else {
        y = i;
        break;
      }
    }
    if(res <= 0) {
      l = t + 1;
      continue;
    }
    if (rem <= 0){
      r = t - 1;
      continue;
    }
    y -= res-1;
    rem -= res-1;
    if(y <= t || rem <= 0){
      r = t - 1;
      continue;
    }
    ll s = 0;
    rep(i, t+1, y+1) {
      s += w - a[i];
    }
    //cerr << a[t] << " " << s << " " << rem << "\n";
    if (s >= 1LL * m * rem){
      r = t - 1; 
    }
    else{
      l = t + 1;
    }
  }
  printf("%d\n", n-(r+1));
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline ll read()
{
	ll x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	return x*f;
}
ll n,ans;
int main()
{
	n=read(); int t=sqrt(n);
	ans=n-1;
	for(int i=2;i<=t;i++)
	{
		if(n%i) continue;
		ans=min(ans,n/i+i-2);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+5;
const int P=1e9+7;
long long n,m,a[N],b[N],s[N][N],dp[N][N];
int main(){
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)   scanf("%lld",&a[i]);
    for(int i=1;i<=m;i++)   scanf("%lld",&b[i]);
    for(int i=0;i<=n;i++)   s[i][0]=1;
    for(int i=0;i<=m;i++)   s[0][i]=1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            s[i][j]=(s[i-1][j]+s[i][j-1]-s[i-1][j-1]+P)%P;
            if(a[i]==b[j])  dp[i][j]=s[i-1][j-1];
            s[i][j]=(s[i][j]+dp[i][j])%P;
        }
    printf("%lld\n",s[n][m]);
    return 0;
}

Measured memory_bytes: 62848
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
	int n, k, x[50], y[50], _x[50], _y[50];
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i];
		_x[i] = x[i];
		_y[i] = y[i];
	} 
	sort(_x, _x+n); sort(_y, _y+n);
	ll area = 1ll*(_x[n-1]-_x[0])*(_y[n-1]-_y[0]);
	//cout<<area<<endl;
	for(int xi=0;xi<n;xi++){
		for(int xj=0;xj<n;xj++){
			for(int yi=0;yi<n;yi++){
				for(int yj=0;yj<n;yj++){
 
					int cnt=0;
 
					ll lx = _x[xi], rx = _x[xj],
					   by = _y[yi], uy = _y[yj]; 
					for(int i=0;i<n;i++){
						if(lx<=x[i]&&x[i]<=rx&&by<=y[i]&&uy>=y[i])
							cnt++;
					}
					if(cnt>=k)
						area = min(area, 1ll*(rx-lx)*(uy-by));
				}
			}
		}
 
	}
	cout<<area<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


int fac(int num) {
  if(num==1) return 1;
  else return num*fac(num-1);
}





int main() {
  ll a,b,c,x,y;
  ll ans = 0;
  cin >> a >> b >> c >> x >> y;
  if(a+b >=2*c) {
    ans += 2*c*min(x,y);
    ll m = min(x,y);
    x-=m;
    y-=m;
    if(y == 0 && a >= 2*c) ans += 2*x*c,x=0;
    else if(x == 0 && b >= 2*c) ans += 2*y*c,y=0;
    ans += x*a + y*b;
  }
  else {
    ans += x*a + y*b;
  }


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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n, k, ans = 0, x;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		cin >> x;
		if (x <= k / 2)
			ans += x * 2;
		else
			ans += (k - x) * 2;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug cerr << "-- " << __LINE__ << " --" << endl
#define MOD 1000000007
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
template <typename T> string to_string(const vector<T> &xs) {string s="["; for(int i=0;i<xs.size();i++) s += (i>0 ? " " : "") + to_string(xs[i]); return s + "]";}



ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y);}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator+=(const llm &y) { *this = *this + y; return *this;}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator-=(const llm &y) { *this = *this - y; return *this;}
	llm operator-() const{ return llm(0) - *this;}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator*=(const llm &y) { *this = *this * y; return *this;}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm operator/=(const llm &y) { *this = *this / y; return *this;}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}

ll n, k;

int main(void){
	cin >> n >> k;
	if (2 * k > n + 1) {cout << -1 << endl; return 0;}

	vector<vector<ll>> ans(n, vector<ll>(3));
	vector<ll> flg(2*n);
	vector<ll> rowFlg(n);

	for(ll i=k-1;i<n;i++){
		if (k + 2 * (i-k+1) >= k + 2*n - 1 - (i-k+1)) break;
		ans[i][0] = k + 2 * (i-k+1);
		ans[i][1] = k + 2*n - 1 - (i-k+1);
		ans[i][2] = 2*k + 2*n - 1 + (i-k+1);
		rowFlg[i] = 1;
		flg[2 * (i-k+1)] = 1;
		flg[2*n - 1 - (i-k+1)] = 1;
	}

	vector<ll> unused;
	for(ll i=0;i<2*n;i++) if (!flg[i]) unused.pb(k + i);

	ll cnt = 0;
	for(ll i=0;i<n;i++){
		if (!rowFlg[i]){
			ans[i][0] = unused[cnt];
			ans[i][1] = unused[unused.size()-1 - cnt];
			ans[i][2] = k+2*n+i;
			cnt++;
		}
	}

	for(ll i=0;i<n;i++){
		cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << endl;
	}


    return 0;
}













Measured memory_bytes: 10996
a = str(input())
if int(a[0]) > int(a[1]):
    print(a[0]*3)
if int(a[0]) < int(a[1]):
    print(str(int(a[0])+1)*3)
if int(a[0]) == int(a[1]):
    if int(a[2]) > int(a[1]):
        print(str(int(a[0])+1)*3)
    if int(a[2]) < int(a[1]):
        print(a[0]*3)
    if int(a[2]) == int(a[1]):
        print(a[0]*3)



Measured memory_bytes: 3064
N = int(input())
S = input()
L = [0]*(N+1)
for i in range(N):
  if S[i]=="E":
    L[i+1] = L[i]+1
  else:
    L[i+1] = L[i]
print(min(i-L[i]+L[N]-L[i+1] for i in range(N)))

Measured memory_bytes: 21036
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    int A,B;
    cin >> A >> B;
    cout << A * B << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c,d; cin>>a>>b>>c>>d;
		if (a+b>c+d) cout<<"Left"<<endl;
		else if (a+b<c+d) cout<<"Right"<<endl;
		else if (a+b==c+d) cout<<"Balanced"<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static String[] str;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        str = in.next().split("");

        String formula;
        int ans;
        for(int i=0; i < Math.pow(2,3); i++){
            formula = str[0];
            ans = Integer.parseInt(str[0]);
            for(int j = 0; j < 3; j++){
                if((1&i>>j) == 0){
                    formula = formula + "+" + str[j+1];
                    ans += Integer.parseInt(str[j+1]);
                }else{
                    formula = formula + "-" + str[j+1];
                    ans -= Integer.parseInt(str[j+1]);
                }
            }
            if(ans == 7){
                System.out.println(formula + "=7");
                break;
            }
        }
    }
}

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

template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}


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

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

using namespace std;

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

int main (){
    string s;
    cin >> s;

    rep(i, s.size()){
           if(i % 2 == 0){
                 cout << s[i];
           }
    }
     cout << endl;


    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
int mod = 1000000007;
long long dp[100005];

int main() {
  long long n;
  cin >> n;
  vector<int> d(n);
  
  for(int i = 0;i<n;i++){
    cin >> d[i];
  }
  sort(d.begin(),d.end());
  
  int res = 0;
  
  if(d[n/2-1] != d[n/2]){
    res = d[n/2] - d[n/2-1];
  }
  //cout << d[(n/2)] << " " << d[(n/2)] << endl;
  cout << res << endl;
}


Measured memory_bytes: 768
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<cstring>
using namespace std;

int main() {

	char s[100];
	int count = 0, i, j=0;

	cin >> s;

	while (s[count] != '\0') {
		count++;
	}

	for (i = 0; i < (int)(count / 2); i++) {
		if (s[i] != s[count-1-i]) {
			s[count-1-i] = s[i];
			j++;
		}
	}

	cout << j << endl;

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main () {
	int a , b , i , sum , month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	char ans[7][16] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
	while ( scanf("%d %d",&a,&b),a&&b) {
		sum = 0;
		for ( i = 0; i < a-1; i++ )
			sum += month[i];
		sum += b-1;
		printf("%s\n",&ans[sum%7][0]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

const int N = 2e5 + 9;
int a[N];

signed main(){
   IOS;
   int n, k; cin >> n >> k;
   int goal = n * n;
   for(int i = 0; i < n; i++) {
      cin >> a[i];
   }
   for(int j = 0; j < k; j++) {
      vector<int> p(n,0);
      for(int i = 0; i < n; i++) {
         int l = max(i-a[i],0ll), r = i + a[i];
         p[l]++;
         if(r + 1 < n ) p[r+1]--;
      }
      int aux = 0;
      for(int i = 0; i < n; i++) {
         if(i > 0) p[i]+=p[i-1];
         a[i] = p[i];
         aux+=a[i];
      }
      if (aux == goal) break;
   }
   for(int i = 0; i < n; i++) {
      cout << a[i] << " ";
   }
   cout << '\n';
}

Measured memory_bytes: 6788
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}


//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let a:i32 = read();
    let b:i32 = read();
    let c:i32 = read();

    println!("{}", min(c, b/a));

}


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

int main() {
    string s;
    cin >> s;

    int ans = 0;
    if (s == "RRR")
        ans = 3;
    else if (s == "RRS" || s == "SRR")
        ans = 2;
    else if (s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR")
        ans = 1;

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


Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  char x, y;
  cin >> x >> y;
  if(x < y) cout << "<" << endl;
  else if(x > y) cout << ">" << endl;
  else cout << "=" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n, i, s=0, k;
  cin >> n;
  for(i=1; i<=n; i++){
    k=n/i;
    s+=(k+1)*k*i/2;
  }
  cout << s;
  return 0;
}

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


int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  if(a>=k){
    cout<<k;
  }else if(a+b>=k){
    cout<<a;
  }else{cout<<a-(k-a-b);}

  }
  


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

int main()
{
  long long i,j,n,m,k;
  cin>>n>>m>>k;
  i=max(n,m);
  if(k%i==0)   cout<<k/i<<endl;
  else cout<<(k/i)+1<<endl;
  return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
int A,B,C,D,N,M;
string in;
int K;
int main() {
  ios::sync_with_stdio(false);
  cin >> N;
  cin >> in;
  cin >> K;
  char t = in[K-1];
  for(int i = 0; i < N; i++) {
    if(in[i] == t) cout << t;
    else cout << '*';
  }


  return 0;
}


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

int main()
{
    int N;
    string S, T;
    cin >> N >> S >> T;

    for (int i = 0; i < N; ++i)
    {
        cout << S[i] << T[i];
    }
    
}


Measured memory_bytes: 256
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

a = list(read())
b = list(read())

cnt = 0
for i in range(3):
    if a[i] == b[i]:
        cnt += 1
print(cnt)


Measured memory_bytes: 6856
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;

long long gcd(long long a,long long b)
{
    return (b>0)?gcd(b,a%b):a;
}


int main()
{
    long long a,b;
    cin >> a >> b;
    long long c=gcd(a,b);long long ans=1;
    long long tmp=2;
    if (c%2==0){
        ans++;while (c%2==0) c/=2;
    }
    tmp++;
    while (tmp*tmp<=c)
    {
        if (c%tmp==0){
            ans++;while(c%tmp==0) c/=tmp;
        }
        tmp+=2;
    }
    if (c>1)
        ans++;
    cout<<ans;

}




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

#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl            "\n"
#define sq(x)           ((x)*(x))

typedef long long ll;


int main()
{
    FastRead

    ll n,m,cnt=0;

    cin>>n>>m;

    vector<ll>h(n+1),graph[n+1],mark(n+1,0);

    for(ll i=1;i<=n;i++)
        cin>>h[i];

    while(m--)
    {
        ll a,b;

        cin>>a>>b;

        graph[a].push_back(b);
        graph[b].push_back(a);

        if(h[a]>h[b])
            mark[a]++;
        if(h[b]>h[a])
            mark[b]++;

    }

    for(ll i=1;i<=n;i++)
        if(graph[i].size()==mark[i])
            cnt++;

    cout<<cnt;

}


Measured memory_bytes: 10580
#include <cstdio>
#include <queue>

using LL = long long;

const int N = 100000;
const int M = 200000;
const int MOD = (int)1e9 + 7;

int n, m, s, t, a[M << 1], c[M << 1], ws[N], wt[N];
LL ds[N], dt[N];
std::vector<std::pair<int, int>> graph[N];

void update(int& x, int a)
{
    x += a;
    if (x >= MOD) {
        x -= MOD;
    }
}

void dij(int src, LL* dist, int* ways)
{
    for (int i = 0; i < n; ++ i) {
        dist[i] = 1000000000000000000LL;
    }
    dist[src] = 0, ways[src] = 1;
    std::priority_queue<std::pair<LL, int>> queue;
    queue.emplace(0, src);
    while (!queue.empty()) {
        auto top = queue.top();
        queue.pop();
        int u = top.second;
        if (-top.first != dist[u]) {
            continue;
        }
        for (auto it : graph[u]) {
            int v = it.first;
            if (dist[u] + it.second < dist[v]) {
                dist[v] = dist[u] + it.second;
                ways[v] = 0;
                queue.emplace(-dist[v], v);
            }
            if (dist[u] + it.second == dist[v]) {
                update(ways[v], ways[u]);
            }
        }
    }
}

int main()
{
    scanf("%d%d%d%d", &n, &m, &s, &t);
    s --;
    t --;
    for (int i = 0; i < m << 1; ++ i) {
        scanf("%d", a + i);
        a[i] --;
        if (i & 1) {
            scanf("%d", c + i);
            c[i ^ 1] = c[i];
        }
    }
    for (int i = 0; i < m << 1; ++ i) {
        graph[a[i]].emplace_back(a[i ^ 1], c[i]);
    }
    dij(s, ds, ws);
    dij(t, dt, wt);
    int result = 1LL * ws[t] * ws[t] % MOD;
    for (int mid = 0; mid < n; ++ mid) {
        if (ds[mid] * 2 == ds[t] && ds[mid] + dt[mid] == ds[t]) {
            int cnt = 1LL * ws[mid] * wt[mid] % MOD;
            update(result, MOD - 1LL * cnt * cnt % MOD);
        }
    }
    for (int i = 0; i < m << 1; ++ i) {
        LL b = ds[a[i]];
        LL e = ds[a[i ^ 1]];
        if (b * 2 < ds[t] && ds[t] < e * 2 && b + c[i] + dt[a[i ^ 1]] == ds[t]) {
            int cnt = 1LL * ws[a[i]] * wt[a[i ^ 1]] % MOD;
            update(result, MOD - 1LL * cnt * cnt % MOD);
        }
    }
    printf("%d\n", result);
}


Measured memory_bytes: 17364
import sys
import math
def input():
    return sys.stdin.readline()[:-1]
a,b,x=map(int,input().split())
if a*a*b/2>x:
    y=float(2*x)/a/b
    tai=pow(y*y+b*b,0.5)
    print(90-math.degrees(math.asin(y/tai)))
else:
    x=a*a*b-x
    y=float(2*x)/a/a
    tai=pow(y*y+a*a,0.5)
    print(math.degrees(math.asin(y/tai)))

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

int main(){
int x,y,t;
for(int i=0; ;i++){
cin >>x >>y;
if(x==0&&y==0)break;
if(x>y){
t=x;
x=y;
y=t;
}
cout <<x <<" " <<y <<endl;
}
return 0;
}

Measured memory_bytes: 3104
#include<iostream>
#include<string.h>
using namespace std;

int judge();
char s[202],p[101];
int y;
int main()
{
  cin>>s;
  cin>>p;
  y=strlen(s);
  for(int i=0;i<y;i++){
    s[y+i]=s[i];
  }
  if(judge())cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

int judge(){
  int sum=0;
  for(int i=0;i<y;i++){
    for(int j=0;j<strlen(p);j++){
      if(s[i+j]==p[j])sum++;
    }
    if(sum==strlen(p))return 1;
    else sum=0;
  }
  return 0;
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  while(n)
  {
    int rem=(n%10);
    if(rem==7)
    {
      cout<<"Yes";
      return 0;
    }
    n=n/10;
  }
  cout<<"No";
  return 0;
}

Measured memory_bytes: 3588
n,a,b = map(int,input().split())
if (a % 2 + b % 2) % 2 == 0:
    print(abs(a - b) // 2)
elif n - b < a - 1:
    p = n - b + 1
    a += n - b
    b = n
    print(abs(a - b) // 2 + p)
else:
    p = a
    b -= a - 1
    a = 1
    print(abs(a - b) // 2 + p)

Measured memory_bytes: 9172
using System;

namespace atCoder
{
    class Program
    {

        static void Main()
        {
            string[] c1 = Console.ReadLine().Split(' ');
            string[] c2 = Console.ReadLine().Split(' ');
            string[] c3 = Console.ReadLine().Split(' ');
            int[,] c = new int[3, 3];

            for (int i = 0; i < 3; i++)
            {
                c[0, i] = int.Parse(c1[i]);
                c[1, i] = int.Parse(c2[i]);
                c[2, i] = int.Parse(c3[i]);
            }

            for (int a1 = 0; a1 <= 100; a1++)
            {
                int b1 = c[0, 0] - a1;
                int b2 = c[0, 1] - a1;
                int b3 = c[0, 2] - a1;
                int a2 = c[1, 0] - b1;
                int a3 = c[2, 0] - b1;

                if (c[1, 1] == a2 + b2 &&
                    c[1, 2] == a2 + b3 &&
                    c[2, 1] == a3 + b2 &&
                    c[2, 2] == a3 + b3)
                {
                    Console.WriteLine("Yes");

                    return;
                }
            }

            Console.WriteLine("No");
        }
    }
}

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

const int N = 105;
typedef long long LL;

int n, x, a[N], ans;

int main() {
	cin>>n>>x;
	for(int i = 1; i <= n; i++)
		cin>>a[i];
	sort(a + 1, a + n + 1);
	for(int i = 1; i < n; i++) {
		if(x < a[i]) {
			cout<<i - 1<<endl;
			return 0;
		}
		x -= a[i];
	}
	if(x == a[n]) cout<<n<<endl;
	else cout<<n - 1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
   long long int n , a , b ;
   cin>>n>>a>>b;
   
   if ( n == 1 )
   {
       if ( a == b )
       {
           cout<<1<<endl;
       }
       else
       {
           cout<<0<<endl;
       }
   }
   
   else if ( n > 1 )
   {
       if ( a > b )
       {
           cout<<0<<endl;
       }
       else
       {
           cout<<(b-a)*(n-2)+1<<endl;
       }
   }
   return 0;
}

Measured memory_bytes: 256
n,a,b,c,d = map(int, input().split())
a-=1
b-=1
c-=1
d-=1
s = input()
s+='X'
ch=1
v=[]
st=[]
if s[0]=='#':
    v.append((0,0))
for i in range(1,n+1):
    if s[i]==s[i-1]:
        ch+=1
    else:
        v.append((ch,i-ch))
        ch=1
judge=[]
for i in range(len(v)):
    if i%2==1:
        x,y=v[i]
        if x>=2 and ((a < y and y < c) or (b < y and y < d)):
            print('No')
            exit()
    else:
        x,y=v[i]
        if x>=3:
            judge.append((y,y+x-1))
check=1
if (a<b and d<c) or (b<a and c<d):
    check = 0
    while judge:
        t1,t2=judge.pop()
        if t2>a and t2>b and t1<c and t1<d:
            check = 1
if check == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 25216
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

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

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

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int n,x,t;
    cin >> n >> x >> t;
    if(n % x == 0) cout << n / x * t << endl;
    else cout << (n / x + 1) * t << endl;
}


Measured memory_bytes: 3596
n,q=map(int,input().split())
G=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  G[a-1].append(b-1)
  G[b-1].append(a-1)
c=[0]*n
for i in range(q):
  p,x=map(int,input().split())
  c[p-1]+=x
from collections import deque
visited=[-1]*n
q=deque()
q.append(0)
while q:
  cur=q.popleft()
  visited[cur]=0
  for nx in G[cur]:
    if visited[nx]!=-1:continue
    c[nx]+=c[cur]
    q.append(nx)
print(*c)


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int64 N;
  cin >> N;
  vector<int64> d(N);
  REP(i, N) cin >> d[i];
  int64 res = 0;
  REP(i, N) {
    FOR(j, i+1, N) {
      res += d[i] * d[j];
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <limits>
typedef unsigned long long ull;
using namespace std;
const ull oo = 1LL << 62LL;

void solve(){
    ull N, W;
    scanf("%llu %llu", &N, &W);
    ull max_value = 0;
    vector<ull> weight(N + 1);
    vector<int> value(N + 1);
    for(int i = 1; i <= N; ++i){
        scanf("%llu %d", &weight[i], &value[i]);        
        max_value += value[i];
    }
    vector<ull> dp(max_value + 1, oo);
    dp[0] = 0;
    for(int i = 1; i <= N; ++i){
        for(int j = max_value; j >= value[i]; --j){
            dp[j] = min(dp[j], dp[j - value[i]] + weight[i]);
        }
    }
    ull ans = 0;
    for(int i = 0; i <= max_value; ++i){
        if(dp[i] <= W){
            ans = max(ans, (ull)i);
        }
    }
    printf("%llu\n", ans);
}
int main(){
    // freopen("/Users/deepsajeda/Documents/FIRST/in", "r", stdin);
    // freopen("/Users/deepsajeda/Documents/FIRST/out", "w", stdout);
    for(int i = 0; i < 1; ++i){
        solve();
    }
}
//printf("%.5f\n", clock() / (float)CLOCKS_PER_SEC); time in seconds


Measured memory_bytes: 1024