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

int main(){
  int n;
  int builds_n, floors_n, rooms_n, residents;
  int a[5][4][11] = {0};
  cin >> n;
  for (int i=0; i<n; ++i) {
    cin >> builds_n >> floors_n >> rooms_n >> residents;
    a[builds_n-1][floors_n-1][rooms_n-1] += residents;
  }
  
  rep(i, 4){
    if (i)
    cout << "####################" << endl;
    rep(j, 3){
      rep(k, 10){
        cout << " ";
        cout << a[i][j][k];
      }
      cout << endl;
    }
  }
        
  return 0;
}



Measured memory_bytes: 3056
/*       _________
        /|______/ \
        ||  _|_|\  |
        || |_|   | /
        ||    _ / |
        ||  _| \\  \    
        ||_|_|\ || |
        |/_|/ | /|_/
              /__/      Written by: Rishabh Roshan
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int            	long long
#define tree         	ped
#define integer        	int32_t
#define mod         	1000000007
#define vint        	vector<integer>
#define pint        	pair<integer, integer>
#define umint        	unordered_map<integer, integer>
#define mint        	map<integer, integer>
#define in(x)        	int x; cin>>x
#define setbits(x)    	__builtin_popcountll(x)
#define zerobits(x)    	__builtin_ctzll(x)
#define w(x)        	int x; cin>>x; while(x--)
#define sp(x, y)    	fixed<<setprecision(y)<<x
#define poll(x)        	x.front(); x.pop()
#define f(x)        	for(int i=0; i<x; i++)
#define endl         	'\n'
#define inf         	1e9 
#define order_set     	tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

// #include "functions.h"

void om_shree_ganeshaya_namah(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main(){
    
    om_shree_ganeshaya_namah();

    string s, t;
    cin>>s>>t;

    vector<vint> dp(s.length()+1, vint(t.length()+1));

    f(s.length()){
    	for(int j=0; j<t.length(); j++){
    		if(s[i]==t[j])
    			dp[i+1][j+1] = dp[i][j]+1;
    		else
    			dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
    	}
    }
    int i = s.length(), j = t.length();
    string ans = "";
    while(i>0 && j>0){
    	if(dp[i][j]==dp[i-1][j])
    		i--;
    	else if(dp[i][j]==dp[i][j-1])
    		j--;
    	else{
    		i--;
    		j--;
    		ans+=s[i];
    	}
    }

    if(ans.length()==0)
    	cout<<' ';
    else
    for(int i=ans.length()-1; i>=0; i--){
    	cout<<ans[i];
    }

}

Measured memory_bytes: 38516
n, d = list(map(int, input().split()))
cnt = 0
d2 = d**2
x, y = [], []
for i in range(n):
	tx, ty = list(map(int, input().split()))
	x.append(tx)
	y.append(ty)

for i in range(n):
	if(x[i]**2 + y[i]**2 <= d2):
		cnt += 1
print(cnt)

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

const ll INF = 1e17;
const ll MOD = 1e9+7;

// https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#5-%E4%BA%8C%E9%A0%85%E4%BF%82%E6%95%B0-ncr
const int MAX = 1e6+1;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    // input
    ll X,Y;
    cin >> X;
    cin >> Y;

    // range check
    bool check =false;
    if (X%3==0 && Y%3==0)check = true;
    if (X%3==2 && Y%3==1)check = true;
    if (X%3==1 && Y%3==2)check = true;
    if (!check) {
        cout << 0 << endl;
        return 0;
    }

    int diff = abs(X-Y);
    int big = max(X,Y);
    int small = min(X,Y);

    int checkb = big - diff*2;
    int checks = small - diff;

    if (checkb != checks || checkb%3 != 0 || checkb < 0) {
        cout << 0 << endl;
        return 0;
    }

    int step2 = checkb /3 + diff;
    int step1 = checkb /3;

    COMinit();
    cout << COM(step2+step1, step2) << endl;


    return 0;
}


Measured memory_bytes: 23680
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
long long gcd(long long a, long long b) { return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b) { return a/gcd(a,b)*b;}

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  int h;
  rep (i, n) {
    cin >> h;
    if (h >= k) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#!python3

LI = lambda: list(map(int, input().split()))

# input
N, W = LI()
WV = [LI() for _ in range(N)]

INF = 10 ** 10
MAX = 10 ** 5


def main():
    dp = [[INF] * (MAX + 1) for _ in range(N + 1)]
    dp[0][0] = 0
    for i in range(1, N + 1):
        w, v = WV[i - 1]
        for j in range(MAX + 1):
            if j < v:
                dp[i][j] = dp[i - 1][j]
            else:
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v] + w)
    for i in range(MAX, -1, -1):
        if dp[-1][i] <= W:
            print(i)
            return


if __name__ == "__main__":
    main()


Measured memory_bytes: 146296
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 1e5+10;
 ll mod = 1e9+7;

vector<bool> b_sta(1e5+10,false);

int main(){
  int r,l;
  int n,k;
  cin >> n >> k;
  ll res = 0;

  vector<int> v(n,0);
  rep(i,n) cin >> v[i];
  for(l=0;l <= k;l++){
    for(r=0;r+l <= min(k,n);r++){
      vector<ll> vec;
      //左側から取り出し
      ll cur = 0;
      for(int i=0;i<l;i++) vec.push_back(v[i]), cur+=v[i];
      //右側から取り出し
      for(int j=0;j<r;j++) vec.push_back(v[n-1-j]), cur+=v[n-1-j];
      sort(all(vec));
      //残り操作回数で0未満を取り除く
      for(int i=0;i<min(k-r-l,(int)vec.size());i++){
        if(vec[i] < 0) cur-=vec[i];
      }
      res = max(res, cur);
    }
  }
  cout << res << endl;
}

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

int main() {
	int n;
	cin >> n;
	int table[10000] = {};
	for(int i = 1; 10 > i; i++)
	for(int j = 1; 10 > j; j++)
	table[i * j] = 1;
	
	if(table[n])
	cout << "Yes" << endl;
	else
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
# AGC039B - Graph Partition
from collections import deque


def is_bipartite() -> bool:
    stack = [(1, 1)]
    color = [-1] * (N + 1)
    color[1] = 1
    while stack:
        v, cur_color = stack.pop()
        next_color = cur_color ^ 1
        for u in E[v]:
            if color[u] == cur_color:
                return False
            if color[u] == -1:
                color[u] = next_color
                stack.append((u, next_color))
    return True


def bfs(start) -> int:
    que = deque([start])
    dist = [0] * (N + 1)  # dist[i] := distance from V_start to V_i
    dist[start] = 1
    while que:
        v = que.popleft()
        cur = dist[v]
        for u in E[v]:
            if not dist[u]:
                dist[u] = cur + 1
                que.append(u)
    return max(dist)


def main():
    # if bipartite graph -> diameter of the graph + 1
    global N, E
    N, *S = open(0).read().split()
    N = int(N)
    E = [0] + [[i for i, flg in enumerate(s, 1) if flg == "1"] for s in S]
    if is_bipartite():
        ans = max(bfs(i) for i in range(1, N + 1))
        print(ans)
    else:
        print(-1)


if __name__ == "__main__":
    main()

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

int main() {
    int n;
    cin >> n;
    vector<int> v;
    for (int i=0; i<n; i++)
    {
        int d;
        cin >> d;
        v.push_back(d); 
    }
    
    int sum = 0;

    for (int i=0; i<n-1; i++)
        for (int j=i+1; j<n; j++)
        {
            sum += v[i]*v[j];
        }
    cout << sum;    
    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main() {
  cin.sync_with_stdio(false);
  int n;
  cin >> n;
  if (n > 999) cout << "ABD" << endl;
  else cout << "ABC" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()



int main()
{
	int A, B;
	cin >> A >> B;


	rep(i, 20000)
	{
		int a = i * 8 / 100;
		int b = i  / 10;

		if (a == A && b == B)
		{
			cout << i << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}

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

int main() {
  char c;
  cin >> c;

  // ここにプログラムを追記

    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')
      cout<<"vowel"<<endl;
    else
      cout<<"consonant"<<endl;
  
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<set>

using std::cout;
using std::endl;
using std::cin;
using std::sort;
using std::queue;
using std::stack;
using std::set;



void print(int a[], int n)
{
	cout << a[0];
	for (int i = 1; i < n; i++)
		cout << " " << a[i];
	cout << endl;
}

int main(int argc, char** argv)
{
	if (argc == 2 && strcmp(argv[1], "-debug") == 0)
	{
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}


	int n;
	int a[100];
	int count = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n - 1 - i; j++)
			if (a[j] > a[j + 1])
			{
				std::swap(a[j], a[j + 1]);
				count++;
			}

	print(a, n);
	cout << count<<endl;





	return 0;
}


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

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr long long mod = 1000003;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vector<ll>> vii;
typedef vector<ll> vl;

// value
ll Q;
vl fact;

// 逆元を求める
long long mod_inv(long long value) {

	long long b = mod, u = 1LL, v = 0LL;

	while (b) {
		long long t = value / b;
		value -= t * b;
		swap(value, b);
		u -= t * v;
		swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;

	return u;
}

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

void solve() {

	cin >> Q;

	fact.resize(mod * 2);
	fact[0] = 1;
	for (int i = 1; i < mod * 2; i++) {
		fact[i] = fact[i - 1] * i %  mod;
	}

	for (int i = 0; i < Q; i++) {
		ll x, d, n;
		cin >> x >> d >> n;
		ll ans = 0;
		if (x == 0) {
			cout << 0 << endl;
			continue;
		}
		if (d == 0) {
			ans = mod_pow(x, n);
			cout << ans << endl;
			continue;
		}
		ll tmp = x * mod_inv(d) % mod;
		if (tmp + n - 1 >= mod && tmp <= mod) {
			cout << 0 << endl;
			continue;
		}
		ans = fact[tmp + n - 1] * mod_inv(fact[tmp - 1]) % mod;
		ans = ans * mod_pow(d, n) % mod;
		cout << ans << endl;

	}

	return;

}

signed main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

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

int main(){
    int N,M;
    int p;
    string s;
    cin >> N >> M;
    int t,f;
    t=0;
    f=0;

    vector<string> ac(N);
    vector<int> wa(N);
    fill(wa.begin(),wa.end(),0);

    for (size_t i = 0; i < M; i++)
    {
        cin >> p >> s;
        if(ac.at(p-1)!="AC" && s=="WA"){
            wa.at(p-1)++;
        }
        if(ac.at(p-1)!="AC" && s=="AC"){
            t++;
        }
        if(s=="AC"){
            ac.at(p-1)=s;
        }
        
    }

    for (size_t i = 0; i < N; i++)
    {
        if(ac.at(i)!="AC"){
            wa.at(i) = 0;
        }
    }
    
    for (size_t i = 0; i < N; i++)
    {
        f+=wa.at(i);
    }
    

    cout << t << ' ' << f;
    
    

    
    
}

Measured memory_bytes: 6144
import java.util.Scanner;

public class Main{
	static boolean unsat(String str) {
		boolean check1 = false, check2 = false, check3 = false;
		for(int i = 0; i < str.length(); i++) {
			if(str.charAt(i) == '3') check3 = true;
			else if(str.charAt(i) == '1') check1 = true;
			else if(str.charAt(i) == '2') check2 = true;
		}
		return !(check3 && check1 && check2);
	}
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt(), A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt();
		int[] l = new int[N];
		for(int i = 0; i < N; i++) l[i] = sc.nextInt();

		int ans = Integer.MAX_VALUE;
		for(int i = 0; i < (1 << (2 * N)); i++) {
			String set = Integer.toString(i, 4);
			while(set.length() < N) set = "0" + set;
			if(unsat(set)) continue;
			int tmp = 0, tmpA = 0, tmpB = 0, tmpC = 0;
			for(int j = 0; j < set.length(); j++) {
				if(set.charAt(j) == '1') {
					if(tmpA != 0) tmp += 10;
					tmpA += l[j];
				}
				else if(set.charAt(j) == '2') {
					if(tmpB != 0) tmp += 10;
					tmpB += l[j];
				}
				else if(set.charAt(j) == '3'){
					if(tmpC != 0) tmp += 10;
					tmpC += l[j];
				}
			}
			tmp += Math.abs(tmpA - A) + Math.abs(tmpB - B) + Math.abs(tmpC - C);
			ans = Math.min(ans, tmp);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 36204
#include <bits/stdc++.h>
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

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

  rep(i, n - 1) {
    if (a[i] + a[i + 1] >= l) {
      cout << "Possible" << '\n';   
      vector<int> ans;
      FORR(j, i + 1, 1) ans.push_back(j);
      FOR(j, i + 2, n) ans.push_back(j);
      repr(i, n - 2) cout << ans[i] << '\n';
      return 0;
    }
  }
  cout << "Impossible" << '\n';




  
  return 0;
}

Measured memory_bytes: 1784
using namespace std;

template <typename T>
T compute_totient(T n) {
    T x = 1;
    for (T p = 2; p * p < n; ++p) {
        if (n % p == 0) {
            x *= p - 1;
            n /= p;
            while (n % p == 0) {
                x *= p;
                n /= p;
            }
        }
    }
    if (n > 1) {
        x *= n - 1;
    }
    return x;
}

#include <iostream>
int main() {
    int n;
    cin >> n;
    cout << compute_totient(n) << endl;
    return 0;
}

Measured memory_bytes: 1164
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [-int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    T = NI()
    for _ in range(T):

        N = NI()
        top = []
        bot = []

        ans = 0
        for _ in range(N):
            k,l,r = LI()
            ans += max(l,r)
            if l < r:
                bot.append((N-k,r-l))
            else:
                top.append((k,l-r))

        top.sort()
        bot.sort()

        q = []
        for k,v in top:
            heapq.heappush(q,v)
            if len(q) > k:
                vd = heapq.heappop(q)
                ans -= vd

        q = []
        for k,v in bot:
            heapq.heappush(q,v)
            if len(q) > k:
                vd = heapq.heappop(q)
                ans -= vd

        print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 100600
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N = 1e5+5;
char s[4],c[4];
int ans;
int main()
{
	cin>>s;
	cin>>c;
	for(int i=0;i<3;i++)
	if(s[i]==c[i]) ++ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();

		if(e - a > k) {
			System.out.println(":(");
		} else {
			System.out.println("Yay!");
		}

	}

}

Measured memory_bytes: 22868
#include <iostream>
 #include <string>
#include <sstream>
using namespace std;
int main(){
	int x , y ;
	while(cin>>x>>y){
		x=x+y;
		stringstream a;
		a << x ;
		string str = a.str();
		y = str.size();
		cout << y << endl;
	}
}

Measured memory_bytes: 1212
#!/usr/bin/env python3
#ABC144 C

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ans = inf
for i in range(1,int(math.sqrt(n)+1)):
    if n % i == 0:
        ans = min(ans,i + n//i)
print(ans-2)

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

vector<int> A;
ll N;
vector<int> v,w;

ll merge_count(vector<int> &a){
	int n=a.size();
	if(n<=1) return 0;

	ll cnt=0;
	vector<int> b(a.begin(),a.begin()+n/2);
	vector<int> c(a.begin()+n/2,a.end());

	cnt+=merge_count(b);
	cnt+=merge_count(c);
	//この段階でbcはソート済み

	int ai=0,bi=0,ci=0;
	while(ai<n){
		if(bi<b.size() && (ci==c.size()||b[bi]<c[ci])){
			a[ai++]=b[bi++];
	}
		else {
			cnt+=n/2-bi;
			a[ai++]=c[ci++];
		}
	}
	return cnt;
}


bool flag(int x,vector<int> v){
  int i;
  int l[N];
  for(i=0;i<N;i++) l[i]=2*(v[i]>=x)-1;
  vector<int> s;
  s.push_back(0);
  for(i=1;i<=N;i++) s.push_back(s[i-1]+l[i-1]);
  reverse(s.begin(),s.end());
  if (merge_count(s)>=(N*(N+1)/2+1)/2) return 1;
  else return 0;
}
	


int main(){
  int i,j;
  int x;
  cin>>N;
  for(i=0;i<N;i++) {
	cin>>x;
	v.push_back(x);
	w.push_back(x);
  }
  
  sort(w.begin(),w.end());
  
  int l=0,r=N-1;
  while(r-l>=1){
	int m=(l+r)/2;
	if(flag(w[m],v)) {
		l=m+1;
	}
	else {
		r=m;
	}
  }
  if(flag(w[r],v)) cout<<w[r]<<endl;
  else cout<<w[r-1]<<endl;
  return 0;
}

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

int coin[] = { 500, 100, 50, 10, 5, 1 };
int main() {
  int n,res;
  while(true) {
    cin>>n;
    if(!n) break;
    n=1000-n,res=0;
    for(int i=0; i<6; i++) {
      res+=n/coin[i];
      n%=coin[i];
    }
    cout<<res<<endl;
  }
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 100;
int n;
int l[2*MAX_N];

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n;
  forn (i,2*n) cin >> l[i];

  sort(l,l+2*n);

  int res = 0;
  for (int i = 0; i < 2*n; i+=2) {
    res += l[i];
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
n,m = [int(x) for x in sys.stdin.readline().split()]
r = [0]*n
for _ in range(m):
	a, b = [int(x) for x in sys.stdin.readline().split()]
	r[a-1] += 1
	r[b-1] += 1
for i in r:
	print(i)

Measured memory_bytes: 3060
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    int N, Q;
    scan(N, Q);
    auto A = aryread();
    auto ft = fenwick_tree!long(N);
    foreach (int i, a; A)
    {
        ft.add(i, a);
    }
    foreach (_; 0 .. Q)
    {
        int t, u, v;
        scan(t, u, v);
        if (t == 0)
        {
            ft.add(u, v);
        }
        else
        {
            writeln(ft.sum(u, v));
        }
    }
}

struct fenwick_tree(T)
{
    import std.traits : isSigned, Unsigned;

    static if (isSigned!T)
    {
        alias U = Unsigned!T;
    }
    else
    {
        alias U = T;
    }
public:
    this(int n)
    {
        _n = n;
        data = new U[](n);
    }

    void add(int p, T x)
    {
        assert(0 <= p && p < _n);
        p++;
        while (p <= _n)
        {
            data[p - 1] += cast(U) x;
            p += p & -p;
        }
    }

    T sum(int l, int r)
    {
        assert(0 <= l && l <= r && r <= _n);
        return sum(r) - sum(l);
    }

private:
    int _n;
    U[] data;

    U sum(int r)
    {
        U s = 0;
        while (r > 0)
        {
            s += data[r - 1];
            r -= r & -r;
        }
        return s;
    }
}


Measured memory_bytes: 42384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const i64 mod = 1e9 + 7;
i64 n;
string s;
i64 fact_memo[200001];
i64 fact(i64 x) {
  if (x == 0) return 1;
  if (fact_memo[x]) return fact_memo[x];
  return fact_memo[x] = x * fact(x - 1) % mod;
}

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

  i64 ans = 1;
  i64 c = 0;
  for (i64 i = 0; i < 2 * n; ++i) {
    /*
    if (s[i] == 'W' && c == 0) {
      cout << 0 << endl;
      return 0;
    }
    */
    // cerr << s[i] << '\t' << c << '\t' << ans << endl;
    if ((s[i] == 'B' && c % 2 == 0) || (s[i] == 'W' && c % 2 == 1)) {
      // left
      ++c;
    } else {
      // right
      (ans *= c) %= mod;
      --c;
    }
  }
  if (c != 0) ans = 0;
  (ans *= fact(n)) %= mod;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 2948
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  vector<int> B(N, 0);
  REP(i, N) B[0] += A[i]*(i%2? -1: 1);
  FOR(i, 1, N){
    B[i] = 2*A[i-1]-B[i-1];
  }

  REP(i, N){
    cout << B[i]; SPBR(i, N);
  }

  return 0;
}

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

int main() {
    // 入力
    int N, C; cin >> N >> C;
    vector<vector<int> > D(C, vector<int>(C, 0));
    for (int i = 0; i < C; ++i) for (int j = 0; j < C; ++j) cin >> D[i][j];
    vector<vector<int> > fi(N, vector<int>(N, 0));
    for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) cin >> fi[i][j], --fi[i][j];
    
    // 前処理
    vector<vector<int> > cost(3, vector<int>(C, 0));
    for (int c = 0; c < C; ++c) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                cost[(i+j)%3][c] += D[fi[i][j]][c];
            }
        }
    }
    
    // 求める
    int res = 1<<30;
    int c[3];
    for (c[0] = 0; c[0] < C; ++c[0]) {
        for (c[1] = 0; c[1] < C; ++c[1]) {
            if (c[1] == c[0]) continue;
            for (c[2] = 0; c[2] < C; ++c[2]) {
                if (c[2] == c[0] || c[2] == c[1]) continue;
                int tmp = 0;
                for (int it = 0; it < 3; ++it) tmp += cost[it][c[it]];
                res = min(res, tmp);
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
#include<list>
using namespace std;
int solve(int n){
	int cnt=0;
	//if(n == 2)return 1;
	while(n%2 == 0){
		n /= 2;
		cnt++;
	}

	return cnt;
}
int main(){
	int n,cnt=-1;
	int ans=0;
	cin>>n;

	if(n==1){
		cout<< 1 <<endl;
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(i%2 == 0){
			int tmp = solve(i);
			if(cnt < tmp){
				cnt = tmp;
				ans = i;
			}
			//cnt = max(cnt, solve(i));
			//cout<<i<<" "<<cnt<<endl;
		}
	}

	cout<< ans <<endl;

	return 0;
}


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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

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

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;

int main(){
    int n;
  	cin >> n;
    vi a(n);
    REP(i,n) cin >> a[i];
    vi b;
    b.push_back(a[0]);
    for(int i=1; i<n; i++){
        if(a[i-1]!=a[i]){
            b.push_back(a[i]);
        }
    }
    b.push_back(0);

    ll mon = 1000;
    ll num = 0;
    REP(i,b.size()-1){
        if(num==0 && b[i]<b[i+1]){
            num = mon/b[i];
            mon %= b[i];
        }else if(num!=0 && b[i]>b[i+1]){
            mon += num*b[i];
            num = 0;
        }
    }

    cout << mon << endl;
}

Measured memory_bytes: 3632
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    rr = []

    m = {}
    def f(s):
        k = s
        if k in m:
            return m[k]
        t = set(re.findall(r"\([^()]+\)", s))
        while t:
            for c in t:
                s = s.replace(c, f(c[1:-1]))
            t = set(re.findall(r"\([^()]+\)", s))
        while '-' in s:
            s = s.replace('-1', '1')
            s = s.replace('-2', '0')
            s = s.replace('-0', '2')
        r = s[0]
        for i in range(len(s)//2):
            if s[i*2+1] == '*':
                r = min(r,s[i*2+2])
            else:
                r = max(r,s[i*2+2])
        m[k] = r
        return r

    while True:
        s = S()
        if s == '.':
            break

        tr = 0
        for P,Q,R in itertools.product(['0', '1', '2'], repeat=3):
            ts = s.replace('P', P)
            ts = ts.replace('Q', Q)
            ts = ts.replace('R', R)
            if f(ts) == '2':
                tr += 1

        rr.append(tr)

    return '\n'.join(map(str, rr))



print(main())



Measured memory_bytes: 9232
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Text;
     
    public class Program
    {
        public void Proc() {
            Reader.IsDebug = false;
            int[] inpt = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray();

            string ans = (inpt[1]-inpt[0]==inpt[2]-inpt[1])?"YES":"NO";
            Console.WriteLine(ans);


        }

        public class Reader {
            public static bool IsDebug = true;
            private static System.IO.StringReader SReader;
            private static string InitText = @"




2 5 6




";
            public static string ReadLine() {
                if(IsDebug) {
                    if(SReader == null) {
                        SReader = new System.IO.StringReader(InitText.Trim());
                    }
                    return SReader.ReadLine();
                } else {
                    return Console.ReadLine();
                }
            }
        }
        public static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }
    }

Measured memory_bytes: 13396
#include<iostream>
#include<cmath>
#define ll long long
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 200004
#define INF 1e9+7

using namespace std;

ll n,ar[N],half,mini=INF,maxi=0;
ll seg[9*N];

void init(ll low,ll high,ll pos)
{
    seg[pos] = 0;

    if(low == high)
        return;

    ll mid = (low + high)/2;

    init(low,mid,pos*2+1);
    init(mid+1,high,pos*2+2);

    return;
}

void update(ll low,ll high,ll pos,ll slow)
{
    if(low == high && low == slow)
    {
        seg[pos]++;
        return;
    }

    if(low > slow || high < slow)
    {
        return;
    }

    ll mid = (low  + high)/2;

    update(low,mid,pos*2+1,slow);
    update(mid+1,high,pos*2+2,slow);

    seg[pos] = seg[pos*2+1] + seg[pos*2+2];

    return;
}

ll query(ll low,ll high,ll pos,ll slow)
{
    if(high <= slow)
    {
        return seg[pos];
    }
    if(low > slow)
    {
        return 0;
    }

    ll mid = (low + high)/2;

    return query(low,mid,pos*2+1,slow) + query(mid+1,high,pos*2+2,slow);
}

ll check(ll x)
{
    init(0,2*n,0);
    ll ans = 0;
    ll sum = n;

    update(0,2*n,0,sum);

    rep(i,0,n)
    {
        if(ar[i] < x)
        {
            sum--;
        }
        else
        {
            sum++;
        }

        ans += query(0,2*n,0,sum);
        update(0,2*n,0,sum);
    }

    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n;

    half = ceil((double)(n*(n+1))/4.0);

    rep(i,0,n)
    {
        cin >> ar[i];
        mini = min(mini,ar[i]);
        maxi = max(maxi,ar[i]);
    }

    ll low = mini;
    ll high = maxi;

    ll res = -1;

    while(low <= high)
    {
        ll x = (low + high)/2;

        if(check(x) >= half)
        {
            low = x+1;
            res = x;
        }
        else
        {
            high = x-1;
        }
    }

   // cout << check(low) << " " << half << endl;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 8960
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int N;
  int M;
  int res = 0;
  rd(N);
  rd(M);
  res = N * (N-1) / 2 + M * (M-1) / 2;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200321-1

// --- original code ---
// {
//   int N, M, res = 0;
//   rd(N,M);
//   res = N * (N-1) / 2 + M * (M-1) / 2;
//   wt(res);
// }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();

        long[] max = new long[4];
        max[0] = a * c;
        max[1] = a * d;
        max[2] = b * c;
        max[3] = b * d;

        long maxValue = max[0];
        for(int i = 0; i<max.length; i++){
            if(maxValue < max[i]){
                maxValue = max[i];
            }
        }

        System.out.println(maxValue);
    }
}

Measured memory_bytes: 35732
#include<bits/stdc++.h> 
#include<random> 
#define int long long 
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back 
#define mod 1000000007 
#define mk(arr,n,type) type *arr=new type[n]; 
#define sl s1.length(); 
#define yes cout<< "Yes"<<endl 
#define no cout<< "No"<<endl 
#define all(v) (v).begin(),(v).end() 
#define mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
using namespace std; 
void fastio() 
{ 
    #ifndef ONLINE_JUDGE 
    freopen("INPUT.txt","r",stdin); 
    freopen("OUTPUT.txt","w",stdout); 
    #endif 
    ios_base :: sync_with_stdio(false); 
    cin.tie(NULL) ; 
    cout.tie(NULL); 
    
} 

signed main() 
{ 
    fastio(); 
    int t=1;
    //cin>>t;
    while(t--)
    {
        // int n,m;
        // cin>>n>>m;
        // int a[n],b[n];
        // for(int i=0;i<n;i++)
        // {cin>>a[i];b[i]=a[i]%m;}
        // int c[m]={},d[m]={};
        // int k=n/m;
        // for(int i=0;i<n;i++)
        // {
        //     c[b[i]]++;
        // }
        // for(int i=0;i<m;i++)
        // {
        //     x+=abs(c[i]-k);
        // }
        // cout<<x<<"\n";
        // for(int i=0;i<n;i++)
        // {
        //     if(d[a[i]]<=k)
            // {cout<<a[i]<<" ";
            // d[a[i]]++;}
           int n,c=0;
           cin>>n;
           int a[n];
           for(int i=0;i<n;i++)
           cin>>a[i];
           for(int i=0;i<n;i++)
           {
               for(int j=i+1;j<n;j++)
               {
                   for(int k=j+1;k<n;k++)
                   {
                       if((a[i]+a[j]>a[k])&&(a[i]+a[k]>a[j])&&(a[j]+a[k]>a[i])&&a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k])
                       c++;
                       //cout<<(a[i]+a[j]>a[k])<<(a[j]+a[k]>a[i])<<(a[k]+a[i]>a[j])<<"\n";
                   }
               }
           }
           cout<<c;
        }
    
}

Measured memory_bytes: 3652
l,r = map(int, input().split())

rl = r-l
l2 = l%2019
r2 = l2+rl

if rl>2019:
    print(0)
else:
    min_dif = 2019
    for i in range(l2, r2):
        for j in range(i+1, r2+1):
            if (i*j)%2019 < min_dif:
                min_dif = (i*j)%2019
    print(min_dif)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
using namespace std;

int main()
{

	int a, b, x;

    cin >> a >> b >> x;

    if(a <= x && x <= a+b) cout << "YES" << endl;
    else cout << "NO" << endl;

	return 0;

}


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

int main(){
  int n;cin >> n;
  int x = n/1.08+0.9;
  if((int)(x*1.08)==n) cout << x << endl;
  else puts(":(");
}

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

using namespace std;

int main() {
	int n;
	string s;

	cin >> n >> s;

	int left = 0;

	while (left < n && s[left] == 'R') {
		left++;
	}

	int right = n-1;

	while (right >= 0 && s[right] == 'W') {
		right--;
	}

	// cout << left << " " << right << "\n";

	int ans = 0;
	while (left < right) {
		while (left < right && s[left] == 'R') {
			left++;
		}
		while (left < right && s[right] == 'W') {
			right--;
		}
		if (left < right) {
			swap(s[left], s[right]);
			left++;
			right--;
			ans++;
		}
	}

	// cout << left << " " << right << " ";
	cout << ans << "\n";
	// cout << s << "\n";

	return 0;
}

// Final sequence will be: RRRR...WWWW



Measured memory_bytes: 3716
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


signed main() {
    ll n, x, t;
    cin >> n >> x >> t;
    
    ll cnt = 0;
   
    while (true) {
        cnt++;
        if(x*cnt >= n) {
            mes(t*cnt);
            re0;
        }
    }
    
    
    
}

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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    long double a, b;
    cin >> a >> b;
    print((Int)floor(a * b));
    return 0;
}

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

#define   ll    long long int

const int N = 100005;
ll ara[N];

int main( )
{
    ll n, x, i, j, k, s = 0;
    cin >> n >> x;
    for (i = 1; i <= n; i++) {
        cin >> ara[i];
    }
    for (i = 2; i <= n; i++) {
        if (ara[i - 1] + ara[i] > x) {
            k = (ara[i - 1] + ara[i]) - x;
            j = min(ara[i], k);
            ara[i] -= j;
            s += j;
            k -= j;
            j = min(ara[i - 1], k);
            ara[i - 1] -= j;
            s += j;
            k -= j;
        }
    }
    cout << s << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, n;
    cin >> h >> n;
    vector<int> A(n), B(n);
    REP(i, 0, n) {
        cin >> A[i] >> B[i];
    }
    const ll inf = 1LL << 60;
    auto dp = make_v(n + 1, h + 1, inf);
    dp[0][h] = 0;
    REP(i, 0, n) {
        for (int j = h; j >= 0; j--) {
            chmin(dp[i + 1][j], dp[i][j]);
            int nxt = max(0, j - A[i]);
            chmin(dp[i][nxt], dp[i][j] + B[i]);

        }
    }
    cout << dp[n][0] << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int x, sum = 0;
    for (int i = 0; i < 4; i++) {
        cin >> x;
        sum += x;
    }
    cout << sum / 60 << "\n" << sum % 60 << endl;
    return 0;
}

Measured memory_bytes: 3060
require 'set'
n, m = gets.split.map(&:to_i)
str = gets.chomp
$n = str.size + 1

size_idx = {}
l = r = 0
m.times do
	gets.chomp =~ /(\w)(.)/
	if $1 == ?R
		r += ($2 == ?+ ? +1 : -1)
	else
		l += ($2 == ?+ ? +1 : -1)
	end
	(size_idx[r - l + 1] ||= Set.new) << l
end

hash = {}
str.each_char.with_index do |c, i|
	(hash[c] ||= []) << i
end
a = []
hash.keys.sort.each_with_index do |c, k|
	hash[c] .each {|i| a[i] = k + 1}
end
rank = [a]

d = 1
loop do
	a = (0..str.size-1).map {|i| rank[-1][i] * $n + (rank[-1][i+d] || 0)}
	hash = {}
	a.each_with_index do |x, i|
		(hash[x] ||= []) << i
	end
	a = []
	hash.keys.sort.each_with_index do |c, k|
		hash[c].each {|i| a[i] = k + 1}
	end
	rank << a
	d <<= 1
	break if d >= str.size
end

def compute_rank(rank, len, i)
	k = 0
	r = 0
	until len == 0
		if len[0] == 1
			r = r * $n + rank[k][i]
			i += (1 << k)
		end
		len >>= 1
		k += 1
	end
	r
end

num = 0
size_idx.each do |len, is|
	if is.size == 1
		num += 1
		next
	end
	ranks = Set.new
	is.each do |i|
		r = compute_rank(rank, len, i)
		unless ranks.include?(r)
			ranks << r
			num += 1
		end
	end
end
p num

Measured memory_bytes: 274172