akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int  ll;
#define nl cout<<"\n";
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
    
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
        c = c-b;
        if(c<=0){cout<<"Yes";break;}
        a = a-d;
        if(a<=0){cout<<"No";break;}
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

using namespace std;

typedef long long ll;

const int dd = (int)2e5 + 7;
int b[dd], P0[dd], P1[dd];
int dp[dd];

struct SegmentTree {
	int T[4 * dd];
	
	SegmentTree() { fill(T, T + 4 * dd, (int)1e9); }
	
	void upd(int v, int tl, int tr, int pos, int val) {	
		if (tl == tr) T[v] = min(T[v], val);
		else {
			int tm = (tl + tr) / 2;
			if (pos <= tm) upd(v * 2, tl, tm, pos, val);
			else upd(v * 2 + 1, tm + 1, tr, pos, val);
			T[v] = min(T[v * 2], T[v * 2 + 1]);
		}
	}
	
	int get(int v, int tl, int tr, int l, int r) {
		if (tl == l && tr == r) return T[v];
		int tm = (tl + tr) / 2;
		if (r <= tm) return get(v * 2, tl, tm, l, r);
		if (l > tm) return get(v * 2 + 1, tm + 1, tr, l, r);
		return min(get(v * 2, tl, tm, l, tm), get(v * 2 + 1, tm + 1, tr, tm + 1, r));
	}
} T0, T1;

int main() {
	int n;
	cin >> n;
	
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < n; i++) P0[i + 1] = P0[i] + (b[i] == 0);
	for (int i = 0; i < n; i++) P1[i + 1] = P1[i] + (b[i] == 1);
	
	int q;
	cin >> q;
	
	vector<pair<int, int> > A(q);
	for (int i = 0; i < q; i++) {
		cin >> A[i].first >> A[i].second;
		A[i].first--, A[i].second--;
	}
	
	sort(A.begin(), A.end());
	
	int ans = P1[n];
	
	for (int i = 0; i < q; i++) {
		
		dp[i] = P0[A[i].second + 1] - P0[A[i].first] + P1[A[i].first];
		
		if (A[i].first > 0) {
			int t = T1.get(1, 0, n - 1, 0, A[i].first - 1);
			t += P1[A[i].first] + P0[A[i].second + 1] - P0[A[i].first];
			dp[i] = min(dp[i], t);
		}
		
		{
			int t = T0.get(1, 0, n - 1, A[i].first, A[i].second);
			t += P0[A[i].second + 1];
			dp[i] = min(dp[i], t);
		}
		
		T0.upd(1, 0, n - 1, A[i].second, dp[i] - P0[A[i].second + 1]);
		T1.upd(1, 0, n - 1, A[i].second, dp[i] - P1[A[i].second + 1]);
		
		/*
		for (int j = 0; j < i; j++) {
			if (A[j].second < A[i].first) {
				int cur = dp[j] + P1[A[i].first] - P1[A[j].second + 1] + P0[A[i].second + 1] - P0[A[i].first];
				dp[i] = min(dp[i], cur);
			}
			if (A[i].first <= A[j].second && A[j].second <= A[i].second) {
				int cur = dp[j] + P0[A[i].second + 1] - P0[A[j].second + 1];
				dp[i] = min(dp[i], cur);
			}
		}*/
		
		//err("%d, ", dp[i]);
	}
	//err("\n");
	
	
	for (int i = 0; i < q; i++) {
		ans = min(ans, dp[i] + P1[n] - P1[A[i].second + 1]);
		//err("i = %d, t = %d\n", i, P1[n] - P1[A[i].second + 1]);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 11264
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a-lin bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
 
    string S,T;cin >> S >> T;
    int N = S.size(),M = T.size();
    int ans = 1000000;
    for(int i = 0;i<N-M+1;i++){
        int count = 0;
        string R = "";
        for(int j = i;j<i+M;j++){
            R += S.at(j);
        }
        for(int j = 0;j<M;j++){
            if(R.at(j) != T.at(j)) count++;
        }
        ans = min(ans,count);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<sstream>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; ++i)
#define per(i, a, n)  for(int i=n-1; i>=a; --i)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF pow(10, 18) + 7;
using namespace std;
typedef long long ll;

int main(){
  int N;  cin >> N;
  vector<int> v(N), c(N), sums(N);
  rep(i, 0, N)  cin >> v[i];
  rep(i, 0, N)  cin >> c[i];
  rep(i, 0, N)  sums[i] = v[i] - c[i];
  sort(rall(sums));
  
  int ans = 0;
  rep(i, 0, N){
    if(sums[i]>=0)  ans+=sums[i];
    else  break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef vector<ll>Vl;
typedef pair<ll,ll>PII;
typedef vector<PII>Vll;
typedef vector<pair<ll,pair<ll,ll> > >Vlll;
typedef priority_queue<ll>PQL;
typedef map<ll,ll>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const ll mod=1e9+7;
ll N;
int main(){
	sl(N);
	ll num;
	ll cnt=1;
	bool check=false;
	for(ll i=0;i<N;i++){
		sl(num);
		//cout<<num<<cnt;
		if(num==cnt){
			cnt++;
			check=true;
		}
	}
	if(check)cout<<N-cnt+1<<endl;
	else cout<<"-1"<<endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
for i in range(n):
    if a[i+1] + a[i] > b[i]:
        ans += b[i]
        a[i+1] = min(a[i+1], a[i] + a[i+1] - b[i])
    else:
        ans += a[i] + a[i+1]
        a[i+1] = 0
print(ans)


Measured memory_bytes: 97612
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
    int n,i;cin>>n;
    int A[n];
    fo(i,0,n)cin>>A[i];
    sort(A,A+n);
    ll sum=A[n-1];
    int cnt,cnt2=0;
    i=n-2;
    while(cnt2<n-2)
    {
        cnt=2;
        while(cnt--)
        {
            sum+=A[i];
            cnt2++;
            if(cnt2==n-2)break;
        }
        i--;
    }
    cout<<sum<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//If wrong on pretest 2 means logically wrong


/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 4428
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, t_time;
	cin >> n >> t_time;
	int c_min=1000;
	bool exist=false;
	int c, t;
	for(int i=0; i<n; i++){
		cin >> c >> t;
		if(t<=t_time && c<=c_min){
			c_min=c;
			exist=true;
		}
	}
	if(!exist) cout << "TLE" << endl;
	else cout << c_min << endl;
	return 0;
}

Measured memory_bytes: 256
W, H, x, y = map(int, input().split())

# 面積は必ず二等分可能
# 面積を二等分する直線は長方形の中心を通る
ans = '{} {}'.format(
    W * H / 2,
    1 if x == W / 2 and y == H / 2 else
    0
)

# 出力
print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9+7;

ll C(ll a,ll b){
		if(b<0) return 0;
		if(b>a) return 0;
		if(b==0) return 1;
		if(b==1) return a;
		if(b==2) return a*(a-1)/2;
		return 0;
}		
	
ll power (ll a,ll b){
		if(b<0)
			return 0;
		return pow(a,b);	
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	int k;
	cin>>s>>k;
	
	ll l = s.length();
	ll ans = 0;
	for(ll i=k;i<=l-1;i++){
		ll p = power(9,k);
		ll cc = C(i-1,k-1);
		ans += (p*cc);
		//ctrl + /cout<<i<<" "<<p<<" "<<cc<<" "<<ans<<"\n";
	}
	ans += (s[0] - '0' - 1) * C(l-1,k-1) * power(9,k-1);
	if(k==1) { 
		ans++;
		cout<<ans;
		return 0;
	}
	int i=1;
	for(;i<l;i++){
		if(s[i] != '0')
			break;
	}
	if(i<l){
		ans += C(l-i-1,k-1) * power(9,k-1);
		ans += (s[i] -'0' -1) * C(l-i-1,k-2) * power(9,k-2);
		if(k==2) {
			ans++;
			cout<<ans;
			return 0;
		}
	}
	i++;
	if(i<l){
		for(;i<l;i++)
			if(s[i] != '0')
				break;
	}
	if(i<l){
		ans += C(l-i-1,k-2) * power(9,k-2);
		ans += (s[i] - '0' - 1) * C(l-i-1,k-3) * power(9,k-3);
		if(k==3) ans++;
	}
	cout<<ans;
	return 0;
}
	
	
	
	
	
	
	
	
	
	
	

























Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<int> p(n), q(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;

        q[p[i]] = i;
    }

    int r = 0, k = 0, i = -1;
    for (int j = 0; j < n; j++) {
        if (q[j] > i) {
            k++;
            r = max(r, k);
        } else {
            k = 1;
        }
        i = q[j];
    }

    cout << n - r << endl;

    return 0;
}

Measured memory_bytes: 1792
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (n : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  s <- T.getLine :: IO T.Text
  let
    g = f n
  T.putStrLn . T.map g $ s

f :: Int -> Char -> Char
f n = toEnum . (+ 65) . (`mod` 26) . (+ n) . subtract 65 . fromEnum

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 1020
import string
alf = 'zabcdefghijklmnopqrstuvwxy'
x = int(input())

def x2a(x):
    s = ''
    while x != 0:
        div, mod = divmod(x, 26)
        s += alf[mod]
        if mod != 0:
            x = div
        else:
            x = div -1
    return s[::-1]
print(x2a(x))


Measured memory_bytes: 9876
import java.io.PrintStream;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		double[] A = new double[N];
		PriorityQueue<Double> pq = new PriorityQueue <Double>((a1,a2)->MyComparator(a1,a2));
		for(int i=0;i<N;i++) {
			A[i] = Double.parseDouble(next());
			pq.add(A[i]);
		}
		double num;
		while(pq.size()>1) {
			num = (pq.poll()+pq.poll())/2;
			pq.add(num);
		}
		out.println(pq.poll());
	}

	private int MyComparator(Double a1, Double a2) {
		if(a1 > a2) return 1;
		else if(a1 < a2) return -1;
		return 0;
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

int N;
P X[200100];
int res[200100];

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

    std::cin >> N;
    for(int i=0;i<N;++i){
        std::cin >> fst(X[i]);
        snd(X[i]) = i;
    }

    sort(X, X+N);
    
    int r = N / 2;
    for(int i=0;i<N;++i){
        if(i < r){
            res[snd(X[i])] = fst(X[r]);
        }else{
            res[snd(X[i])] = fst(X[r-1]);
        }
    }

    for(int i=0;i<N;++i){
        std::cout << res[i] << std::endl;
    }
}


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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

bool D(pair<ll,ll> A, pair<ll,ll> B, pair<ll,ll> C) {
	return (long double)A.ff*(long double)B.ss + (long double)A.ss*(long double)C.ff + (long double)B.ff*(long double)C.ss -
	((long double)B.ss*(long double)C.ff + (long double)A.ff*(long double)C.ss + (long double)A.ss*(long double)B.ff) < 0;
}

bool cross(pair<ll,ll> A, pair<ll,ll> B, pair<ll,ll> C) {
	pair<ll, ll> D = mp(B.ff-A.ff, B.ss-A.ss);
	pair<ll, ll> E = mp(C.ff-B.ff, C.ss-B.ss);
	return D.ff*E.ss < D.ss*E.ff;
}

vector<pair<ll,ll>> v;

void add(pair<ll,ll> a) {
	while(v.size() >= 2 and D(v[v.size()-2], v[v.size()-1], a))
		v.pop_back();
	v.push_back(a);
}

ll dot(pair<ll,ll> a, pair<ll,ll> b) {
	return a.ff*b.ff + a.ss*b.ss;
}

ll bisearch(ll x) {
	int l = 0, r = (int)v.size()-1;
	while(l < r) {
		int m = (l+r)/2;
		if(dot(mp(x,1), v[m]) < dot(mp(x,1), v[m+1]))
			r = m;
		else
			l = m+1;
	}
	return dot(mp(x,1), v[r]);
}

int n, h[200005];
ll c, dp[200005];

ll f() {
	for(int i = 0; i < n; i++) {
		if(i == 0) dp[i] = 0;
		else dp[i] = bisearch(h[i]) + (ll)h[i]*h[i] + c;
		add(mp(-2LL*h[i], (ll)h[i]*h[i] + dp[i]));
	}
	return dp[n-1];
}

int main() {
	scanf("%d%lld", &n, &c);

	for(int i = n-1; i >= 0; i--)
		scanf("%d", &h[i]);

	// printf("oi\n");
	printf("%lld\n", f());
	
    return 0;
}

Measured memory_bytes: 8304
#include <bits/stdc++.h>
#include<set>
#include <algorithm>
#define ll long long 
#include <string.h>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
using namespace std;
int main()
{
	ll int n;
	cin>>n;
	if (n>=30)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	
	
	
}

    
	
		

	
			

		


 







Measured memory_bytes: 3632
from bisect import bisect_left

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n + 1):
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

x = int(input())

ps = primes(10**5+100)

i = bisect_left(ps,x)
print(ps[i])

Measured memory_bytes: 4200
#include<stdio.h>
int main(){
	int a,b;
	while(1){
		scanf("%d%d",&a,&b);
		if(a==0&&b==0) return 0;
		if(a>b) printf("%d %d\n",b,a);
		else printf("%d %d\n",a,b);
	}
	return 0;
}



Measured memory_bytes: 1992
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#define rep(i,n) for(int i = 0;i<(n);i++);
using namespace std;
using ll = long long;
const ll INF = 100100100100100;

int main() {
	string s;
	cin >> s;
	ll size = s.size();
	bool yes = true;
	if (size % 2 == 1)yes = false;
	else {
		for (int i = 0; i < size / 2; i++) {
			if (s[2 * i] == 'h' && s[2 * i + 1] == 'i') continue;
			else {
				yes = false;
				break;
			}
		}
	}
	if (yes)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        Console.WriteLine(n < 1200 ? "ABC" : (n < 2800 ? "ARC" : "AGC"));
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
class Tree{
public:
    string s;
    Tree *left = NULL, *right = NULL;
    Tree(string word){
        s = word;
    }
    int check(string word){
        if(word == s){
            return 0;
        }else if(word < s){
            if(left == NULL){
                left =new Tree(word);
                return 1;
            }else{
                return left->check(word);
            }
        }else{
            if(right == NULL){
                right = new Tree(word);
                return 1;
            }else{
                return right->check(word);
            }
        }
    }
};
int main(){
    int n;
    cin >> n;
    string s[n], sc;
    int i, j, p=1;
    cin >> sc;
    Tree root(sc);
    for(i=1; i<n; i++){
        cin >> sc;
        p+=root.check(sc);
    }
    cout << p << endl;
    return 0;
}

Measured memory_bytes: 22316
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;

int main()
{
    int N;
    std::cin >> N;
    std::vector<std::array<int, 3>> s(N);
    for (int i = 0; i < N; i++) {
        std::cin >> s.at(i).at(0) >> s.at(i).at(1);
        s.at(i).at(2) = s.at(i).at(0) + s.at(i).at(1);
    }
    std::sort(s.begin(), s.end(), [] (auto a, auto b) { return a.at(2) > b.at(2); });

    bint ans = std::accumulate(s.begin(), s.end(), bint(0), [] (auto acc, auto a) { return acc - a.at(1); });
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            ans += s.at(i).at(2);
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
long long int INF = 1<<29;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
long long int i,j,k;
int n,m,r;
long long int x[202][202];
int a,b,d;
int rp[10];
bool visited[10];
bool flag = false;
int ans=0,res;


void dfs(int c,int las,int score){
	if(c==r+1){
		res = min(res,score);
		return;
	}
	for(int i=1;i<=r;i++){
		if(!visited[i]){
			visited[i]=true;
			if(las==-1)dfs(c+1,i,0);
			else dfs(c+1,i,score+x[rp[las]][rp[i]]);
			visited[i]=false;
		}
	}

}


int main(){
	//nは頂点の数、mは辺の数
	cin>>n>>m>>r;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(i!=j)
			x[i][j]=INF;
		}
	}
	for(i=1;i<=r;i++){
		cin>>rp[i];
	}
	for(i=1;i<=m;i++){
		cin>>a>>b>>d;
		if(x[a][b]>d){
		x[a][b]=d;
		x[b][a]=d;
		}
	}
	for(k=1;k<=n;k++){
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				if(x[i][k]+x[k][j]<x[i][j])x[i][j]=x[i][k]+x[k][j];
			}
		}
	}
	res = INF;
	dfs(1,-1,0);
	cout<<res<<endl;
	return 0;
}

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

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

using namespace std;

int main(){
    vector<int> n(3), c(3);
    for(int i = 0; i < 3; i++){
        cin >> n[i];
    }
    sort(ALL(n));
    vector<bool> odd(3);
    for(int i =0 ;i < 3; i++){
        odd[i] = (n[i] % 2 == 0);
    }
    int ans = 0;
    if(odd[0] == odd[2] && odd[1] == odd[0]){}
    else{
    if(odd[0] == odd[2]){
        n[0]++;
        n[2]++;
    }
    else if(odd[0] == odd[1]){
        n[0]++;
        n[1]++;
    }
    else{
        n[1]++;
        n[2]++;
    }
    ans++;
    }
    sort(ALL(n));
    for(int i = 0; i < 2; i++){
        while(n[i] != n[2]){
            n[i] += 2;
            ans++;
        }
    }


    cout << ans << endl;
    
        



	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace AtCoder {
    class Program {
        static void Main(string[] args) {

            var n = int.Parse(Console.ReadLine());

            for (int i = 0; i <= n / 4; i++) {
                for (int j = 0; j <= n / 7; j++) {
                    if ((i * 4 + j * 7) == n) {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }

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

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

#if debug
#include "printer.hpp"
#define dump(a) cerr << #a << "(" << __LINE__ << ") = " << a << endl;
#else
#define dump(...)
#endif

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a, b) for (int i = (b)-1; i >= a; i--)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
const ll mod = 1000000007;

ll pow(ll x, ll y) {
  ll ret = 1, tmp = x;
  while (y) {
    if (y % 2) ret = ret * tmp % mod;
    tmp = tmp * tmp % mod;
    y /= 2;
  }
  return ret;
}

ll inverse(ll x) { return pow(x, mod - 2); }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(8);

  ll N;
  cin >> N;
  vi a(N);
  rep(i, 0, N) {
    cin >> a[i];
  }
  ll i = 0;
  rep(j, 0, N) {
    if (a[j] == i + 1) {
      i++;
    }
  }
  if (i == 0) cout << -1 << endl;
  else cout << N - i << endl;
}


Measured memory_bytes: 1792
/*
author : seryu
title : ABC175C_"Walking Takahashi"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
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 solve()
{   
    ll x, k, d;
    cin >> x >> k >> d;
    ll r = x % d;
    ll q = x / d;
    if (abs(q) > k)
    {
        cout << abs(x) - d * k << endl;
    }
    else
    {
        k -= abs(q);
        if (k % 2 == 0)
        {
            cout << abs(r) << endl;
        }
        else
        {
            cout << min(abs(r+d), abs(r-d)) << endl;
        }
    }    
    return;	
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int IINF = INT_MAX;

int n, m;
int solve(vector<int> b, vector<int> a){
    int res = 0;
    for(int i=0;i<n;i++){
        if(b[i] != a[i]){
            int j = i+1;
            while(j<n && b[j]!=a[i]) j++;
            if(j==n) return IINF;
            swap(b[i],b[j]);
            res += j-i;
        }
    }
    return res;
}

int main() {
    cin >> n >> m;
    vector<int> b(n), a(n);
    for(int i=0;i<n;i++) cin >> b[i];
    for(int i=0,j=0;i<m;i++){
        int p;
        cin >> p;
        for(int k=0;k<p;k++){
            a[j++] = i%2;
        }
    }
    int ans;
    ans = solve(b, a);
    for(int i=0;i<n;i++) a[i] ^= 1;
    ans = min(ans, solve(b,a));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3160
#include <iostream>
using namespace std;
#include <vector>
#include <utility>
#include <math.h>
#include <climits>
#include <string.h>
#include <algorithm>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <iomanip>

#define loopi(i,n) for(int i=0;i<n;i++)
#define loopi1(i,n) for(int i=1;i<=n;i++)
#define vin vector<int>v(n,0)
#define pi pair<int,int>
#define f first
#define s second
#define lli long long int
#define ll long long
#define li long int
#define MODPRM  1000000009
#define MOD 1000000007



int main() {
	// your code goes here
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);

    // Printing the Output to output.txt file
    freopen("output.txt", "w", stdout);

	#endif // ONLINE_JUDGE*/
   int n;
   cin>>n;
   string s;
   cin>>s;
   if(n%2){cout<<"No"<<endl;return 0;}
   loopi(i,n/2){
       if(s[i]!=s[i+n/2]){cout<<"No"<<endl;return 0;}
   }
   cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    bool c=true;
    char x[a][a],y[b][b];
    for(int i=0;i<a;i++){
        for(int j=0;j<a;j++)cin>>x[i][j];
    }
    for(int i=0;i<b;i++){
        for(int j=0;j<b;j++)cin>>y[i][j];
    }
    for(int i=0;i<=a-b;i++){
        for(int j=0;j<=a-b;j++){
            c=true;
            for(int k=0;k<b;k++){
                for(int l=0;l<b;l++){
                    if(x[i+k][j+l]!=y[k][l])c=false;
                }
            }
            if(c){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,M,C;
  cin>>N>>M>>C;
  vector<int> B(M);
  vector<vector<int>> A(N,vector<int>(M));
  for(int i=0;i<M;i++){
    cin>>B[i];
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>>A[i][j];
    }
  }
  int ans=0;
  int D=C;
  for(int i=0;i<N;i++){
    C=D;
    for(int j=0;j<M;j++){
      C+=A[i][j]*B[j];
    }
    if(C>0){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
n,k = gets.split.map &:to_i

solve = -> b {
  q,r = (n + 1).divmod(b)
  ans = q * [b - k, 0].max
  ans += [r - k, 0].max
  k == 0 ? ans - 1 : ans
}

ans = 0
1.upto(n) do |i|
  ans += solve[i]
end

puts ans

Measured memory_bytes: 1916
// Author : SAGORIKA DAS
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
#define debug(x) cerr << "#" << x <<"\n";
#define int long long 
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
int a[MAX], b[MAX];
 main() {
   // fr;fw;
    int n;
    cin >> n;
    REP(i,n){
    	cin >> a[i];
    	b[i] = a[i];
    }
    sort(b,b+n);
    int ret = 0;
    REP(i,n){
    	int k = lower_bound(b,b+n, a[i])-b;
    	if(k%2 == i%2) continue;
    	else ret++;
    }
    cout << ret/2;
    return 0;
}

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

int main(void) {
    long long n;
    int c1,c2,c;
    int sum = 0;
    cin >> n;
   
  long long num = n;
    for(int i=0; i<8; i++){
        sum += num % 10;
        num /= 10;
    }

    if(n%sum==0) cout << "Yes";
    else cout << "No";
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

	var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long A = inputArray[0];
			long B = inputArray[1];


			//答えの出力
			var ans = A-B*2 >=0? A-B*2 : 0;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}

Measured memory_bytes: 18908
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
 int a,b;
  double f;

  cin>>a>>b;

  cout<<a/b<<" ";
  cout<<a%b<<" "<<flush;
  cout<<fixed<< setprecision(6);
  cout<<(double)a/(double)b<<endl;
}


Measured memory_bytes: 3284
using System;
using static System.Console;

class Program
{
	static void Main(string[] args)
	{
		long H, W, re;
		string[] str = ReadLine().Split(' ');
		H = long.Parse(str[0]);
		W = long.Parse(str[1]);

		if(H == 1 || W == 1)
		{
			re = 1;
		}
		else if(H % 2 == 0)
		{
			re = W * (H / 2);
		}
		else if(W % 2 == 0)
		{
			re = H * (W / 2);
		}
		else
		{
			re = (W * ((H - 1) / 2)) + ((W + 1) / 2);
		}
		WriteLine($"{re}");
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector<string> S(3);
  cin >> S[0] >> S[1] >> S[2];
  vector<int> index(3, 0);
  int player = 0;
  while(true){
    if(index[player] == S[player].size()){
      cout << (char)('A'+player) << endl;
      return 0;
    }
    index[player]++;
    player = S[player][index[player]-1] - 'a';
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    vector <ll> as;
    map <ll, ll> m;
    unordered_set <ll> s;
    REP(i, n){
        ll a; cin >> a;
        as.push_back(a);
        m[a]++;
        s.insert(a);
    }

    ll tot = 0;
    for(auto key: s){
        tot += (m[key]-1) * m[key] / 2;
    }
    for(auto a: as){
        ll num = m[a];
        cout << tot - num*(num-1)/2 + (num-1)*(num-2)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 18492
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int n,m,vis[800],size1,size2;
bool p[800][800],f[2000],g[2000];
void dfs(int u,int now)
{
	if (vis[u]!=0)
	{
		if (vis[u]!=now) { puts("-1");exit(0);}
		return;
	}
	if (now==1) size1++;else size2++;
	vis[u]=now;
	for (int i=1;i<=n;i++)
		if (i!=u&&!p[u][i]) dfs(i,-now);
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		p[u][v]=p[v][u]=1;
	}
	f[0]=1;
	for (int i=1;i<=n;i++)
	if (vis[i]==0)
	{
		size1=size2=0;
		dfs(i,1);
		memset(g,0,sizeof(g));
		for (int j=0;j<=n;j++)
		{
			g[j+size1]|=f[j];
			g[j+size2]|=f[j];
		}
		for (int j=0;j<=n;j++) f[j]=g[j];
	}
	int ans=1<<29;
	for (int i=0;i<=n;i++)
		if (f[i]) ans=min(ans,i*(i-1)/2+(n-i)*(n-i-1)/2);
	printf("%d\n",ans);
	return 0;
}


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

// types - only for stuff used a lot 
using ll = long long;
#define vv vector
#define Pp pair

// IO
#define get(x) scanf("%d",&x)
#define getl(x) scanf("%d",&x);

// Operations
#define pb push_back
#define pob pop_back
#define sz(a) int(a.size()) 
#define re(a,b) a=max(a,b) // relax
#define ri(a,b) a=min(a,b) // relaxi

// Debugging

#ifndef LOCAL
#define cerr if (0) cerr
#else
#define cerr cout
#endif

#define print(arr,n) {for (int _ = 0; _ < n; _++) cerr<<arr[_]<<" "; cerr << endl; }
#define printv(vec)  {for (int _ : vec) cerr<<_<<" "; cerr<<endl;}

const int mod = 1e9+7, oo = 1e9;
const ll loo = 1e18;

// Functions 
ll modpow(ll a, ll b) {
	ll ans = 1; // faster modpow than recursive
	for (; b; b/=2,a=a*a%mod)
		if (b&1) ans = (ans*a)%mod;
	return ans;
}
ll gcd(ll a, ll b) {
	while (a) b%=a,swap(a,b);
	return b;
}
#define bitcount __builtin_popcount
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)

/* 

   ALRIGHT HACKERS, THIS IS WHERE THE ACTUAL CODE BEGINS

 */

const bool DEBUG = 1;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	if (DEBUG) freopen("input.txt", "r", stdin);
	if (DEBUG) freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n;
	get(n);
	char buffer[n];
	scanf("%s",buffer);
	string s(buffer);
	vv<int> adj[n];	
	int subsz[n];
	ll tot[n],lo[n];	
	f(e,0,n-1) {
		int a,b;
		get(a); get(b);
		a--; b--;
		adj[a].pb(b); adj[b].pb(a);
	}
	function<int(int,int)> dfs = [&](int v, int p) {
		subsz[v] = s[v]=='1'; 
		tot[v] = 0;
		int mx = -1, mi = -1;
		for (int w : adj[v]) if (w != p) {
			subsz[v] += dfs(w,v);
			tot[v] += tot[w] + subsz[w];
			if (lo[w] + subsz[w] > mi) {
				mi = lo[w] + subsz[w];
				mx = tot[w] + subsz[w];
			}
		}
		lo[v] = mi>tot[v]-mx?mi-(tot[v]-mx):tot[v]%2;
		return subsz[v];
	};
	ll ans = oo;
	for (int v = 0; v < n; v++) {
		dfs(v,-1);
		if (!lo[v])
			ri(ans,tot[v]/2);
	}
	cout << (ans==oo?-1:ans) << endl;


#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_B&lang=jp

int n;
int A[1000005];

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

int main() {
    cin >> n;
    REP(i, n) cin >> A[i];
    int q = partition(0, n-1);
    REP(i, n) {
        if (i > 0) cout << " ";
        if (i == q) cout << "[";
        cout << A[i];
        if (i == q) cout << "]";
    }
    cout << "\n";
    return 0;
}



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


int main(void){
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    vector<int> a;
    vector<int> b;
    rep(i,n){
        int c;
        cin >> c;
        a.push_back(c);
    }
    rep(i,m){
        int c;
        cin >> c;
        b.push_back(c);
    }
    sort(a.begin(),a.end(),greater<int>());
    sort(b.begin(),b.end());
    
    bool flag = 0;
    for(int i=x+1;i<=y;i++){
        if(a[0]<i && i <= b[0]){
            flag = 1;
        }
    }
    if(flag){
        cout << "No War";
    }
    else{
        cout << "War";
    }
    
    
    return 0;
    
}






















































Measured memory_bytes: 256
#include <iostream>
#include <string>
 
using namespace std;
 
long add(const string& numbers, const int& bitsOfPlusPosition);
 
int main() {
    string numbers;
    cin >> numbers;
    
    long answer = 0;
    for (int bits = 0; bits < (1 << (numbers.size() - 1)); ++bits) {
        answer += add(numbers, bits);
    }
    cout << answer << endl;       
}
 
long add(const string& numbers, const int& bitsOfPlusPosition) {
    const int DECIMAL_BASE = 10;
    long sum = 0;
    long term = 0;
    for (size_t i = 0U; i < numbers.size(); ++i) {
        term *= DECIMAL_BASE;
        term += numbers.at(i) - '0';
        if (bitsOfPlusPosition & (1 << i) || i == numbers.size() - 1) {
            sum += term;
            term = 0;
        }
    }
    return sum;
}

Measured memory_bytes: 3596
#include<stdio.h>

int main(){
    int con_cat;
    int con_unkn;
    int var_cat;
    
    scanf("%d %d %d",&con_cat,&con_unkn,&var_cat);
    
    if(var_cat>=con_cat && var_cat<=con_cat+con_unkn-1){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (h, w) = [int(e) for e in lines[0].split(" ")]

    return (h, w)


def solve(h, w):

    if h == 1 or w == 1:
        return 1

    cell = h * w
    tmp = cell // 2
    result = None
    if cell % 2 == 0:
        result = tmp
    else:
        result = tmp + 1
        

    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s[n];
  int ans = 0,a=0,b=0,w=0;
  for(int i=0;i<n;i++){
    cin >> s[i];
    for(int j=0;j<s[i].length()-1;j++){
      if(s[i][j]=='A'&&s[i][j+1]=='B'){
        ans++;
      }
    }
    if(s[i][0]=='B'&&s[i][s[i].length()-1]=='A') w++;
    else if(s[i][0]=='B') b++;
    else if(s[i][s[i].length()-1]=='A') a++;
  }
  if(a+b!=0) cout << ans+min(a+w,b+w) << endl;
  else cout << max(ans,ans+w-1) << endl;
  return 0;
}


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

int main() {
	int N;
	int Q;
	cin >> N;
	cin >> Q;
	vector<int> eda(N);
	for (int i = 0; i < N-1; i++) {
		int a, b;
		cin >> a >> b;
		eda.at(b - 1) = a-1;
	}
	vector<int>answer(N,0);
	for (int i = 0; i < Q; i++) {
		int p;
		int x;
		cin >> p >> x;
		answer.at(p-1) += x;
	}
	for (int i = 1; i < N; i++) {
		answer.at(i) += answer.at(eda.at(i));
	}
	for (int i = 0; i < N; i++) {
		cout << answer.at(i) << endl;
	}
}

Measured memory_bytes: 3968
def powmod(m, n, p):
    pow = m
    ret = 1
    while n > 0:
        if n & 1:
            ret = ret * pow % p
        pow = (pow * pow) % p
        n >>= 1
    return ret

m, n = [int(x) for x in input().split()]
p = 10 ** 9 + 7
print(powmod(m, n, p))


Measured memory_bytes: 5604
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    ll n,i,j,k;
    cin>>n;
    string s;
    cin>>s;
    vector<ll> cnt;
    cnt.pb(0);
    cnt.pb(0);
    cnt.pb(0);
    ll dist[n][3];
    memset(dist,0LL,sizeof(dist));
    if (s[n-1]=='R')
        cnt[0]++;
    else if (s[n-1]=='G')
        cnt[1]++;
    else if (s[n-1]=='B')
        cnt[2]++;
    for (i=n-2;i>=0;i--)
    {
        dist[i][0]=cnt[0];
        dist[i][1]=cnt[1];
        dist[i][2]=cnt[2];
        if (s[i]=='R')
            cnt[0]++;
        else if (s[i]=='G')
            cnt[1]++;
        else if (s[i]=='B')
            cnt[2]++;
    }
    ll ans=0;
    for (i=0;i<n-1;i++)
    {
        for (j=i+1;j<n;j++)
        {
            if (s[i]!=s[j])
            {
                k=2*j-i;
                if (k<n)
                {
                    if ((s[i]=='R' && s[j]=='G') || (s[i]=='G' && s[j]=='R'))
                    {
                        if (s[k]=='B')
                            ans+=dist[j][2]-1;
                        else
                            ans+=dist[j][2];
                    }
                    else if ((s[i]=='G' && s[j]=='B') || (s[i]=='B' && s[j]=='G'))
                    {
                        if (s[k]=='R')
                            ans+=dist[j][0]-1;
                        else
                            ans+=dist[j][0];
                    }
                    else if ((s[i]=='R' && s[j]=='B') || (s[i]=='B' && s[j]=='R'))
                    {
                        if (s[k]=='G')
                            ans+=dist[j][1]-1;
                        else
                            ans+=dist[j][1];
                    }
                }
                else
                {
                    if ((s[i]=='R' && s[j]=='G') || (s[i]=='G' && s[j]=='R'))
                        ans+=dist[j][2];
                    else if ((s[i]=='G' && s[j]=='B') || (s[i]=='B' && s[j]=='G'))
                        ans+=dist[j][0];
                    else if ((s[i]=='R' && s[j]=='B') || (s[i]=='B' && s[j]=='R'))
                        ans+=dist[j][1];
                }
            }
        }
    }
    cout<<ans<<endl;
}

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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

    ll n;
    string s;
    cin >> n >> s;

    vector<pair<pair<ll,ll>,ll>> x(n);
    for (ll i = 0;i < n;i++){
        if (i != 0){
            x[i] = x[i-1];
        }

        if (s[i] == 'R'){
            x[i].first.first++;
        }
        else if (s[i] == 'G'){
            x[i].first.second++;
        }
        else{
            x[i].second++;
        }
    }

    /*for (ll i = 0; i < 39; i++){
        cout << x[i].first.first << " " << x[i].first.second << " " << x[i].second << endl;
    }*/

    ll ans = 0;

    for (ll j = 1; j < n-1; j++){
        for (ll k = j+1; k < n; k++){
            //cout << j << k << endl;
            ll i = j-1;
            if (s[j] == s[k]){
                continue;
            }

            if (s[j] == 'R'){
                if (s[k] == 'G'){
                    ans += x[i].second;
                }
                else{
                    ans += x[i].first.second;
                }
            }
            else if (s[j] == 'G'){
                if (s[k] == 'R'){
                    ans += x[i].second;
                }
                else{
                    ans += x[i].first.first;
                }
            }
            else{
                if (s[k] == 'R'){
                    ans += x[i].first.second;
                }
                else{
                    ans += x[i].first.first;
                }
            }

            ll t = 2*j - k;

            if (0 <= t && t <= i && s[t] != s[j] && s[t] != s[k]){
                ans--;
                //cout << t << endl;
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 3712
N, K = list(map(int, input().split(" ")))

count = 0

for i in range(K, N+2):
    count += (N + N - i + 1) * i / 2 - (0 + i - 1) * i / 2 + 1
    count %= pow(10, 9) + 7

print(int(count))


Measured memory_bytes: 9184
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>
 
using namespace std;
 
int main() {
  int n;
  int a,i;
  cin >> n;
 
  vector<int> ma;
  if(n==2){
    cout<<2<<endl;
    return 0;
  }
  for (a = 2; a < n; ++a) {
    int b = n-a;
    int ac=a;
    // cout<<a<<endl;
    // cout<<b<<endl;
 
    int as=0;
    while(true){
      as+=ac%10;
      if(log10(ac)<1)
        break;
      ac=ac/10;
      // cout<<as<<endl;
    
    }
 
    int bs=0;
    while(true){
      bs+=b%10;
      if(log10(b)<1)
        break;
      b=b/10;
    
    }
    // cout<<as+bs<<endl;
    // cout<<a<<" "<<as<<" "<<bs<<endl;
    ma.push_back(as+bs);
  
  }
  int minn = *min_element(ma.begin(), ma.end());
  cout<<  minn<<endl;

}



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

using namespace std;

int main() {
  int N;
  cin >> N;
  int prev = 0;
  int streak = 0;
  int max_ = 0;
  for (int i = 1; i <= N; ++i) {
    int H;
    cin >> H;
    if (prev >= H) {
      max_ = max(max_, ++streak);
    } else {
      streak = 0;
    }
    prev = H;
  }
  cout << max_ << endl;
}


Measured memory_bytes: 256
from math import floor
def kill(life):
    if life in dp.keys():
        return dp[life]
    if life == 1:
        dp[life] = 1
        return 1
    elif life > 1:
        dp[life] = kill(floor(life/2)) * 2 + 1
        return dp[life]
h = int(input())
dp = {}
print(kill(h))

Measured memory_bytes: 38384