akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
set<int>s;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int i,j,n,l,m=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>l;
        if(l>0 && l<400)
        {
            s.insert(1);
        }
        else if(l>=400 && l<800)
        {
            s.insert(2);
        }
        else if(l>=800 && l<1200)
        {
            s.insert(3);
        }
        else if(l>=1200 && l<1600)
        {
            s.insert(4);
        }
        else if(l>=1600 && l<2000)
        {
            s.insert(5);
        }
        else if(l>=2000 && l<2400)
        {
            s.insert(6);
        }
        else if(l>=2400 && l<2800)
        {
            s.insert(7);
        }
        else if(l>=2800 && l<3200)
        {
            s.insert(8);
        }
        else
        {
            m++;
        }
    }
    l=s.size();
    cout<<max(l,1)<<" "<<(l+m)<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  for(char c:s)
    cout<<char((c-'A'+n)%26+'A');
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

#define p pair<string, string>
#define ll long long
using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;

    map<p, ll> front;
    for (int i = 0; i < 1 << n; i++) {
        string a, b;
        for (int j = 0; j < n; j++) {
            if ((i & (1 << j)) > 0) a = a + s[j];
            else b = s[j] + b;
        }
        front[p(a, b)]++;
    }
    map<p, ll> back;
    for (int i = 0; i < 1 << n; i++) {
        string a, b;
        for (int j = 0; j < n; j++) {
            if ((i & (1 << j)) > 0) a = a + s[n + j];
            else b = s[n + j] + b;
        }
        back[p(b, a)]++;
    }

    ll ret = 0;
    for (auto x:front) ret += x.second * back[x.first];

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 101376
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
#define debug(x) cout << #x << " = " << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(void){
    
    int n, k;
    cin >> n >> k;

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

    vector<int> b(n * 2), c(n), d(n);
    rep(i, n)b[i] = b[i + n] = a[i];

    map<int, int> mp;
    rep(i, n * 2){
        if(mp.find(b[i]) == mp.end()){
            mp[b[i]] = i % n;
        } else {
            c[mp[b[i]]] = i % n;
            mp[b[i]] = i % n;
        }
    }

    rep(i, n){
        if(c[i] == i)d[i] = n + 1;
        else d[i] = (c[i] - i + n) % n + 1;
    }

    int sum = 0, pos = 0;
    vector<bool> used(n, false);
    while(true){
        if(used[pos])break;
        sum += d[pos];
        used[pos] = true;
        pos = (c[pos] + 1) % n;
    }

    k *= n;
    k %= sum;

    while(true){
        if(k < d[pos])break;
        k -= d[pos];
        pos = (c[pos] + 1) % n;
    }

    mp.clear();
    vector<int> ans;
    rep(i, k){
        if(mp.find(b[pos]) == mp.end()){
            mp[b[pos]] = pos;
            ans.push_back(b[pos++]);
        } else {
            int tmp = mp[b[pos++]];
            while(mp[ans.back()] != tmp){
                mp.erase(ans.back());
                ans.pop_back();
            }
            mp.erase(ans.back());
            ans.pop_back();
        }
    }

    rep(i, ans.size()){
        if(i > 0)cout << ' ';
        cout << ans[i];
    }
    cout << endl;

}

Measured memory_bytes: 23424
#include<iostream>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if (n == 1 && m == 1) ans = 1;
    else if (n == 1 || m == 1) ans = n * m - 2;
    else {
        ll f = 2 * (n + m) - 4; 
        ans = n * m - f;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3216
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as C8

type Pair = (Int, Int)

main :: IO ()
main = do
  [n,m] <- readInts
  ps <- sortOn fst <$> replicateM n readPair
  print $ solve m ps


solve :: Int -> [Pair] -> Int
solve m = fst . foldl' f e
  where
    e = (0,0)
    f (!s,!n) (a,b)
      | n == m    = (s,n)
      | c > m     = (s+a*(m-n),m)
      | otherwise = (s+a*b,c)
      where
        c = n+b

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

readPair :: IO Pair
readPair = do
  [x,y] <- readInts
  return (x,y)

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

int getGCM(int a, int b)
{
    int r;
    if (a > b)
        swap(a, b);
    r = a;
    while (r != 0)
    {
        a = r;
        r = b % r;
        if (r == 0)
        {
            break;
        }
        b = a;
    }
    return a;
}

int getGCMof3(int a, int b, int c)
{
    int res1 = getGCM(a, b);
    int res2 = getGCM(b, c);
    return getGCM(res1, res2);
}

int main()
{
    int k;
    cin >> k;
    long res = 0;
    for (int i = 1; i <= k; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            for (int l = 1; l <= k; l++)
            {
                res += getGCMof3(i, j, l);
            }
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>
int main(void)
{
    int input, output;
    if (scanf("%d", &input) == 1) {
        if(input < 1 || input > 100) return -1;
        output =  (input + 1)/2;
        printf("%.10f\n", output/(double)input);
        return 0;
    } else {
        printf("Failed to read integer.\n");
        return -1;
    }
}

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

long long dp[20][10][10][10][2][2];

int main(){
  string S;
  cin >> S;
  int N = S.length();
  //dp[i][j][k][l][m][n]
  ++dp[0][0][0][0][0][1];
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < 10; ++j){
      for(int k = 0; k < 10; ++k){
        for(int l = 0; l < 10; ++l){
          for(int m = 0; m < 2; ++m){
            for(int n = 0; n < 2; ++n){
              for(int o = 0; o < 10; ++o){
                if(n and o > S[i]-'0') break;
                int m_ = (m or (j == 5 and k == 1 and o == 3));
                int n_ = (n and (S[i]-'0' == o));
                dp[i+1][k][l][o][m_][n_] += dp[i][j][k][l][m][n];
              }
            }
          }
        }
      }
    }
  }
  long long ans = 0;
  for(int i = 0; i < 10; ++i)
    for(int j = 0; j < 10; ++j)
      for(int k = 0; k < 10; ++k)
        for(int l = 0; l < 2; ++l)
          ans += dp[N][i][j][k][1][l];
  cout << ans << endl;
}



Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
vector<int> v;
v.push_back(a*c);
v.push_back(a*d);
v.push_back(b*c);
v.push_back(b*d);

	cout<<*max_element(v.begin(),v.end());
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	long long ans = 0, a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	pair<long long, long long> ord[n];
	for(int i = 0; i < n; i++) ord[i] = make_pair(a[i], i);
	sort(ord, ord + n);
	set<long long> s;
	s.insert(-1);
	s.insert(n);
	for(int i = 0; i < n; i++){
		auto it = s.lower_bound(ord[i].second);
		auto up = *it;
		auto lo = *--it;
		auto m = ord[i].second;
		ans += ord[i].first * (m - lo) * (up - m);
		s.insert(ord[i].second);
	}
	cout << ans << endl;
}

Measured memory_bytes: 14336
from functools import reduce

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

def lcm_base(x, y):
    return (x*y)//gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
a = [int(i) for i in input().split()]

c = lcm_list(a)-1
print(sum([c % b for b in a]))

Measured memory_bytes: 3812
//AtCoder A - Still TBD
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
std::vector<std::string> split(const std::string& input, char delimiter){
    std::istringstream stream(input);
    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}
int main() {
#if LOCAL&0
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    string S; cin>>S;
    auto tbl = split(S,'/');
    //20140430
    ll c=stol(tbl[0])*10000+stol(tbl[1])*100+stol(tbl[2]);
    bool ans=(c<=20190430);
    cout<<(ans?"Heisei":"TBD")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
  int N,K;
  string S;
  cin >> N >> S >> K;
  char X = S.at(K - 1);
  for( int i = 0;i < N;i++){
      if(S.at(i) != X){
          S.at(i) = '*';
      }
  }
  cout << S << endl;
}


Measured memory_bytes: 256
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
x = int(input())

if x >= 30:
    print("Yes")

else:
    print("No")


Measured memory_bytes: 9140
#include <bits/stdc++.h>
#include <map>
#include <cmath>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define mpi map<int,int>
#define  si set<int>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define reP(i,a,n) for(int i=a;i<=n;i++)
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define st string
#define sz size()
#define case(i,n) Case<<" "<<i<<": "<<n<<endl;
#define tc ll t;cin>>t;while(t--)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x;
    ld y,z;
    cin>>x>>y;
    z = (double)(x * y);
	cout<<(ll)z; 
}


Measured memory_bytes: 3712
import java.util.Scanner;
public class  Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] a = new int[n];
		int cnt2 = 0;
		int cnt4 = 0;
		int cntelse = 0;
		
		for(int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
			
			if(a[i]%2==0 && a[i]%4 != 0) {
				cnt2++;
			}else if(a[i] % 4 == 0) {
				cnt4++;
			}else {
				cntelse++;
			}
		}
		
		if(cnt2==0 && cnt4+1>=cntelse) {
			System.out.println("Yes");
		}else if(cnt4 >= cntelse) {
			System.out.println("Yes");
		}else {
			System.out.println("No");			
		}
		
	}

}


Measured memory_bytes: 50000
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int a,b; cin >> a >> b;
    if(a >= 13){}
    else if(a <= 5) b = 0;
    else b /= 2;
    cout << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int     main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	cin >> a[0];
	int xor_sum = a[0];
	for (int i = 1; i < n; i++) {
		cin >> a[i];
		xor_sum = xor_sum ^ a[i];
	}
	for (int i = 0; i < n-1; i++)
		cout << (a[i] ^ xor_sum) << SEP;
	cout << (a[n-1] ^ xor_sum) << endl;
}


Measured memory_bytes: 4004
#include<bits/stdc++.h>
using namespace std;
int main(void)
{	
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=0;i<k;i++){
		if(i%2==0){
			if(a%2!=0){
				a--;
			}
			int x=a/2;
			a-=a/2;
			b+=x;
		}
		else{
			if(b%2!=0){
				b--;
			}
			int y=b/2;
			b-=b/2;
			a+=y;
		}
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}
				

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

/*ソートの時に使う
int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}
    qsort (data,sizeof(data),sizeof(int),sort); 
*/

int main(void){
    int x,sum=0;
    scanf("%d",&x);
    for (int i=1; i<=x; i++){
        sum+=i;
        if (sum>=x){
            printf("%d\n",i);
            exit(0);
        }
    }
    
    
	return 0 ;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
# 標準入力を取得
X, K, D = list(map(int, input().split()))

# 求解処理
ans = int()
C = int(abs(X) / D)
if C >= K:
    if X < 0:
        ans = X + K * D
    else:
        ans = X - K * D
else:
    if X < 0:
        ans = -1 * (abs(X) % D) + ((K - C) % 2 == 1) * D
    else:
        ans = (abs(X) % D) - ((K - C) % 2 == 1) * D
ans = abs(ans)

# 結果出力
print(ans)


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

using lint = long long;

void solve() {
    lint n;
    std::cin >> n;
    --n;

    int d = 0;
    lint pat = 1;
    while (true) {
        ++d;
        pat *= 26;
        if (n < pat) break;
        n -= pat;
    }

    std::string ans(d, '$');
    for (int i = 0; i < d; ++i) {
        ans[i] = (n % 26) + 'a';
        n /= 26;
    }
    std::reverse(ans.begin(), ans.end());

    std::cout << ans << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3644
package main
import "fmt"
 
func swap(num,num2 int)(bool,int,int){
    if num<=num2{
        return false,num,num2
    }else{
        return true,num2,num
    }
}
 
func main(){
    nums:=[3]int{}
    fmt.Scan(&nums[0],&nums[1],&nums[2])
     
    var check bool=true
    for{
        for i:=0;i<2;i++{
            check,nums[i],nums[i+1]=swap(nums[i],nums[i+1])
            if check==true{
                break
            }
        }
        if check==false{
                break
            }
    }
    fmt.Println(nums[0],nums[1],nums[2])
}


Measured memory_bytes: 1132
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();

		int[] b = new int[m];
		for(int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}

		int count = 0;
		for(int i = 0; i < n; i++) {
			int tmp = 0;
			for(int j = 0; j < m; j++) {
				tmp += sc.nextInt() * b[j];
			}
			tmp += c;
			if(tmp > 0) count++;
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 24916
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;
const ll max_N = 110000;
ll fac[max_N + 1000], facinv[max_N + 1000];
const ll MOD = 1e9 + 7;
ll N,M;

ll power(ll x, ll n){
    if(n == 0) return 1LL;
    ll res = power(x * x % MOD, n/2);
    if(n % 2 == 1){
        res = res * x % MOD;
    }
    return res;
}

ll nck(ll n, ll k){
    if(k == 0 || n == k){
        return 1;
    }
    return (((fac[n] * facinv[k]) % MOD) * facinv[n-k]) % MOD;
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    ll a = 2;
    ll val[max_N] = {};
    ll m = M;
    while(a * a <= M){
        while(m % a == 0){
            m /= a;
            val[a]++;
        }
        a++;
    }
    fac[0] = 0;
    fac[1] = 1;
    rep(i,2,max_N){
        fac[i] = (fac[i-1] * i) % MOD;
    }
    rep(i,0,N+1){
        facinv[i] = power(fac[i], MOD - 2);
    }
    ll ans = 1;
    if(m != 1){
        ans *= N;
        ans %= MOD;
    }

    rep(i,0,max_N){
        if(val[i] != 0){
            ans *= nck(val[i] + N - 1, N - 1);
            ans %= MOD;
        }
    }
    print(ans);

}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
typedef pair<ll,mp> mmp;
#define inf 1e9

int dx[2][6] = { {1,1,1,0,-1,0 },{0,1,0,-1,-1,-1} };
int dy[2][6] = { {-1,0,1,-1,0,1 },{-1,0,1,-1,0,1} };

int main(){
    while(1){
	int n,m;
	cin>>m>>n;
	if(n==0)break;
	queue<mmp> q;
	vector<vector<int> > dp(m+2,vector<int>(n+2,inf) );
	vector<vector<int> > dp2(m+2,vector<int>(n+2,inf) );
	int s;
	cin>>s;
	for(int i=0;i<s;i++){
		int x,y;
		cin>>x>>y;
		dp[x][y] = 0;
		q.push(mmp(0,mp(x,y) ) );
	}
	while(!q.empty() ){
		mmp now = q.front();
		int x  = now.second.first;
		int y  = now.second.second;
		int cost = now.first;
		q.pop();
		/*if(dp[x][y] <= cost ){
			continue;
		}*/
		//dp[x][y] = cost;
		for(int i=0;i<6;i++){
			int nx = x + dx[y%2][i];
			int ny = y + dy[y%2][i];
			if(0<nx&&0<ny&&nx<=m&&ny<=n&& dp[nx][ny] > cost+1 ){
				q.push(mmp(cost+1, mp(nx,ny) ) );
				dp[nx][ny] = cost + 1;
			}
		}
	}
	/*for(int i=1;i<=n;i++){
		for(int j = 1;j<=m;j++){
			cout<<dp[i][j]<<' ';
		}
		cout<<endl;
	}*/
	int t;
	cin>>t;
	int ans = 0;
	dp2 = dp;
	for(int i=0;i<t;i++){
		int x,y;
		cin>>x>>y;
		dp = dp2;
		int tmp = 0;
		dp[x][y] = 0;
		q.push(mmp(0,mp(x,y) ) );
		while(!q.empty() ){
			mmp now = q.front();
			int x  = now.second.first;
			int y  = now.second.second;
			int cost = now.first;
			q.pop();
			/*if(dp[x][y] <= cost ){
				continue;
			}*/
			//cout<<x<<' '<<y<<' '<<cost<<' '<<dp[x][y]<<endl;
			dp[x][y] = cost;
			tmp++;
			for(int i=0;i<6;i++){
				int nx = x + dx[y%2][i];
				int ny = y + dy[y%2][i];
				if(0<nx&&0<ny&&nx<=m&&ny<=n&& dp[nx][ny] > cost+ 1  ){
					q.push(mmp(cost+1, mp(nx,ny) ) );
					dp[nx][ny] = cost + 1;
				}
			}
		}
		ans = max(ans,tmp);
	}


	cout<<ans<<endl;
	}

	return 0;
}



Measured memory_bytes: 3060
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

struct Info1{
	Info1(){
		value = 0;
	}

	Info1(int arg_value){
		value = arg_value;
	}

	bool operator<(const struct Info1 &arg) const{
		return value < arg.value;
	};

	int value;
};

struct Info2{
	Info2(){
		value = 0;
	}

	Info2(int arg_value){
		value = arg_value;
	}

	bool operator<(const struct Info2 &arg) const{
		return value < arg.value;
	};

	int value;
};



int main(){

	Info1 info1[30];
	Info2 info2[30];

	priority_queue<Info1> Q1;
	priority_queue<Info2> Q2;

	int D,one_num,two_num,index_1,index_2,value;
	scanf("%d",&D);

	scanf("%d",&one_num);

	index_1 = 0;
	char buf[3];

	for(int loop = 0; loop < one_num; loop++){
		scanf("%s %d",buf,&value);

		if(buf[0] == 'D'){
			Q1.push(Info1(value));
		}
	}

	while(!Q1.empty()){
		info1[index_1++].value = Q1.top().value;
		Q1.pop();
	}

	scanf("%d",&two_num);

	index_2 = 0;

	for(int loop = 0; loop < two_num; loop++){
		scanf("%s %d",buf,&value);

		if(buf[0] == 'D' && buf[1]== 'D'){
			Q2.push(Info2(value));
		}
	}

	while(!Q2.empty()){
		info2[index_2++].value = Q2.top().value;
		Q2.pop();
	}

	int limit_1 = min(D,index_1),limit_2 = min(D/2,index_2),maximum = 0,tmp_sum;

	for(int i = 0; i <= limit_1; i++){
		for(int k = 0; k <= limit_2; k++){
			if(i + 2*k > D)break;

			tmp_sum = 0;
			for(int p = 0; p < i; p++)tmp_sum += info1[p].value;
			for(int p = 0; p < k; p++)tmp_sum += info2[p].value;
			maximum = max(maximum,tmp_sum);
		}
	}

	printf("%d\n",maximum);

	return 0;
}

Measured memory_bytes: 2728
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
//#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
int main() {
  int r;
  cin >> r;
  print10(2 * r * M_PI);
  return 0;
}

Measured memory_bytes: 3708
from sys import exit
N,M = map(int,input().split())

itemlist = [int(x) for x in input().split()]
itemlist.sort(reverse=True)

point = sum(itemlist)/(4*M)

for i in range(M):
    if itemlist[i] < point:
        print('No')
        exit(0)

print('Yes')

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

using namespace std;

int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;

	if (e - a <= k) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define show(x) #x " = " << x

int main() {
    string s,t; cin >> s >> t;
    int c = 0;
    rep (i,3) if (s[i] == t[i]) c++;
    cout << c << endl;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    ll n,m;cin>>n>>m;
    ll ans=0;

    vector<pair<ll,ll>>ab(n);
    rep(i,n){
        int a,b;
        cin>>a>>b;
        ab[i]=make_pair(a,b);
    }

    sort(ab.begin(),ab.end());

    rep(i,n){
        ans+=min(m,ab[i].second)*ab[i].first;
        m-=ab[i].second;
        if(m<1)break;
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long int LL;
const double PI = acos(-1.0);
const int N = 1e2 + 10;
LL n, l, r;
int main()
{
//    freopen("/Users/wangjiaolv/Desktop/test/in.txt", "r", stdin);
    int n, m, x, y, a[N], b[N];
    scanf("%d%d%d%d", &n, &m, &x, &y);
    for(int i=1;i<=n;i++) scanf("%d", &a[i]);
    for(int i=1;i<=m;i++) scanf("%d", &b[i]);
    sort(a+1, a+1+n); sort(b+1, b+1+m);
    if(a[n] >= b[1]) puts("War");
    else {
        if(y<=a[n] || x>=b[1]) puts("War");
        else puts("No War");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define e(i,n) for(int i=0;i<n;i++)
using namespace std;
int h,w,d[2010][2010][2];bool s[2010],t[2010];
int main(){
	cin>>h>>w;int a=0;char z;
	e(i,h){cin>>z;s[i+1]=z==79;}
	e(i,h+1)e(j,w+1){
		if(!i&&j){cin>>z;t[j]=z==79;}
		d[i][j][0]=0,d[i][j][1]=0;
		if(i){if(!s[i])d[i][j][1]=d[i-1][j][0]+1;else if(d[i-1][j][1])d[i][j][0]=d[i-1][j][1]+1;}
		if(j){if(!t[j])d[i][j][1]=max(d[i][j][1],d[i][j-1][0]+1);else if(d[i][j-1][1])d[i][j][0]=max(d[i][j][0],d[i][j-1][1]+1);}
		a=max(a,d[i][j][1]);
	}cout<<a<<endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<vector<int> > A(n, vector<int>(n, 0));
    for(int i=0; i<n; ++i){
        int k;
        cin >> k;
        // 1~n???index?????¨????????????????????????????????????1????????????0~n-1????????????
        k -= 1;
        int u;
        cin >> u;
        for(int j=0; j<u; ++j){
            int v;
            cin >> v;
            v -= 1;
            A[k][v] = 1;
        }
    }
    
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cout << A[i][j];
            if(j != n-1)
            cout << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k,r,s,p;cin>>n>>k>>r>>s>>p;
    string t;cin>>t;
    ll ans = 0;
    vector<int> win(n);
    for(int i=0; i<n; i++){
        if(i<k){
            win[i]=1;
            if(t[i]=='r')ans+=p;
            if(t[i]=='s')ans+=r;
            if(t[i]=='p')ans+=s;
        }
        else{
            if(win[i-k]&&t[i]==t[i-k])win[i]==0;
            else{
                win[i]=1;
                if(t[i]=='r')ans+=p;
                if(t[i]=='s')ans+=r;
                if(t[i]=='p')ans+=s;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 848
s=int(input())

def f(n):
	if n%2==0: return(n//2)
	else: return(3*n+1)

ai=s
i=1
a=[s]


while True:
	if f(ai) in a:
		print(i+1)
		break
	else:
		a.append(f(ai))
		ai=f(ai)
		i+=1


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#include <string>
#define SIZE 505
#define MX 10005

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

char mp[SIZE];
int gt[MX];

int main()
{
	string ANS="GRBY";
	int H,W,d;
	scanf("%d %d %d",&H,&W,&d);
	for(int i=0;i<d;i++)
	{
		gt[i]=0;
		for(int j=i+d;j<MX;j+=d)
		{
			gt[j]=1-gt[j-d];
		}
	}
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			int a=i+j,b=i-j;
			int ret=0;
			if(gt[a]==1) ret|=1;
			if(gt[b+MX/2]==1) ret|=2;
			mp[j]=ANS[ret];
		}
		printf("%s\n",mp);
	}
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 999999999
#define llong long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
31 41 5
)");
#define cin input
#endif

int mx(int x, int y, int z)
{
	if (x>=y && x>=z)
		return x;
	else if (y>=x && y>=z)
		return y;
	else
		return z;
}

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int count = 0;

	int max;
	if (a%2==0 && b%2==0 && c%2==0 || a%2==1 && b%2==1 && c%2==1)
	{
		max = mx(a, b, c);
		count = (max-a)/2+(max-b)/2+(max-c)/2;
	}
	else if (a%2==0 && b%2==0 && c%2==1 || a%2==1 && b%2==1 && c%2==0)
	{
		a+=1;
		b+=1;
		max = mx(a, b, c);
		count = 1+(max-a)/2+(max-b)/2+(max-c)/2;
	}
	else if (a%2==0 && b%2==1 && c%2==0 || a%2==1 && b%2==0 && c%2==1)
	{
		a+=1;
		c+=1;
		max = mx(a, b, c);
		count = 1+(max-a)/2+(max-b)/2+(max-c)/2;
	}
	else if (a%2==1 && b%2==0 && c%2==0 || a%2==0 && b%2==1 && c%2==1)
	{
		b+=1;
		c+=1;
		max = mx(a, b, c);
		count = 1+(max-a)/2+(max-b)/2+(max-c)/2;
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import math
n,m = map(int,input().split())

B=list(map(int,input().split()))
ro = [[]  for i in range(n+1)]
ans = 0

for i in range(m):
    a,b = map(int,input().split())
    ro[a-1].append(b)
    ro[b-1].append(a)
def sec(p):
    cnt = 0
    for i in range(len(ro[p])):
        if B[p] <= B[ro[p][i]-1]:
            return cnt
            break
    return 1

for k in range(n):
    ans += sec(k)

print(ans)

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

int f(int x) {
  int out = 0;
  while (x >= 1) {
    out += x%10;
    x /= 10;
  }
  return out;
}

int main() {
  int N;
  cin >> N;
  int min = 100;
  for (int i = 1; i < N; i++) {
    if (f(i) + f(N-i) < min) min = f(i) + f(N-i);
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int R, G, B, N;
int ans;

int main()
{
  scanf( "%d%d%d%d", &R, &G, &B, &N );

  rep( r, (N+R-1)/R+1 ) rep( g, (N+G-1)/G+1 )
  {
    if( N-r*R-g*G >= 0 && (N-r*R-g*G) % B == 0 )
      ++ans;
  }

  printf( "%d\n", ans );

  return 0;
}

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

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define _shv(v) for (auto _t1 : v) cerr << _t1 << " "; cerr << endl;
#define dg(x) cerr << #x << ": " << (x) << endl;
#define dgv(v) cerr << #v << ": "; _shv(v);
#define dgm(m) cerr << #m << ":" << endl; for (auto _t2 : m) { _shv(_t2); }

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

template<typename T> inline void pt(T x) { cout << x << endl; }
template<typename T> inline void inv(T& v) { for (auto& t : v) cin >> t; }
template<typename T> inline int siz(T& x) { return x.size(); }
template<typename T> inline ll pow2(T n) { return 1ll << n; }
template<typename T, typename U> inline int bit(T x, U n) { return x >> n & 1; }
template<typename T, typename U>
inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }


int main() {
    int n; cin >> n;
    vl a(n); inv(a);
    vl d(n, INF);
    rep(i, n) {
        auto l = lower_bound(rng(d), a[i]);
        *l = a[i];
    }
    rep(i, 1, n) {
        if (d[i] == INF) {
            pt(i);
            return 0;
        }
    }
    pt(n);

    return 0;
}



Measured memory_bytes: 4380
k = 0
m = 0
d = int(input())
p = [0]*d
for i in range(d):
  p[i] = int(input())
  if i == 0:
    if p[0] != 0:
      print(-1)
      m = 1
      break
  else:
    if p[i]  <= p[i-1]:
      k += p[i]
    elif p[i] <= 1 + p[i-1]:
      k += 1
    else:
      print(-1)
      m = 1
      break
 
if m != 1:
  print(k)

Measured memory_bytes: 12616
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, a, b, c[100000], res[100000];
ll ans;
bool vis[100000];
priority_queue<int>q;
vector<int>v[100000];

void dfs(int x) {
	vis[x] = true;
	res[x] = q.top();
	ans += q.top();
	q.pop();
	for (int i : v[x]) {
		if (!vis[i]) {
			dfs(i);
		}
	}
}


int main() {
	cin >> N;
	for (int i = 1; i < N; ++i) {
		cin >> a >> b;
		--a;
		--b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for (int i = 0; i < N; ++i) {
		cin >> c[i];
		q.push(c[i]);
	}
	ans = -q.top();
	dfs(0);
	cout << ans << endl;
	for (int i = 0; i < N; ++i) {
		cout << res[i];
		if(i!=N-1)cout << sp;
		else cout << endl;
	}
}

Measured memory_bytes: 3456
### 18. Prison

input_line = input()
N,M = [int(s) for s in input_line.split(' ') if s]
Ls = []
Rs = []
for _ in range(M):
    input_line = input()
    L,R = [int(s) for s in input_line.split(' ')if s]
    Ls.append(L)
    Rs.append(R)

output = min(Rs)-max(Ls)+1
output = output if output > 0 else 0
print(output)

Measured memory_bytes: 11084
#include <algorithm>
#include<bits/stdc++.h>
#include <ios>
#include <iterator>
using namespace std;
#define ll long long
#define f(n)  for(int i=0;i<n;i++) 
#define pb push_back
#define mp make_pair
#define vi vector< int>
#define all(v)   v.begin(),v.end()  
#define take(n)   ll int n;cin>>n
#define space       cout<<endl
void speed (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
int main() {
	speed();

  take(n);
    vi v(n,0);
    for(int i=1;i<n;i++){
        int x;cin>>x;v[i]=x;}
    vi ans(n,0);
    for(int i=1;i<n;i++){
        ans[v[i]-1]++;
    }
    for(auto  x:ans){
        cout<<x<<endl;
    }
    
	return 0;
}

 

Measured memory_bytes: 4724
S = input()
ans = ""
if S == "SUN":
    ans = "7"
elif S == "MON":
    ans = "6"
elif S == "TUE":
    ans = "5"
elif S == "WED":
    ans = "4"
elif S == "THU":
    ans = "3"
elif S == "FRI":
    ans = "2"
elif S == "SAT":
    ans = "1"
print(ans)


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

int main(){

    string n;
    cin >> n;

    if(n[0]=='9'||n[1]=='9'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/5 20:34:12
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

int n;
int a[3];
string s[N];

void run() {
    cin >> n;
    cin >> a[0] >> a[1] >> a[2];
    vector <char> ans;
    bool f = true;
    for (int i = 0; i < n; i++) {
        cin >> s[i];   
    }
    for (int i = 0; i < n; i++) {
        int x = s[i][0] - 'A', y = s[i][1] - 'A';
        if (a[x] < a[y]) {
            ++a[x], --a[y];
            ans.push_back(s[i][0]);
        } else if (a[x] > a[y]) {
            --a[x], ++a[y];
            ans.push_back(s[i][1]);
        } else {
            if (a[x] == 0 && a[y] == 0) {
                f = false;
            } else if (i < n - 1 && a[x] == 1 && a[y] == 1) {
                for (int j = 0; j < 2; j++) {
                    for (int k = 0; k < 2; k++) {
                        if (s[i][j] == s[i + 1][k]) {
                            ans.push_back(s[i][j]);
                            ans.push_back(s[i + 1][k ^ 1]);
                            --a[s[i][j ^ 1] - 'A'];
                            ++a[s[i + 1][k ^ 1] - 'A'];
                            ++i;
                            goto nxt;
                        }
                    }
                }
            } else {
                --a[x], ++a[y];
                ans.push_back(s[i][1]);
            }
        }
        nxt:;
    }
    if (!f) {
        cout << "No" << '\n';   
    } else {
        cout << "Yes" << '\n';
        for (auto it : ans) {
            cout << it << '\n';
        }   
    }
}

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

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

using namespace std;

typedef long long LL;

#define MAX_N 100005
#define INF 1145141919
int N;
LL A[MAX_N];

void input()
{
  cin >> N;
  for (size_t i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
}

int main()
{
  input();

  LL ans = 0;
  LL p = 1;
  for (size_t i = 0; i < N; i++) {
    if(A[i] > p){
      LL cnt = A[i]/p;
      if(A[i]/p > 0 && A[i]%p == 0){
        cnt--;
      }

      ans += cnt;
      if(cnt > 0)
        A[i] = 1;
      p = max(p, A[i]+1);
      //cerr << i << " " << ans << " " << p << endl;
    }
    else if(A[i] == p){
      p++;
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, int>;

ll calc(ll base, ll sum, set<P>& s, set<P>& s2) {
    ll v1 = base + sum;
    if (s.size() % 2 == 0 || s2.empty()) return v1;
    v1 -= s.begin()->first;
    
    ll v2 = base + sum - s2.begin()->first;
    return max(v1, v2);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    int m = 2 * n;
    vector<ll> a(m), b(m);
    for (int i = 0; i < m; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];

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

    ll base = 0;
    ll sum = 0;
    set<P> s, s2;
    for (int i = 0; i < m; i++) {
        base += a[i];
        if (i > 0 && i < m - 1) {
            if (a[i] <= b[i]) {
                sum += b[i] - a[i];
                s.emplace(b[i] - a[i], i);
            } else {
                s2.emplace(-b[i] + a[i], i);
            }
        }
    }

    for (int i = 0; i < q; i++) {
        base += x[i] - a[p[i]];
        if (p[i] == 0 || p[i] == m - 1) {
            cout << calc(base, sum, s, s2) << endl;
        } else {
            if (b[p[i]] >= a[p[i]]) {
                s.erase(P(b[p[i]] - a[p[i]], p[i]));
                sum -= b[p[i]] - a[p[i]];
            } else{
                s2.erase(P(-b[p[i]] + a[p[i]], p[i]));
            }
            if (y[i] >= x[i]) {
                s.emplace(y[i] - x[i], p[i]);
                sum += y[i] - x[i]; 
            } else {
                s2.emplace(-y[i] + x[i], p[i]);
            }
            cout << calc(base, sum, s, s2) << endl;
        }
        a[p[i]] = x[i];
        b[p[i]] = y[i];
    }
    return 0;
}

Measured memory_bytes: 19328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef pair<int,int> P;
const int INF = 1e9+7;

int main(){
    unsigned long long n;
    cin >> n;
    string s;
    while(n>26){
        if(n%26==0){
            s.push_back('z');
            n = n/26-1;
        }else{
            char c = 'a'+n%26-1;
            s.push_back(c);
            n /= 26;
        }
        
    }
    char c = 'a' +n-1;
    s.push_back(c);
    reverse(s.begin(),s.end());
    cout << s;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
template<typename T>
void print_to(std::ostream &os,const char *,const char *tail,const T &fst){
  os<<fst<<tail;
}
template<typename Fst,typename... Rst>
void print_to(std::ostream &os,const char *del,const char *tail,const Fst &fst,const Rst &... rst){
  os<<fst<<del;
  print_to(os,del,tail,rst...);
}
template<typename Iter>
void print_to_(std::ostream &os,const char *del,const char *tail,Iter bgn,Iter end){
  for(Iter it=bgn;it!=end;){
    os<<*it;
    if(++it!=end)os<<del;
    else os<<tail;
  }
}
template<typename Fst,typename... Rst>
void println(const Fst &fst,const Rst &... rst){
  print_to(std::cout,"\n","\n",fst,rst...);
}
template<typename Fst,typename... Rst>
void print(const Fst &fst,const Rst &... rst){
  print_to(std::cout," ","\n",fst,rst...);
}
template<typename Iter>
void println_(Iter bgn,Iter end){
  print_to_(std::cout," ","\n",bgn,end);
}

using namespace std;
//const ll MOD=(ll)1e9+7;
//const ll inf=(ll)1e14;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int n,m,h,w;
string s;
vector<pair<int,int> > aka,ao;
bool past[101];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  cin>>n;
  for(int i=0;i<n;i++){
    int a,b;cin>>a>>b;
    aka.push_back({a,b});
  }
  for(int i=0;i<n;i++){
    int a,b;cin>>a>>b;
    ao.push_back({a,b});
  }
  sort(ao.begin(),ao.end());
  int ans=0;
  for(int i=0;i<n;i++){
    int maxy=-1;
    int res=-1;
    for(int j=0;j<n;j++){
      if(past[j])continue;
      if(aka[j].fi<ao[i].fi && aka[j].se<ao[i].se){
        if(maxy<aka[j].se){
          res=j;
          maxy=aka[j].se;
        }
      }
    }
    if(res!=-1){
      past[res]=1;
      ans++;
    }
  }
  print(ans);
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
// #define INT_MAX 1000000000 this is wrong as INT_MAX is already included in header<climits> and  2147483647  
// #define INT_MIN -1000000000
#define INF 1000000000
#define LL_MAX 1000000000000000000
#define LL_MIN -1000000000000000000
#define mod1 1000000007
#define ll long long 
#define ld long double
#define vi vector <int>
#define vvi vector <vector<int>>
#define vll vector<long long>
#define vvl vector <vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pair<int,int>>
#define pld pair<ld,ld>
#define vpll vector<pair<ll,ll>>
#define vpld vector<pair<ld,ld>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; } 
constexpr int pct(int x) { return __builtin_popcount(x); } 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))

template<class T>
T binpow(T a, T b, T m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main(){
	int n;
    cin>>n;
    ll a[n],b[n];
    for(int i=0;i<n;i++)cin>>a[i];
    b[n-1]=0;
    for(int i=n-2;i>=0;i--)b[i]=(b[i+1]+a[i+1])%mod1;
    ll sum=0;
    for(int i=0;i<n;i++){
        sum+=(a[i]*b[i])%mod1;
        sum%=mod1;
    }
    cout<<sum<<endl;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do smth instead of nothing and stay organized
*/



Measured memory_bytes: 6664
#include <stdio.h>
#include <math.h>
struct xy{
	double x;
	double y; 
};
int kock(int n,struct xy,struct xy);
int main(){
	struct xy p1 ={0,0}, p2 ={100,0};
	int n;
	scanf("%d",&n);
	printf("%.8lf %.8lf\n",p1.x,p1.y);
	kock(n,p1,p2);
	printf("%.8lf %.8lf\n",p2.x,p2.y);
	return 0;
}

int kock(int n,struct xy p1,struct xy p2){
	struct xy s,t,u;
	if(n==0) return 0;
	s.x = (2*p1.x+1*p2.x)/3;
	s.y = (2*p1.y+1*p2.y)/3;
	t.x = (1*p1.x+2*p2.x)/3;
	t.y = (1*p1.y+2*p2.y)/3;
	u.x=(t.x-s.x)/2 -(t.y-s.y)*sqrt(3)/2 +s.x;
	u.y=(t.x-s.x)*sqrt(3)/2 +(t.y-s.y)/2 +s.y;
	kock(n-1,p1,s);
	printf("%.8lf %.8lf\n",s.x,s.y);
	kock(n-1,s,u);
	printf("%.8lf %.8lf\n",u.x,u.y);
	kock(n-1,u,t);
	printf("%.8lf %.8lf\n",t.x,t.y);
	kock(n-1,t,p2);
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define inchar			getchar
#define outchar(x)		putchar(x)
#define ll long long int
#define all(v) v.begin(), v.end()
#define SP outchar(' ')
#define LN outchar('\n')
using namespace std;
const ll MOD  = int(1e9 + 7);

template<typename T> void inpos(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=0; if(c=='-')neg=1;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
template<typename T> void outpos(T n){if(n<0){outchar('-');n*=-1;}char snum[65];int i=0;do{snum[i++]=n%10+'0';n/=10;}while(n);i=i-1;while(i>=0)outchar(snum[i--]);}
inline void instr(char *str){register char c=0;register int i=0;while(c<33)c=inchar();while(c!='\n'&&c!=' '&&c!=EOF){str[i]=c;c=inchar();++i;}str[i]='\0';}

const int NAX = 600;
double dp[NAX][NAX][NAX] = {0};
bool calc[NAX][NAX][NAX] = {false};

double solve (int a , int b , int c  , int n) {
	if (a == 0 && b == 0 && c ==0) {
		return	 0;
	}
	if (calc [a][b][c]) {
		return dp[a][b][c];
	} else {
		int k = a + b + c;
		double first = (a>0) ?solve(a-1,b,c,n):0.0;
		double second = (b>0)?solve(a+1,b-1,c,n):0.0;
		double third = (c>0) ?solve(a,b+1,c-1,n):0.0;
		dp[a][b][c] = (double)n/k + (double)a/k * first + (double) b/k * second + (double) c/k * third;
		calc[a][b][c] = true;
		return dp[a][b][c];
	}
}




int main () {
	// Har state pe char option hai...
	// ya to unrolled 
	int n;
	cin >> n;
	int temp;
	vector <int > count(4,0);
	for (int i = 0 ; i<n;i++) {
		cin >> temp;
		count[temp]++;
	}

	dp [0][0][0] = 0;
	// for (int a = 0 ; a< n ; a++ ) {
	// 	for (int b = 0; b<n;b++) {
	// 		for (int c = 0 ; c < n ; c++) {
	// 			if (a ==0 || b == 0 || c == 0 ) {
	// 				continue;
	// 			}
	// 			int k = a + b + c;
	// 			dp[a][b][c] = (double) n/k + (double) a/k* dp[a-1][b][c] * + (double) b/k * dp[a+1][b-1][c] + (double)c / k * dp[a] [b+1] [c-1]; 
	// 			cout << a << ' ' << " " << b << " " << c << " "; 
	// 			cout << setprecision(10) << dp[a][b][c]<<endl;
	// 		}
	// 	}
	// }
	cout << setprecision(10) << solve (count[1], count[2], count[3], n)<<endl;


}

Measured memory_bytes: 888192