akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #include <boost/functional/hash.hpp>
using namespace std;
typedef long long ll;
// typedef int long long int;
typedef unsigned long long ull;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll>   vl;
#define f(i,n)  for(i=0;i<n;i++)
#define f1(i,n)  for(i=1;i<n;i++)
#define fr(i,n) for(i=n-1;i>=0;i--)
#define em emplace_back
#define mp make_pair
#define in insert
#define fi first
#define sc second
#define b begin
#define e end
#define er erase
#define l length
#define c clear
#define si size
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
const double pi=3.141592653;
const ll MOD=1000000007;
const ll mod=998244353;
const string no="NO\n",yes="YES\n";

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

// void dfs(vl v[],ll node,ll hai[]){
//     hai[node]=1;
//     for(auto i:v[node]){
//         if(hai[i]==0){
//             dfs(v,i,hai);
//         }
//     }
// }

// ll con(vl v[],ll hai[],ll sz){
//     ll count=0;
//     for(int i=1;i<sz;i++){
//         if(hai[i]==0){
//             count++;
//             dfs(v,i,hai);
//         }
//     }
    // return count;
// }

// void gcde(int a,int b,int *x,int *y){
//     if(a==0){
//         *x=0;
//         *y=1;
//         return;
//     }    
//     int x1,y1;
//     gcde(b%a,a,&x1,&y1);
    
//     *x=y1-(b/a)*x1;
//     *y=x1;
// }


// ll recur(vl v,ll in,ll m,ll n){
//     if(in==-1)  return 1000000000001;
//     ll d,e,c;
//     d=max(m/v[in],n*v[in]);
//     c=recur(v,in-1,m/v[in],n*v[in]);
//     e=recur(v,in-1,m,n);
//     return min(c,min(e,d));
// }

// ll bexpo(ll a,ll p){
//     ll x=1;
//     while(p){
//     if(p&1){
//         x=(x*a)%mod;
//     }
//     a=(a*a)%mod;
//     p>>=1;
//     }
//     return x;
// }
// ll fact[500001],invf[500001];

int main() {
    fastio
    int t=1;
    // cin>>t;
    ull n,m,a,b,i,j,k,l,r,d,ans;
    
    while(t--){ans=0;
        cin>>n;
        int a[n+1]{};
        f1(i,100)
            f1(j,100)
                f1(k,100){
                    d=i*i+j*j+k*k+i*j+k*j+k*i;
                    if(d<=n){
                        a[d]++;
                    }
                }
        
        f1(i,n+1) cout<<a[i]<<endl;
    }
    
	return 0;
}

Measured memory_bytes: 3648
import sys
def input():
	return sys.stdin.readline()[:-1]
import heapq
class DijkstraList():
	#隣接リスト版
	#同一頂点の複数回探索を防ぐため訪問した頂点数を変数cntで持つ
	def __init__(self, adj, start):
		self.list = adj
		self.start = start
		self.size = len(adj)

	def solve(self):
		self.dist = [10**30 for _ in range(self.size)]
		self.dist[self.start] = 0
		self.prev = [-1 for _ in range(self.size)]
		self.q = []
		self.cnt = 0

		heapq.heappush(self.q, (0, self.start))

		while self.q and self.cnt < self.size:
			u_dist, u = heapq.heappop(self.q)
			if self.dist[u] < u_dist:
				continue
			for v in self.list[u]:
				if self.dist[v] > u_dist + 1:
					self.dist[v] = u_dist + 1
					self.prev[v] = u
					heapq.heappush(self.q, (self.dist[v], v))
			self.cnt += 1
		return

	def distance(self, goal):
		return self.dist[goal]

	def path(self, goal):
		self.path = [goal]
		while self.path[-1] != self.start:
			self.path.append(self.prev[self.path[-1]])
		return self.path[::-1]

n, m = map(int, input().split())
adj = [[] for _ in range(n)]
for _ in range(m):
	a, b = map(int, input().split())
	adj[a-1].append(b-1)
	adj[b-1].append(a-1)

d = DijkstraList(adj, 0)
d.solve()
print("Yes")
for x in d.prev[1:]:
	print(x+1)

Measured memory_bytes: 99392
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;
 
int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int m,d;
   cin >> m >> d;
   string s;
   int ans = 0;
   f(i,1,m+1){
      f(j,1,d+1){
         s = to_string(j);
         int d1,d10;
         if(s.size() == 1){
            d1 = s[0]-'0';
            d10 = 0;
         }else{
            d1 = s[1]-'0';
            d10 = s[0]-'0';
         }
         if(d1 >=2 and d10>=2){
            if(d1*d10 == i){
               ans ++;
            }
         }
      }
   }
   cout << ans << '\n';
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define ll long long int
#define p pair
#define pll pair<long long, long long>
#define pii pair<int, int>
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define enl '\n'
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

int main(){
    FAST;
    int n; 
    cin >> n; 
    if(n%2 == 0){
        cout << n/2-1;
        return 0; 
    }
    cout << n/2;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()

int ar[200005];
int pre[200005];
int32_t main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
		pre[i]=pre[i-1]+ar[i];
	}
	int ans = 1e15;
	for(int i=1;i<n;i++){
		ans = min(ans,abs(pre[n]-pre[i]-pre[i]));
		//cout<<ans<<"\n";
	}
	cout<<ans;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(int, N);
  vi B(N - 1);
  rep(i, N-1) cin >> B[i];
  
  ll sum = 0;
  sum += B[0];
  rep(i, N - 2) sum += min(B[i], B[i + 1]);
  sum += B[N - 2];
  
  fin(sum);
}

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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

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

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 show(vi a)
{
    cout << a[0];
    for(int i = 1; i < a.size(); i++) cout << " " << a[i];
    cout << endl;
}

void insertionSort(vi a, int n)
{
    for(int i = 1; i < n; i++)
    {
        int v = a[i];
        int j = i-1;
        while(j >= 0 && a[j] > v)
        {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        show(a);
    }
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];
    show(A);
    insertionSort(A, N);
}


Measured memory_bytes: 3152
n = int(input())
t,a = map(int, input().split())
arr = map(int, input().split())

ans = (-1,float('inf'))
for i,h in enumerate(arr):
  tmp = t - h * 0.006
  if abs(tmp - a) < abs(ans[1]):
    ans = (i, tmp-a)
    
print(ans[0]+1)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

typedef long long ll;

int N;
string A;

const ll MOD = 1000000007;

int main() {
	cin >> N;
	cin >> A;
	
	if (A[0] == 'W' || A.back() == 'W') {
		cout << 0 << endl;
		return 0;
	}

	for (int i = 0; i < 2 * N; i++) {
		if (i % 2 == 0) {
			if (A[i] == 'W')A[i] = 'B';
			else A[i] = 'W';
		}
	}
	ll ans = 1;
	ll cnt = 0;

	for (int i = 0; i < 2 * N; i++) {
		if (A[i] == 'W')cnt++;
		else {
			if (cnt >= 1) {
				ans *= cnt, ans %= MOD;
				cnt--;
			}
			else {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	if (cnt != 0) {
		cout << 0 << endl;
		return 0;
	}
	for (ll i = 1; i <= N; i++) {
		ans *= i, ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <set>

using namespace std;

set<int> v;

int dfs(int i, int m, int **s, int *p, int n, int *k) {
    if (i == n) {
        bool flag = true;
        for (int j = 0; j < m; j++) {
            int cnt = 0;
            for (int l = 0; l < k[j]; l++) {
                if (v.find(s[j][l]) != v.end())
                    cnt++;
            }
            if (cnt % 2 != p[j])
                flag = false;
        }
        if (flag)
            return 1;
        else 
            return 0;
    }

    int ans = 0;
    v.insert(i);
    ans += dfs(i+1, m, s, p, n, k);
    v.erase(i);
    ans += dfs(i+1, m, s, p, n, k);
    return ans;
}

int main() {
    int n, m;   cin >> n >> m;
    int *k = new int[m], **s = new int*[m], *p = new int[m];
    for (int i = 0; i < m; i++) {
        cin >> k[i];
        s[i] = new int[k[i]];

        for (int j = 0; j < k[i]; j++) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }

    for (int i = 0; i < m; i++)
        cin >> p[i];

    cout << dfs(0, m, s, p, n, k) << endl;

    return 0;
}

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

static class NagataKanaIsAGenius {
    public static void Main() {
        int[]nq=Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n=nq[0];
        int q=nq[1];
        List<int>[]graph=Enumerable.Range(0,n).Select(_=>new List<int>()).ToArray();
        for(int i=0;i<n-1;i++){
            int[]uv=Console.ReadLine().Split().Select(int.Parse).ToArray();
            int u=uv[0]-1;
            int v=uv[1]-1;
            graph[u].Add(v);
            graph[v].Add(u);
        }
        int[]a=new int[n];
        for(int i=0;i<q;i++){
            int[]px=Console.ReadLine().Split().Select(int.Parse).ToArray();
            a[px[0]-1]+=px[1];
        }
        Action<int,int>dfs=null;
        dfs=(x,p)=>{
            foreach(int y in graph[x]){
                if(y==p)continue;
                a[y]+=a[x];
                dfs(y,x);
            }
        };
        dfs(0,0);
        for(int i=0;i<n;i++){
            if(0<i)Console.Write(' ');
            Console.Write(a[i]);
        }
        Console.WriteLine("");
    }
}


Measured memory_bytes: 59284
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] f = new int[n][10];
		int[][] p = new int[n][11];
		for(int i = 0 ; i < n ; i++) {
			for(int j = 0 ; j < 10 ; j++) {
				f[i][j] = sc.nextInt();
			}
		}
		for(int i = 0 ; i < n ; i++) {
			for(int j = 0 ; j < 11 ; j++) {
				p[i][j] = sc.nextInt();
			}
		}
		int ans = -1001001001;
		for(int mask = 1 ; mask < (1<<10) ; mask++) {
			int money = 0;
			for(int i = 0 ; i < n ; i++) {
				int cnt = 0;
				for(int j = 0 ; j < 10 ; j++) {
					if(((mask>>j)&1) >= 1 && f[i][j] == 1) cnt++;
				}
				money += p[i][cnt];
			}
			ans = Math.max(ans, money);
		}
		System.out.println(ans);
	}
}


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

#define N 100

#define white 1
#define gray 0
#define black 2
#define infinity 1000000

void bfs(void);

int M[N][N] = {}, n, color[N];

int main(){
  int i, j, u, k, a;

  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    scanf("%d%d", &u, &k);
    u--;
    for(j = 0; j < k; j++){
      scanf("%d", &a);
      a--;
      M[u][a] = white;
    }
  }

  bfs();

  return 0;
}

void bfs(){
  int i, j, k, u, que[N], head = 0, tail = 0, d[N];

  for(i = 0; i < N; i++){
    color[i] = white;
    d[i] = infinity;
  }
  
  color[0] = gray;
  d[0] = 0;
  que[tail] = 0;
  tail++;

  while(head != tail){
    if(head == n)
      head = 0;
    
    u = que[head];
    head++;


    for(i = 0; i < n; i++){
      if(M[u][i] == white && color[i] == white){
	color[i] = gray;
	d[i] = d[u] + 1;
	if(tail ==  n)
	  tail = 0;
	que[tail] = i;
	tail++;
	  }
      
      color[u] = black;
    }
  }
  
  for(i = 0; i < n; i++){
    if(d[i] == infinity)
      d[i] = -1;
    printf("%d %d\n", i + 1, d[i]);
  }
  
}



Measured memory_bytes: 2112
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
using namespace std;

int main()
{
	vector<string> cards(3);
	for (int i = 0; i < 3; ++i) cin >> cards[i];

	int turn = 0;
	while (true) {
		if (cards[turn].empty()) {
			cout << (char)('A' + turn) << endl;
			break;
		}
		int next = cards[turn][0] - 'a';
		cards[turn].erase(0, 1);
		turn = next;
	}

}

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

const string march = "MARCH";
const string combination[10] = {"MAR", "MAC", "MAH", "MRC", "MRH", "MCH", "ARC", "ARH", "ACH", "RCH"};

int main(){
    long long N;
    map<char, long long> name2num;
    for(auto m:march) name2num[m] = 0;

    cin >> N;
    string tempS;
    for(long long i=0;i<N;i++){
        cin >> tempS;
        name2num[tempS[0]]++;
    }
    // for(auto nn:name2num) cout << nn.first << " " << nn.second << endl;
    long long ans = 0;
    for(long long i=0;i<10;i++){
        ans += name2num[combination[i][0]] * name2num[combination[i][1]] * name2num[combination[i][2]];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n,y = map(int,input().split())
import sys
for a in range(n+1):
    for b in range(n-a+1):
        c=n-a-b
        if 10000*a+5000*b+1000*c==y:
            print(a, b, c)
            sys.exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1000000007;

int main(){
    const int maxSize = 200001;
	vector<long long> inv(maxSize);
    vector<long long> powinv2(maxSize);
	vector<long long> fact(maxSize);
	vector<long long> factInv(maxSize);
	for(int i=0;i<2;i++) inv[i] = fact[i] = factInv[i] = 1;
	for(int i=2;i<maxSize;i++){
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		fact[i] = fact[i-1] * i % MOD;
		factInv[i] = factInv[i-1] * inv[i] % MOD;
	}
    powinv2[0] = 1;
    for(int i=1;i<maxSize;i++) powinv2[i] = powinv2[i-1] * inv[2] % MOD;
	auto comb = [&](int n, int r){
		if(n < r || r < 0) return 0LL;
		return fact[n] * factInv[n-r] % MOD * factInv[r] % MOD;
	};
    int B, W; cin >> B >> W;
    long long allB = 0, allW = 0;
    cout << inv[2] << endl;
    for(int i=1;i<B+W;i++){
        allB = (allB + comb(i-1, B-1) * powinv2[i]) % MOD;
        allW = (allW + comb(i-1, W-1) * powinv2[i]) % MOD;
        cout << (allW + (1 + (MOD-allB) + (MOD-allW)) * inv[2])%MOD << endl;
    }
}

Measured memory_bytes: 8448
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>

typedef unsigned long long LL;

using namespace std;
vector<vector<int> >path(100000 + 3, vector<int>(0));
vector<int> rightVec, leftVec;
map<int, int>used;

int search(int currentNode) {
	for (int i = 0; i < path[currentNode].size(); i++) {
		auto itr = used.find(path[currentNode][i]);
		if (itr == used.end()) {
			return path[currentNode][i];
		}
	}
	return -1;
}

int main() {
	int N, M;
	vector<pair<int, int> >AB;
	cin >> N >> M;
	int firstR = 0;
	int firstL = 0;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		if (i == 0) {
			firstR = a;
			firstL = b;
		}
		AB.push_back(make_pair(a, b));
	}
	
	for (int i = 0; i < AB.size(); i++) {
		path[AB[i].first].push_back(AB[i].second);
		path[AB[i].second].push_back(AB[i].first);
	}
	
	used[firstR] = 1;
	used[firstL] = 1;
	rightVec.push_back(firstR);
	leftVec.push_back(firstL);
	int currentNode = firstR;
	int next = search(currentNode);
	while (next != -1) {
		rightVec.push_back(next);
		used[next] = 1;
		currentNode = next;
		next = search(currentNode);
	}
	currentNode = firstL;
	next = search(currentNode);
	while (next != -1) {
		leftVec.push_back(next);
		used[next] = 1;
		currentNode = next;
		next = search(currentNode);
	}
	cout << rightVec.size() + leftVec.size() << endl;
	for (int i = rightVec.size()-1; i > -1; i--) {
		cout << rightVec[i] << " ";
	}
	for (int i = 0; i  < leftVec.size(); i++) {
		cout << leftVec[i];
		if (i != leftVec.size()-1)cout << " ";
	}
}

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

const int maxn = 2e5+5;
int N, M;
vector<pair<int,int>> v;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        int l, r; cin >> l >> r;
        v.push_back({l,r});
    }
    sort(v.begin(),v.end(),[](auto a, auto b) {
            if (a.first != b.first) return a.first < b.first;
            return a.second > b.second;
            });
    set<int> pq;
    for (int i = 1; i <= M; i++) {
        pq.insert(i);
    }
    vector<pair<int,int>> rights;
    for (auto p: v) {
        if (pq.empty()) {
            rights.push_back(p);
            continue;
        }
        int mn = *pq.begin();
        if (mn <= p.first) {
            pq.erase(pq.begin());
        }
        else {
            rights.push_back(p);
        }
    }
    sort(rights.begin(),rights.end(),[](auto a, auto b) {
            return a.second > b.second;
            });
    int ans = 0;
    for (auto p: rights) {
        if (pq.empty()) {
            ans++;
            continue;
        }
        int mx = *pq.rbegin();
        if (mx >= p.second) {
            pq.erase(prev(pq.end()));
        }
        else {
            ans++;
        }
    }
    cout << ans << '\n';
}



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

using namespace std;

void solve();
int sum(vector<int>::iterator,vector<int>::iterator);

int main() {

   solve();
   return 0;

}

void solve() {

   string o;
   string e;
   string ans;
   string::iterator oitr;
   string::iterator eitr;

   cin >> o >> e;

   oitr=o.begin();
   eitr=e.begin();

   while (eitr < e.end()) {

      ans+=*oitr;
      ans+=*eitr;

      oitr++;eitr++;

   }

   if(oitr<o.end())ans+=*oitr;

   cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int x,max=0,cnt=0;
    for(int i=0;i<3;i++){
        scanf("%d",&x);
        if(x>max) max=x;
        cnt += x;
    }
    if(max*2==cnt) printf("Yes");
    else printf("No");
}


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

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

    int r = 0;
    for(int i = 1; i <= n; i++){
        int c = 0, t = i;
        for(int j = 0; j < 5; j++){
            c += t % 10;
            t /= 10;
        }
        if(a <= c && c <= b){
            r += i;
        }
    }
    cout << r << endl;
}

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

#define INF (2e9)
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

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

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

using pii = pair<ll, ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void DumpRow(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

template<class T>
void DumpColumn(const T& A) {
    auto isFirst = true;
    for (const auto& value : A) {
        if (isFirst) {
            cout << value;
            isFirst = false;
        } else {
            cout << " " << value;
        }

    }
    cout << endl;
}

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

    ll n;
    cin >> n;
    auto v = set<int>();

    REP(i, n) {
        int q, x;
        cin >> q >> x;
        if (q == 0) {
            v.insert(x);
            cout << v.size() << endl;
        } else if (q == 1){
            auto it = v.find(x);
            if (it != v.end()) cout << 1 << endl;
            else cout << 0 << endl;
        } else if (q == 2){
            v.erase(x);
        } else if (q == 3){
            int y;
            cin >> y;
            auto it = v.lower_bound(x);
            while (it != v.end() && *it <= y){
                cout << *it << endl;
                ++it;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 12480
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod = 1e9 + 7;
const ll mod2 = 1e9 + 9 ;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ll Pow(ll a , ll b){
	if(b == 0) return 1 ;
	ll c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) ));
	return (c * c) ;
}
const int N = 1e5 + 10, LOG_A = 61;

ll basis[LOG_A];

void insertVector(ll mask) {
	for (int i = LOG_A - 1; i >= 0; i--) {
		if ((mask & Pow(2 , i)) == 0) continue;

		if (!basis[i]) {
			basis[i] = mask;
			return;
		}

		mask ^= basis[i];
	}
}
int main(){
	IOS;
	cout.precision(50) ;
	int n ; cin >> n ;vll a(n);for(int i = 0 ; i < n ; i++) cin >> a[i] ;
	vi b(61 , 0) ;
	for(ll i = 0 ; i < 61 ; i++){
		for(int  j = 0 ; j < n ; j++){
			if(a[j] & Pow(2 , i)) b[i]++ ;
		}
	}
	for(ll i = 0 ; i < 61 ; i++){
		if(b[i] % 2){
			for(int j = 0 ; j < n ; j++){
				if(a[j] & Pow(2 , i)) a[j] ^= Pow(2 , i) ;
			}
		}
	}
	for(int i = 0 ; i < n ; i++){
		insertVector(a[i]) ;
	}
	ll ans = 0 ;
	for (int i = LOG_A - 1; i >= 0; i--) {
		if (!basis[i]) continue;
		if (ans & Pow(2 , i)) continue;

		ans ^= basis[i];
	}
	ans *= 2 ;
	for(ll i = 0 ; i < 61 ; i++) if(b[i] % 2) ans += Pow(2 , i) ;
	cout << ans << endl ;
	
	return 0;
}


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

using namespace std;

typedef long long ll;

ll F(ll a, ll b){
        ll acnt=1, bcnt=1;
        while(a>=10){
                acnt++;
                a/=10;
        }
        while(b>=10){
                bcnt++;
                b/=10;
        }
        return max(acnt, bcnt);
}

int main(){
        ll N, res=12;
        cin>>N;
        for(ll i=1;i<=sqrt(N);i++){
                if(N%i!=0){
                        continue;
                }
                ll a=i;
                ll b=N/a;
                res=min(res, F(a, b));
        }
        cout<<res<<endl;
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


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

int n;
int p[100];
int q[100];
int cou=0;
int main(){
	cin>>n;
	REP(i,n){
		cin>>p[i];
		q[i]=p[i];
	}
	sort(p,p+n);
	REP(i,n){
		if(p[i]!=q[i])cou++;
	}
	if(cou<=2){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	n=n%10;
	if(n==2 || n==4 || n==5 || n==7 || n==9)
		cout<<"hon"<<endl;
	else if(n==0 || n==1 || n==6 || n==8)
		cout<<"pon"<<endl;
	else
		cout<<"bon"<<endl;
	return 0;
}

Measured memory_bytes: 3620
import java.util.*;

// 足し算の数式を保持するクラス
// usage
// AddForm f = new AddForm();
// f.append(1,1);
// f.append(2,0);
// f.append(3,0);
// f.append(4,1);
// f.append(5,0); // 123 + 45
// int ans = f.eval(); // 168
//
class AddFormula {
  long[] a = new long[11]; // 式の数字列、123 + 45 なら [123,45,0,0,0..]
  int n = 0; // 式の数字の数、123 + 45 なら 5
  int m = 0; // 値が0である最初の位置、123 + 45 なら 2

  // 式に数字を追加する
  // flag: 0 -> 式の最後の数字の1の位に追加
  // flag: 1 -> 式の最後に足し算で追加
  public void append(long x, int flag) {
    if (flag == 0) {
      a[m - 1] = a[m - 1] * 10L + x;
    } else {
      a[m] = x;
      m++;
    }
    n++;
  }

  // 式の値を計算
  public long eval() {
    long ans = 0;
    for (int i = 0; i < m; i++) {
      ans += a[i];
    }
    return ans;
  }
}

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      String s = scanner.next();
      int n = s.length();
      int m = 1 << n-1;
      long ans = 0;

      for (int bit = 0; bit < m; bit++) {
        AddFormula f = new AddFormula();
        f.append(s.charAt(0) - '0', 1);
        for (int i = 1; i < n; i++) {
          int flag = (bit >> (i - 1)) & 1;
          long x = s.charAt(i) - '0';
          f.append(x,flag);
        }
        ans += f.eval();
      }
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
}


Measured memory_bytes: 35812
import java.util.Scanner;

public class Main {

	public static void main (String[] args)  {


		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int m = sc.nextInt();
		int[] fridge = new int[a];
		int[] microwave = new int[b];

		
		int aMin = Integer.MAX_VALUE;
		int bMin = Integer.MAX_VALUE;
		for (int i=0;i<a;i++) {
			fridge[i]=sc.nextInt();
			aMin=Math.min(fridge[i],aMin);
		}
		for (int i=0;i<b;i++) {
			microwave[i]=sc.nextInt();
			bMin=Math.min(microwave[i],bMin);
		}
		
		int ans = aMin+bMin;
		for (int i=0;i<m;i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int c = sc.nextInt();
			
			ans = Math.min(ans, fridge[x-1]+microwave[y-1]-c);
		}
		System.out.println(ans);
	}


}


Measured memory_bytes: 135172
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let X: usize = sc.get();
    let mut yen = 100.;
    let mut ans = 0;
    while yen < X as f64 {
        yen = (yen * 101. / 100.).floor();
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2664
#include <iostream>
#include <string>
#include <vector>

using namespace std;


int main(void) {

  int X;
  cin >> X;

  if (X == 7 || X == 5 || X == 3){
    cout << "YES" << endl;
  }else {
    cout << "NO" << endl;
  }

  return 0;
}

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

int main() {
    int n;
    int el;
    cin >> n;

    vector<vector<int>> dp(n, vector<int>(3));

    cin >> dp[0][0] >> dp[0][1] >> dp[0][2];

    for(int i = 1; i < n; i++) {
        cin >> el;
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + el;

        cin >> el;
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + el;

        cin >> el;
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + el;
    }

    cout << *max_element(dp[n-1].begin(), dp[n-1].end());
}

Measured memory_bytes: 5760
// Last Change: 12/05/2019 20:05:04.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

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

  int lb, rb;
  lb = rb = 0;
  ll cnt = 0;
  for (auto &x : S) {
    if (x == '(') {
      ++lb;
    } else if (x == ')') {
      ++rb;
    } else {
      cnt += lb - rb;
    }
  }
  cout << cnt << endl;
}



Measured memory_bytes: 3204
n = int(input())
a = list(map(int,input().split()))
cnt = [0]*n
for i in a:
    cnt[i] += 1

output = 1
if a[0] != 0 or cnt[0] != 1:
    print(0)
elif max(a) == 1:
    print(1)
else:
    for i in range(2, n):
        output *= cnt[i-1]**cnt[i]
        output %= 998244353
    print(output)

Measured memory_bytes: 14008
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[]a=new int[n];
        for(int i=0;i<n;i++)a[i]=sc.nextInt();
        Arrays.sort(a);
        if(n==2)System.out.println((a[0]==a[1])?0:a[1]-a[0]);
        else if(a[n/2]-a[n/2-1]==0){
            System.out.println(0);
        }
        else 
            System.out.println(a[n/2]-a[n/2-1]);
        //else System.out.println((a[n/2]-a[n/2-1]==0)?0:(a[n/2-1]==a[n/2-2])?(a[n/2]==a[n/2+1])?a[n/2]-a[n/2-1]-1:a[n/2]-a[n/2-1]:(a[n/2]==a[n/2+1])?a[n/2]-a[n/2-1]:a[n/2]-a[n/2-1]+1);
    }
}


Measured memory_bytes: 50424
def main():
    import networkx as nx
    import sys
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for i in range(N-1+M)]
    DG = nx.DiGraph(AB)

    G = [set() for i in range(N)]
    for a, b in AB:
        a -= 1
        b -= 1
        G[a].add(b)

    DG = list(nx.topological_sort(DG))

    parent = [0]*N
    for i, x in enumerate(DG):
        x -= 1
        if i == 0:
            parent[x] = 0
        for y in G[x]:
            parent[y] = x+1
    print(*parent, sep='\n')


main()


Measured memory_bytes: 222884
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,k,j;
    cin>>n>>k;
    vector<int>v(200000,0);
    vector<int>pre(200000,0);
    for(i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    int dp[200000];
    for(i=1;i<200000;i++)
    dp[i]=INT_MAX;
    dp[1]=0;
    dp[2]=abs(v[2]-v[1]);
    for(i=3;i<=n;i++)
    {
        for(j=1;j<=k && j<i;j++)
        {
            dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
        }
    }
    cout<<dp[n];
}

Measured memory_bytes: 2560
from functools import reduce


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a // gcd(a, b) * b

def llcm(l):
    return reduce(lcm, l)

def modinv(a, m):
    b, u, v = m, 1, 0
    while b:
        t = a // b
        a, b = b, a - t * b
        u, v = v, u - t * v
    u %= m
    if u < 0:
        u += m
    return u

def main():
    MOD = 10**9 + 7
    N = int(input())
    A = list(map(int, input().split()))
    l = llcm(A) % MOD
    r = 0
    for i, a in enumerate(A):
        r = (r + l * modinv(a, MOD)) % MOD
    return r

print(main())


Measured memory_bytes: 42460
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
var pn=arr.shift().split(" ").map(Number);
if(pn.join(" ")=="0 0")break;
var p=Math.sqrt(pn[0]);
var n=pn[1];
var max=0;
var min=Infinity;
var ans=[];
var J=[];
for(var i=1;i<=n;i++)J.push(i);
for(var i=1;i<=n;i++){
   var L=0;
   var R=J.length-1;
   while(true){
      var m=Math.floor((L+R)/2);
      var j=J[m];
      var v=i/j;
      if(v==p){
         break;
      }else if(v<p){
         if(max<v){
            max=v;
            ans[1]=i+"/"+j;
         }
         R=m-1;
      }else if(v>p){
         if(min>v){
             min=v;
             ans[0]=i+"/"+j;
         }
         L=m+1;
      }
      if(L>R)break;
   }
}
console.log(ans.join(" "));
}

Measured memory_bytes: 20220
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	rs := []rune(s)

	if rs[0] == rs[1] || rs[1] == rs[2] || rs[2] == rs[3] {
		fmt.Println("Bad")
	} else {
		fmt.Println("Good")
	}
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << (H-h)*(W-w);
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3620
//17
#include<iostream>
#include<algorithm>
#include<queue>
#include<utility>
#include<set>

using namespace std;

char g[1000][1001];
int w,h;
set<pair<int,int> > s;

bool ff(pair<int,int> p){
  bool r=false;
  if(s.count(p)){
    queue<pair<int,int> > que;
    que.push(p);
    while(!que.empty()){
      int x=que.front().first;
      int y=que.front().second;
      que.pop();
      if(x<0||w<=x||y<0||h<=y||g[y][x]=='p'){
	continue;
      }else if(g[y][x]=='#'){
	s.insert(make_pair(x,y));
      }else{
	r|=g[y][x]=='t';
	g[y][x]='p';
	for(int i=0;i<4;i++){
	  const static int d[]={0,1,0,-1,0};
	  que.push(make_pair(x+d[i],y+d[i+1]));
	}
      }
    }
  }
  return r;
}

int main(){
  cin>>w>>h;
  for(int i=0;i<h;i++){
    cin>>g[i];
  }
  s.insert(make_pair(0,0));
  int t=-1;
  if(ff(make_pair(0,0))){
    t=0;
  }
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    int x,y;
    cin>>x>>y;
    g[y][x]='.';
    if(ff(make_pair(x,y))){
      t=i;
    }
  }
  cout<<t<<endl;
  return 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  vector<int>s(n);
  int sum=0;
  rep(i,n){
    cin>>s[i];
    sum+=s[i];
  }
  
  
  rep(i,n)s[i]*=-1;
  sort(s.begin(),s.end());
  rep(i,n)s[i]*=-1;
  rep(i,m){
    if(sum>4*m*s[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  
}

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

int N;
int A[210];         // 最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよいです

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];

    int res = 0;

    // 操作が行える限り操作を繰り返す
    while (true) {
        bool exist_odd = false;  // A[i] がすべて偶数かどうかを判定するフラグ
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;  // 奇数があったらフラグを立てる
        }

        if (exist_odd) break;  // 奇数があったら break

        // 操作を行えるなら操作を実際に行う
        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res;  // 操作回数をインクリメント
    }

    cout << res << endl;}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		int a,b;
		Scanner sc= new Scanner(System.in);
		a=sc.nextInt();
		b=sc.nextInt();
		if (a>9 ||b>9||a<1||b<1)
			System.out.print(-1);
		else
			System.out.println(a*b);
	}
}

Measured memory_bytes: 23636
#include <stdio.h>

int main(void)
{
	int N;
	scanf("%d",&N);
	
	int L[2*N];
	int i,j,tmp;
	for(i=0;i<2*N;i++)
	{
		scanf("%d",&L[i]);
	}
	for(i = 0 ; i < 2*N-1;i++)
	{
		for(j=2*N-1;j >i;j--)
		{
			if(L[j-1] > L[j])
			{
				tmp = L[j-1];
				L[j-1] = L[j];
				L[j] = tmp;
			}
		}
	}
	int ans = 0;
	for(i = 0; i < 2*N;i+=2)
	{
		ans = ans+L[i];
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b >= c) cout << "Yes" << endl;
    else  cout << "No" << endl;
}

Measured memory_bytes: 256
def change(d,ans,X,Y):
    z = {'A': 0, 'B': 1, 'C': 2}
    d[z[X]]+=1
    d[z[Y]]-=1
    ans.append(X)
    return d,ans

n,a,b,c = map(int, input().split())
d = [a,b,c]
q = [input() for i in range(n)]
z = {'A': 0, 'B': 1, 'C': 2}

if sum(d)==0:
    print('No')
elif sum(d)==1:
    ans = []
    for i in range(n):
        X = q[i][0]
        Y = q[i][1]
        if d[z[X]]>0:
            d,ans = change(d,ans,Y,X)
        elif d[z[Y]]>0:
            d,ans = change(d,ans,X,Y)
        else:
            print('No')
            exit()
    print('Yes')
    print('\n'.join(ans))
else:
    ans = []
    X = q[0][0]
    Y = q[0][1]
    if d[z[X]]==d[z[Y]]==0:
        print('No')
        exit()
    for i in range(n-1):
        X = q[i][0]
        Y = q[i][1]
        if d[z[X]]==0:
            d,ans = change(d,ans,X,Y)
        elif d[z[Y]]==0:
            d,ans = change(d,ans,Y,X)
        else:
            if X in q[i+1]:
                d,ans = change(d,ans,X,Y)
            elif Y in q[i+1]:
                d,ans = change(d,ans,Y,X)
    X = q[-1][0]
    Y = q[-1][1]
    if d[z[X]]>0:
        ans.append(Y)
    else:
        ans.append(X)
    print('Yes')
    print('\n'.join(ans))

Measured memory_bytes: 85744
#include<bits/stdc++.h>
using namespace std;
void getmin(int &x,int y){x=min(x,y);}
int n,q,l,r;
int b[200100],dat[524288],mx=262144,dp[200100],w[200100],pre[200100];
vector<int> opr[200100];
void update(int l,int r,int delta){
	l+=mx;r+=mx;
	while(l<=r){
		getmin(dat[l],delta);
		getmin(dat[r],delta);
		l=(l+1)>>1;
		r=(r-1)>>1;
	}
}
int get(int p){
	p+=mx;
	int ret=1e9;
	while(p){
		getmin(ret,dat[p]);
		p>>=1;
	}
	return ret;
}
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	for(int i=1;i<mx*2;i++)
		dat[i]=1e9;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>w[i];
		pre[i]=pre[i-1]+(1-w[i]);
	}
	cin>>q;
	for(int i=1;i<=q;i++){
		cin>>l>>r;
		opr[r].push_back(l); 
	}
	for(int i=1;i<=n;i++){
		update(i-1,i-1,dp[i-1]-pre[i-1]);
		dp[i]=dp[i-1]+w[i];
		for(int j:opr[i]){
			update(j,i,get(j-1));
		}
		getmin(dp[i],get(i)+pre[i]);
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 14208
#include<stdio.h>
#include<stdlib.h>
#define MAX 25
#define NIL -1
struct Node_struct{
  int p,r,l,s;
};
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX], H[MAX];

int getSibling(int);
void calcDepth(int, int);
int setHeight(int);

int main(){
  int i, n, id, root = NIL;
  scanf("%d", &n);

  for(i = 0; i < n; i++) T[i].p = T[i].r = T[i].l = NIL;
  for(i = 0; i < n; i++){
    if(i == 0){
      T[0].p = NIL;
    }
    scanf("%d", &id);
    scanf("%d %d", &T[id].l, &T[id].r);
    T[T[id].r].p = T[T[id].l].p = id;
    T[T[id].r].s = T[id].r;
    T[T[id].l].s = T[id].l;
  }

  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }

  calcDepth(root, 0);

  for(i=0; i<n; i++) {
    int deg=0;
    printf("node %d: parent = %d, ", i, T[i].p);
    printf("sibling = %d, ",getSibling(i));
    if(T[i].l != NIL){
      deg++;
    }
    if(T[i].r != NIL){
      deg++;
    }
    printf("degree = %d, ",deg);
    printf("depth = %d, ",D[i]);
    printf("height = %d, ",setHeight(i));
    if(T[i].p == NIL) printf("root");
    else if(T[i].l == T[i].r && T[i].l == NIL) printf("leaf");
    else printf("internal node");
    printf("\n");
  }
  return 0;
}

  int getSibling(int u){
    if(T[u].p == NIL){
      return NIL;
    }
    if(T[T[u].p].l != u && T[T[u].p].l != NIL){
      return T[T[u].p].l;
    }
    if(T[T[u].p].r != u && T[T[u].p].r != NIL){
      return T[T[u].p].r;
    }
    return NIL;
  }

  int setHeight(int u){
    int h1 = 0, h2 = 0;
    if(T[u].l != NIL){
      h1 = setHeight(T[u].l) + 1;
    }
    if(T[u].r != NIL){
      h2 = setHeight(T[u].r) +1;
    }
    if(h1 > h2){
      H[u] = h1;
    }else{
      H[u] = h2;
    }
    return H[u];
  }


  void calcDepth(int u, int p) {
    D[u] = p;
    if(T[u].l != NIL) calcDepth(T[u].l, p+1);
    if(T[u].r != NIL) calcDepth(T[u].r, p+1);
  }



Measured memory_bytes: 2104
using System;
class grade{
    public static void Main(){
        int m,e,r;
        String temp = Console.ReadLine();
        while(!temp.Equals("-1 -1 -1")){
            String[] str = temp.Split(' ');
            m = int.Parse(str[0]);
            e = int.Parse(str[1]);
            r = int.Parse(str[2]);
            if(m == -1 || e == -1){
                Console.WriteLine("F");
            }
            else if(m+e < 30){
                Console.WriteLine("F");
            }
            else{
                if(m+e >= 80){
                    Console.WriteLine("A");
                }
                else if(65 <= m+e){
                    Console.WriteLine("B");
                }
                else if(50 <= m+e){
                    Console.WriteLine("C");
                }
                else{
                    if(r >= 50){
                        Console.WriteLine("C");
                    }
                    else{
                        Console.WriteLine("D");
                    }
                }
            }
            temp = Console.ReadLine();
        }
    }
}


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

int A[100000];

int partition(int A[], int p, int r){
  int x = A[r];
  int i = p-1;

  for(int j=p; j<r; j++){
    if(A[j] <= x){
      i++;
      swap(A[i],A[j]);
    }
  }

  swap(A[i+1],A[r]);
  return i+1;
}

int main(){

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

  int q = partition(A, 0, n-1);

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

    if(i != n-1){
      printf(" ");
    }
    else{
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 3560
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int long long

void test_case(){
	int n,N;
	cin >> n;
	N = n;

	set<int> s; // prime factors

	if(n%2==0) s.insert(2);
	while(n%2==0) n/=2;
	for(int i=3 ; i*i <=n ; i+=2){
		if(n%i==0){
			s.insert(i);
			while(n%i==0) n/=i;
		}
	}
	if(n>1) s.insert(n);

	int cnt=0;

	for(int prime : s){
		int p=prime;
		while(N%p==0){
			N = N/p;
			cnt++;
			p = prime*p;
		}
	}
	
	cout << cnt << endl;

}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	int t=1;
	// cin >> t;

	while(t--) test_case();
	
	return 0;
}


Measured memory_bytes: 3632