akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<functional>
#include<vector>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
using ll =long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T=ll>
using v =vector<T>;
template<typename T=ll>
using vv = vector<v<T>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
const ll INF = (ll)1e9;
const ll MOD = INF+7;
template<typename T> T chmin(T &a,T b){a=min(a,b);}
template<typename T> T chmax(T &a,T b){a=max(a,b);}

void a(){
    string s,t; 
    cin >> s >> t;
    if(s==t.substr(0,t.size()-1)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

void b(){
    ll a,b,c,k; 
    cin >> a >> b >> c >> k;
    ll count=0;

  	rep(i,a){
      	if(k<=0) break;
        k--;
        count++;
    }
  
    rep(i,b){
      	if(k<=0) break;
        k--;
    }
  
    rep(i,c){
      	if(k<=0) break;
        k--;
        count--;
    }

  	cout << count << endl;

}
void c(){}
void d(){}

int main(){
    a();
    return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;
const long double PI=3.14159265358979;

int main() {
  int a,b,k;
  cin>>k>>a>>b;
  if(abs(a-b)>k){
    cout<<"OK";
  }
  else{
    for(int i=a;i<=b;i++){
      if(i%k==0){
        cout<<"OK";
        break;
      
      }
      if(i==b){
        cout<<"NG";
      }
    }
  }
  
      
}

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

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm

    int N;
    cin >> N;

    int xi = 0, yi = 0, ti = 0, x, y, t;
    for( int i = 1; i <= N; i++ ){
        cin >> t >> x >> y;
        if( t-ti < abs(x-xi)+abs(y-yi) ){
            cout << "No\n";
            return 0;
        }
        if( (t-ti - abs(x-xi)-abs(y-yi))%2 != 0 ){
            cout << "No\n";
            return 0;
        }
        xi = x, yi = y, ti = t;
    }
    cout << "Yes\n";
    return 0;
}


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

const int inf = 1000000037;
const int maxn = 41;
const int maxs = 401;

int n, ma, mb, ans = inf;
int dp[maxn][maxs][maxs];
pair < int, pair < int, int > > cab[maxn];

void prepare () {
	for (int i = 0; i < maxn; ++i) {
		for (int j = 0; j < maxs; ++j) {
			for (int w = 0; w < maxs; ++w) {
				if (j || w)
					dp[i][j][w] = inf;
			}
		}
	}
}

signed main () {
	prepare();
	
	scanf("%d %d %d", &n, &ma, &mb);
	for (int i = 1; i <= n; ++i) 
		scanf("%d %d %d", &cab[i].second.first, &cab[i].second.second, &cab[i].first);
	sort(cab + 1, cab + n + 1);
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j < maxs; ++j) {
			for (int w = 1; w < maxs; ++w) {
				dp[i][j][w] = dp[i - 1][j][w];
				if (j >= cab[i].second.first && w >= cab[i].second.second)
					dp[i][j][w] = min(dp[i][j][w], dp[i - 1][j - cab[i].second.first][w - cab[i].second.second] + cab[i].first);
			}
		}
	}
	for (int i = ma; max(i, (i / ma) * mb) < maxs; i += ma) 
		ans = min(ans, dp[n][i][(i / ma) * mb]);
	if (ans == inf)
		ans = -1;
	printf("%d\n", ans);
}


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

struct Point{
    double x, y;
};

void koch(int n, Point a, Point b){
    if (n == 0) return;
    Point s, t, u;
    double th = acos(-1) * 60.0 / 180.0;
    
    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
    
    koch(n-1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n-1, t, b);
}

int main(void){
    Point a, b;
    int n;
    cin >> n;
    
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;
    
    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        cin>>n;
        vl P(n);
        vl Pos(n);
        rep(i,n){
            cin>>P[i];
            Pos[P[i]-1]=i;
        }
        multiset<ll> S{-1,-1,n,n};
        ll res=0;
        rrep(i,n){
            S.insert(Pos[i]);
            auto itr=S.lower_bound(Pos[i]);
            auto l=prev(itr);
            ll l1=*l;
            ll l2=*prev(l);
            auto r=next(itr);
            ll r1=*r;
            ll r2=*next(r);
            res+=(i+1)*((l1-l2)*(r1-Pos[i])+(Pos[i]-l1)*(r2-r1));
        }
        cout<<res<<endl;
    }

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Task {
    int time;
    int limit;
public:
    Task(int t, int l) {
        time = t;
        limit = l;
    }

    bool operator<(const Task &another) const {
        return limit < another.limit;
    }

    int getTime() {
        return time;
    }

    int getLimit() {
        return limit;
    }
};

int main() {
    int N;
    vector<Task> t;

    cin >> N;
    for (int i = 0; i < N; ++i) {
        int time, limit;
        cin >> time >> limit;
        Task task = Task(time, limit);
        t.push_back(task);
    }

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

    // for (int i = 0; i < t.size(); i++)
    // {
    //     cout << t[i].getTime() << "  " << t[i].getLimit() << endl;
    // }

    int sum;
    for (int i = 0; i < t.size(); ++i) {
        sum += t[i].getTime();
        if (sum > t[i].getLimit()) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 2420
s0 = list(input())
s1 = list(input())
s2 = list(input())
s = [s0, s1, s2]
m = 0

for _ in range(301):
    if s[m]:
        if s[m][0] == "a":
            del s[m][0]
            m = 0
        elif s[m][0] == "b":
            del s[m][0]
            m = 1
        else:
            del s[m][0]
            m = 2 
    else:
        if m == 0:
            print("A")
        elif m == 1:
            print("B")
        else:
            print("C")
        break


Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXN = 100, MAXT = 1440 * 2;
int main()
{
    int n, t, e, w[MAXN + 10], check[MAXT + 10] = {};
    memset(check, -1, sizeof(check));
    cin >> n >> t >> e;
    REP(n)
    {
        cin >> w[i];
        for(int j = 1; j * w[i] <= MAXT; j++) check[j * w[i]] = i + 1;
    }
    
    int ans = -1;
    REP(e + 1)
    {
        if(t - i <= 0) continue;
        if(check[t - i] != -1) { ans = check[t - i]; break;}
        if(t + i > MAXT) continue;
        if(check[t + i] != -1) { ans = check[t + i]; break;}
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

const int maxN = 100005;

class TaskC {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		int n, m, x;
		cin >> n >> m >> x;
		vector<int> cost(n);
		vector<vector<int>> increase(n, vector<int>(m));
		for(int i = 0; i < n; i++){
			cin >> cost[i];
			for(int j = 0; j < m; j++){
				cin >> increase[i][j];
			}
		}
		int ans = -1;
		for(int mask = 0; mask < 1<<n; mask++){
			int total = 0;
			vector<int> have(m, 0);
			for(int i = 0; i < n; i++){
				if(mask & (1<<i)){
					for(int j = 0; j < m; j++){
						have[j] += increase[i][j];
					}
					total += cost[i];
				}
			}
			bool valid = true;
			for(int j = 0; j < m; j++){
				if(have[j] < x){
					valid = false;
				}
			}
			if(valid){
				if(ans == -1 or total < ans){
					ans = total;
				}
			}
		}
		cout << ans << endl;

	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskC solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3668
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define v first
#define w second
vector<vector<pair<int,int>>> g;
vector<int> l,r,d,x;
int n,m;
vector<bool> vis;
bool ok=1;

void dfs(int u,int wt=0)
{
	x[u]=wt;
	vis[u]=1;
	for(auto i:g[u])
	{
		if(vis[i.v])continue;
		dfs(i.v, x[u]+i.w);
	}
}


int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	#endif
	cin>>n>>m;
	g=vector<vector<pair<int,int>>>(n+1);
	l=r=d=vector<int>(m);vis=vector<bool>(n);
	x=vector<int>(n,-1);
	for(int i=0;i<m;i++)
	{
		cin>>l[i]>>r[i]>>d[i];
		l[i]--;r[i]--;
		g[l[i]].push_back({r[i],d[i]});
		g[r[i]].push_back({l[i],-d[i]});
	}

	for(int i=0;i<n;i++)
		if(!vis[i])dfs(i);


	for(int i=0;i<m;i++)
	{
		ok&=(x[r[i]]-x[l[i]]==d[i]);
	}
	if(ok)puts("Yes");
	else puts("No");

	

	
}

Measured memory_bytes: 23880
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

auto input() {
    return InputType();
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

int main() {
    size_t n = input();
    size_t a = input();
    size_t b = input();
    auto c = a + b;
    auto d = a * (n / c);
    auto e = min(n % c, a);
    cout << d + e << endl;
    return 0;
}


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

int main(void){
    int x=1 , y=1;
    while ((x !=0) || (y !=0)){
        cin >> x >> y ;
        if((x !=0) || (y !=0)){
            if ( x <= y){
                 cout << x << " " << y << endl;
            }else cout << y << " " << x << endl;            
        }
    }
        return 0;
}


Measured memory_bytes: 3076
#include<iostream>
using namespace std;
int main(){
  string S,T;
  cin>>S>>T;
  bool ans=false;
  for(int i=0;i<S.size();i++){
    if(S==T){
      ans=true;
      break;
    }
    S=S.back()+S.substr(0,S.size()-1);
  }
  if(ans){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  return 0;
}


Measured memory_bytes: 256
N, K = gets.chomp.split(" ").map(&:to_i)
for i in 1..K
    if i > N - K + 1
        puts 0
    else
        puts (1..(i + 1)).to_a.repeated_combination((N - K + 1 - i)).size * (1..i).to_a.repeated_combination(K-i).size % (10**9 + 7)
    end
end

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

//#define int long long
#define X first
#define Y second
#define mp make_pair
#define pr pair
#define vc vector
#define sz(v) (int) v.size()

using namespace std;

typedef long long ll;
typedef long double ld;

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    vc<int> a(n), cnt(1001, 0);
    for (auto &x : a) {
        cin >> x;
        cnt[x]++;
    }
    vc<int> pref(1001);
    for (int i = 1; i <= 1000; ++i) pref[i] = pref[i - 1] + cnt[i];
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            int A = a[i], B = a[j];
            int up = min(1000, A + B - 1), down = max({0, A - B, B - A}) + 1;
            ans += 1ll * (pref[up] - pref[down - 1]);
            if (down <= A && A <= up) ans--;
            if (down <= B && B <= up) ans--;
        }
    }
    cout << ans / 3 << "\n";

    return 0;
}


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

using namespace std;
int main()
{

   int n,cnt=0;
   cin>>n;
   string s;
   cin>>s;
   for(int i=0;i<s.length()-2;i++)
   {
       if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
        cnt++;
   }
   cout<<cnt<<endl;

return 0;

}



Measured memory_bytes: 3632
import collections

N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
c1 = collections.Counter(S)
answer = 0
for word in c1:
    count = c1[word] - T.count(word)
    answer = max(answer, count)
print(answer)    

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

#define ll              long long int
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, k;
    cin >> n >> k;
    vector<int> v(n);

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

    vector<int> dp(n, INT_MAX);
    dp[n-1] = 0;
    dp[n-2] = abs(v[n-1]-v[n-2]);

    for(int i=n-3; i>=0; i--){
        for(int j=1+i; j<= (k+i) and j<n; j++){
            dp[i] = min(dp[i], dp[j] + abs(v[i]-v[j]));
        }
    }
    
    cout<<dp[0]<<"\n";

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    
   int n,a,i,min,max;
   long sum=0;

    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d ",&a);
        sum=sum+a;
        if(i==0){
            min=a; max=a;
        }
        else{
            if(a<min) min=a;
            else if(a>max) max=a;
        }
    }
    
    printf("%d %d %ld\n",min,max,sum);
   
    return 0;
    
}


Measured memory_bytes: 2128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    string S; cin >> S;
    int cnt = 0;
    int N = S.size();
    for(int i=0; i<N; i++){
        if(S[i]=='o') cnt++;
    }
    if(cnt + 15 - N >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int mo=998244353;
int n,ans=1,a[100000+10];
int gcd(int x,int y) {
    if (y==0) return x;
    return gcd(y,x%y);
}
int main() {
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    for (int i=1;i<=n;i++)
        ans=(long long)ans*gcd(i-1,a[i])%998244353;
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int M = max(max(a, b), c);
    int ans = a + b + c - M + M * powl(2, k);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#include<string.h>
using namespace std;
int main()
{ 
  long long int i,a;
 for(i=0;i<5;i++)
 {cin>>a;
  if(a==0)
      break;
 }
    cout<<i+1<<"\n";
}

Measured memory_bytes: 3592
from functools import reduce
def gcd(a, b):
    while b: a, b = b, a % b
    return a
def lcm(a, b):
    return b//gcd(a, b)*a

P = 10**9+7
N = int(input())
A = [int(a) for a in input().split()]
print(reduce(lcm, A) % P * sum([pow(a, P-2, P) for a in A]) % P)

Measured memory_bytes: 42332
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  xyhs <- replicateM n $ map read . words <$> getLine
  let [xt, yt, ht] = head [ [x, y, h] | [x, y, h] <- xyhs, h > 0 ]
  putStrLn $ unwords $ map show $ solve xt yt ht xyhs

solve :: Int -> Int -> Int -> [[Int]] -> [Int]
solve xt yt ht xyhs =
  let
    (cx, cy) = head $ foldl (step xt yt ht) ((,) <$> [0 .. 100] <*> [0 .. 100]) xyhs
  in
    [cx, cy, ht + abs (xt - cx) + abs (yt - cy)]

step :: Int -> Int -> Int -> [(Int, Int)] -> [Int] -> [(Int, Int)]
step xt yt ht cxys [x, y, h] =
  [ (cx, cy)
  | (cx, cy) <- cxys
  , let ch = ht + abs (xt - cx) + abs (yt - cy)
  , h == (ch - abs (x - cx) - abs (y - cy)) `max` 0
  ]

Measured memory_bytes: 1148
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
template <class T>
bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
template <class T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main() {
	lint n; cin >> n;
	lint ans = 0;
	lint cnt = 0;
	lint minn = INF;
	for (int i = 0; i < n; i++) {
		lint x; cin >> x;
		if (x < 0) cnt++;
		ans += abs(x);
		minn = min(minn, abs(x));
	}
	if (cnt % 2 == 0) printf("%lld\n", ans);
	else printf("%lld\n", ans - minn * 2);

	return 0;
}

Measured memory_bytes: 3732
from collections import deque
from enum import Enum

class Color(Enum):
  WHITE = 0
  GRAY = 1
  BLACK = 2


N = int(input())
adj = [list(map(int, input().split()))[2:] for i in range(N)]


colors = [Color.WHITE for i in range(N)]
INF = N
d = [-1 for i in range(N)]
d[0] = 0

q = deque()
q.append(1)
colors[0] == Color.GRAY
while len(q) > 0:
  u = q.popleft()-1
  for v in adj[u]:
    v -= 1
    if colors[v] != Color.WHITE:
      continue
    d[v] = d[u] + 1
    colors[v] = Color.GRAY
    q.append(v+1)
  colors[u] = Color.BLACK

for i in range(N):
  print(i+1, d[i])


Measured memory_bytes: 6376
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()

ll mod = 1000000007;



int main() {

	ll H, W, K;
	cin >> H >> W >> K;

	vector<vector<ll>> dp(H + 1, vector<ll>(W, 0));
	dp[0][0] = 1;

	fori(i, 1, H + 1) {
		rep(j, W) {
			rep(k, 1 << (W - 1)) {
				bool ok = true;
				rep(l, W - 2) {
					if (((k >> l) & 1) && ((k >> (l + 1)) & 1)) {
						ok = false;
					}
				}
				if (ok) {
					if (j >= 1 && ((k >> (j - 1)) & 1)) {
						dp[i][j - 1] += dp[i - 1][j];
						dp[i][j - 1] %= mod;
					}
					else if (j <= W - 2 && ((k >> j) & 1)) {
						dp[i][j + 1] += dp[i - 1][j];
						dp[i][j + 1] %= mod;
					}
					else {
						dp[i][j] += dp[i - 1][j];
						dp[i][j] %= mod;
					}
				}
			}
		}
	}

	cout << dp[H][K - 1] << endl;
}

Measured memory_bytes: 256
while True:
    n = float(raw_input())
    if n<0.0 : break
    st = ""
    a = int(n)
    b = n - a
    for i in range(8):
        st = str(a%2) + st
        a /= 2
    st += "."
    for i in range(4):
        b *= 2
        st += str( int(b) )
        b -= int(b)
    if a>0 or b>0.00000000 :
        print "NA"
    else :
        print st
    

Measured memory_bytes: 4248
using System;
namespace Answer{
	class Program {
  		public static void Main(string[] args) {
            char[] charSeparators = new char[] {' '};
    		var values = Console.ReadLine().Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);
    		var A = int.Parse(values[0]);
    		var B = int.Parse(values[1]);
    		var C = int.Parse(values[2]);
    
    		var ans = Math.Max(0, C - (A - B));
    		Console.WriteLine(ans);
  		}
	}
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, ans = 0,b;
  cin >> n;
  vector<ll> a(n);
  priority_queue<ll> q;
  rep(i, n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  q.push(a[0]);
  for (int i = 1; i < n; ++i)  {
    ans += q.top();
    q.pop();
    q.push(a[i]), q.push(a[i]);
   }

  // if (n == 2) ans = a[0];

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


Measured memory_bytes: 6928
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}


int main() {
    string a, b;
    R a>>b;
    a+=b;
    int n=stoi(a);
    rep(i, n){
        if(i*i==n){
            co("Yes");
            return 0;
        }
    }
    co("No");
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    H, N = map(int, input().split())
    A = []
    B = []
    for _ in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    A_max = max(A)
    dp = [1e14] * (H+A_max + 1) # ダメージ量がiの最小コスト
    dp[0] = 0
    for i in range(H):
        for j in range(N):
            dp[i+A[j]] = min(dp[i+A[j]], dp[i]+B[j])

    ans = 1e30
    for i in range(H, H+A_max+1):
        ans = min(ans, dp[i])
    print(ans)
main()

Measured memory_bytes: 73740
s = input()
ans = 0

if len(s)==1:
    if s.count("A")+s.count("G")+s.count("C")+s.count("T") == 1:
        print(1)
        exit()

 
for i in range(len(s)-1):
    for j in range(i+1, len(s)+1):
        x = s[i:j]
        if x.count("A")+x.count("G")+x.count("C")+x.count("T") == len(x) and len(x) > ans:
            ans = len(x)
 
print(ans)

Measured memory_bytes: 38384
#include<stdio.h>
int main()
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==7&&b==5&&c==5)
  {
    printf("YES");
  }
  else if(b==7&&a==5&&c==5)
  {
    printf("YES");
  }
  else if(c==7&&a==5&&b==5)
  {
    printf("YES");
  }
  else
  {
    printf("NO");
  }
    return 0;
}

Measured memory_bytes: 1708
import java.util.*;

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

      int n = Integer.parseInt(sc.next());

      int ans = 0;

      if(n==1){
        ans = 1;
      }
      if(n==2){
        ans = 8;
      }
      if(n>=3){
        int a = n;
        int b = n*(n-1)*(n-2);
        int c = 6*n*(n-1)/2;
        ans = a + b + c;
      }

      System.out.println(ans);

    }
}


Measured memory_bytes: 21972
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
 
int main() {
    int n;
    cin >> n;
    if (n / 100 == n % 10) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#define NDEBUG
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

#ifdef NDEBUG
# define dump(x)
# define debug if (0)
#else
# define dump(x) cerr << __LINE__ << ": " << (#x) << " = " << x << endl
# define debug
#endif

pair<vector<int>, map<int, int>> compress(vector<int> poss) {
  sort(begin(poss), end(poss));
  auto last = unique(begin(poss), end(poss));
  vector<int> allPos(begin(poss), last);
  map<int, int> compressed;
  int N = allPos.size();
  for (int i = 0; i < N; i++)
    compressed[allPos[i]] = i;
  return { move(allPos), move(compressed) };
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> ls(N), rs(N), ts(N), bs(N);
  vector<int> xs, ys;
  for (int i = 0; i < N; i++) {
    cin >> ls[i] >> bs[i] >> rs[i] >> ts[i];
    xs.push_back(ls[i]);
    xs.push_back(rs[i]);
    ys.push_back(ts[i]);
    ys.push_back(bs[i]);
  }
  auto&& xcs = compress(move(xs)), ycs = compress(move(ys));
  auto& xps = xcs.first, yps = ycs.first;
  auto& nx = xcs.second, ny = ycs.second;
  int xpos = xps.size(), ypos = yps.size();
  dump(xpos);
  dump(ypos);
  debug {
    for (auto x: xps)
      cerr << x << ' ';
    cerr << endl;
    for (auto y: yps)
      cerr << y << ' ';
    cerr << endl;
  }
  vector<vector<int>> count(xpos + 1, vector<int>(ypos + 1));
  for (int i = 0; i < N; i++) {
    count[nx[ls[i]]][ny[bs[i]]]++;
    count[nx[ls[i]]][ny[ts[i]]]--;
    count[nx[rs[i]]][ny[bs[i]]]--;
    count[nx[rs[i]]][ny[ts[i]]]++;
  }
  for (int i = 0; i < xpos; i++)
    for (int j = 0; j < ypos; j++)
      count[i][j + 1] += count[i][j];
  for (int i = 0; i < xpos; i++)
    for (int j = 0; j < ypos; j++)
      count[i + 1][j] += count[i][j];

  debug {
    for (int i = 0; i <= xpos; i++) {
      for (int j = 0; j <= ypos; j++) {
        cout << count[i][j] << ' ';
      }
      cout << endl;
    }
  }

  long long ans = 0;
  for (int i = 0; i < xpos; i++) {
    for (int j = 0; j < ypos; j++) {
      if (count[i][j] == 0) continue;
      debug {
        cerr << i << ' ' << j << ": " << (xps[i + 1] - xps[i]) << ' ' << yps[j + 1] - yps[j] << endl;
      }
      ans += ((long long)xps[i + 1] - (long long)xps[i]) * ((long long)yps[j + 1] - (long long)yps[j]);
    }
  }
  cout << ans << endl;
}



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

struct Data{
  string name;
  int C,V,D,L;
  Data(){};
  Data(string s,int c,int v,int d,int l){name=s;C=c;V=v;D=d;L=l;}
};
int main()
{
  int N,M;
  int C,V,D,L;
  string s;
  while(cin>>N>>M){
    vector<Data>bydol(N);
    for(int i=0;i<N;i++){
      cin.ignore();
      getline(cin,s);
      cin>>C>>V>>D>>L;
      bydol[i]=Data(s,C,V,D,L);
    }

    vector< vector<int> >dpV(N+1,vector<int>(M+1,0));
    vector< vector<int> >dpD(N+1,vector<int>(M+1,0));
    vector< vector<int> >dpL(N+1,vector<int>(M+1,0));
    for(int i=0;i<N;i++){
      dpV[i+1]=dpV[i];
      dpD[i+1]=dpD[i];
      dpL[i+1]=dpL[i];
      for(int j=bydol[i].C;j<=M;j++){
	dpV[i+1][j]=max(dpV[i+1][j],dpV[i+1][j-bydol[i].C]+bydol[i].V);
	dpD[i+1][j]=max(dpD[i+1][j],dpD[i+1][j-bydol[i].C]+bydol[i].D);
	dpL[i+1][j]=max(dpL[i+1][j],dpL[i+1][j-bydol[i].C]+bydol[i].L);
      }
    }
    int ans=0;
    for(int j=0;j<=M;j++){
      ans=max(ans,dpV[N][j]);
      ans=max(ans,dpD[N][j]);
      ans=max(ans,dpL[N][j]);
    }
    cout<<ans<<endl;
  }
}

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


def solve(a: int, b: int, c: int, d: int, e: int, k: int):
    print('Yay!' if e - a <= k else ':(')



# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    e = int(next(tokens))  # type: int
    k = int(next(tokens))  # type: int
    solve(a, b, c, d, e, k)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9144
#include<bits/stdc++.h>
typedef long long ll;
typedef long long INT;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define ALL(x) x.begin(),x.end()
#define VI vector<int>
using namespace std;
/*........................................Define functions.........................................*/
set<int> factors(int n) {
	set<int> ret;
	for (int i = 1; i * i <= n; i++) {//まずは素因数だけ追加
		if (n % i == 0) {ret.insert(i); ret.insert(n / i);}
	}
	return ret;
}
/*....................................Define global variables .....................................*/

/*.........................................kemkemG0................................................*/
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N;
	cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i];
	sort(ALL(A));
	if (N == 1) {cout << A[0] << endl; return 0;}

	set<int> f1, f2;
	f1 = factors(A[0]);
	f2 = factors(A[1]);

	set<int> st;
	for (auto m : f1) {st.insert(m);}
	for (auto m : f2) {st.insert(m);}

	set<int> ans_list;

	for (auto s : st) {
		int n = 0;
		for (auto v : A) { if (v % s == 0) {n++;} }
		if (n == N - 1 || n == N) ans_list.insert(s) ;
	}

	auto itr = ans_list.end(); itr--;
	int ans = *itr;

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3720
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> smt(1,0);
  vector<int> ksmt(1,0);
  int a;
  for(int i=1;i<10000;i++){
    a=i*(i+1)*(i+2)/6;
    smt.push_back(a);
    if(a%2==1)ksmt.push_back(a);
    if(a>1000000)break;
    //cout << a << endl;
  }
    //cout <<smt.size()<<" "<<ksmt.size()<<endl;
  int dp[2][1000001]={};
  //cout <<"2"<<endl;
  //
  for(int i=1;i<=1000000;i++){
    dp[0][i]=i;
    dp[1][i]=i;
  }
  //all
  for(int i=1;i<smt.size();i++){
    for(int j=1;j<=1000000;j++){
      if(smt[i]>j) dp[0][j]=dp[0][j];
      else{
	dp[0][j]=min(dp[0][j],dp[0][j-smt[i]]+1);
      }
      //cout <<dp[k][j]<<" ";
    }
  }
  //kisuu
  for(int i=1;i<ksmt.size();i++){
    for(int j=1;j<=1000000;j++){
      if(ksmt[i]>j) dp[1][j]=dp[1][j];
      else{
	dp[1][j]=min(dp[1][j],dp[1][j-ksmt[i]]+1);
      }
    }
  }
  while(1){
    int n;
    cin >> n;
    if(n==0)break;
    cout << dp[0][n]<<" "<<dp[1][n]<<endl;
  }
return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;

    if (a < b)
    {
        cout << "a < b" << endl;
    }
    else if (a > b)
    {
        cout << "a > b" << endl;
    }
    else
    {
        cout << "a == b" << endl;
    }
}



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

using namespace std;

#define FOR(i, j, k, in) for (int i = j; i < k; i += in)
#define RFOR(i, j, k, in) for (int i = j; i >= k; i -= in)
#define REP(i, j) FOR(i, 0, j, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

#define IOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

#define int long long

int dp[100+5][100000 + 5];
int a[100+5];
signed main()
{
    IOS int n, k;
    cin >> n >> k;
    REP(i, n)
    cin >> a[i];
    sort(a,a+n);
    if(k==0 && a[n-1]!=0)
    {
        cout << 0;
        return 0;
    }
    if(k==0&&a[n-1]==0)
    {
        cout << 1;
        return 0;
    }
    REP(i, k + 1)
    {
        REP(j, n)
        {
            if (i == 0)
                dp[j][0] = 1;
            else if (j == 0)
            {
                if (a[0] >= i)
                    dp[j][i] = (dp[j][i - 1] + 1) % MOD;
                else
                    dp[j][i] = dp[j][i - 1];
            }
            else
            {
                int ind = 0;
                if(i>a[j])
                    ind = i-a[j];
                dp[j][i] = (dp[j - 1][i] + dp[j][i - 1]) % MOD;
                if (ind)
                    dp[j][i] = (dp[j][i] - dp[j - 1][ind - 1]) % MOD;
            }
        }
    }
    int ans =  (dp[n - 1][k] - dp[n - 1][k - 1]) % MOD ;
    if(ans<0)   ans += MOD;
    cout << ans << "\n";
}

Measured memory_bytes: 80128
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <unordered_map>

int main()
{
	unsigned long long N = 0, ans = 0;

	std::cin >> N;
	std::vector<std::string> S(N);

	std::unordered_map<std::string, long long> mp;
	std::unordered_map<std::string, long long>::iterator itr = mp.begin();

	for (long long i = 0; i < N; i++)
	{
		std::cin >> S[i];
		std::sort(S[i].begin(), S[i].end());
		mp[S[i]] += 1;
	}

	for(auto& s : mp) {
		ans += s.second * (s.second - 1) / 2;
	}

	std::cout << ans << std::endl;

	return 0;
}

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

int main(){
	int n;
	cin >> n;
	int dp[n][3];
	for(int i=0 ; i<n ; i++){
		int a,b,c;
		cin >> a >> b >> c;
		if(i==0){dp[i][0]=a; dp[i][1]=b; dp[i][2]=c; continue;}

		dp[i][0] = a + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = b + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = c + max(dp[i-1][0],dp[i-1][1]);

	}

	cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << "\n";
	return 0;
}

Measured memory_bytes: 1408
N, M = map(int, input().split())

like_total = [0]*M
cnt = 0
for _ in range(N):
    l = list(map(int, input().split()))
    for i in range(1, l[0]+1, 1):
        like_total[l[i]-1] += 1

for v in like_total:
    cnt += v==N
print(cnt)


Measured memory_bytes: 3060
n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]

count = {}

for v in s:
    count[v] = count.get(v, 0) + 1

def sig(k):
    return ((k + 1) * k) // 2

ans = 0
for key, value in count.items():
    ans += (sig(value - 1))
print(ans)


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

template<class t> void vin(vector<t>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll N, x;
    cin >> N >> x;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0;
    rep(i, N) {
        if (x >= a[i]) {
            x -= a[i];
            ans++;
        }
        else {
            x = 0;
            break;
        }
    }
    if (x > 0) ans--;
    if (ans < 0) ans = 0;
    cout << ans << endl;
}


Measured memory_bytes: 256
N,A,B,C = map(int,input().split())
L = [int(input()) for i in range(N)]

def cost(group,target):
    res = 10*(len(group)-1)
    return res + abs(sum(group)-target)

ans = []
for i in range(1<<(2*N)):
    groupA = []
    groupB = []
    groupC = []
    for j in range(N):
        s = i>>(2*j)
        if (s & 3) == 3:
            groupA.append(L[j])
        elif (s & 2) == 2:
            groupB.append(L[j])
        elif (s & 1) == 1:
            groupC.append(L[j])
    
    if len(groupA)==0 or len(groupB)==0 or len(groupC)==0:
        pass
    else:
        ans.append(cost(groupA,A)+cost(groupB,B)+cost(groupC,C))
print(min(ans))

Measured memory_bytes: 5004
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ ) {
    if ( A[j] <= x ) {
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}

int main() {
  int i, q;

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

  q = partition(0, n - 1);

  for ( i = 0; i < n; i++) {
    if ( i ) printf(" ");
    if ( i == q) printf("[");
    printf("%d", A[i]);
    if ( i == q) printf("]");
  }
  printf("\n");

  return 0;
}

    



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

int main() {
	int sum;
	int a,b;
	
	cin >> a >> b;
	
	sum = a+b;
	
	if(sum % 2 == 0){
		cout << sum / 2;
	}else{
		cout << "IMPOSSIBLE";
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;

bool cmp(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.second > right.second;
}

int main() {

	int n, m;
	lli b, c;
	lli temp = 0, ans = 0;

	cin >> n >> m;
	
	vector<int> vec(n);
	rep0(i, n) {
		cin >> vec[i];
		ans += vec[i];
	}

	vector<pair<lli, lli>> change(m);
	rep0(i, m) {
		cin >> b >> c;
		change[i]=make_pair(b,c);
	}
	sort(all(vec));
	sort(all(change), cmp);


	rep0(i, m) {
		
		
		for (lli j = temp; j < temp + change[i].first;j++) {
			if (j >= n)break;
			if (vec[j] >= change[i].second)break;
			ans += change[i].second-vec[j];
		}
		temp += change[i].first;
		if (temp >= n)break;
		
	}
	cout << ans;

}

Measured memory_bytes: 2176
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
string a;
int main()
{
	cin>>a;
	int k = a.length();
	for(int i = 0; i < k; i++){
		if(a[i] == '9'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
    }
    if a - b > c {
        println!("0");
    } else {
    println!("{}", c - (a - b));
    }
}


Measured memory_bytes: 4352
def main():
    N, K = input().split()
    N = int(N)
    K = int(K)

    inputs = input().split()
    h = [int(i) for i in inputs]

    c = 0

    for hh in h:
        if hh >= K:
            c += 1

    print(c)

if __name__ == "__main__":
    main()


Measured memory_bytes: 11904
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef long long i64;
//#define rep(i,n) for(int i=0;i<n;++i)
#define _vcppunko4(tuple) _getname4 tuple
#define _getname4(_1,_2,_3,_4,name,...) name
#define _getname3(_1,_2,_3,name,...) name
#define _trep2(tuple) _rep2 tuple
#define _trep3(tuple) _rep3 tuple
#define _trep4(tuple) _rep4 tuple
#define _rep1(n) for(lint i=0;i<n;++i)
#define _rep2(i,n) for(lint i=0;i<n;++i)
#define _rep3(i,a,b) for(lint i=a;i<b;++i)
#define _rep4(i,a,b,c) for(lint i=a;i<b;i+=c)
#define _trrep2(tuple) _rrep2 tuple
#define _trrep3(tuple) _rrep3 tuple
#define _trrep4(tuple) _rrep4 tuple
#define _rrep1(n) for(lint i=n-1;i>=0;--i)
#define _rrep2(i,n) for(lint i=n-1;i>=0;--i)
#define _rrep3(i,a,b) for(lint i=b-1;i>=a;--i)
#define _rrep4(i,a,b,c) for(lint i=a+(b-a-1)/c*c;i>=a;i-=c)
#define rep(...) _vcppunko4((__VA_ARGS__,_trep4,_trep3,_trep2,_rep1))((__VA_ARGS__))
#define rrep(...) _vcppunko4((__VA_ARGS__,_trrep4,_trrep3,_trrep2,_rrep1))((__VA_ARGS__))

int main(){
  lint n,ans=0,tmp=0; cin>>n;
  vector<lint>a(n); rep(n)cin>>a[i];
  rep(i,n-1){//rep(i,0,n)
    if(a[i]<a[i+1])tmp=0;
    else ++tmp;
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
[x1, x2, y1 ,y2] = [int(i) for i in input().split()]
max = x1 * y1
x = [x1, x2]
y = [y1, y2]
for num_x in x:
    for num_y in y:
        re = num_x * num_y
        if re >= max:
            max = re
print(max)

Measured memory_bytes: 9156