akhauriyash/Code-Regression huggingface dataset:
<?php
  
while ($line = fgets(STDIN)) {
   $stdin[] = trim($line);
}
#$v2 = str_split($stdin[0]);
$v2 = explode(" ", $stdin[0]);

#var_dump($v2);

$res[] = $v2[0] + $v2[1];
$res[] = $v2[0] - $v2[1];
$res[] = $v2[0] * $v2[1];

$ans = max($res);

echo $ans . PHP_EOL;



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

int main()
{ 
   int n;
   cin>>n;
   pair<int,int> a[n],b[n];
   for(int i=0;i<n;i++){
       int x,y;
       cin>>x>>y;
       a[i]=make_pair(x,y);
   }
   for(int i=0;i<n;i++){
       int x,y;
       cin>>x>>y;
       b[i]=make_pair(y,x);
   }
   sort(a,a+n);
   reverse(a,a+n);
   sort(b,b+n);
   int ans=0;
   int used[n];
   for(int i=0;i<n;i++){
       used[i]=0;
   }
   for(int i=0;i<n;i++){
       for(int j=0;j<n;j++){
           if(a[i].first<b[j].second && a[i].second<b[j].first && used[j]==0){
               used[j]=1;
               ans++;
               break;
           }
       }
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final long n = scanner.nextInt();
        final int k = scanner.nextInt();

        if (k == 0) {
            System.out.println(n * n);
            return;
        }

        long answer = 0;
        for (int b = k + 1; b <= n; b++) {
            answer += n / b * (b - k) + Math.max(n % b - k + 1, 0);
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 24148
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int a[maxn],b[maxn],n,m;
int main()
{
    int N;
    scanf("%d",&N);
    for(int i=1,x;i<=N;i++)
    {
        scanf("%d",&x);
        if(x>=0)
            a[++n]=x;
        else
            b[++m]=x;
    }
    if(m==0)
    {
        int sum=0;
        sort(a+1,a+n+1);
        for(int i=1;i<=n;i++)
            sum+=a[i];
        sum-=2*a[1];
        printf("%d\n",sum);
        int cnt=a[1];
        for(int i=n-1;i>1;i--)
        {
            printf("%d %d\n",cnt,a[i]);
            cnt-=a[i];
        }
        printf("%d %d\n",a[n],cnt);
    }
    else if(n==0)
    {
        int sum=0;
        sort(b+1,b+m+1);
        for(int i=1;i<=m;i++)
            sum-=b[i];
        sum+=2*b[m];
        int cnt=b[m];
        printf("%d\n",sum);
        for(int i=1;i<m;i++)
        {
            printf("%d %d\n",cnt,b[i]);
            cnt-=b[i];
        }
    }
    else
    {
        int sum=0;
        for(int i=1;i<=n;i++)
            sum+=a[i];
        for(int i=1;i<=m;i++)
            sum-=b[i];
        printf("%d\n",sum);
        int cnt1=a[1];
        for(int i=2;i<=m;i++)
        {
            printf("%d %d\n",cnt1,b[i]);
            cnt1-=b[i];
        }
        int cnt2=b[1];
        for(int i=2;i<=n;i++)
        {
            printf("%d %d\n",cnt2,a[i]);
            cnt2-=a[i];
        }
        printf("%d %d\n",cnt1,cnt2);
    }
    return 0;
}


Measured memory_bytes: 2304
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {

		Scanner scanner = new Scanner(System.in);// ??\?????????????????????
		int count = scanner.nextInt();
		int flag = 0;
		
		for(int i = 0; i < count; i++){
			int num = scanner.nextInt();
			for(int j = (int) Math.sqrt(num); 1 < j; j--){
				if(j == 1){
					break;
				}
				if(num % j == 0){
					flag++;
					break;
				} 
			}
		}
		System.out.println(count - flag);
	}
}

Measured memory_bytes: 40852
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n;
vector<P> g[100005];

void rec(int now, int from, int c, int ma, vector<int>& ans) {
  REP(i, g[now].size()) {
    if(g[now][i].first == from) continue;
    c = (c + 1) % ma;
    ans[g[now][i].second] = c;
    rec(g[now][i].first, now, c, ma, ans);
  }
}

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

  cin >> n;

  REP(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(P(b, i));
    g[b].push_back(P(a, i));
  }

  int ma = 0;
  REP(i, n) ma = max(ma, (int)g[i].size());

  vector<int> ans(n);
  rec(0, -1, -1, ma, ans);

  cout << ma << endl;
  REP(i, n - 1) cout << ans[i] + 1 << endl;
}


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

using namespace std;

typedef long long ll;

bool prime(ll n) {
	for (int i = 2; i <= sqrt(n); i++) {
    	if (n % i == 0)	return false;	
    }
  	return true;
}

ll next(ll n) {
	while (!prime(n)) {
    	n++;	
    }
  	return n;
}

int main() {
	ll x;
  	cin >> x;
  	cout << next(x) << endl;
  	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

/*
3
10 40 70
20 50 80
30 60 90

210
 */
public class Main {
    static long[][] mindist;
    static int[][] graph;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        mindist = new long[1000000][3];
        for (long[] longs : mindist) {
            Arrays.fill(longs, 0);
        }

        graph = new int[N][3];
        for (int i = 0; i < N; i++) {
            for (int k = 0; k < 3; k++) {
                graph[i][k] = scanner.nextInt();
            }
        }

        for (int i = 0; i < N; i++) { // prev_dist
            for (int k = 0; k < 3; k++) { // act_prev
                for (int s = 0; s < 3; s++) { // act_now
                    if (k == s) {
                        continue;
                    }
                    if (mindist[i + 1][k] < mindist[i][s] + graph[i][k]) {
                        mindist[i + 1][k] = mindist[i][s] + graph[i][k];
                    }
                }
            }
        }

        System.out.println(Math.max(Math.max(mindist[N][0], mindist[N][1]), mindist[N][2]));
    }
}

Measured memory_bytes: 142548
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

vector<vector<int> >adj;
int vis[100005];
int ind=1;
int parent[100005];

void dfs(int ver,int pr)
{
    parent[ver]=pr;
    vis[ver]=1;
    int cnt=0;
    for(auto i:adj[ver])
    {
        if(!vis[i])
        {
            ++cnt;
            dfs(i,ver);
        }
        else if(vis[i]==2)
        {
            cnt++;
        }
    }
    vis[ver]=2;
    if(cnt==0)
    {
        ind=ver;
        return ;
    }
}

vector<int>path;
int fi=0;
void dfs2(int ver,int pr)
{
    if(fi)
        return ;
    vis[ver]=1;
    parent[ver]=pr;
    int x=0;
    if(!path.empty())
    {
        x=path.back();
        path.pop_back();
        dfs2(x,ver);
    }

    int cnt=0;
    for(auto i:adj[ver])
    {
        if(x!=0 && i==x)
            continue;
        if(!vis[i])
        {
            ++cnt;
            dfs2(i,ver);
        }
        else if(vis[i]==2)
        {
            cnt++;
        }
    }

    if(cnt==0 && fi==0)
    {
        fi=ver;
        return ;
    }
    vis[ver]=2;
}


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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n,m;
    cin>>n>>m;
    adj.resize(n+1);
    int x,y;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    
    dfs(1,0);
    int ini=ind;
    while (ini!=1)
    {
        path.push_back(ini);
        ini=parent[ini];
    }
    path.push_back(1);
    fill_n(vis,n+1,0);
    reverse(path.begin(),path.end());
    x=path.back();
    path.pop_back();
    dfs2(x,0);
    path.clear();
    while (fi!=ind)
    {
        path.push_back(fi);
        fi=parent[fi];
    }
    path.push_back(fi);
    cout<<path.size()<<'\n';
    for(auto i:path)
        cout<<i<<" ";

} 
    


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

using namespace std;

int main (void) {
    string S;
    cin >> S;

    int ans = 0;
    for ( int i = 0; i < S.size(); i++ ) {
        switch ( S.at(i) ) {
            case '+':
                ans++;
                break;
            case '-':
                ans--;
                break;
            default:
                assert(true);
        }
    }

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


Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long H,W;
    cin >> H>>W;
    if(H == 1 || W ==1 ){
        cout <<1;
        return 0;
    }
    else if(H%2 != 0 && W%2 != 0 ){
    cout << H*W/2 +1 ;
    return 0;
    }
    
    else cout << H * W /2;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    mp[x]++;
  }
  int ans = 0;
  for (auto x : mp) {
    if (x.first == x.second) continue;
    if (x.first < x.second) {
      ans += x.second - x.first;
      continue;
    }
    ans += x.second;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 4736
N = int(input())
A = list(map(int,input().split()))
L = []
ans = 0
for i in range(N):
  L.append(A[i] - (i + 1))
L = sorted(L)
B = L[N // 2]
for i in range(N):
  ans += abs(A[i]-(B + i + 1))
print(ans)


Measured memory_bytes: 25200
#include <iostream>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;
void init();
#ifdef DEBUG_BUILD
#define DBG(expr) cout << #expr << " = " << expr << endl;
#endif
#define ECHO(expr) cout << expr << endl;
#define REP(var, num) for(ll var = 0; var < num; var++)
#define REP_FROM(var, from, num) for(ll var = from; var < num; var++)
#define MAX_OF(type) numeric_limits<type>::max()
#define MIN_OF(type) numeric_limits<type>::min()
#define SORT(vec) sort(vec.begin(), vec.end())
#define REVERSE(vec) reverse(vec.begin(), vec.end())
#define T_FIRST(tuple) (std::get<0>(tuple))
#define T_SECOND(tuple) (std::get<1>(tuple))
#define T_THIRD(tuple) (std::get<2>(tuple))
typedef signed long long ll;
typedef unsigned long long ull;

void solve() {
    ll n;
    cin >> n;
    ll ans = 0;
    ll max_h = 0;
    REP(i, n) {
        ll h;
        cin >> h;
        if (h >= max_h) {
            ans++;
            max_h = h;
        }
    }

    ECHO(ans)
}

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

#ifdef INPUT_FILE
    if (!freopen(INPUT_FILE, "r", stdin)) {
        perror("freopen");
        exit(1);
    }
#endif

    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include <set>

void renew(std::pair<int, int>& a, const std::pair<int, int> pair) {
	if (a.first < pair.first) {
		a = pair;
	}
	else if (a.first == pair.first && a.second > pair.second) {
		a = pair;
	}
}
int main() {
	while (true) {
		int n; std::cin >> n; if (n == 0) break;
		std::vector<int> price(n); for (auto& p : price) std::cin >> p;
		std::vector<std::vector<std::pair<int, int>>> memo(2, std::vector<std::pair<int, int>>(n * 500 + 1, std::make_pair(-1, 0))); memo[0][0].first = 0;
		for (const auto p : price) {
			if (p % 1000 == 0) {
				for (auto i = 0; i < memo[0].size(); ++i) {
					if (memo[0][i].first >= 0) {
						renew(memo[1][i], memo[0][i]);
						if (i >= 500) {
							renew(memo[1][i - 500], std::make_pair(memo[0][i].first + 1, memo[0][i].second + p));
						}
					}
				}
			}
			else if (p % 1000 == 500) {
				for (auto i = 0; i < memo[0].size(); ++i) {
					if (memo[0][i].first >= 0) {
						renew(memo[1][i], memo[0][i]);
						renew(memo[1][i], std::make_pair(memo[0][i].first + 1, memo[0][i].second + p));
					}
				}
			}
			else if (p % 1000 <= 500) {
				const auto diff = 500 - p % 500;
				for (auto i = 0; i < memo[0].size(); ++i) {
					if (memo[0][i].first >= 0 ) {
						renew(memo[1][i], memo[0][i]);
						if (i + diff < memo[1].size())
							renew(memo[1][i + diff], std::make_pair(memo[0][i].first + 1, memo[0][i].second + p));
					}
				}
			}
			else {
				const auto diff = 500 - p % 500;
				for (auto i = 0; i < memo[0].size(); ++i) {
					if (memo[0][i].first >= 0) {
						renew(memo[1][i], memo[0][i]);
						if (i >= p % 500) {
							renew(memo[1][i - p % 500], std::make_pair(memo[0][i].first + 1, memo[0][i].second + p));
						}
						if (i + diff < memo[1].size()) {
							renew(memo[1][i + diff], std::make_pair(memo[0][i].first, memo[0][i].second + p));
						}
					}
				}
			}
			std::swap(memo[0], memo[1]);
		}
		const auto res = *std::max_element(memo.front().begin(), memo.front().end(), [](std::pair<int, int>& a, const std::pair<int, int>& b) {return a.first == b.first ? a.second > b.second : a.first < b.first; });
		std::cout << res.first << ' ' << res.second << '\n';
	}
}


Measured memory_bytes: 3952
from collections import defaultdict

n, k = map(int, input().split())

ddict = defaultdict(int)
li_a = list(input().split())

for a in li_a:
    ddict[a] += 1

counter = 0
for w in sorted(ddict, key=lambda x: ddict[x], reverse=True)[k:]:
    counter += ddict[w]

print(counter)

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

int main() {
	int n,k;
	cin>>n>>k;
	vector<int>a(n);
	int minVal = INT_MAX;
	for(int i = 0 ; i < n ; i++){ 
	    cin>>a[i];
	    minVal = min(minVal , a[i]);
	}
	vector<int>dp(k+1);
	
	if(k < minVal){
	    cout<<"Second\n";
	}
	else{
	    for(int i = 0 ; i < minVal ; i++) dp[i] = -1;
	    for(int i = minVal ; i <= k ; i++){
	        int x = 1;
	        for(int j = 0 ; j < n ; j++){
	            if(i >= a[j]) x = min(x,dp[i-a[j]]);
	        }
	        if(x == -1) dp[i] = 1;
	        else dp[i] = -1;
	    }
	    if(dp[k] == -1) cout<<"Second\n";
	    else cout<<"First\n";
	}
	
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
/*----------------------------------------------------------------------------------*/


int main() {
    int h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];

    vector<vector<bool>> ok(h, vector<bool>(w,false));
    
    // h->h, w->w, grid[][]->s[][]
    auto bfs = [&](int sy, int sx) -> ll {
        ll a = 0, b = 0;
        queue<pair<int, int>> que;
        que.push(make_pair(sy, sx));
        ok[sy][sx] = true;
        while(!que.empty()) {
            pair<int, int> cur = que.front(); que.pop();
            int cy = cur.first, cx = cur.second;
            if (s[cy][cx] == s[sy][sx]) a++;
            else b++;

            for(int i = 0; i < 4; ++i) {
                int ny = cy + dy[i], nx = cx + dx[i];
                if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
    
                if(ok[ny][nx]) continue;

                if(s[ny][nx] != s[cy][cx]) {
                    // cout << ny << ' ' << nx << endl;
                    que.push(make_pair(ny, nx));
                    ok[ny][nx] = true;
                }
            }
        }
        return a*b;
    };

    ll ans = 0;
    rep(i,h) rep(j,w) {
        if (!ok[i][j]) ans += bfs(i,j);
        // cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int x,y,z;
  cin>>x>>y>>z;
  int temp = x;
  x = y;
  y = temp;
  int temp2 = x;
  x = z;
  z = temp2;
  cout<<x<<" "<<y<<" "<<z;
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>

using namespace std;

int main () {
    int a, b, r = 0;
    char op;
    cin >> a >> op >> b;
    while (op != '?') {
        switch (op) {
            case '+' : {
                cout << a + b << endl;
                break;
            }
            case '-' : {
                cout << a - b << endl;
                break;
            }
            case '*' : {
                cout << a * b << endl;
                break;
            }
            case '/' : {
                cout << a / b << endl;
                break;
            }
        }
        cin >> a >> op >> b;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1};
typedef pair<ll, ll> P;
bool compareB(P a, P b) {
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vector<P> bri;
    bri.resize(m);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        bri[i] = P(a, b);
    }
    sort(bri.begin(), bri.end(), compareB);

    int tmp = bri[0].second;
    int cnt = 1;
    rep(i, m) {
        if (tmp <= bri[i].first) {
            cnt++;
            tmp = bri[i].second;
        }
    }
    cout << cnt << endl;

    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int m; cin >> m;
  ll sumn = 0;
  ll sumk = 0;
  for(int i = 0; i < m; ++i){
    ll d,c; cin >> d >> c;
    sumn += d*c;
    sumk += c;    
  }
  cout << (sumn-1)/9 + sumk -1<< endl;
  return 0;
}


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

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<int> a(N);
	for (auto& e: a) scanf("%d", &e);
	int now{};
	for (auto& e: a)
		if (e == now + 1)
			now++;
	if (now == 0)
		puts("-1");
	else
		printf("%d\n", N - now);

	return 0;
}

Measured memory_bytes: 1024
//package 挑战程序竞赛数据结构;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int temp = 1;
		while(sc.hasNext()) {
			int num = sc.nextInt();
			if(num == 0) break;
			System.out.println("Case "+temp+": "+num);
			temp++;
		}
	}
}



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

using namespace std;

int main(void){
  int N,i;
  cin >> N;
  pair<int,int> work[N];
  for(i=0;i<N;i++){
    cin >> work[i].second >> work[i].first;
  }
  sort(work,work+N);
  int sumA=0;
  bool check=true;
  for(i=0;i<N;i++){
    sumA+=work[i].second;
    if(sumA>work[i].first){
      cout << "No" << endl;
      check=false;
      break;
    }
  }
  if(check){
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 1792
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 300010
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
k,n = arrIN()
a = arrIN()
cd = 0
mx = -1
ad = 0
for i in range(1,n):
    cd+=a[i]-a[i-1]
    mx = max(mx,a[i]-a[i-1])
cd+=k-a[-1]+a[0]
mx = max(mx,k-a[-1]+a[0])
cd-=mx
print(cd)

Measured memory_bytes: 40296
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import numpy as np
S = input()
l = len(S)
n = list(map(int, str(S)))
a = np.arange(l) # 12345...
b = np.where(a%2==0, 0, 1) # 010101010...
c = np.where(a%2==1, 0, 1) # 101010101...
bool1 = np.logical_xor(n, b)
bool2 = np.logical_xor(n, c)
 
count1 = np.sum(bool1)
count2 = np.sum(bool2)
 
if count1 < count2:
    print(count1)
else:
    print(count2)

Measured memory_bytes: 16700
n,m = map(int,input().split())
if n > m:
  (n,m) = (m,n)
if n == 1 and m == 1:
  print(1)
elif (n == 1 and m == 2) or (n == 2 and m == 2) or (n == 2 and m == 3):
  print(0)
elif (n == 1):
  print(m-2)
else:
  print((n-2)*(m-2))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int mod2 = 998244353;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> task(n);
  for (int i = 0;i < n;i++) {
    cin >> task[i].first >> task[i].second;
    swap(task[i].first, task[i].second);
  }
  sort(task.begin(), task.end());
  int time = 0;
  for (int i = 0;i < n;i++) {
    time += task[i].second;
    int dline = task[i].first;
    if (time > dline) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

/* #include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree
    <T, null_type, greater<T>, 
    rb_tree_tag,tree_order_statistics_node_update>;
 */ 

#define rep(i,k,n) for(int i = k; i < n; i++)  
#define per(i,k,n) for(int i = k; i >= n; i--)  
#define repp(i,a,n,k) for(typeof(a) i=a;i!=n;i+=k)

#define int long long
#define all(a) a.begin(),a.end()       

#define pb push_back
typedef long long ll; 
typedef pair<int, int> ii;
typedef pair<int,ii > iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<char> vchar;

#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)

#define ff first
#define ss second

#define lb lower_bound
#define ub upper_bound
#define me max_element

#define INF 1000000000
//#define mod 998244353
#define mod 1000000007
#define endl "\n"


  


int modPow(int a, int b);
int modInv(int a);     

vi gr[1000005];
bool vis[1000005];

int dfs(int n){
    if(vis[n])return 0;
    vis[n]=1;
    for(auto i : gr[n])dfs(i);
    return 1;
}


void solve(){
    
    int n; cin >> n;
    int m; cin >> m;
    while(m--){
        int a1,b1;
        cin >> a1 >> b1;
        gr[a1].pb(b1);
        gr[b1].pb(a1);
    }
    int ans =0;
    rep(i,1,n+1){
        ans += dfs(i);
    }
    cout << ans-1;

}


// lower_bound & upper_bound only works on sorted array (Not reverse sorted)
// Recheck if it is 2^9 or 10^9 
//check for long long overflow
//while adding and subs check if mod becomes -ve
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;




signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed;
    //cout <<setprecision(6);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
  // int test=1; cin >> test; while(test--)
    solve();
}

int modPow(int a, int b){
    if(b==0)return 1;
    if(b%2==0){
        int x = a*a;
        x%=mod;
        return modPow(x,b/2);
    }
    return (a*modPow(a,b-1))%mod;
}


int modInv(int a){
    return modPow(a,mod-2);
}





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

int main() {
  string S;
  cin >> S;
  string res;
  if (S.at(0) == 'S') {
    res = "Cloudy";
  }
  if (S.at(0) == 'C') {
    res = "Rainy";
  }
  if (S.at(0) == 'R') {
    res = "Sunny";
  }
  cout << res << endl;
} 


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

int main(){
  int n; cin>>n;
  vector<string> s(n); rep(i,n) cin>>s[i];
  rep(i,n) sort(s[i].begin(),s[i].end());
  sort(s.begin(),s.end());
  vll num;
  ll cnt=1;
  rep(i,n-1){
    if(i<n-2&&s[i]==s[i+1]) cnt++;
    else{
      if(s[i]==s[i+1]) cnt++;
      num.push_back(cnt);
      cnt=1;
    }
  }
  ll ans=0;
  for(auto x:num){
    ans+=(x-1)*x/2;
  }
  cout<<ans<<endl;
}


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

int main() {
  
  int N, D; cin >> N >> D; int table[N][D]; int ans = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> table[i][j];
    }
  }
  
  for (int i = 0; i < N - 1; i++) {
    for (int j = i; j < N; j++) {
      int sum = 0;
      for (int k = 0; k < D; k++) {
        sum += pow(table[i][k] - table[j][k], 2);
      }
      for (int k = 1; k * k <= sum; k++) {
        if (k * k == sum) ans++;
      }
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    sort( A.begin(),A.end(),greater<int>() );
    int a = 0, b = 0;
    for ( int i = 0; i < N; i++ ) {
        if ( i%2 == 0 ) { a += A[i]; }
        else { b += A[i]; }
    }
    cout << a-b << endl;
    return 0;
}

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

int main(void) 
{
    int N;
    cin >> N;
    long long sum = 0;
    for (int i = 1; i <= N; i++)
    {
        if (i % 15 == 0 || i % 5 == 0 || i % 3 == 0)
        {

        }
        else
        {
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(int.Parse).ToList();
            Console.WriteLine(a.Max() - a.Min());
        }
    }
}


Measured memory_bytes: 28384
using System.Linq;
using System;
using System.IO;

class Program
{
  static void Main(string[] args)
  {
    var seq = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    var k = seq[0];
    var s = seq[1];

    var count = 0;
    for (int x = 0; x <= k; x++)
    {
      var t = s - x;
      for (int y = 0; y <= k; y++)
      {
        var z = t - y;
        if(z < 0) break;
        if(z > k) continue;

        count++;
      }
    }

    Console.WriteLine(count);
  }
}

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

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

    int x;
    cin >> x;
    if (x == 3 || x == 5 || x == 7) {
        cout << "YES";
    } else {
        cout << "NO";
    }
}

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

//ABC117C
int compare_int(const void *a, const void *b) { //sort
  return *(int*) a-*(int*) b;
}
int main(void) {
  int n, m, k, i, cou=0, tmp, tm2;
  scanf("%d %d", &n, &m);
  int x[m],xx[m-1];
  for(i=0; i<m; i++){
    scanf(" %d", &x[i]);
  }

  if(n>=m){
    printf("%d", 0);
    return 0;
  }

  qsort(x, m, sizeof(int), compare_int); //sort

  for(i=0; i<m-1; i++)
    xx[i]=x[i+1]-x[i];
  qsort(xx, m-1, sizeof(int), compare_int); //sort
  for(i=0; i<m-n; i++)
      cou+=xx[i];
  printf("%d", cou);

  return 0;
}

Measured memory_bytes: 1396
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>




int main() {
	
	int sec;
	int min;
	int hour;

	std::cin >> sec;

	min = sec / 60;
	sec %= 60;

	hour = min / 60;
	min %= 60;

	printf("%d:%d:%d\n", hour, min, sec);

	//system("pause");
	return 0;
}


Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <queue>

int main()
{
	int n;
	std::cin >> n;
	std::vector<std::vector<int> > E(n); 
	for (int i = 0; i < n; i++)
	{
		int u, k;
		std::vector<int> G;
		std::cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++)
		{
			int g;
			std::cin >> g;
			g--;
			G.push_back(g);
		}
		E.at(u) = G;
	}
	std::vector<int> Dist(n, -1);
	Dist.at(0) = 0;
	std::queue<int> Que;
	Que.push(0);
	while (!(Que.empty()))
	{
		int s = Que.front();
		Que.pop();
		for (int i = 0; i < E.at(s).size(); i++)
		{
			int next = E.at(s).at(i);
			if (Dist.at(next) == -1)
			{
				Dist.at(next) = Dist.at(s) + 1;
				Que.push(next);
			}
		}
	}
	for (int i = 0; i < n; i++)
		std::cout << i + 1 << ' ' << Dist.at(i) << '\n';
	return 0;
}


Measured memory_bytes: 3140
#include <stdio.h>
#include <math.h>
int main()
{
	long x,a,b,s,t;
	scanf("%d%d%d",&x,&a,&b);
	if(a!=b)
	{
		s=x-a;
		s=abs(s);
		t=x-b;
		t=abs(t);
	    if(s>t)
	    printf("B");
	    else
	    printf("A");
	}
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MOD = 1000000007;
int main() {
    int N; cin >> N;
    string S; cin >> S;
    vector<int> A(2*N);
    for (int i = 0; i < 2*N; i++) A[i] = S[i] == 'B';
    for (int i = 0; i < 2*N; i++) A[i] ^= (i % 2);
    Int ans = 1, cnt = 0;
    for (int i = 0; i < 2*N; i++) {
        if (A[i]) {
            cnt++;
        } else {
            ans = ans * cnt % MOD;
            cnt--;
        }
    }
    if (cnt != 0) ans = 0;
    for (int i = 1; i <= N; i++) ans = ans * i % MOD;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1412
import std.stdio, std.string, std.array, std.conv;

void main() {
    int[][][] bld = new int[][][](4, 3, 10);
    int n = readln.chomp.to!int;
    foreach (i; 0 .. n) {
        int[] tmp = readln.chomp.split.to!(int[]);
        int b = tmp[0], f = tmp[1], r = tmp[2], v = tmp[3];
        bld[b-1][f-1][r-1] += v;
    }
    foreach (i; 0 .. 4) {
        foreach (j; 0 .. 3) {
            foreach (k; 0 .. 10) {
                write(" ", bld[i][j][k]);
            }
            writeln;
        }
        if (i != 3) "####################".writeln;
    }
}


Measured memory_bytes: 2496
list = []
for _ in range(5):
    list.append(int(input()))



menu_time = 0
apart_time = 0
total_time = 0
max_apart_time = 0
for i in range(5):
    menu_time = list[i]
    apart_time =  0 if menu_time % 10 == 0 else \
        (menu_time // 10 + 1) * 10 - menu_time
    total_time += menu_time + apart_time
    if apart_time > max_apart_time:
        max_apart_time = apart_time

total_time -= max_apart_time

print(total_time)



Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
char s[101];
int main(void) {
scanf("%s", s);
int res = 0;
int n = strlen(s);
for (int i = 0; i < n; i++) {
  if (s[i] != s[n - 1 - i]) res++;
  }
	printf("%d\n", res / 2);
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(){
  double a,b,c,d,e,f,y,x;
  while(cin >> a>>b>>c>>d>>e>>f){
    
      y = (double)(d*c-a*f)/(d*b-a*e);
      x = (double)((e*c-b*f) / (a*e-b*d));
    if(x == 0){
      x = 0;
    }
    if(y == 0){
      y = 0;
    }
    printf("%.3f %.3f\n",x,y);
  }

}

Measured memory_bytes: 3124
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#include <cassert>
#define SIZE 200005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

char str[SIZE];
int A[SIZE*2];

int main()
{
	int n,zan;
	scanf("%d %d",&n,&zan);
	scanf("%s",&str);
	for(int i=0;i<n;i++)
	{
		if(str[i]=='A') A[i]=0;
		else A[i]=1;
	}
	int now=0,pos=0;
	while(pos<n&&zan>0)
	{
		if(zan>0&&(A[pos]+now)%2==0)
		{
			A[pos]^=1;
			zan--;
		}
		if(zan>0)
		{
			zan--;
			pos++;
			now++;
			A[pos+n-1]=now;
		}
	}
	if(pos==n&&zan>0)
	{
		if(n%2==0)
		{
			for(int i=0;i<n/2;i++) printf("BA");
			puts("");
		}
		else
		{
			//printf("%d %d %d\n",A[n],now,zan);
			int nt=(A[n]+now)%2;
			if((nt+zan)%2==0) printf("A");
			else printf("B");
			for(int i=0;i<n/2;i++) printf("BA");
			puts("");
		}
	}
	else
	{
		for(int i=0;i<n;i++)
		{
			if((A[pos+i]+now)%2==0) printf("A");
			else printf("B");
		}puts("");
	}
	return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<stdio.h>

using namespace std;


int main(){


	int a,b,ans;
	char op;

	while(true)
	{
		cin >> a >>op >>b;
		//scanf("%d %c %d",&a,&op,&b);
		if(op == '?') break;
		else if(op == '+') ans = a+b;
		else if(op == '-') ans = a-b;
		else if(op == '*') ans = a*b;
		else if(op == '/') ans = a/b;

		cout << ans <<"\n";
	}
	return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>

int main(){
    int n;
    long long int a[100010];
    long long int prod = 1;

    scanf("%d",&n);


    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);

            if(a[i]==0){
                printf("0\n");
                return 0;
            }
    }


    for(int i=0;i<n;i++){
        if(a[i]<=1000000000000000000/prod){ // oq essa linha faz??
            prod*=a[i];
    }else{
        printf("-1\n");
        return 0;
        }
    }



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

    return 0;

}


Measured memory_bytes: 2496
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    int a;
    string s;
    cin >> a >> s;
    cout << (a >= 3200? s : "red") << "\n"; 
 }




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

int main() {
	string s1,s2;
	cin>>s1>>s2;
	int m=s1.size();
	int n=s2.size();
	int a[m+1][n+1];
	int b[m+1][n+1];
	for(int i=0;i<=n;i++)
		a[0][i]=0;
	for(int i=0;i<=m;i++)
		a[i][0]=0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(s1[i-1]==s2[j-1]){
				a[i][j]=a[i-1][j-1]+1;
				b[i][j]=1;
			}
			else{
				int x=a[i][j-1];
				int y=a[i-1][j];
				if(x>y){
					a[i][j]=x;
					b[i][j]=2;
				}
				else{
					a[i][j]=y;
					b[i][j]=3;
				}
				
			}
		}
	}
	string s,ans;
	for(int i=m,j=n;i>0&&j>0;){
			if(b[i][j]==1){
				s+=s1[i-1];
				i--;j--;
			}
			else if(b[i][j]==2){
				j--;
			}
			else if(b[i][j]==3){
				i--;
			}
	}
	int i=0,j=s.size()-1;
	while(i<j)
	   swap(s[i++],s[j--]);
	cout<<s;
	return 0;
}

Measured memory_bytes: 70656
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int [] H = new int [N];
        long ans = 0;
        
        for(int i=0; i<N; i++){
            H[i] = sc.nextInt();
        }
        
        Arrays.sort(H);
        
        for(int i=H.length-K-1; i>=0; i--){
            ans+=H[i];
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 60924
//#pragma GCC optimize("-O3")
/*
				C++
				encoding: UTF-8
				Last Modified: 12/Apr/20 05:39:48 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		int                    long long
#define		ve                     vector
#define		pb                     push_back
#define		endl                   "\n"
#define		ff                     first
#define		ss                     second
#define		pii                    pair<int, int>
#define		len(v)                 (int)v.size()
#define		all(v)                 v.begin(), v.end()
#define		reset(a, b)            memset(a, b, sizeof(a));
#define		fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on


signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int n;
	cin >> n;
	int ans = 0;
	fr (i, 1, n + 1) {
		if (i % 3 == 0 or i % 5 == 0)
			continue;
		else
			ans += i;
	}
	pr (ans);
	return 0;
}

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


#define mod                1000000000000000007
#define pi                 3.1415926535897932384626433832795
#define ll                 long long
#define pb                 push_back
#define pii                pair < int , int >
#define vecsort(v)         sort(v.begin(),v.end())
#define lcm(x,y)           (x/__gcd(x,y))*y
#define forn(i,n)          for(i = 0 ; i < n ; i++)
#define deb(x)             cout << #x << " " << x << endl;
#define vecsum(v)          accumulate(v.begin(), v.end(), 0)
#define T(t)               cout << "Case " << t <<": ";
#define fast_cin           ios_base::sync_with_stdio(false);cin.tie(NULL)

int n , m , k ;
vector < ll > a,b;





int main() {

    cin >> n >> m >> k;
    vector < ll > sumA(n+1),sumB(m+1);

    for( int i = 0 ; i < n ; i++ ){
        ll x ;
        cin >> x;
        a.pb(x);
    }
    for( int i = 0 ; i < m ; i++ ){
        ll x ;
        cin >> x;
        b.pb(x);
    }

    for( int i = 0 ; i < n  ; i++ ){
        sumA[i+1] = sumA[i] + a[i];
    }
    for( int i = 0 ; i < m  ; i++ ){
        sumB[i+1] = sumB[i] + b[i];
    }

    ll mx = 0 ;
    ll total = 0 ;
    for( int i = 0 ; i <= n ; i++ ){

       //ll taken = sumA[i];
        ll rem = k - sumA[i];
        if(rem<0)continue;
        ll j = lower_bound(sumB.begin(),sumB.end(),rem)-sumB.begin();
        if( j > m || sumB[j] > rem ){
            j--;
        }

        total = max( total , i + j );


    }

    cout << total << endl;








    return 0;
}

Measured memory_bytes: 11092
N,X,Y = map(int,input().split())

X -= 1
Y -= 1
ans = [0]*(N)

d = [[N]*N for i in range(N)]

for i in range(N):
    for j in range(i,N):
        if i<=X and Y<=j:
            d[i][j] = X-i+j-Y+1
        else:
            d[i][j] = min(abs(i-X)+abs(Y-j)+1,j-i)



for i in range(N):
    for j in range(i+1,N):
        ans[d[i][j]] += 1

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


Measured memory_bytes: 80476
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <cassert>
using namespace std; typedef long long ll; const int MINF=-1e9; typedef pair<int,int> P;

int main() {
  ll lo,oo,u1,u2; cin>>lo>>oo>>u1>>u1>>u2;
  ll an=0;
  an = max(an,(lo/2)*2+(u1/2)*2+(u2/2)*2);
  if (lo>0 && u1>0 && u2>0) an = max(an,(lo-1)/2*2+(u1-1)/2*2+(u2-1)/2*2+3);
  an+=oo;
  cout<<an<<endl;
}

Measured memory_bytes: 256
import sys
N, M = map(int,input().split())
Xm = list(map(int,input().split()))

if N >= M:
  print(0)
  sys.exit()
  
Xm.sort()
ans = Xm[M-1]-Xm[0]

Li = [Xm[i+1]-Xm[i] for i in range(M-1)]
Li.sort(reverse=True)
ans -= sum(Li[0:N-1])
print(ans)


Measured memory_bytes: 13960
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
    A.at(i)--;
    B.at(i) = A.at(i);
  }
  
  sort(B.begin(), B.end());

  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    auto it = lower_bound(B.begin(), B.end(), A.at(i));
    if ((it - B.begin()) % 2 != i % 2) ans++;
  }
  ans /= 2;
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;

signed main(){
    string s,t; cin>>s>>t;
    int ns = s.length();
    int nt = t.length();
    int res = nt;

    for(int i=0;i<=(ns-nt);i++){
        int an = 0;
        for(int j=i;j<i+nt;j++){
            if(s[j]!=t[j-i]) an++;
        }
        res = min(res,an);
        //cout<<i<<endl;
    }

    cout<<res<<endl;
}

Measured memory_bytes: 3636
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    string s;
    cin >> s;
    s.erase(s.begin() + s.size() - 1);

    while(1){
        if(s.size() % 2 == 0){
            int j = s.size() / 2;
            int f = 0;
            REP(i, s.size() / 2){
                if(s[i] == s[j]){
                    j++;
                }else{
                    f = 1;
                    break;
                }
            }
            if(f == 1){
                s.erase(s.begin() + s.size() - 1); 
            }else{
                cout << s.size() << endl;
                break;
            }
        }else{
            s.erase(s.begin() + s.size() - 1);
        }
    }



    return 0;
}

Measured memory_bytes: 256
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7

def sol():
    N = int(input())
    prob = map(float, input().split())

    dp = [0] * (N + 1)  # dp[head]
    dp[0] = 1

    for p in prob:
        for count in range(1, N + 1)[:: -1]:
            dp[count] = dp[count] * (1 - p) + dp[count - 1] * p
        dp[0] *= (1 - p)

    print(sum(dp[(N + 1) // 2:]))


sol()

Measured memory_bytes: 41412
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	if (abs(a - b) <= d && abs(b - c) <= d) {
		puts("Yes");
	}
	else if (abs(a - c) <= d)puts("Yes");
	else puts("No");

	return 0;
}

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

int main(){
  ll buf = 0;
  int n;
  cin >> n;
  vector<ll> water(n);
  rep(i,n){
    cin >> water[i];
    buf += (i%2 == 0) ? water[i] : -water[i]; 
  }
  buf /=2;
  cout << buf*2;
  rep(i,n-1){
    cout << " " << (water[i] - buf)*2;
    buf = water[i]-buf;
  }
  cout << endl;
}



Measured memory_bytes: 2048