akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define inf 1000000100

int main()
{
    int n;
    cin >> n;
    vi sieve(n+1, 1);
    ll ans = 1;
    for(int i = 2; i <= n; i++)
    {
        if(!sieve[i])
        {
            continue;
        }
        for(int j = i; j <= n; j *= i)
        {
            for(int k = j; k <= n; k += j)
            {
                sieve[k] = 0;
                sieve[i]++;
            }
        }

    }

    for(int i = 2; i <= n; i++)
    {
        if(sieve[i])
        {
            ans *= (sieve[i]+1);
            if(ans >= 1000000007)
            {
                ans %= 1000000007;
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll n;cin>>n;
  vector<string> s(n);
  vvll alpha(n,vll(30,0));
  vll ans(30,0);
  rep(i,0,n){
    cin>>s[i];
    rep(j,0,s[i].size()){
      ll x=s[i][j]-'a';
      alpha[i][x]++;
    }
  }
  rep(i,0,30){
    ll tmp=INF;
    rep(j,0,n){
      tmp=min(tmp,alpha[j][i]);
    }
    ans[i]=tmp;
    rep(k,0,ans[i]){
      char x=i+'a';
      cout<<x;
    }
  }
  cout<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int X, N; cin >> X >> N;
    vec p(N); cin >> p;
    int ans = 0;

    FOR(x, 1, 102){
        bool f = false;
        REP(i, N) if(p[i] == x) f = true;
        if(!f){
            if(llabs(x - X) < llabs(ans - X)) ans = x;
        }
    }
    Out(ans);

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N;
	cin >> N;
	int candies[2][N];
	int solution[2][N] = {0};
	REP(i, 0, 2){
		REP(j, 0, N) cin >> candies[i][j];
	}
	REP(i, 0, 2){
		REP(j, 0, N){
			if(i == 0){
				if(j == 0) solution[i][j] = candies[i][j];
				else solution[i][j] = solution[i][j-1] + candies[i][j];
			}
			else{
				if(j==0) solution[i][j] = candies[i][j]+  + solution[i-1][j];
				else solution[i][j] = max(candies[i][j]+  + solution[i-1][j], candies[i][j]+  + solution[i][j-1]);
			}
		}
	}
	cout << solution[1][N-1];
	

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
        int height,width;
        
        for(;;){
            cin >> height >> width;
            if((!height) && (!width)){
                break;
            }
            for(int i = 0; i < height; ++i){
                for(int j = 0; j < width; ++j){
                    cout << "#";
                    if(j == (width - 1)){
                        cout << "\n";
                    }
                }
            }
            cout << "\n";
        }
}



Measured memory_bytes: 3088
# a < b < c
a, b, c = map(int, input().split())
k = int(input())
greenok = False
if a < b:
    greenok = True
for _ in range(k):
    if greenok:
        c *= 2
    else:
        b *= 2
    if a < b:
        greenok = True
if a < b < c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9164
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x);
    }
    return res;
}
bool flag(lli x, lli temp){
	if(x == 0 && temp >= 0)
		return true;
	else if(x < 0 || temp < 0)
		return false;
	temp--;
	bool a = flag(x-1, temp);
	bool b = flag(x-2, temp);
	bool c = flag(x-3, temp);
	bool d = flag(x-4, temp);
	bool e = flag(x-5, temp);
	if(a || b || c || d || e)
		return true;
	else
		return false; 
}
lli solve(){
	lli x;
	cin>>x;
	if(x < 100){
		cout<<0<<"\n";
		return 0;
	}
	lli temp = x/100;
	x = x%100;
	if(x == 0){
		cout<<1<<"\n";
		return 0;
	}
	if(temp * 5 < x)
		cout<<0<<"\n";
	else
		cout<<1<<"\n";
//	bool check = flag(x, temp);
//	cout<<check<<"\n";
	return 0;
}
int main(){
	fastio;
	lli t;
//	cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
char s[20001];
int depth[20000], len;
int rain() {
	int i=0, left, right = 0, k;
	while (i < len && s[i] != '\\')i++;
	while (i < len && s[i] != '/')i++;
	if (i == len) return 0;
	right = i;
	while (i >= 0 && s[i] != '\\')i--;
	if (i < 0)return 0;
	left = i;
	depth[left] = 1;
	for (k = left + 1; k < right; k++)depth[k] += 2;
	depth[right] = 1;
	s[left] = '_';
	s[right] = '_';
	return right - left;
}
int main() {
	scanf("%s", s);
	len = strlen(s);
	int i, r, sum = 0;
	for (i = 0; i < len; i++)depth[i] = 0;
	while (true) {
		r = rain();
		if (r == 0)break;
		sum += r;
	}
	printf("%d\n", sum);
	sum = 0;
	std::vector<int> v;
	bool flag=false;
	for (i = 0; i < len; i++) {
		sum += depth[i];
		if (depth[i] == 1) {
			if (flag) {
				v.push_back(sum/2);
				sum = 0;
			}
			flag = !flag;
		}
	}
	if (sum > 0)v.push_back(sum/2);
	printf("%d", v.size());
	for (i = 0; i < v.size(); i++)printf(" %d", v[i]);
	printf("\n");
	return 0;
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e18;
const int MOD = 1e9 + 7;

signed main(){
    string s, t; cin >> s >> t;
    int ans = 0;
    REP( i, 3 ){
        if( s[i] == t[i] ){
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
      int[] arr=str.Select(int.Parse).ToArray();
      int[] arr2=arr;
      Array.Sort(arr2);
      Console.WriteLine(arr2[0]+arr2[1]);
      
      
    }
    
  }

}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loop2(num) for (lli j = 0 ; j < num ; j ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back ()
#define pof pop_front ()

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void solve ()
{
    st s ; cin >> s ;
    (s[2] == s[3] && s[4] == s[5] ? Yes : No) ;
}

signed main ()
{
    fastio
    solve ();
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
import sys
import math

input = sys.stdin.readline
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

def dist(y, z):
    ret = 0
    for i, j in zip(y, z):
        ret += (i-j)**2
    return math.sqrt(ret)

cnt = 0
for x in X:
    for y in X:
        if dist(x, y) % 1 == 0:
            cnt += 1
    cnt -= 1
print(cnt//2)


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

int main(){
while(1){
	int n,m;
	vector<int> p,q;
	scanf("%d%d",&n,&m);
if(n==0&&m==0)break;
	q.push_back(0);
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		p.push_back(a);
		q.push_back(a);
	}
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			q.push_back(p[i]+p[j]);
		}
	}
	sort(q.begin(),q.end());
	int ans=0;
	int f=0,s=q.size()-1;
	while(1){
		if(q[f]+q[s]>ans&&q[f]+q[s]<=m)ans=q[f]+q[s];
		if(q[f]+q[s]<=m)f++;
		if(q[f]+q[s]>m)s--;
		if(f>s)break;
	}
	printf("%d\n",ans);
}
}

Measured memory_bytes: 5000
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, ll> pill;
typedef vector< pill > vpill;
typedef vector< vpill > vvpill;
typedef vector< ll > vll;

void dfs(int v, int par, ll accm, vvpill& g, vll& dis) {
  dis[v] = accm;
  for(auto kv : g[v]) {
    int adj = kv.first;
    ll  weight = kv.second;
    if(adj != par) {
      dfs(adj, v, accm + weight, g, dis);
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vvpill g(n, vpill());
  for(int i=1; i<n; ++i) {
    int u, v;
    ll c;
    cin >> u >> v >> c, --u, --v;
    g[u].push_back({v, c});
    g[v].push_back({u, c});
  }
  int q, K;
  cin >> q >> K, --K;
  vll dis(n, 0);
  dfs(K, -1, 0, g, dis);
  while(q--) {
    int x, y;
    cin >> x >> y, --x, --y;
    cout << dis[x] + dis[y] << endl;
  }
}


Measured memory_bytes: 17408
import collections

n = int(input())
u = list(map(int,input().split()))

hantei = 0

for i in range(0,n):
    if u[0] != u[i]:
        hantei = 1
        break

if hantei == 0:
    print(n // 2)
else:
   u1 = [] 
   u2 = [] 
   ans = 0
   for j in range(n):
       if j % 2 == 0:
           u2.append(u[j])
       else:
           u1.append(u[j])
   u1_list =collections.Counter(u1)
   u2_list =collections.Counter(u2)
   values1, counts1 = u1_list.most_common()[0]
   values2, counts2 = u2_list.most_common()[0]
   if values1 != values2:
       ans += n // 2 - counts1
       ans += n // 2 - counts2
   else:
       if len(u1_list) > 1 and len(u2_list) > 1:
           values3, counts3 = u1_list.most_common()[1]
           values4, counts4 = u2_list.most_common()[1]
           ans1 = n - counts1 - counts4
           ans2 = n - counts2 - counts3
           ans = max(ans1,ans2)
       elif len(u1_list) > 1 and len(u2_list) < 2:
           values3, counts3 = u1_list.most_common()[1]
           ans = n - counts2 - counts3
       elif len(u1_list) < 2 and len(u2_list) > 1:
           values3, counts3 = u2_list.most_common()[1]
           ans = n - counts1 - counts3

       ans = min(ans1,ans2)
   print(ans)


Measured memory_bytes: 20576
def g;gets.to_i end
 # p (g-g)%g
  
#puts gets=~/^(dream|dreamer|erase|eraser)+$/?:YES: :NO
A,B,C,X=g,g,g,g
p (0..A).map{|a|(0..B).map{|b|(0..C).count{|c|500*a+100*b+50*c==X}}}.flatten.reduce :+


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

const int maxn = 5e3 + 5;
char s[maxn];

int wa[maxn], wb[maxn], wv[maxn], Ws[maxn];
int cmp(int* r, int a, int b, int l) {
	return r[a] == r[b] && r[a + l] == r[b + l];
}
void da(const char r[], int sa[], int n, int m) {
	int i, j, p, * x = wa, * y = wb, * t;
	for (i = 0; i < m; i++) Ws[i] = 0;
	for (i = 0; i < n; i++) Ws[x[i] = r[i]]++;
	for (i = 1; i < m; i++) Ws[i] += Ws[i - 1];
	for (i = n - 1; i >= 0; i--) sa[--Ws[x[i]]] = i;
	for (j = 1, p = 1; p < n; j *= 2, m = p) 	{
		for (p = 0, i = n - j; i < n; i++) y[p++] = i;
		for (i = 0; i < n; i++) if (sa[i] >= j) y[p++] = sa[i] - j;
		for (i = 0; i < n; i++) wv[i] = x[y[i]];
		for (i = 0; i < m; i++) Ws[i] = 0;
		for (i = 0; i < n; i++) Ws[wv[i]]++;
		for (i = 1; i < m; i++) Ws[i] += Ws[i - 1];
		for (i = n - 1; i >= 0; i--) sa[--Ws[wv[i]]] = y[i];
		for (t = x, x = y, y = t, p = 1, x[sa[0]] = 0, i = 1; i < n; i++)
			x[sa[i]] = cmp(y, sa[i - 1], sa[i], j) ? p - 1 : p++;
	}
	return;
}
int sa[maxn], Rank[maxn], height[maxn];
void calheight(const char* r, int* sa, int n) {
	int i, j, k = 0;
	for (i = 1; i <= n; i++) Rank[sa[i]] = i;
	for (i = 0; i < n; height[Rank[i++]] = k)
		for (k ? k-- : 0, j = sa[Rank[i] - 1]; r[i + k] == r[j + k]; k++);
	for (int i = n; i >= 1; --i) ++sa[i], Rank[i] = Rank[i - 1];
}

int main() {
	int n, m = 130, ans = 0;
	scanf("%d%s", &n, s);
	da(s, sa, n + 1, m);
	calheight(s, sa, n);
	for (int i = 1; i <= n; i++) {
		for (int j = i, res = n - sa[i] + 1; j > 1; j--) {
			res = min(res, height[j]);
			ans = max(ans, min(res, abs(sa[i] - sa[j - 1])));
		}
		for (int j = i + 1, res = n - sa[i] + 1; j < n; j++) {
			res = min(res, height[j]);
			ans = max(ans, min(res, abs(sa[i] - sa[j])));
		}
	}
	printf("%d", ans);
	return 0;
}


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

class Cmondai
{
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToArray();
        var A = line[0];
        var B = line[1];
        var C = line[2];
        var D = line[3];
        var E = line[4];
        var F = line[5];

        decimal max = -1;
        decimal maxSugarWater = 0;
        decimal maxSugar = 0;

        var waterAmax = F / (A * 100);
        for (int i = 0; i <= waterAmax; ++i)
        {
            var bCount = (F - (A * i * 100)) / (B * 100);
            for (int j = 0; j <= bCount; ++j)
            {
                if (i == 0 && j == 0) continue;
                var cCount = (F - (A * i * 100 + B * j * 100)) / C;
                for (int k = 0; k <= cCount; ++k)
                {
                    var dCount = (F - ((A * i * 100 + B * j * 100) + C * k)) / D;
                    for (int l = 0; l <= dCount; ++l)
                    {
                        if ((C * k + D * l) <= (i * A + j * B) * E)
                        {
                            var sugarWater = (A * i) * 100 + (B * j) * 100 + C * k + D * l;
                            var sugar = C * k + D * l;
                            var concentration = sugar == 0 ? 0 : sugar / sugarWater * 100;
                            if (max < concentration)
                            {
                                max = concentration;
                                maxSugarWater = sugarWater;
                                maxSugar = sugar;
                            }
                        }
                    }

                }
            }
        }
        Console.WriteLine($"{maxSugarWater} {maxSugar}");
    }
}

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

int main() {

    int n;
    cin >> n;

    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int m = 0;
    ll ans = 0;
    rep(i,n) {
        if (a[i] < m) {
            ans += m - a[i];
        }
        m = max(m, a[i]);
    }

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

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;

string s[maxr];
int32_t main()
{
	GO;
	int h, w, k;
	cin >> h >> w >> k;
	for (int i = 0; i < h; i++)
		cin >> s[i];

	int ans = 0;
	for (int row = 0; row < (1ll << h); row++) {
		for (int col = 0; col < (1ll << w); col++) {
			int count = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {

					if ((row & (1ll << i)) && (col & (1ll << j))) {
						if (s[i][j] == '#')
							count++;
					}
				}
			}
			if (count == k)
				ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

//!

Measured memory_bytes: 6772
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll INFL = 1e18;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////

int a[26];
void ok(string S){
    int num[26];
    memset(num, 0, sizeof(num));
    for (int i = 0;i < S.size();i++){
        num[S[i] - 'a']++;
    }
    for (int i = 0;i < 26;i++){
        a[i] = min(a[i], num[i]);
    }
    return;
}

int main(){
    int n;
    cin >> n;
    string s;
    memset(a, 9999, sizeof(a));
    for (int i = 0;i < n;i++){
        cin >> s;
        ok(s);
    }

    for (int i = 0;i < 26;i++){
        for (int j = 0;j < a[i];j++){
            cout << char(i + 'a');
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 55
#define MAXK 5
//~ #define MAXK 1000000000000005
#define lint long long
#define trace(x) cout<<#x<<" = "<<x<<'\n'
#define trace2(x, y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<'\n'
#define tracea(arr, i) cout<<#arr<<"["<<i<<"]"<<" = "<<arr[i]<<'\n'
#define print(arr, n) for (int iDx = 0; iDx < (n); iDx++) cout << arr[iDx] << " \n"[iDx == (n)-1]
#define sz(x) (int)(x).size()
using namespace std;
struct ii {
	int a, b;
	bool operator < (ii o) const { return make_tuple(a, b) < make_tuple(o.a, o.b); }
};
struct iii {
	int a, b, c;
	bool operator < (iii o) const { return make_tuple(a, b, c) < make_tuple(o.a, o.b, o.c); }
};
int TC, N, M, Q;

lint arr[MAXN];

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%lld", &arr[i]);
	
	lint ans = 0;
	bool selesai = 0;
	while (!selesai) {
		selesai = 1;
		for (int i = 0; i < N; i++) {
			lint step = arr[i]/N;
			if (step > 0) selesai = 0;
			ans += step;
			arr[i] %= N;
			for (int j = 0; j < N; j++) {
				if (i == j) continue;
				arr[j] += step;
			}
		}
	}
	printf("%lld\n", ans);
	
	return 0;
}


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

int main()
{
	int dataset;
	cin >> dataset;
	int miin[200000];
	int ma= -2047483647;
	int a[200000];
	for (size_t i = 0; i < dataset; i++)
	{
		cin >> a[i];
	}
	miin[0] = a[0];
	for (size_t i = 1; i < dataset-1; i++)
	{
		miin[i] = min(miin[i - 1], a[i]);
	}
	for (size_t i = 1; i < dataset; i++)
	{
		ma = max(ma, a[i] - miin[i - 1]);
	}
	cout << ma << endl;
    return 0;
}

Measured memory_bytes: 4628
#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++)
#define ll long long
#define INF 999999999
using namespace std;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int main(){
  int n;
  cin>> n;
  int a;
  cin>> a;
  for (int i = 1; i < n; i++) {
    int b;
    cin>> b;
    a = gcd(a,b);
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

int main() {
	IOS;
	int H, W;
	cin >> H >> W;
	bool h[100], w[100];
	MEM(h, false);
	MEM(w, false);
	vector<string> v(H);
	REP(i, H)cin >> v[i];

	REP(i, W) {
		bool tmp = true;
		REP(j, H)if (v[j][i] == '#')tmp = false;
		if (tmp)w[i] = true;
	}
	REP(i, H) {
		bool tmp = true;
		REP(j, W)if (v[i][j] == '#')tmp = false;
		if (tmp)h[i] = true;
	}
	REP(i, H) {
		REP(j, W) {
			if (!h[i] && !w[j])cout << v[i][j];
		}
		if(!h[i])cout << endl;
	}
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int H, W, ans = 0;
	cin >> H >> W;
	vector<string> S(H);
	for (string& i : S) cin >> i;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '.') {
				for (int k = 0; k < H; k++) {
					for (int l = 0; l < W; l++) {
						if (S[k][l] == '.') {
							queue<pair<int, int>> a;
							a.emplace(i, j);
							vector<vector<int>> b(H, vector<int>(W, -1));
							b[a.front().first][a.front().second] = 0;
							while (!a.empty()) {
								if (-1 < a.front().first - 1) {
									if (S[a.front().first - 1][a.front().second] == '.' && b[a.front().first - 1][a.front().second] == -1) {
										a.emplace(a.front().first - 1, a.front().second);
										b[a.front().first - 1][a.front().second] = b[a.front().first][a.front().second] + 1;
									}
								}
								if (-1 < a.front().second - 1) {
									if (S[a.front().first][a.front().second - 1] == '.' && b[a.front().first][a.front().second - 1] == -1) {
										a.emplace(a.front().first, a.front().second - 1);
										b[a.front().first][a.front().second - 1] = b[a.front().first][a.front().second] + 1;
									}
								}
								if (a.front().second + 1 < W) {
									if (S[a.front().first][a.front().second + 1] == '.' && b[a.front().first][a.front().second + 1] == -1) {
										a.emplace(a.front().first, a.front().second + 1);
										b[a.front().first][a.front().second + 1] = b[a.front().first][a.front().second] + 1;
									}
								}
								if (a.front().first + 1 < H) {
									if (S[a.front().first + 1][a.front().second] == '.' && b[a.front().first + 1][a.front().second] == -1) {
										a.emplace(a.front().first + 1, a.front().second);
										b[a.front().first + 1][a.front().second] = b[a.front().first][a.front().second] + 1;
									}
								}
								a.pop();
							}
							ans = max(ans, b[k][l]);
						}
					}
				}
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#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++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	string s, a, b;
	cin >> s;
	REP(i, (int)s.size()){
		if (i%2) a.push_back('1');
		else a.push_back('0');
	}
	REP(i, (int)s.size()){
		if (i%2==0) b.push_back('1');
		else b.push_back('0');
	}

	int cnt1 = 0;
	int cnt2 = 0; 

	REP(i, (int)s.size()){
		if (s[i] != a[i]) cnt1++;
		if (s[i] != b[i]) cnt2++;
	}

	cout << min(cnt1, cnt2) << endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <bitset>

using namespace std;

int main(){
    string w;
    cin>>w;;
    int result;

    if(w.at(0)=='S' && w.at(1)=='S' && w.at(2)=='S'){
        result = 0;
    }
    else if (w.at(0)=='R' && w.at(1)=='R' && w.at(2)=='R'){
        result = 3;
    }
    else if ((w.at(0)=='R' && w.at(1)=='R' && w.at(2)=='S')||(w.at(0)=='S' && w.at(1)=='R' && w.at(2)=='R')){
        result = 2;
    }
    else{
        result = 1;
    }
    cout<<result<<endl;


}








Measured memory_bytes: 3188
N,K = map(int,input().split())
A = list(map(int,input().split()))
A_dict = {i:a for i,a in enumerate(A,1)}

History = [1]
History_set = {1}
now = 1
for i in range(N):
    now = A_dict[now]
    if now not in History_set:
        History.append(now)
        History_set.add(now)
    else:
        break
#print(History,now)
if K < i:
    print(History[K])
else:
    e = History.index(now)
    #print(e)
    #print(History[e:])
    loop_num = len(History[e:])
    #print(loop_num)
    num = (K-e)%loop_num
    #print(num)
    print(History[e:][num])

Measured memory_bytes: 49092
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a=0,b,c,d,e=0,f;
  cin >>a>>b>>c;
  a=a+b;
  if(a>=c) cout <<"Yes\n";
  else cout <<"No\n";
  return(0);
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>


#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}


ll gcd(ll a,ll b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}

const ll INF = 1e10;
int main(){
    ll a, b;
    cin >> a >> b;
    ll r = gcd(a, b);

    map<ll, int>mp;
    for(ll i = 2; i * i <= r; i++){
        while(r % i == 0){
            mp[i]++;
            r /= i;
        }
    }
    if(r != 1)mp[r]++;
    ll res = 0;
    for(auto m : mp){
        res++;
    }
    cout << res + 1<< endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define FOR_EX(i, a, b) for (int i = a; i < b; i++)
#define FOR_IN(i, a, b) for (int i = a; i <= b; i++)

#define ALL(a) a.begin(), a.end()

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    long long n, a, b;
    cin >> n >> a >> b;
    long long steps = abs(b - a);
    if (steps % 2 == 0) {
        cout << steps / 2 << endl;
    } else {
        // can go to the ends, and go back towards the middle
        if (b - 1 < n - a) {
            steps = a - 1;
            a = 1;
            b -= steps;
            if (abs(b - a) % 2) {
                steps++;
                b--;
            }
            cout << abs(b - a) / 2 + steps << endl;
        } else {
            steps = n - b;
            a += steps;
            b = n;
            if (abs(b - a) % 2) {
                steps++;
                a++;
            }
            cout << abs(b - a) / 2 + steps << endl;
        }
    }
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

bool f(int x)
{
	if(1 <= x and x <= 12) return true;
	return false;
}

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

	int a = (s[0]-'0')*10+(s[1]-'0');
	int b = (s[2]-'0')*10+(s[3]-'0');

	if(f(a) and f(b)){
		cout << "AMBIGUOUS" << endl;
	}else if(f(a)){
		cout << "MMYY" << endl;
	}else if(f(b)){
		cout << "YYMM" << endl;
	}else{
		cout << "NA" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
E = [0] * N
W = [0] * N
ans = [0] * N

count = 0
for i in range(N):
    if S[i] == 'W':
        count += 1
        W[i] = count
    else:
        W[i] = count


count = 0
for i in reversed(range(N)):
    if S[i] == 'E':
        count += 1
        E[i] = count
    else:
        E[i] = count

ans[0] = E[1]
ans[-1] = W[-2]
for i in range(1, N - 1):
    ans[i] = W[i - 1] + E[i + 1]

print(min(ans))

Measured memory_bytes: 29472
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N;
double res, x;
string u;

int main() {
	cin >> N;
	for (int i = 0; i != N; ++i) {
		cin >> x >> u;
		if (u.front() == 'J') {
			res += x;
		}
		else {
			res += x * 380000;
		}
	}
	printf("%.10f\n", res);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define 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)--)

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

ll dp[101][100001];

int main(){
    int N,W;
    cin >> N >> W;
    ll w,v;
    cin >> w >> v;
    dp[0][w] = v;
    for(int i=1; i<N; i++){
        cin >> w >> v;
        rep(j,W+1){
            dp[i][j] = dp[i-1][j]; 
            if(j-w>=0) dp[i][j] = max(dp[i][j], dp[i-1][j-w]+v);
        }
    }
    ll ans = 0;
    rep(j,W+1){
        ans = max(ans, dp[N-1][j]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 77568
#include<bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    int main(){
    ll n;
    cin>>n;
    ll a[n+1];
    for(ll i=0;i<n;i++) cin>>a[i];
      
    ll dp[n+1];
  
    dp[1]=abs(a[1]-a[0]);
    dp[2]=min(dp[1]+abs(a[2]-a[1]),abs(a[2]-a[0]));
     
    for(ll i=3;i<n;i++){
     dp[i]=min((dp[i-1]+abs(a[i]-a[i-1])),(dp[i-2]+abs(a[i]-a[i-2]))); 

    }
      cout<<dp[n-1]<<endl;
     
    }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))
 
typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b;
  cin>>a>>b;
  
  int ans = -1;
  for (int i = 1; i < 1500; ++i) {
    int tax8 = i*0.08;
    
    if(tax8==a) {
      int tax10 = i*0.1;
      if(tax10==b) {
        ans = i;
        break;
      }
    }
  }
  
  cout<<ans;
    
  return 0;
}

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)


typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////


ll SOLVE(){
    ll n,k;cin>>n>>k;
    vector<ll> x(n),y(n);
    rep(i,0,n-1)cin>>x[i]>>y[i];
    ll ans=4e18;
    for(auto x1:x){
        for(auto x2:x){
            if(x1>=x2)continue;
            for(auto y1:y){
                for(auto y2:y){
                    if(y1>=y2)continue;
                    ll cnt=0;
                    rep(i,0,n-1){
                        if(x1<=x[i]&&x[i]<=x2&&y1<=y[i]&&y[i]<=y2)cnt++;
                    }
                    if(cnt>=k)chmin(ans,(y2-y1)*(x2-x1));
                }
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

int main(){fastio
    
    clock_t start = clock();
    SOLVE();
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    cerr<<endl<<time<<"ms"<<endl;
    
    return 0;
}



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

int main(){
  int N,K;
  cin >> N >> K;
  
  vector<int> fruits(N);
  
  for(int i = 0; i < N; i++){
    cin >> fruits.at(i);
  }
  sort(fruits.begin(),fruits.end());
   int ans = 0; 
    for(int i = 0; i < K; i++){
      ans += fruits.at(i);
    }
  cout << ans << endl;
}
      

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

typedef long long ll;
const int N = 100233;
int n, m, fa[N], p[N], visit[N];
ll a[N], b[N], f[N], s[N];
vector<int> G[N], E[N];
int F(int x) {while (x != fa[x]) x = fa[x] = fa[fa[x]]; return x;}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld", &a[i], &b[i]);
  }
  for (int i = 1, x, y; i <= m; i++) {
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    fa[i] = p[i] = i;
  }
  sort(p + 1, p + 1 + n, [&](const int &x, const int &y){return a[x] - b[x] < a[y] - b[y];});
  for (int i = 1; i <= n; i++) {
    int x = p[i], z;
    visit[x] = 1;
    s[x] = b[x];
    for (auto y : G[x]) if (visit[y]) {
      if ((z = F(y)) == x) continue;
      fa[z] = x;
      s[x] += s[z];
      E[x].push_back(z);
    }
  }
  for (int i = 1; i <= n; i++) {
    int x = p[i];
    if (E[x].empty()) f[x] = max(a[x], b[x]);
    else f[x] = 1ll << 60;
    for (auto y : E[x]) {
      f[x] = min(f[x], max(f[y], a[x] - b[x]) + s[x] - s[y]);
    }
  }
  printf("%lld\n", f[p[n]]);
}


Measured memory_bytes: 14972
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,i,sum=0;
	cin>>a>>b>>c>>d;
	if(a<b)
	{
		for(i=1;i<=a;i++)
		{
			sum+=c;
		}
	}
	else
	{
		for(i=1;i<=b;i++)
		{
			sum+=c;
		}
		for(i=b+1;i<=a;i++)
		{
			sum+=d;
		}
	}
	cout<<sum;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,a,sum;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>a;
		sum=sum+a;
	}
	if(n-sum<0)
	cout<<"-1";
	else
	cout<<n-sum;
	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
 
#define MOD 1000000007
#define ll long long
#define ld long double
 
using namespace std;
 
bool func(pair<ll,ll>a, pair<ll,ll>b){
  return (double)((double)a.first/(double)a.second) <(double)((double)b.first/(double)b.second);
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //price, size*4
  vector<pair<ll,ll> >P;
 
  ll price,size;
  ll N;
 
  for(ll i =0;i<4;i++){
    size = pow(2,i);
    cin >> price;
    P.push_back(make_pair(price, size));
  }
 
  cin >> N;
  N*=4;
 
  sort(P.begin(), P.end(), func);
 
  ll res = 0;
  for(ll i =0;i<P.size();i++){
    ll num = N/P[i].second;
    res += num*P[i].first;
    N%=P[i].second;
    //if(N==0) break;
  }
  cout << res << endl;
  return 0;
  
  
}

Measured memory_bytes: 256
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        n:u8,
        s:chars
    }

    let len = s.len();
    let mut ans = vec!['a'; len];
    for i in 0..len {
        ans[i] = f(s[i], n);
    }
    // let ans = ans.iter().collect::<String>();
    // println!("{}", ans);
    for i in ans {
        print!("{}", i);
    }
    println!("");
}

fn f(c: char, n: u8) -> char {
    let mut a = c as u8 + n;
    if a > 'Z' as u8 {
        a = a - 26;
    };
    a as char
}


Measured memory_bytes: 4352
/*  In the name of ALLAH */

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define ll long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif



int main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
  
    string s;
    cin>>s;
    for(int i = 0 ; i < s.length();i++){
        if(s[i]=='7'){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
 
 
 
    
 
    return 0;
}


Measured memory_bytes: 3628