akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; (i) < (int) (n); (i) ++)
using namespace std;

struct StronglyConnectedComponent {
        int n;
        vector<bool> used;
        vector<int> order, cmp;
        vector<vector<int>> g, rg;
        StronglyConnectedComponent(int x) {
                n = x;
                g.resize(x);
                rg.resize(x);
                used.resize(x);
                cmp.resize(x);
        }
        void add_edge(int from, int to) {
                g[from].push_back(to);
                rg[to].push_back(from);
        }
        void dfs(int u) {
                used[u] = true;
                for (auto v : g[u]) if (!used[v]) {
                        dfs(v);
                }
                order.push_back(u);
        }
        void rdfs(int u, int k) {
                used[u] = true;
                cmp[u] = k;
                for (auto v : rg[u]) if (!used[v]) {
                        rdfs(v, k);
                }
        }
        int init() {
                used.assign(n, false);
                for (int u = 0; u < n; u ++) {
                        if (!used[u]) {
                                dfs(u);
                        }
                }
                used.assign(n, false);
                int k = 0;
                for (int i = order.size() - 1; i >= 0; i --) {
                        if (!used[order[i]]) {
                                rdfs(order[i], k ++);
                        }
                }
                return k;
        }
};

int main() {
        int n, m;
        scanf("%d%d", &n, &m);
        StronglyConnectedComponent scc(n);
        vector<vector<int>> rev(n);
        vector<int> in(n);
        rep(i, n + m - 1) {
                int a, b;
                scanf("%d%d", &a, &b);
                a --, b --;
                rev[b].push_back(a);
                scc.add_edge(a, b);
                in[b] ++;
        }
        int root = -1;
        rep(i, n) {
                if (in[i] == 0) {
                        root = i;
                        break;
                }
        }
        scc.init();
        vector<int> par(n, -1);
        rep(i, n) {
                int ma = -1;
                int p = -1;
                for (auto v : rev[i]) {
                        if (ma < scc.cmp[v]) {
                                ma = scc.cmp[v];
                                p = v;
                        }
                }
                if (p != -1) {
                        par[i] = p;
                }
        }
        rep(i, n) {
                printf("%d\n", par[i] + 1);
        }
        return 0;
}


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

using namespace std;

int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  if (b >= c) cout << b + c << '\n';
  else if (a >= c - b) cout << b + c << '\n';
  else cout << 2 * b + a + 1 << '\n';
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]++;
    }
    queue<int> q;
    int mx = 0;
    int s = 0;
    rep(i, n) {
        s += p[i];
        q.push(p[i]);
        if (q.size() > k) {
            s -= q.front(); q.pop();
        }
        if (q.size() == k) {
            mx = max(mx, s);
        }
    }
    double ans = mx;
    ans /= 2;
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 1792
import collections
s = list(input())
n = len(s)

cnt = [0,0,0]

for i in range(n):
  if s[i]=="a":
    cnt[0]+=1
  elif s[i]=="b":
    cnt[1]+=1
  else:
    cnt[2]+=1
    
print('YES' if max(cnt)-min(cnt) <= 1 else 'NO')


Measured memory_bytes: 10004
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    res = {
        'AC': 0,
        'WA': 0,
        'TLE': 0,
        'RE': 0}
    for i in range(n):
        res[IS()] += 1
    for k,v in res.items():
        print('{} x {}'.format(k, v))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9208
#include <string.h>
#include <stdio.h>

int main(){
    int k;
    scanf("%d", &k);
    char s[30];
    if (k == 5)
        printf("%s", "ACLACLACLACLACL");
    if(k == 4)
        printf("%s", "ACLACLACLACL");
    if(k == 3)
        printf("%s", "ACLACLACL");
    if(k == 2)
        printf("%s", "ACLACL");
    if(k == 1)
        printf("%s", "ACL");
    

    return 0;
}

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

using namespace std;

int main() {
        int n;
        cin >> n;
        map<long long, long long> C;
        vector<long long> B;
        for (int i=0; i<n; i++) {
                long long a, b, c;
                cin >> a;
                b = a + i + 1;
                c = i + 1 - a;
                B.push_back(b);
                if (!C.count(c)) {
                        C[c] = 1;
                } else {
                        C.at(c)++;
                }
        }
        long long cnt = 0;
        for(long long b : B) {
                if (C.count(b)) cnt += C.at(b);
        }
        cout << cnt << endl;
        return 0;
}


Measured memory_bytes: 16240
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define debug(n) cout<<"# "<<#n<<": "<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

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

int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}
int lcm(int a,int b)
{
	return a/gcd(a,b)*b;
}

int main()
{
	for(int a,b;cin>>a>>b;)
		cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
	
	return 0;
}

Measured memory_bytes: 0
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

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 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(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >> N;
  ll a[N];
  rep(i, N) cin>> a[i];
  double add_num = 0;
  rep(i, N){
    add_num += 1.0/(double)a[i];
  }
  cout << scientific << 1.0/add_num << endl;
}


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

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

void get_comb(int N, vector<vector<int>>& comb);
void sub_get_comb(int n, vector<int> c, int N, vector<vector<int>>& comb);


int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<int>> c(H, vector<int>(W));
	int cnt = 0;
	int ans = 0;

	REP (i, H) {
		string buf;
		cin >> buf;

		REP (j, W) {
			if (buf[j] == '#') {
				c[i][j] = 1;
				++cnt;
			}
		}
	}

	/* まず、あり得る組み合わせを全部列挙してしまう */
	vector<vector<int>> combH;
	vector<vector<int>> combW;

	get_comb(H, combH);
	get_comb(W, combW);

	REP(i, combH.size()) {
		REP(j, combW.size()) {
			vector<vector<int>> _c = c;
			int _cnt = cnt;

			REP(k, combH[i].size()) {
				REP(l, W) {
					if (_c[combH[i][k]][l] == 1) {
						--_cnt;
						_c[combH[i][k]][l] = 2;
					}
				}
			}

			REP(k, combW[j].size()) {
				REP(l, H) {
					if (_c[l][combW[j][k]] == 1) {
						--_cnt;
						_c[l][combW[j][k]] = 2;
					}
				}
			}

			if (_cnt == K) ++ans;
		}
	}

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


void get_comb(int N, vector<vector<int>>& comb) {
	REP(i, N + 1) {
		sub_get_comb(i, vector<int>(0), N, comb);
	}
}

void sub_get_comb(int n, vector<int> c, int N, vector<vector<int>>& comb) {
	if (n == 0) {
		comb.push_back(c);
//		REP(i, c.size()) cout << c[i] << " ";
//		cout << endl;
		return;
	}

	if (c.size() == 0) {
		REP(i, N) {
			vector<int> _c = c;
			_c.push_back(i);
			sub_get_comb(n - 1, _c, N, comb);
		}
	}
	else {
		FOR(i, c[c.size() - 1] + 1, N) {
			vector<int> _c = c;
			_c.push_back(i);
			sub_get_comb(n - 1, _c, N, comb);
		}
	}
}

Measured memory_bytes: 3608
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <queue> 
#include <map>
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
using namespace std;

int main(){

  int n;
  cin >> n;
  
  int candy[2][100];
    
  REP(i,2){
    REP(j,n){
	  cin >> candy[i][j];
    }
  }
  
  int ans = 0;
  
  REP(i,n){
    int sum = 0;
    REP(j,i+1)
      sum += candy[0][j];   
    FOR(j,i,n)
      sum += candy[1][j];
    //dump(sum);
    ans = max(ans,sum);
  }
  
  cout << ans << endl;

 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>

using namespace std;

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


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

    bool res = false;
    int len = s.length();
    if(s.substr(0, 7) == "keyence"){
        res = true;
    }
    for(int i = 0; i < 7; i++){
        string s1 = s.substr(0, i);
        // cout << s1 << endl;
        string s2 = s.substr(len-7+i);
        // cout << s2 << endl;
        // cout << endl;
        if(s1 + s2 == "keyence"){
            res = true;
        }
    }
    if(s.substr(len-7) == "keyence"){
        res = true;
    }
    if(res){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }


    return 0;

}



Measured memory_bytes: 256
#![allow(dead_code)]
use std::io;

fn main() {
    solve_b();
}

fn solve_d() {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    let n = n.trim().parse::<u32>().unwrap();

    let mut i = 1;
    while i <= n {
        let mut x = i;
        if (x % 3) == 0 {
            print!(" {}", i);
            i += 1;
            continue;
        }

        loop {
            if (x % 10) == 3 {
                print!(" {}", i);
                break;
            }
            x /= 10;
            if x == 0 {
                break;
            }
        }
        i += 1;
    }
    print!("\n");
}

fn solve_c() {
    loop {
        let mut x = String::new();
        io::stdin().read_line(&mut x).unwrap();

        let v: Vec<u64> = x.trim()
            .split(' ')
            .map(|s| s.parse::<u64>().unwrap())
            .collect();

        let h = v[0];
        let w = v[1];
        if h == 0 && w == 0 {
            break;
        } else {
            for i in 0..h {
                if i % 2 == 0 {
                    for j in 0..w {
                        if j % 2 == 0 {
                            print!("#");
                        } else {
                            print!(".");
                        }
                    }
                } else {
                    for j in 0..w {
                        if j % 2 == 0 {
                            print!(".");
                        } else {
                            print!("#");
                        }
                    }
                }
                print!("\n");
            }
            print!("\n");
        }
    }
}

fn solve_b() {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();

    let mut cards = vec![0; 13 * 4];
    for _i in 0..n.trim().parse::<usize>().unwrap() {
        let mut line = String::new();
        io::stdin().read_line(&mut line).unwrap();
        let v: Vec<&str> = line.trim().split(' ').collect();

        let card: &str = v[0];
        let num = v[1].parse::<u16>().unwrap();

        let mut index = 13 * if card == "S" {
            0
        } else if card == "H" {
            1
        } else if card == "C" {
            2
        } else {
            3
        };
        index += num - 1;
        //println!("{:?}", index);
        cards[index as usize] += 1;
    }

    for i in 0..cards.len() {
        if cards[i] == 0 {
            let card = match i / 13 {
                0 => "S",
                1 => "H",
                2 => "C",
                _ => "D",
            };
            let num = i % 13 + 1;
            println!("{} {}", card, num);
        }
    }
}



Measured memory_bytes: 5028
N, x = map(int, input().split())
*A, = map(int, input().split())

A.sort()
i = 0
while i < N-1 and A[i] <= x:
    x -= A[i]
    i += 1
if i == N-1:
    if A[i] == x:
        i += 1
print(i)

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
using ll = long long;
 
const int nax = 10123;
char k[nax];
const int mod = 1e9 + 7;
 
void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}
 
int modder(int x, int moddi)
{
	if (x >= moddi)
        return x % moddi;
    return x;
}
 
int main() {
    scanf("%s", k);
    int D;
    scanf("%d", &D);
    int len = strlen(k);
    vector<array<int,2>> dp(D, array<int,2>{});
    vector<array<int,2>> new_dp(D, array<int,2>{});
    // dp[sum][smaller_already] - the number of ways to choose digits so far
    // such that the sum of digits modulo D is 'sum' and 'smaller_already'
    // says whether we already chosen some digit smaller than in K
    dp[0][0] = 1;
    for(int where = 0; where < len; ++where) {
        memset(new_dp.data(), 0, 8 * new_dp.size());
      	//fill(new_dp.begin(), new_dp.end(), array<int,2>{});
        for(int sum = 0; sum < D; ++sum) {
            int sum2 = sum % D;
            for(bool sm_already : {false, true}) {
                for(int digit = 0; digit < 10; ++digit) {
                    if(digit > k[where] - '0' && !sm_already) {
                        break;
                    }
                    add_self(new_dp[modder(sum2+digit,D)][sm_already || (digit < k[where]-'0')],
                        dp[sum][sm_already]);
                }
            }
        }
        swap(dp, new_dp);
    }
    int answer = (dp[0][false] + dp[0][true]) % mod;
    --answer;
    if(answer == -1) {
        answer = mod - 1;
    }
    printf("%d\n", answer);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin >> n;
  VEC<string> s(3);
  int m = 3;
  REP(i, 0, m) cin >> s[i];
  int ans = 0;
  REP(i, 0, n) {
    set<char> c;
    REP(j, 0, m) { c.insert(s[j][i]); }
    ans += c.size() - 1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(x, n)              for (int x = 0; x < n; x++)
#define forr(x, n)              for (int x = n; x >= 0; x--)
#define fore(x, a, b, c)        for (int x = a; x <= b; x += c)
#define forre(x, a, b, c)       for (int x = a; x >= b; x -= c)
#define clr                     cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define all(container)          (container).begin(), (container).end()
#define rall(container)         (container).rbegin(), (container).rend()
#define FILL(x, val)            memset(x, val, sizeof(x))
#define sz(container)           ((int) (container).size())
#define pb                      push_back
#define eb                      emplace_back
#define fi                      first
#define se                      second
#define mod                     (ll)1000000007
#define INF                     (int)0x3f3f3f3f

using namespace std;

#ifdef LOCAL_DEFINE
    #include "../../CLionProjects/Codeforces/library/DEBUG.hpp"
#endif

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }  

typedef long long ll; 
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<long long, long long>> vpll;

void solve() {
    ll n; cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << '\n';
}

int main(void) {    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in.txt", "r", stdin);
#endif
    int t = 1; 
//    cin >> t;
    while (t--)
        solve();
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << '\n';
#endif
    return 0;
}

Measured memory_bytes: 3636
n = int(input())
a = [int(input()) for _ in range(n)]
a.sort(reverse = True)
b = [0] * n
l = n // 2 - 1
for i in range(l):
    b[i] = 2
b[l] = 1
if n % 2 == 1:
    b[l + 1] = 1
else:
    b[l + 1] = -1
for i in range(l + 2, n):
    b[i] = -2
ans1, ans2 = 0, 0
for i in range(n):
    ans1 += (a[i] * b[i])
    ans2 += (-1 * a[i] * b[n - i - 1])
print(max(ans1, ans2))

Measured memory_bytes: 7892
using System;

class Program {
  static void Main(string[] args) {
    string[] str = Console.ReadLine().Split(' ');
    int A = int.Parse(str[0]);
    int B = int.Parse(str[2]);
    switch(str[1][0]) {
    case '+':
      Console.WriteLine("{0}", A + B);
      break;
    case '-':
      Console.WriteLine("{0}", A - B);
      break;
    }
  }
}


Measured memory_bytes: 13268
A, B, M = map(int, input().split())
list_A = list(map(int, input().split()))
list_B = list(map(int, input().split()))
ans = min(list_A) + min(list_B)


for i in range(M):
    tmp_list = list(map(int, input().split()))
    tmp_cost = list_A[tmp_list[0]-1] + list_B[tmp_list[1]-1] - tmp_list[2]
    ans = min(tmp_cost, ans)

print(ans)

    

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

int main(){
    int H,W;
    cin >> H >> W;
    char c[H][W];
    for(int i=0;i<W+2;i++){
        cout << '#';
    }
    cout << endl;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> c[i][j];
        }
    }
    for(int i=0;i<H;i++){
        cout << '#';
        for(int j=0;j<W;j++){
            cout << c[i][j];
        }
        cout << '#' << endl;
    }
    for(int i=0;i<W+2;i++){
        cout << '#';
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0 ; i<(n) ; ++i)
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <ll, ll> P;

int main(){
  ll X;
  cin >> X;
  ll sum = 100;
  int count =0;
  while(true){
    sum *= 1.01;
    count += 1;
    if(sum >=X){
      break;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3624
/**
 *      ABC 51 C
 *      author  : kyomukyomupurin
 *      created : 2018-09-29 18:09:13
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;

    int dx = tx - sx; int dy = ty - sy;

    for (auto i = 0; i < dx; ++i) {
        cout << 'R';
    }
    for (auto i = 0; i < dy; ++i) {
        cout << 'U';
    }
    for (auto i = 0; i < dx; ++i) {
        cout << 'L';
    }
    for (auto i = 0; i < dy; ++i) {
        cout << 'D';
    }
    cout << 'D';
    for (auto i = 0; i < dx + 1; ++i) {
        cout << 'R';
    }
    for (auto i = 0; i < dy + 1; ++i) {
        cout << 'U';
    }
    cout << "LU";
    for (auto i = 0; i < dx + 1; ++i) {
        cout << 'L';
    }
    for (auto i = 0; i < dy + 1; ++i) {
        cout << 'D';
    }
    cout << 'R';

    
    return 0;
}

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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {
  
  int n,p;
  cin >> n;
  
  int mp = 100,sum = 0;
  
  for ( int i = 0; i < n; i++){
    cin >> p;
    sum += p;
    if ( mp < p ){
      mp = p;
    }
  }
  
  cout << sum - mp / 2 << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n, h, w;
	cin >> n >> h >> w;

	int a, b;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;

		if (a >= h && b >= w) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scan= new Scanner(System.in);
    int K=scan.nextInt();
    int X=scan.nextInt();
    int N=500*K;
    
    if(N>=X){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	string s;
	cin >> s;
	int Q;
	cin >> Q;
	int F = 0;
	deque<char> S;
	for (char c : s) { S.emplace_back(c); }
	for (int q = 0; q < Q; ++q) {
		int t;
		cin >> t;
		if (t == 1) {
			F = 1 - F;
			continue;
		}
		int f;
		char c;
		cin >> f >> c;
		if (F == 0) {
			if (f == 1) { S.push_front(c); }
			else { S.push_back(c); }
		} else {
			if (f == 1) { S.push_back(c); }
			else { S.push_front(c); }
		}
	}
	if (F == 0) {
		while (!S.empty()) {
			cout << S.front();
			S.pop_front();
		}
		cout << endl;
	} else {
		while (!S.empty()) {
			cout << S.back();
			S.pop_back();
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 896
n = int(input())
s = list(input())
l = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
a = []

for i in s:
  t = l.index(i)+n
  if t < 26:
    a.append(l[t])
  else:
    a.append(l[t-26])

print("".join(a))


Measured memory_bytes: 3188
from fractions import gcd
def lcm(a,b):
    return a*b/gcd(a,b)
def ge(a,m):
        i, b = 1, a%m
        while b!=1:
            b = (a*b)%m
            i += 1
        return i
while True:
    tmp = map(int, raw_input().split(" "))
    if all(t==0 for t in tmp):
        break
    print reduce(lcm,(ge(a,m) for a,m in zip(tmp[::2],tmp[1::2])))

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

#define pb push_back
#define ss second
#define ff first
#define N 1000006
#define inf 1000000009
#define ll long long
#define mid(a,b) (a+b)/2
#define pii pair<int,int>

using namespace std;

const int mod = 1e9+7;
int a[N],lc[N],x,cnt,n,pr;
ll ans,jog,l;
int b[N];
vector <int> v;

ll pw(ll a,ll b){
	if(b == 0) return 1;
	ll x = pw(a,b / 2);
	if(b % 2) return (((x * x) % mod)*a)%mod;
	return (x * x) % mod;
}

int main()
{
	for(int i = 2;i <= 1e6;i++) b[i] = i;
	for(int i = 4;i <= 1e6;i += 2) b[i] = 2;
	for(int i = 3;i*i <= 1e6;i += 2)
		if(b[i] == i) for(int j = i * i;j <= 1e6;j += i) if(b[j] == j) b[j] = i;
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		scanf("%d",&a[i]);
		x = a[i],cnt = 0,pr = 0;
		while(x > 1){
			if(b[x] != pr){
				lc[pr] = max(lc[pr],cnt);
				cnt = 0;
			}
			pr = b[x];
			x /= b[x];
			cnt++;
		}
		lc[pr] = max(lc[pr],cnt);
	}
	l = 1;
	for(int i = 2;i <= 1e6;i++)
		if(lc[i]) l = (l * pw(i,lc[i])) % mod;
	for(int i = 1;i <= n;i++){
		ans = (ans + (l * pw(a[i],mod - 2)) % mod) % mod;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 8448
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

template <typename T>
void say(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}


/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	int N;
	cin >> N;
	cout << N * 800 - (N / 15) * 200 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,p[20],i,s=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&p[i]);
    for(i=1;i<n-1;i++){
        if(((p[i]>p[i-1])&&(p[i]<p[i+1]))||((p[i]<p[i-1])&&(p[i]>p[i+1])))
            s++;
    }
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 128
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int color[100000];
vector<pair<int, ll>> vv[100000];

int main(){
  int N;
  cin >> N;
  rep(i, N){
    color[i] = -1;
  }
  rep(i, N - 1){
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    vv[u].emplace_back(v, w);
    vv[v].emplace_back(u, w);
  }
  stack<int> st;
  color[0] = 0;
  st.push(0);
  while(st.size()){
    int a = st.top();
    int current_color = color[a];
    st.pop();
    for(auto &x: vv[a]){
      int y = x.first;
      int w = x.second;
      if(color[y] == -1){
        if(w % 2){
          color[y] = 1 - current_color;
        }else{
          color[y] = current_color;
        }
        st.push(y);
      }
    }
  }
  rep(i, N){
    cout << color[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 8320
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := getInt()
	s, t := getString(), getString()

	ans := ""
	for i := 0; i < n; i++ {
		ans += s[i:i+1] + t[i:i+1]
	}

	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 640
//##MohK..
//22/05/2020   ...   5,07
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    int counter=0;
    string a,b;
    cin>>a>>b;
    for(int i=0;i<a.size();i++){
        if(a[i]==b[i])counter++;
    }
    if(counter==a.size())cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
   /* string a,b;
    cin>>a>>b;
    b.pop_back();
    if(b==a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    /*ll a;
    cin>>a;
    ll c=a%10;
    if(c==2||c==4||c==5||c==7||c==9)cout<<"hon"<<endl;
    else if(c==0||c==1||c==8||c==6)cout<<"pon"<<endl;
    else if(c==3)cout<<"bon"<<endl;*/

    return 0;
}



Measured memory_bytes: 3608
#include<stdio.h>
int A[4];
int B[4];
int keisan();
int keisan2();
int main(){
  int c=0;
  int d=0;
  while(scanf("%d %d %d %d %d %d %d %d",&A[0],&A[1],&A[2],&A[3],&B[0],&B[1],&B[2],&B[3])!=EOF){
    c=keisan();
    d=keisan2();
    printf("%d %d\n",c,d);
  }
  return 0;
}
int keisan(){
  int f=0;
  int g=0;
  for(f=0;f<4;f++){
    if(A[f]==B[f]){
      g=g+1;
    }
  }
  return (g);
  g=0;
}
int keisan2(){
  int e=0;
  int f=0;
  int h=0;
    for(e=0;e<4;e++){
    for(f=0;f<4;f++){
      if(A[e]==B[f]&&e!=f){
	h=h+1;
      }
    }
  }
  return (h);
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){

      int h1,m1,h2,m2,k;
       cin>>h1>>m1>>h2>>m2>>k;

          ll total=0;

         if(m1!=0)
          {
            total+=60-m1;
             h1+=1;
          }
           total+=(h2-h1)*60;

             total+=m2;

            cout<<total-k;
}


Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(r, &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &a[i])
	}
	sort.Ints(a)
	max := a[n-1]
	b := make(map[int]int)
	for i := 0; i < n; i++ {
		b[a[i]]++
	}

	var ans int
	for i := 0; i < n; i++ {
		if b[a[i]] == 1 {
			ans++
		}
		for j := a[i] * 2; j <= max; j += a[i] {
			b[j] = 0
		}
	}
	fmt.Println(ans)
}


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

using namespace std;
using vi = vector<int>;

int main(void)
{
    int n, x, y;
    vi  cnt;

    cin >> n >> x >> y;
    cnt.resize(n, 0);

    for (int u = 1; u < n; ++u)
    {
        for (int v = u + 1; v <= n; ++v)
        {
            int dist = min({v - u,
                            abs(x - u) + 1 + abs(y - v),
                            abs(x - v) + 1 + abs(y - u)});
            cnt[dist]++;
        }
    }
    for (int k = 1; k < n; ++k)
        cout << cnt[k] << endl;

    return 0;
}


Measured memory_bytes: 3608
N, K = map(int, input().split())
S = input()

if S[K-1] == 'A':
  print(S[:K-1] + 'a' + S[K:])
elif S[K-1] == 'B':
  print(S[:K-1] + 'b' + S[K:])
elif S[K-1] == 'C':
  print(S[:K-1] + 'c' + S[K:])

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
# B

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n = list(input())[:-1]
n = [int(s) for s in n]

if sum(n) % 9 == 0:
    print('Yes')
else:
    print('No')


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

int main(){
    int n;
    cin >> n;
    int temp;
    if(n % 2 == 0){
        temp = n/2;
    }else{
        temp = (n/2)+1;
    }
    double ans = (double)temp/(double)n;
    cout << ans << endl;
}


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

int main(void){
    string s;
    cin >> s;
    map<char,int> map;
    for(char c : s){
        map[c]++;
    }
    cout << min(map['0'], map['1'])*2 << endl;
    return 0;
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if (A+B > C+D)
    cout <<"Left"<<endl;
  else if (A+B < C+D)
    cout <<"Right"<<endl;
  else
    cout <<"Balanced"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; for(int i = 0; i < l; i++) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	for(unsigned i = 0; i < v.size(); i++) os<<v[i]<<' ';
	return os;
}
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a = next<int>();
	double b = a/3.0;
	printf("%.6f\n", b*b*b); 
	return ~~(0-0);
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

class Pair<E extends Comparable<E>,F extends Comparable<F>> implements Comparable<Pair<E,F>>{
    E first;
    F second;
    public Pair(E first, F second){
        this.first=first;
        this.second=second;
    }
    public E getFirst(){return first;}
    public F getSecond(){return second;}
    public String toString(){
        return "<"+first.toString()+","+second.toString()+">";
    }
    public int hashCode(){
        return first.hashCode()*30011+second.hashCode()+2;
    }
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Pair another = (Pair) obj;
        return this.getFirst().equals(another.getFirst())&&this.getSecond().equals(another.getSecond());
    }

    public int compareTo(Pair<E,F> another){
        if(this.getFirst().equals(another.getFirst())){
            return this.getSecond().compareTo(another.getSecond());
        }
        return this.getFirst().compareTo(another.getFirst());
    }

}
public class Main {

    static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();

        PriorityQueue<Pair<Long,Long>> cards = new PriorityQueue<>(Collections.reverseOrder());
        for(int n=0; n<N; n++){
            long a = sc.nextLong();
            cards.add(new Pair<>(a,1L));
        }
        for(int m=0; m<M; m++){
            long b = sc.nextLong();
            long c = sc.nextLong();
            cards.add(new Pair<>(c,b));
        }

        long ans = 0;
        while(N>0){
            Pair<Long,Long> largest = cards.poll();
            long elements=largest.getFirst(), amount=largest.getSecond();
            ans += elements * Math.min(amount, N);
            N -= amount;
        }

        System.out.println(ans);

    }
}

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

int main(){
	int r,D,x;
  	scanf("%d%d%d",&r,&D,&x);
  	for(int i = 0 ; i < 10 ; i ++){
      	x = r * x - D;
      	printf("%d\n",x);
    }
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int A, P; cin>>A>>P;
  cout<<(3*A+P)/2<<endl;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N;
    ll dp[N+1][4][4][4]; CLR(dp);
    dp[0][3][3][3] = 1;
    REP(i,N)REP(c1,4)REP(c2,4)REP(c3,4)REP(c4,4){
        if(c2==0 && c3==2 && c4==1) continue;
        if(c1==0 && c3==2 && c4==1) continue;
        if(c1==0 && c2==2 && c4==1) continue;
        if(c2==0 && c3==1 && c4==2) continue;
        if(c1==0 && c2==2 && c3==1) continue;
        if(c2==2 && c3==0 && c4==1) continue;
        dp[i+1][c2][c3][c4] += dp[i][c1][c2][c3];
        dp[i+1][c2][c3][c4] %= MOD;
    }
    ll ans = 0;
    REP(c1,4)REP(c2,4)REP(c3,4) ans += dp[N][c1][c2][c3];
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int s;
  cin >> s;
  int d = s % 10;
  int c = s / 10 % 10;
  int b = s / 10 / 10 % 10;
  int a = s / 10 / 10 / 10 % 10;
  
  if (a+b+c+d == 7) {
    cout << a << "+"<< b << "+" << c << "+" << d << "=" << 7;
  }
  else if (a+b+c-d == 7) {
    cout << a << "+"<< b << "+" << c << "-" << d << "=" << 7;
  }
  else if (a+b-c+d == 7) {
    cout << a << "+"<< b << "-" << c << "+" << d << "=" << 7;
  }
  else if (a-b+c+d == 7) {
    cout << a << "-"<< b << "+" << c << "+" << d << "=" << 7;
  }
  else if (a-b+c-d == 7) {
    cout << a << "-"<< b << "+" << c << "-" << d << "=" << 7;
  }
  else if (a+b-c-d == 7) {
    cout << a << "+"<< b << "-" << c << "-" << d << "=" << 7;
  }
  else if (a-b-c+d == 7) {
    cout << a << "-"<< b << "-" << c << "+" << d << "=" << 7;
  }
  else if (a-b-c-d == 7) {
    cout << a << "-"<< b << "-" << c << "-" << d << "=" << 7;
  }
    
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
    int a[10];
    int cou = 0;
    int coua = 0;
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
        if (a[i] == 5)cou++;
        if (a[i] == 7)coua++;
    }
    if (cou == 2 && coua == 1)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,x;
  scanf("%d %d\n",&n,&x);
  int a[n];
  for(int i = 0; i < n; ++i) scanf("%d",&a[i]);
  int bin = a[0];
  long answer = 0;
  if(a[0] > x){
    answer += (long) (a[0] - x);
    bin = x;
  }
  for(int i = 1; i < n; ++i){
    if(a[i] > x - bin){
      answer += (long) (a[i] - (x - bin));
      a[i] = x - bin;
    }
    bin = a[i];
  }
  printf("%ld\n",answer);
  return 0;
}

Measured memory_bytes: 512