akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

vector<ll> decom;

void decompositPrime(ll n)
{
    ll a = 2;
    while (n >= a * a)
    {
        if (n % a == 0)
        {
            decom.push_back(a);
            n /= a;
        }
        else
        {
            a++;
        }
    }
    decom.push_back(n);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
ll func(ll n){
    int hold;
    REP(i,50){
        if(n < i*(i+1)/2){
            hold = i;
            //cout << "n= " << n << " i= " << hold << endl;
            return i-1;
        }
    }

    return 0;
}

int main()
{

    ll N; cin >> N;
    decompositPrime(N);
    if(N==1){
        cout << 0 << endl;
        return 0;
    }

    //REP(i,decom.size()) cout << decom[i] << " ";
    //cout << endl;

    ll ans=0, res=decom[0];
    int cnt = 1;
    REP(i,decom.size()){
        if(res!=decom[i+1] or i==decom.size()-1){
            res = decom[i+1];
            ans += func(cnt);
            cnt = 1;
        }else{
            cnt++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3640
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    #cost[i]:i日後に報酬が貰える仕事の報酬
    cost = [[] for _ in range(10**5+10)]
    for _ in range(n):
        a,b = map(int, input().split())
        cost[a].append(b)

    res = 0
    hq = [0]
    heapq.heapify(hq)
    for i in range(1, m+1):
        for c in cost[i]:
            heapq.heappush(hq, -c)
        if not hq:
            continue
        res -= heapq.heappop(hq)
    print(res)
            





if __name__ == '__main__':
    main()

Measured memory_bytes: 67504
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    double n, k;
    cin >> n >> k;
    double ret = 0.0;
    for (int i = 1; i <= n; ++i) {
        int t = 0;
        int j = i;
        while (j < k) {
            t++;
            j *= 2;
        }
        ret += pow(0.5, t);
    }
    ret /= n;
    cout << fixed << setprecision(10) << ret << "\n";
    return 0;
}

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

int main(){
	
	int n,k; cin>>n>>k;
	vector s(n,0);
	for(int i=0; i<k; i++){
		int d; cin>>d;
		for(int j=0; j<d; j++){
			int a; cin>>a;
			s.at(--a)++;
		}
		
	}
	int sum{};
	for(int i=0; i<n; i++){
		sum += s.at(i)==0;
	}
	cout << sum << endl;
}

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

int main() {
  int N,T;
  cin >> N >> T;
  int ans = 100000;
  for (int i = 0; i<N;i++) {
    int c,t;
    cin >> c >> t;
    if (t <= T) {
      ans = min(ans,c);
    }
  }
  if (ans == 100000) cout << "TLE" << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n';

#define MAXN   1000001 
  
// stores smallest prime factor for every number 
int spf[MAXN]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

map<int, int> mp;
  
// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
void getFactorization(int x) 
{ 
    while (x != 1) 
    { 
        int val = spf[x];
        mp[val]++;
        while(x%val==0){
            x/=val;
        }
    } 
} 
signed main(){
	int n;cin>>n;
	int gc = 0;
	sieve();
	for(int i = 0; i < n; ++i){
        int x;cin>>x;
        getFactorization(x);
        gc = __gcd(gc, x);
	}
	bool ok = 1;
	for(auto x : mp) ok &= x.second < 2;
	if(ok){cout<<"pairwise coprime";}
	else if(gc==1){
		cout<<"setwise coprime";
	} else{
		cout<<"not coprime";
	}
 
	return 0;
}

Measured memory_bytes: 11148
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(){

    int i,j,k;
    char line[256];
    int N,v;

    fgets(line,sizeof(line),stdin);
    sscanf(line,"%d",&N);

    int num[N];

    for(i=0;i<N;i++){   /*初期化*/
        num[i] = 0;
    }

    for(i=0;i<N;i++){
        scanf("%d",&v);
        //fgets(line,sizeof(line),stdin);
        //sscanf(line,"%d",&v);
        num[v] += 1;
    }

    if(N % 2 != 0){
        if(num[0] != 1){
            //printf("zero is't exist\n");
            printf("0");
            return 0;
        }
    }

    for(i=1;i<N/2+1;i++){   /*矛盾判定、Nが奇数だったら0,2,4,6,,,で偶数だったら1,3,5,7,,,*/
        
        if(N % 2 == 0){ /*偶数の場合*/

            if(num[i*2-1] != 2){
            //printf("contradiction occured! at %d\n",i);
            printf("0");
            return 0;
            }

        }

        else{           /*奇数の場合*/
            if(num[i*2] != 2){
            //printf("contradiction occured! at %d\n",i);
            printf("0");
            return 0;
            }
        }

    }

    long long int ans=1;

    //ans = (int)pow(2,N/2) % (int)(1e9+7);
   
    for(i=0;i<N/2;i++){
        ans *= 2;
        ans %= (int)(1e9+7);
    }

    printf("%lld",ans);

    return 0;
}

Measured memory_bytes: 512
class Island
  attr_accessor :weight, :limit

  def initialize(inputs)
    @weight = inputs[0].to_i
    @limit = inputs[1].to_i
  end

  def pass?(weight)
    weight <= @limit
  end
end

def get_all?(weight = 0, islands = [])

  islands = islands.dup
  now_weight = 0

  until islands.empty?
    max_limit_island = islands.max {|a, b| a.limit <=> b.limit }

    if max_limit_island.pass? islands.inject(0) {|sum, v| sum + v.weight }
      now_weight += max_limit_island.weight
      islands.delete max_limit_island
    else
      return false
    end
  end

  true
end

while n = gets.chomp.to_i
  break if n == 0

  islands = n.times.map { Island.new gets.chomp.split(' ') }


  if get_all? 0, islands
    puts 'Yes'
  else
    puts 'No'
  end
end

Measured memory_bytes: 8800
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
int main(){
    int x, y;
    cin >> x >> y;
    bool ans = false;
    for (int i = 0; i <= x ; i++){
        for(int j = 0; j <= x ; j++){
            if(j + i == x){
                if(i*2 + j*4 == y){
                    ans = true;
                }
            }
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
n=gets.chomp.split("").map(&:to_i)
ll=n.length

sum=0
i=0
ll.times{
    sum+=n[i]
    i+=1
}

sum1=sum-n[0]


if n.length==1 
    p n[0]
elsif sum1==9*(ll-1)
    p sum 
else
    p n[0]+9*(ll-1)-1
end


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

using ll = long long;
const int N = 3010;
const int MOD = 998244353;

int n, s, a[N];
ll dp[3][N][N];

ll DP(int ty, int i, int sum) {
  if(i < 1) return sum == 0;
  if(dp[ty][i][sum] != -1) return dp[ty][i][sum];

  if(ty == 2) {
    dp[2][i][sum] = DP(2, i - 1, sum) + DP(1, i, sum);
    if(dp[2][i][sum] >= MOD) dp[2][i][sum] -= MOD;
  } else if(ty == 1) {
    dp[1][i][sum] = DP(1, i - 1, sum);
    if(sum - a[i] >= 0) dp[1][i][sum] += DP(1, i - 1, sum - a[i]);
    if(dp[1][i][sum] >= MOD) dp[1][i][sum] -= MOD;
    dp[1][i][sum] += DP(0, i, sum);
    if(dp[1][i][sum] >= MOD) dp[1][i][sum] -= MOD;
  } else {
    dp[0][i][sum] = DP(0, i - 1, sum);
  }
  return dp[ty][i][sum];
}

int main () {
  scanf("%d %d", &n, &s);
  for(int i = 1; i <= n; i++)
    scanf("%d", &a[i]);
  memset(dp, -1, sizeof dp);
  printf("%lld\n", DP(2, n, s));
  return 0;
}

Measured memory_bytes: 212864
// ref: https://drken1215.hatenablog.com/entry/2019/03/21/234900

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    
    uint N, M; cin >> N >> M;
    
    vector<int> vP(M), vY(M);
    vector<vector<int>> vvPY(N);
    for(uint i=0; i<M; ++i){
        int p, y; cin >> p >> y; --p;
        vP[i] = p;
        vY[i] = y;
        vvPY[p].push_back(y);
    }
    
    for(uint pi=0; pi<vvPY.size(); ++pi){
        sort(vvPY[pi].begin(), vvPY[pi].end());
        
        vvPY[pi].erase( unique(vvPY[pi].begin(), vvPY[pi].end()), vvPY[pi].end() );
    }
    
    for(uint i=0; i<M; ++i){
        int pi = vP[i];
        int idx = lower_bound(vvPY[pi].begin(), vvPY[pi].end(), vY[i]) - vvPY[pi].begin();
        printf("%06d%06d\n", pi+1, idx+1);
    }
    
    return 0;
}


Measured memory_bytes: 7808
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	char c;
	while(~scanf("%c",&c)){
		if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') printf("vowel\n");
		else if(c >= 'a' && c <= 'z') printf("consonant\n");
	}
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    int n;
    cin >> n;
    int a = n%10;
    if(a==3){
        cout << "bon" << endl;
    }else if(a==0 || a==1 ||a==6 ||a==8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3592
c2n = {
  "M" => 1000, "D" => 500, "C" => 100, "L" => 50,
  "X" => 10, "V" => 5, "I" => 1
}

### main

while (line =gets)
  chs = line.chomp.split("")

  sum = 0

  for i in (0...chs.length)
    n0 = c2n[chs[i]] || 0
    n1 = c2n[chs[i + 1]] || 0

    if n0 < n1
      sum -= n0
    else
      sum += n0
    end
  end

  puts sum
end

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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
ll f[maxn][4][4][4][4];

struct mask{
  int a, b, c, d;
  mask(int _a = 0, int _b = 0, int _c = 0, int _d = 0) : a(_a), b(_b), c(_c), d(_d) {}
  bool operator == (const mask &op) const{
    return a == op.a && b == op.b && c == op.c && d == op.d;
  }
  bool check(){
    if (a == 0 && c == 2 && d == 1) return false;
    if (a == 0 && b == 2 && d == 1) return false;
    if (b == 0 && c == 1 && d == 2) return false;
    if (b == 2 && c == 0 && d == 1) return false;
    if (b == 0 && c == 2 && d == 1) return false;
    if (a == 0 && b == 1 && c == 2) return false;
    if (a == 2 && b == 0 && c == 1) return false;
    if (a == 0 && b == 2 && c == 1) return false;
    return true;
  }
};

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);
//  freopen(Task".out", "w", stdout);
  int n; cin >> n;
  if (n == 3) {
    cout << 61;
    return 0;
  }
  For(a, 0, 3) For(b, 0, 3) For(c, 0, 3) For(d, 0, 3){
    mask ok(a, b, c, d);
    if (ok.check())
    f[4][a][b][c][d]++;
  }
  for (int i = 4; i < n; ++i){
    For(a, 0, 3) For(b, 0, 3) For(c, 0, 3) For(d, 0, 3){
      mask ok(a, b, c, d);
      if (not ok.check()) continue;
      For(e, 0, 3){
        mask n_c(b, c, d, e);
        if (n_c.check())
          f[i + 1][b][c][d][e] = (f[i + 1][b][c][d][e] + f[i][a][b][c][d]) % mod;
      }
    }
  }
  ll ans = 0;
  For(a, 0, 3) For(b, 0, 3) For(c, 0, 3) For(d, 0, 3){
    mask ok(a, b, c, d);
    if (ok.check()){
      ans = (ans + f[n][ok.a][ok.b][ok.c][ok.d]) % mod;
    }
  }
  cout << ans;
return 0;
}



Measured memory_bytes: 512
n = int(input())
pair_list = list()
for i in range(n):
    pair = list(map(str,input().split()))
    pair_list.append(pair)

a = 0
b = 0
for card in pair_list:
    if card[0] == card[1]:
        a += 1
        b += 1
        continue

    if card == sorted(card):
        b += 3
    else:
        a += 3

print(a,b)



Measured memory_bytes: 5716
/*input
8
1 2 3 4 5 6 7 8
2
1 6
3 8
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_
}

fn main() {
    read_line();
    let mut v: Vec<i64> = read_line()
        .trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    let i: u16 = read_line().trim().parse().unwrap();
    for _ in 0..i {
        let v_: Vec<u16> = read_line()
            .trim()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect();
        &v[(v_[0]) as usize..(v_[1]) as usize].reverse();
    }
    for i in 0..v.len() {
        print!("{}", v[i]);
        if i != v.len() - 1 {
            print!(" ");
        }
    }
    print!("\n");
}



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

using namespace std;

typedef pair<char, char> P;
int N, Q;
string label;
P command[200000];
int leftpos, rightpos;

bool left_f(int a) {
	int nowpos = a;
	for (int i = 0; i < Q; i++) {
		if (label[nowpos] == command[i].first) {
			if (command[i].second == 'L')nowpos--;
			else nowpos++;
		}
		if (nowpos == -1)return true;
	}
	return false;
}

bool right_f(int a) {
	int nowpos = a;
	for (int i = 0; i < Q; i++) {
		if (label[nowpos] == command[i].first) {
			if (command[i].second == 'L')nowpos--;
			else nowpos++;
		}
		if (nowpos == N)return true;
	}
	return false;
}

int main() {
	cin >> N >> Q >> label;
	for (int i = 0; i < Q; i++) {
		cin >> command[i].first >> command[i].second;
	}

	//左からの二分探索

	int u = N, l = -1;
	for (int i = 0; i < 40; i++) {
		int mid = (u + l) / 2;
		if (left_f(mid))l = mid;
		else u = mid;
	}
	if (left_f(u))leftpos = u;
	else leftpos = l;

	//右からの二分探索

	u = N, l = -1;
	for (int i = 0; i < 40; i++) {
		int mid = (u + l) / 2;
		if (right_f(mid))u = mid;
		else l = mid;
	}
	if (right_f(l))rightpos = l;
	else rightpos = u;

	cout << rightpos - leftpos - 1 << endl;
	
	return 0;
}

Measured memory_bytes: 900
//C - Multiple Gift: 
//Assunto: 
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100005
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ll x, y, aux;
    int size = 0;
    cin >> x >> y;
    aux = x;
    while(aux <= y) {
        size++;
        aux *= 2;
    }
    cout << size << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

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

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};


int main(){
	int x[5];
	rep(i, 0, 5)cin >> x[i];
	rep(i, 0, 5) {
		if (x[i] == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	return 0;
}

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

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


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


int main() {
    int A, B;
    cin >> A >> B;
    int ans = 0;
    if (A>B) {
        ans += A;
        A -= 1;
    } else {
        ans += B;
        B -= 1;
    }
    if (A>B) {
        ans += A;
        A -= 1;
    } else {
        ans += B;
        B -= 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from bisect import*
def solve(x):
  s=t=0
  i=n
  j=-1
  for y in a:
    while i and a[i-1]*y>x:i-=1
    while j+1<m and b[j+1]*y<=x:j+=1
    s+=j+1
    t+=i
    if y*y<=x:t-=1
  s+=t//2
  t=0
  i=m
  for y in c:
    while i and c[i-1]*y>x:i-=1
    t+=i
    if y*y<=x:t-=1
  s+=t//2
  return s
n,k,*t=map(int,open(0).read().split())
t.sort()
i=bisect(t,0)
a,b,c=t[i:],t[:i],t[i-1::-1]
n,m=len(a),len(b)
ok=10**18
ng=-ok
while ok-ng>1:
  mid=(ok+ng)//2
  if solve(mid)>=k:ok=mid
  else:ng=mid
print(ok)

Measured memory_bytes: 98056
#include<iostream>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;


long long a[200011];
int n;
long long ans;

void gao(long long t)
{
     int i;
     long long tmp=0;
     for(i=1;i<=n;i++)
     {
         tmp+=abs(a[i]-t);
     }
     
     ans=min(ans,tmp);
}

int main()
{
    int i,j,k;
    long long s=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        a[i]=a[i]-i;
    }
    
    sort(a+1,a+n+1);
    
    s=(n+1)/2;
    
    
    ans=0x3f3f3f3f3f3f3f3fll;
    gao(a[s]);
    if(n>1)
    {
        gao(a[s+1]);
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1792
/*====Corycle====*/
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<vector>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
int read(){
	int s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
	return s*f;
}

int main(){
//	freopen("_.in","r",stdin);
//	freopen("_.out","w",stdout);
	int n=read()%10;
	if(n==2||n==4||n==5||n==7||n==9)puts("hon");
	if(n==0||n==1||n==6||n==8)puts("pon");
	if(n==3)puts("bon");
	return 0;
}

Measured memory_bytes: 3032
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
using namespace std;

#define ll long long

int main(){
    int N;
    double T,A,d = 1000,ans;
    cin >> N >> T >> A;
    double H[N];
    for(int i = 0; i < N; i++){
        cin >> H[i];
        if(fabs(T - H[i]*0.006 - A) < d){
            ans = i+1;
            d = fabs(T - H[i]*0.006 - A);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main(void){
    int l[200], top = -1, b;
    string a;
    while(cin >> a){
        if(a[0] == '+'){
            l[top-1] += l[top];
            top--;
            //cout << '+';
        } else if(a[0] == '*'){
            l[top-1] *= l[top];
            top--;
            //cout << a;
        } else if(a[0] == '-'){
            l[top-1] -= l[top];
            top--;
            //cout << a;
        } else {
            top++;
            b = atoi(a.c_str());
            l[top] = b;
            //cout <<" " << l[top] << " " << b << " ";
        }
        //cout << a << endl;
        for(int i = 0; i <= top ;i++){
            //cout << l[i] << " ";
        }
        //cout << endl;
    }
    cout << l[0] << endl;
    return 0;
}



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


int main(){
    int n,k;cin>>n>>k;
    int a[1000000];map <int,int> mp;
    set <int> s;
    rep(i,n){
        cin>>a[i];mp[a[i]]++;
        s.insert(a[i]);
    }
    int sum=0;
    vector<int> v;
    for(auto x:mp){
        v.push_back(x.second);
    }
    sort(all(v));
    if(s.size()<=k){
        cout<<0<<endl;
    }
    else{
        int m=s.size()-k;
        rep(i,m)sum+=v[i];
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 20988
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}



int main()
{
    fastio();
    int l,r,n; int cnt = 0;
    cin>>l>>r>>n;
    rep(i,l,r) if(i%n==0) cnt++;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3604
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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







int main(){
    int N, r(0), w(0); std::cin >> N;
    std::string c; std::cin >> c;
    for(int i(0); i < N; ++i){
        if(c[i] == 'R') ++r;
    }
    int ans(std::max(r, w));
    for(int i(0); i < N; ++i){
        if(c[i] == 'R') --r;
        else ++w;
        chmin(ans, std::max(r, w));
    }
    std::cout << ans << std::endl;
}


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


using namespace std;


using ll = long long;


int main() {
    ll h, w, k;
    cin >> h >> w >> k;

    vector<string> s(h);
    for (int i = 0; i < h; i++)
        cin >> s[i];

    int ans = INT_MAX;
    for (int bits = 0; bits < 1 << (h - 1); ++bits) {
        int num_groups = 0;
        vector<int> gid(h);
        for (int j = 0; j < h; j++) {
            gid[j] = num_groups;
            if (bits >> j & 1) {
                num_groups++;
            }
        }
        num_groups++;
        vector<vector<int>> c(num_groups, vector<int>(w, 0));
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                c[gid[i]][j] += (s[i][j] - '0');
            }
        }

        int num_lines = num_groups - 1;
        vector<int> whites(num_groups, 0);

        for (int i = 0; i < w; i++) {
            for (int j = 0; j < num_groups; j++) {
                whites[j] += c[j][i];
            }
            bool fail = false;
            for (auto e : whites) {
                if (k < e) {
                    fail = true;
                    break;
                }
            }

            if (fail) {
                num_lines++;
                for (int j = 0; j < num_groups; j++) {
                    whites[j] = c[j][i];
                }
                for (auto e : whites) {
                    if (k < e) {
                        num_lines = (INT_MAX / 2);
                        break;
                    }
                }
            }
        }

        ans = min(ans, num_lines);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi
#define se second
 
#define forz(i,n) for(long long int i=0;i<n;i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0) 
 
using namespace std;

int main()
{
	lli n , a, b;
	cin >> n >>a >> b;
	if (n%(a+b) >= a)
	{
		cout << a*(n/(a+b))+a << endl;
	}
	else if (n%(a+b) <  a)
	{
		cout << a*(n/(a+b)) + n%(a+b)<< endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <iterator>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    bool flag = true;
    string s, s_inv;
    cin >> s;

    reverse_copy(s.begin(), s.end(), back_inserter(s_inv));
    REP(i, (s.length()-1)/2){
        if(s[i] != s_inv[i]) flag = false;
    }

    s_inv = "";
    reverse_copy(s.begin(), s.begin() + (s.length()-1)/2, back_inserter(s_inv));
    // cout << s << endl;
    // cout << s_inv << endl;
    REP(i, (s.length()-1)/2){
        if(s[i] != s_inv[i]) flag = false;
    }

    s_inv = "";
    reverse_copy(s.begin() + (s.length()+3)/2 - 1, s.end(), back_inserter(s_inv));
    // cout << s << endl;
    // cout << s_inv << endl;
    REP(i, (s.length()-1)/2){
        if(s[i + (s.length()+3)/2 - 1] != s_inv[i]) flag = false;
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int mod = 1000000007;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(max_n);
vector<ll> sieve(int N){
  vector<bool> is_prime(N+1,true);
  vector<ll> P;
  for(int i=2;i<=N;i++){
    if(is_prime[i]){
      for(int j=2*i;j<=N;j+=i)is_prime[j] = false;
      P.emplace_back(i);
    }
  }
  return P;
}
int main(){
  ll n;ll m;cin >> n >>m;
  ll x=sqrt(m)+1;
  vl prime=sieve(x);
  mint ans=1;
  map<ll,ll> mp;
  for(auto p:prime){
    while(m%p==0){
      m/=p;mp[p]++;
    }
  }
  if(m!=1)mp[m]++;
  for(auto p:mp){
    ll c=p.se;
    ans*=comb(c+n-1,c);
  }
  cout << ans <<endl;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a,b,c;

int main()
{
    cin>>a>>b;
    int c1=ceil(a/0.08);
    int c2=ceil(b/0.1);
    int ans=max(c1,c2);
    int f1=floor(ans*0.08);
    int f2=floor(ans*0.1);
    if(f1==a&&f2==b) cout<<ans;
    else cout<<-1;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll w,h; cin >> w >> h; // w = 4, h = 3
    vector<ll> p(w), q(h);
    rep(i,w) cin >> p[i];
    rep(i,h) cin >> q[i];

    using P = pair<ll,ll>;
    vector<P> a;
    rep(i,w) a.emplace_back(p[i],0); 
    rep(i,h) a.emplace_back(q[i],1);
    sort(all(a));
    //debug(a);

    ll pc=h+1;
    ll qc=w+1;
    ll wh = w + h;
    ll ans = 0;
    for(ll i=0;i<wh;i++){
        ll cnt = (a[i].second == 0) ? pc : qc;
        ans += cnt * a[i].first;
        if(a[i].second == 0){
            qc--;
        }else{
            pc--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7664
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <numeric>
#include <cmath>
#include <cctype>

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

ll inf = pow(10,9)+7;

int main(){
  string s; cin>>s;
  ll N = s.size();
  ll dp[N+1][4];
  REPR(i,N){
    REPR(j,3){
      if(i==N){
        if(j==3){ dp[i][j] = 1; }
        else{ dp[i][j] = 0; }
      }else{
        if(j==3){
          int m = ( s[i]=='?'? 3:1);
          dp[i][j] = m * dp[i+1][j];
          dp[i][j] %= inf;
        }else{
          int m1= (s[i]=='?'?3:1);
          int m2;
          if(s[i]=='?'){ m2 = 1; }
          else{
            if((int)(s[i]-'A')==j){ m2 = 1;}
            else{ m2 = 0;}
          }
          dp[i][j] = m1*dp[i+1][j] + m2*dp[i+1][j+1];
          dp[i][j] %= inf;
        }
      }
    }
  }
  cout << dp[0][0] << "\n";
  
}

Measured memory_bytes: 3712
#include <stdio.h>

int main(int argc, const char * argv[]) {

        int w,h,x,y,r;
        
        scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
        if (0 <= x-r  && x+r <= w && 0 <= y-r && y+r <= h) {
            printf("Yes\n");
        } else printf("No\n");
        
    
    
    return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,a,b;
    cin>>n>>a>>b;

    ll p = n/(a+b);
    ll q = n%(a+b);

    p*=a;
    if(q>=a) cout<<p+a<<endl;
    else cout<<p+q<<endl;
    return 0;
}


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

#define ll long long
#define pb push_back

int main(){

	int a[4] = {0,0,0,0};
	for(int i = 0; i < 6; i ++){
		int x;
		cin >> x;
		a[x - 1] ++;//310212
	}
	int num1 = 0, num2 = 0;
	for(int i = 0; i < 4; i ++){
		if(a[i] == 1)num1 ++;
		if(a[i] == 2)num2 ++;
	}
	if(num1 == 2 && num2 == 2)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    ll n;

    cin >> n;

    string s(to_string(n));
    bool flag = true;

    while (flag)
    {
        s = to_string(n);
        if (s[0] == s[1] && s[1] == s[2] && s[2] == s[1])
            flag = false;

        ++n;
    }
    
    cout << s << endl; 

    return 0;
}


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

typedef long long int ll;

int main(){
	int n,m;cin >> n >> m;
	vector<int> arr(n + 1, -1);
	while(m--){
		int s,c;cin >> s >> c;
		if(arr[s] == -1 || arr[s] == c)arr[s] = c;
		else return cout << -1, 0;
	}
	if(arr[1] == 0 && n > 1)return cout << -1, 0;
	for(int i = 1;i <= n;i++){
		if(i == 1 && arr[i] == -1 && n > 1)cout << 1;
		else if(arr[i] == -1)cout << 0;
		else cout << arr[i];
	}
}


Measured memory_bytes: 256
////////////////////////    W H I T E C L O U D    ////////////////////////
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


int main()
{
    FAST();
    ll x;
    cin>>x;
    if(x==0)cout<<"1"<<endl;
    else cout<<"0"<<endl;


    return 0;
}







Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define int ll
int dx[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] = { 0, 0, 1, -1, 1, -1, 1, -1 };

int n, arr[200010], ans;
map<int, int> M;

main() {
  fastio;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
		M[i - arr[i]]++;
	}
	for (int i = 1; i <= n; i++) {
		ans += M[i + arr[i]];
	}
	cout << ans;
}

Measured memory_bytes: 27880
n = int(input())
a_list = list(map(int, input().split()))

a_list.sort(reverse = True)
alice_sum = 0
bob_sum = 0
for i in range(len(a_list)):
    if i % 2 == 0:
        alice_sum += a_list[i]
    else:
        bob_sum += a_list[i]

print(alice_sum - bob_sum)

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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

int main() {
    int a;
    int flg = 0;
    for(int i=0;i<5;i++){
        cin >> a;
        if(flg == 0 && a == 0){
            cout << i+1 << endl;
            flg = 1;
        }
    }
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
main()
{
        int i, n, q, com, x, y, *a, *min;
        int count = 0;
        scanf("%d %d", &n, &q);
        a = (int*)malloc(sizeof(int) * n);
        min = (int*)malloc(sizeof(int) * n);
        for(i = 0; i < n; i++){
                a[i] = 2147483647;
        }
        for(i = 0; i < q; i++){
                scanf("%d %d %d" , &com, &x, &y);
                switch(com){
                case 0:
                        a[x] = y;
                        break;
                case 1:
                        min[count] = a[x];
                        for(n = x + 1; n <= y; n++){
                                if(min[count] > a[n]){
                                        min[count] = a[n];
                                }
                        }
                        count++;
                        break;
                }
        }
        for(i = 0; i < count; i++){
                printf("%d\n", min[i]);
        }
        
}

Measured memory_bytes: 2436
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
class UnionFind {
private:
    int sz;
    vector<int> par, size_;
public:
    UnionFind(){}
    UnionFind(int node_size) : sz(node_size), par(sz), size_(sz, 1){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x,int y){
        x = find(x), y = find(y);
        if(x == y) return;
        if(size_[x] < size_[y]) swap(x,y);
        par[y] = x;
        size_[x] += size_[y];
    }
    int size(int x){
        x = find(x);
        return size_[x];
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
};
int main(){
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    int ans = n;
    while(m--){
        int x,y,z;
        cin >> x >> y >> z;
        x--,y--;
        if(!uf.same(x,y)){
            ans--;
            uf.unite(x,y);
        }
    }
    cout << ans << endl;
}

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

// int main(){
//     long long w,h,x,y;
//     cin >> w >> h >> x >> y;
//     long long yoko[2],tate[2];
//     yoko[0] = w*(h-y);
//     yoko[1] = w*y;
//     tate[0] = h*x;
//     tate[1] = h*(w-x);
//     cout << fixed << setprecision(6)<< double((max(min(yoko[0],yoko[1]),min(tate[0],tate[1]))));
//     cout << " ";
//     if (min(yoko[0],yoko[1])==min(tate[0],tate[1])){
//         cout << "1"<<endl;
//     }else{
//         cout << "0"<<endl;
//     }
//     return 0;
// }

int main(){
    long long w,h,x,y;
    cin >> w >> h >> x >> y;
    double res = (double)w*h/2;
    cout << fixed << setprecision(10) << res << " ";
    if(x*2==w&&y*2==h){
        cout << "1";
    }else{
        cout << "0";
    }
}

Measured memory_bytes: 3792