akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
template<long long Mod = mod>
constexpr long long MOD(long long in) {
    return in % Mod;
}
template<class T>
constexpr T UP(T left, T div) {
    return (left + div - 1) / div;
}

int k;
ll a[100005];
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> k;
    for (int i = 0; i < k; ++i)
        std::cin >> a[i];

    ll minn = 2, maxn = 2;
    bool ok = true;
    for (int i = k - 1; i >= 0; --i) {
        auto dminn = ((minn + a[i] - 1) / a[i]) * a[i];
        auto dmaxn = (maxn / a[i]) * a[i] + a[i] - 1;

        if (a[i] > maxn || dminn > maxn || dmaxn < minn) {
            ok = false;
            break;
        }

        minn = dminn;
        maxn = dmaxn;

    }

    if (ok)
        std::cout << minn << " " << maxn << std::endl;
    else
        std::cout << -1 << std::endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

const int MOD = 1000000007;

struct Combination{
  vector<int> fact; //　fact[i] = iの階乗
  Combination(int n) : fact(n+1){
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= n; i++){
      fact[i] = fact[i-1] * i % MOD;
    }
  }

  int nCr(int n, int r){ // nCr = n!/r!(n-r)!
    if(n < r) return 0;
    return fact[n] * inv(fact[r]*fact[n-r]%MOD) % MOD;
  }

  int inv(int n, int p = MOD-2){ // a/n ≡ a*n^(p-2) nとpは互いに素
    int r = 1;
    for(; p > 0; p >>= 1){
      if(p & 1LL) r = r * n % MOD;
      n = n * n % MOD;
    }
    return r; // r = n^p % MOD
  }
};

signed main(){

  int n, k; cin >> n >> k;
  int l = 0, r = 0;
  for(int i = 0; i < k; i++){
    l += i+1;
    r += (n+1 - i);
  }
  int ans = 0;
  for(int i = k; i <= n+1; i++){
    //cout << l << " " << r << endl;
    ans = (ans + r - l + 1) % MOD;
    l += i+1;
    r += (n+1 - i);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            int inputNumber = Integer.parseInt(br.readLine());

            int pairCount = 0;
            if (inputNumber % 2 == 0) {
                pairCount = (inputNumber / 2) * (inputNumber / 2);
            } else {
                pairCount = (inputNumber / 2 + 1) * (inputNumber / 2);
            }

            System.out.println(pairCount);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 22484
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] line = scanner.nextLine().split(" ", n);

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(line[i]);
        }
        Arrays.sort(arr);

        int min = arr[0];
        int result = arr[0];
        while (true) {
            int nextMin = Integer.MAX_VALUE;
            boolean withNon0 = false;
            for (int i = 0; i < n; i++) {
                if (arr[i] == min) continue;
                arr[i] %= min;
                if (arr[i] > 0) {
                    withNon0 = true;
                    result = Math.min(result, arr[i]);
                    nextMin = Math.min(nextMin, arr[i]);
                }
            }

            if (withNon0) {
                min = nextMin;
            } else {
                break;
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 48696
use proconio::marker::Usize1;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        h: [usize; n],
        es: [(Usize1, Usize1); m],
    }

    let mut e: Vec<Vec<usize>> = vec![vec![]; n];
    for (a, b) in es.iter() {
        e[*a].push(*b);
        e[*b].push(*a);
    }

    let mut res = 0;
    for i in 0..n {
        let mut ok = true;
        for j in e[i].iter() {
            if h[i] <= h[*j] {
                ok = false;
            }
        }
        if ok {
            res += 1;
        }
    }

    println!("{}", res);
}


Measured memory_bytes: 12216
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    a = list(map(int,input().split()))
    pr = [0]*(max(a)+1)
    flag = True
    for num in a:
        pr[num] += 1
    for i in range(2, max(a)+1):
        count = sum(pr[i::i])
        if count == N:
            print("not coprime")
            exit()
        elif count > 1:
            flag = False
    if flag:
        print("pairwise coprime")
    else:
        print("setwise coprime")

if __name__ == "__main__":
    main()


Measured memory_bytes: 191136
//cnt0 += s[i] == '0';
#include <bits/stdc++.h>
# define ll long long 
# define all(vc) vc.begin(),vc.end()
# define str string 
# define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
stack <char> stk;
vector <ll> vc;
vector <char> A;
set <char> B;
ll a,b,c,d,e,f,g,h,cnt,bnt,p,sum;
str s,cal;
map <char,ll> mp;
ll arr[1000][6];
char ch;
bool ok=true;
int main(){
	speed;
	cin>>a>>b;
	if(a%b==0) cout<<a/b;
	else cout<<(a/b)+1;
	time;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
counter=0
flag=0
for i in range(n):
    a,b=input().split()
    if(a==b):
        counter=counter+1
    else:
        counter=0
    if(counter>2):
        flag=1
if(flag==1):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int n[3];
    for (size_t i=0; i<3; ++i)
        scanf("%d", &n[i]);

    sort(n, n+3);
    for (size_t i=0; i<3; ++i)
        printf("%d%c", n[i], i<2? ' ':'\n');

    return 0;
}

Measured memory_bytes: 2792
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll n, m; cin >> n >> m;
    vector<vector<ll>> g(n);
    vector<ll> ans(n,0);
    vector<ll> dist(n,1002003004);

    rep(i,m){
        int a, b; cin >> a >> b;
        a--; b--;

        g[a].emplace_back(b);
        g[b].emplace_back(a);

    }

    queue<int> q;

    auto push = [&] (int v, int d){
        if(dist[v] != 1002003004) return;
        dist[v] = d;
        q.push(v);
    };

    //初期push
    push(0,0);

    //BFS内部
    while(!q.empty()){
        int v = q.front(); q.pop();
        int d = dist[v];

        for(auto e: g[v]){
            int nv = e;
            if(dist[e] == 1002003004){
                ans[e] = v;
            }
            push(nv,d+1);
        }

    }

    rep(i,n){
        if(i==0){
            cout << "Yes" << endl;
            continue;
        }

        cout << ans[i] + 1 << endl;
        
    }
    
}

Measured memory_bytes: 13480
#include<cstdio>
using namespace std;
const int maxn=200005;
int n,a[maxn],pos[maxn];
int main() {
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",a+i);
	for(int i=0;i<n;i++) pos[a[i]]=i;
	int cur=0,ans=0;
	for(int i=1;i<=n;i++) {
		if (pos[i]<pos[i-1]) {
			if (cur>ans) ans=cur;
			cur=1;
		} else {
			cur++;
		}
	}
	if (cur>ans) ans=cur;
	printf("%d\n",n-ans);
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(){
	int a,b,c,d,e,i,n=5,average;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	for(i = 0;i<n;i++){
		if(a<40){
			a = 40;
		} else if(b<40){
			b = 40;
		} else if(c<40){
			c = 40;
		} else if(d<40){
			d = 40;
		} else if(e<40){
			e = 40;
		}
	}
	average = (a+b+c+d+e)/5;
	printf("%d\n",average);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<bool> f(n + 1, false);
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int b = 1;
    f[1] = true;
    int count = 0;
    while (true)
    {
        if (b == 2)
        {
            cout << count << endl;
            return 0;
        }
        b = a[b];
        if (!f[b])
        {
            f[b] = true;
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
        count++;
    }
}

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

#define Set(a, b) memset(a, b, sizeof (a))
#define For(i, j, k) for (int i = j; i <= k; ++ i)
#define Forr(i, j, k) for (int i = j; i >= k; -- i)

using namespace std;

typedef long long ll;

inline int read() {
	int x = 0, p = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') p = -1;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x * p;
}

inline void File() {
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
}

const int N = 1e5 + 10, bas = 1e5, inf = 0x3f3f3f3f;
int a[N], n, s[N], ans;

struct BIT {
	int c[N << 1], lim = N << 1; 

	inline void init() { Set(c, 0); }	
	
	inline void update(int x, int v) {
		for (; x <= lim; x += x & -x) c[x] += v;
	}

	inline int query(int x) {
		static int res;
		for (res = 0; x; x -= x & -x) res += c[x];
		return res;
	}
} T;

inline bool check(int x) {
	T.init(), Set(s, 0);
	For(i, 1, n) s[i] = s[i - 1] + (a[i] >= x ? 1 : -1);

	ll res = 0;
	T.update(bas, 1);
	For(i, 1, n) {
		res += T.query(s[i] + bas);
		T.update(s[i] + bas, 1);
	}

	return res >= 1ll * n * (n + 1) / 4;
}

int main() {

	n = read();

	int mx = 0;
	For(i, 1, n) mx = max(mx, a[i] = read());

	for (int l = 1, r = mx; l <= r; ) {
		int mid = l + r >> 1;
		if (check(mid)) ans = mid, l = mid + 1;
		else r = mid - 1;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
n = int(input())
input_list = [int(input()) for i in range(n)]
min_value = input_list[0]
profit = -1000000000
for i in input_list[1:]:
    if(profit < (i - min_value)):
        profit = i - min_value
    # print(min_value, i, profit)
    if (min_value > i):
        min_value = i
print(profit)



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

int main() {
    string s;
    cin >> s;
    string ans = s[2] == s[3] && s[4] == s[5] ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int N, T;
  cin >> N >> T;
  int c[N];
  int t[N];
  for (int i = 0; i < N; i++)
  {
    cin >> c[i] >> t[i];
  }
  int ans = 1001;
  for (int i = 0; i < N; i++)
  {
    if (t[i] <= T && c[i] < ans)
    {
      ans = c[i];
    }
  }
  if (ans == 1001)
  {
    cout << "TLE" << endl;
  }
  else
  {
    cout << ans << endl;
  }
  return 0;
}

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

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 1e5 + 5;
char s[N];

int main()
{
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	
	if (s[1] == '0') return puts("-1"), 0;
	if (s[n] == '1') return puts("-1"), 0;
	for (int i = 1; i < n; ++i)
		if (s[i] != s[n - i]) return puts("-1"), 0;
	
	int cur = 1;
	for (int i = 1; i < n; ++i)
	{
		printf("%d %d\n", cur, i + 1);
		if (s[i] == '1') cur = i + 1;
	}
	
	return 0;
}


Measured memory_bytes: 3836
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	vector<ll> A(9);
	rep(i, 9) {
		cin >> A.at(i);
	}
	ll N;
	cin >> N;
	rep(j, N) {
		ll b;
		cin >> b;
		rep(i, 9) {
			if (A.at(i) == b) {
				A.at(i) = 0;
			}
		}
	}
	if ((A[0] + A[1] + A[2]) == 0 || (A[3] + A[4] + A[5]) == 0|| (A[6] + A[7] + A[8]) == 0|| (A[0] + A[3] + A[6]) == 0|| (A[4] + A[1] + A[7]) == 0|| (A[8] + A[5] + A[2]) == 0|| (A[0] + A[4] + A[8]) == 0|| (A[2] + A[4] + A[6]) == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  ll r, D, x;
  cin >> r >> D >> x;
  rep(i, 10) {
    x = r * x - D;
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 256
x = int(input())

max_exp = 1
for b in range(2, x + 1):
    
    p = 2
    while True:
        ans = b ** p
        #print(ans)
        if ans <= x:
            max_exp = max(max_exp, ans)
            p += 1
        else:
            break

print(max_exp)

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

int main()
{
    int a,b,c,d,s1,s2=0;
    cin >> a >> b >> c >> d;
    s1 = a * b;
    s2 = c * d;
    
    if(s1 > s2){
        cout << s1 << endl;
    }
    else {
        cout << s2 << endl;
        
    }
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100010)

N, M = map(int,input().split())
E = [[] for k in range(N)]

for k in range(M):
    X, Y, Z = map(int,input().split())
    E[X-1].append(Y-1)
    E[Y-1].append(X-1)
G = [-1]*N

def dfs(now,group):
    if G[now] == -1:
        G[now] = group
        for tsugi in E[now]:
            dfs(tsugi,group)

ans = 0
for k in range(N):
    if G[k] == -1:
        dfs(k,ans)
        ans += 1
print(ans)


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define INF 1e15
ll N, A[101010];
ll Asum[101010];
ll ans[101010],ans2;
ll i, j, k,l;


int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
    }
    sort(A, A + N);
    ans2 -= A[0];
    fornum(i,1,N-1){
        if(A[i]>0){
            ans2 += A[i];
        }else{
            ans2 -= A[i];
        }
    }
    ans2 += A[N - 1];
    printf("%lld\n", ans2);
    /*
    if(A[N-1]<0){
        j = A[N - 1];
        fornum(i,0,N-1){
        printf("%lld %lld\n", j, A[i]);
            j = j - A[i];
        }
    }
    else{*/
        j = A[0];
        ll flg = 0;
        fornum(i,0,N-1){
        if(i<N-2&&A[N-2-i]>0||flg){
            printf("%lld %lld\n", j, A[N - 1 - i]);
            j = j - A[N - 1 - i];
        }else{
            printf("%lld %lld\n", A[N - 1 - i], j);
            j = A[N - 1 - i] - j;
            flg = 1;
        }
    }
    //}
    
    
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  int x,y=0;
  cin>>x;
  for(int i=x;i<=2*x;i++){
    bool ans=true;
    for(int j=2;j*j<=i;j++){if(i%j==0){ans=false;}}
    if(ans){y=i;break;}}
  cout<<y<<endl;
}

Measured memory_bytes: 256
#C
N=int(input())
alpha="zabcdefghijklmnopqrstuvwxy"
cnt=1
while True:
    if N<=26**cnt:
        break
    N-=26**cnt
    cnt+=1
ans=""
for i in range(cnt):
    ans=alpha[N%26]+ans
    N=(N-1)//26+1
print(ans)

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

int main(){
    int N, W; cin >> N >> W;
    vector<int> v(N), w(N);
    for(int i = 0; i < N; i++){
        cin >> v.at(i) >> w.at(i);
    } 
    vector<vector<int>> dp(N+1, vector<int>(W+1));
    dp.at(0).at(0) = 0;
    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= W; j++){
            dp.at(i).at(j) = dp.at(i - 1).at(j);
            if(j - w.at(i - 1) >= 0){  
                dp.at(i).at(j) = max(dp.at(i - 1).at(j), dp.at(i).at(j - w.at(i - 1)) + v.at(i - 1)); 
            }
        }
    }
    cout << dp.at(N).at(W) << endl;
}


Measured memory_bytes: 6836
#include<bits/stdc++.h>
#define lowbit(x) x&-x
using namespace std;

const int N=100000+10;
const int mod=1e9+7;

int n,m,cnt,top;
int a[N],b[N],S[N];
pair<int,int> p[N];
int f[N];

inline int cmp(pair<int,int> a,pair<int,int> b) {
    if (a.first!=b.first) return a.first<b.first;
    else return a.second>b.second;
}

int c[N];
inline int query(int x) { int res=0;
    for (;x;x-=lowbit(x)) res=(res+c[x])%mod;
    return res;
}
inline void add(int x,int y) {
    for (;x<=top;x+=lowbit(x)) c[x]=(c[x]+y)%mod;
}

int main() {
	cin>>n>>m;
    for(int i=1;i<=n;++i)cin>>a[i];
    for(int i=1;i<=m;++i)cin>>b[i];
    for(int i=1;i<=n;++i) {
        if (a[i]<=b[1]||a[i]>=b[m]) continue;
        int x=lower_bound(b+1,b+m+1,a[i])-b;
        if (b[x]==a[i]) continue;
        p[++cnt]=make_pair(a[i]-b[x-1],b[x]-a[i]);
        S[++top]=b[x]-a[i];
    }
    sort(S+1,S+top+1); top=unique(S+1,S+top+1)-S-1;
    for(int i=1;i<=cnt;++i)
        p[i].second=lower_bound(S+1,S+top+1,p[i].second)-S;
    sort(p+1,p+cnt+1,cmp); cnt=unique(p+1,p+cnt+1)-p-1;
    f[0]=1;
    for(int i=1;i<=cnt;++i)
        f[i]=query(p[i].second-1)+1,add(p[i].second,f[i]);
    int ans=0;
    for(int i=0;i<=cnt;++i) ans=(ans+f[i])%mod;
    printf("%d\n",ans);
}

Measured memory_bytes: 2688
import java.util.*;

class Demand implements Comparable {
    int from;
    int to;

    public int compareTo(Object other) {
        Demand otherDemand = (Demand) other;
        return to - otherDemand.to;
    }
}

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

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

        Demand[] demands = new Demand[m];

        for (int i = 0; i < m; i++) {
            Demand demand = new Demand();
            demand.from = sc.nextInt();
            demand.to = sc.nextInt();
            demands[i] = demand;
        }

        Arrays.sort(demands);

        int ans = 0;
        int lastBridge = -1;

        for (int i = 0; i < m; i++) {
            if (demands[i].from > lastBridge) {
                lastBridge = demands[i].to - 1;
                ans++;
            }
        }

        System.out.println(ans);
    }

}

Measured memory_bytes: 90288
def main():
    from sys import stdin
    def input():
        return stdin.readline().strip()

    def str_to_bool(i):
        if i == '0':
            return False
        else:
            return True

    n = int(input())
    f = [[str_to_bool(i) for i in input().split()] for _ in range(n)]
    p = [[int(i) for i in input().split()] for _ in range(n)]

    # full search
    from itertools import product

    ans = -float('inf')
    flag = True
    for iterator in product([False, True], repeat=10):
        if flag:
            flag = False
            continue

        profit = 0
        for store_ind in range(n):
            num = 0
            for i in range(10):
                if iterator[i] and f[store_ind][i]:
                    num += 1
            profit += p[store_ind][num]
        
        if ans < profit:
            ans = profit

    print(ans)

main()

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll D = 0;
    REP(i, N){
        if(S[i] == 'R'){
            D++;
        }
    }

    ll R = D;
    //ll W = N - R;

    ll ma = (1ll<<60);
    REP(i, N+1){
        ll tmp = 0;
        ll r = i;
        ll rd = abs(R-r);
        tmp += rd;
        ll delta = D - rd;
        if(delta&1){
            delta--;
            tmp++;
        }
        tmp += delta/2;
        chmin(ma, tmp);
        if(i<N){
            if(S[i] == 'R') D--;
            if(S[i] == 'W') D++;
        }
    }

    cout << ma << endl;

    return 0;
}

Measured memory_bytes: 3776
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		if (S.substring(0, 1).equals("a") &&
				S.substring(1, 2).equals("b") &&
				S.substring(2, 3).equals("c")) {
			System.out.println("Yes");
		}else if (S.substring(0, 1).equals("a") &&
				S.substring(1, 2).equals("c") &&
				S.substring(2, 3).equals("b")) {
			System.out.println("Yes");
		}else if (S.substring(0, 1).equals("b") &&
				S.substring(1, 2).equals("c") &&
				S.substring(2, 3).equals("a")) {
			System.out.println("Yes");
		}else if (S.substring(0, 1).equals("b") &&
				S.substring(1, 2).equals("a") &&
				S.substring(2, 3).equals("c")) {
			System.out.println("Yes");
		}else if (S.substring(0, 1).equals("c") &&
				S.substring(1, 2).equals("b") &&
				S.substring(2, 3).equals("a")) {
			System.out.println("Yes");
		}else if (S.substring(0, 1).equals("c") &&
				S.substring(1, 2).equals("a") &&
				S.substring(2, 3).equals("b")) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N, K, h[100000]; cin >> N >> K;
  int ans = 0;
  REP(i, N){
    cin >> h[i];
    if(h[i] >= K) ans++;
  }
  cout << ans << endl;

}

Measured memory_bytes: 1024
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string S, T;
    cin >> S;
    cin >> T;

    ll length = SIZE(S), ans = 0;

    REP(i, length)
    {
        if (S[i] != T[i])
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3792
n, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

mod = 10**9+7

A_ = set(A)
B_ = set(B)

if len(A) != len(A_) or len(B) != len(B_):
    print(0)
    exit()

A.sort()
B.sort()

import bisect

ans = 1
for i in reversed(range(1, n*m+1)):
    if i in A_ and i in B_:
        ans *= 1
    elif i in A_ and i not in B_:
        ans *= (len(B)-bisect.bisect_left(B, i))
    elif i not in A_ and i in B_:
        ans *= (len(A)-bisect.bisect_left(A, i))
    else:
        a = len(A)-bisect.bisect_left(A, i)
        b = len(B)-bisect.bisect_left(B, i)
        ans *= a*b-(len(A)*len(B)-i)
    ans %= mod
    
print(ans)

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

int main() {
	// your code goes here
	string s;
	cin>>s;
	int si=s.size();
	int o=0;
	int one=0;
	for(int x=0;x<si;x++)
	{
		if(s[x]=='0')
		{
			o++;
		}
		else
		{
			one++;
		}
	}
	if(one<o)
	{
		cout<<(2*one)<<endl;
	}
	else
	{
		cout<<(2*o)<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_B
# Selection Sort
# Result:
import sys

nums_len = int(sys.stdin.readline())
nums_str = sys.stdin.readline().split(' ')
nums = map(int, nums_str)

swap_count = 0
for i in range(0, nums_len):
    minj = i
    for j in range(i, nums_len):
        if nums[j] < nums[minj]:
            minj = j
    if minj != i:
        v = nums[i]
        nums[i] = nums[minj]
        nums[minj] = v
        swap_count += 1

print ' '.join(map(str, nums))
print swap_count

Measured memory_bytes: 4224
//By Vlgd
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
using namespace std;
class Point{
	public:
	double x,y;
	Point(double x=0,double y=0):x(x),y(y){}
	Point operator + (Point p){return Point(x+p.x,y+p.y);}
	Point operator - (Point p){return Point(x-p.x,y-p.y);}
	Point operator * (double a){return Point(a*x,a*y);}
	Point operator / (double a){return Point(x/a,y/a);}
	double abs() {return sqrt(norm());}
	double norm() {return x*x+y*y;}
	bool operator < (const Point &p) const{
		return x!=p.x?x<p.x:y<p.y;
	}
	bool operator == (const Point &p) const{
		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
	}
};
struct Segment{Point p1,p2;};
typedef Point Vector;
double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}
int ccw(Point p0,Point p1,Point p2){
	Vector a=p1-p0,b=p2-p0;
	if(cross(a,b)>EPS) return 1;
	if(cross(a,b)<-EPS) return -1;
	if(dot(a,b)<-EPS) return 2;
	if(a.abs()<b.abs()) return -2;
	if(a.abs()>=b.abs()) return 0;
}
bool intersect(Segment s1,Segment s2){
	Point p1=s1.p1,p2=s1.p2;
	Point p3=s2.p1,p4=s2.p2;
	return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 && ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0 );
}
main(){
	int q;
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		int x1,y1,x2,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		Point p1(x1,y1),p2(x2,y2);
		Segment s1;
		s1.p1=p1;s1.p2=p2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		Point p3(x1,y1),p4(x2,y2);
		Segment s2;
		s2.p1=p3;s2.p2=p4;
		if(intersect(s1,s2)) printf("1\n");
		else printf("0\n");
	}
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
 
using vd=vector<double>;
using vvd=vector<vd>;
 
 
int main(){
    int h,w;
    cin>>h>>w;
    vvi f(h+2,vi(w+2,1));
    vvi walk(h+2,vi(w+2,0));
    int gy,gx,y=0,x=0,v=0;
    range(i,1,h+1)range(j,1,w+1){
        char c;
        cin>>c;
        switch(c){
            case 'G': gy=i,gx=j,f[i][j]=0; break;
            case '.': f[i][j]=0;break;
            case '#': break;
            case '^': y=i,x=j,v=0,f[i][j]=0; break;
            case '>': y=i,x=j,v=1,f[i][j]=0; break;
            case 'v': y=i,x=j,v=2,f[i][j]=0; break;
            case '<': y=i,x=j,v=3,f[i][j]=0; break;
        }
    }
    walk[y][x]=1;
    rep(loop,(2650+2680)/2){
        vvi vec={{-1,0},{0,1},{1,0},{0,-1}};
        if(f[y+vec[(v+1)%4][0]][x+vec[(v+1)%4][1]]==0){ //右手が道なら右に曲がって前に進む
            //cout<<"hoge";
            v=(v+1)%4;
            y+=vec[v][0], x+=vec[v][1];
            walk[y][x]=1;
        }else if(f[y+vec[v][0]][x+vec[v][1]]==1){ //（右が壁で、）正面が壁なら左に回る
            //cout<<"fuga";
            v=(v+3)%4;
        }else{ //そうでないならまえに進む
            //cout<<"zako";
            y+=vec[v][0],x+=vec[v][1];
            walk[y][x]=1;
        }
        if(y==gy&&x==gx){
            break;
        }
        // cout<<y<<","<<x<<","<<v<<endl;
        // rep(i,h+2){
        //     rep(j,w+2){
        //         if(i==y&&j==x){
        //             cout<<"^>v<"[v];
        //         }else{
        //             cout<<".#"[f[i][j]];
        //         }
        //     }
        //     cout<<endl;
        // }
    }
    if(y==gy&&x==gx){
        int ans=0;
        rep(i,h+2)rep(j,w+2)ans+=walk[i][j];
        cout<<ans<<endl;
    }else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3192
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val sticks = readLine()!!.split(" ").map { it.toInt() }.sorted()
    
    var sumCombination = 0
    for (i in 0 until sticks.size) {
        for (j in i + 1 until sticks.size) {
            for (k in sticks.size - 1 downTo j + 1) {
                val a = sticks[i]
                val b = sticks[j]
                val c = sticks[k]
                if (c < a + b) {
                    sumCombination += k - j
                    break
                }
            }
        }
    }

    println(sumCombination)
}

Measured memory_bytes: 45128
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>
#include <numeric>
#include <stdio.h>
#include<cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

struct UnionFind
{
  vector<int> par;
  UnionFind(int n) : par(n, -1) { }
  void init(int n) { par.assign(n, -1); }

  int root(int x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }

  bool issame(int x, int y) {
    return root(x) == root(y);
  } 

  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x) {
    return -par[root(x)];
  }
};

int main() {
  long long N, M; cin >> N >> M;
  vector<int> A(M), B(M);
  for( int i = 0; i < M; i++) {
    cin >> A[i] >> B[i], --A[i], --B[i];
  }
  UnionFind uf(N);
  long long cur = N * (N-1) / 2;
  vector<long long> res;
  for (int i = 0; i < M; i++) {
    res.push_back(cur);
    int a = A[M-1-i], b = B[M-1-i];
    if (uf.issame(a, b)) continue;

    long long sa = uf.size(a), sb = uf.size(b);
    cur -= sa * sb;
    uf.merge(a, b);
  }

  reverse(res.begin(), res.end());
  for(int i = 0; i < res.size(); i++) cout << res[i] << endl;


  return 0;
}


Measured memory_bytes: 3444
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
      
        if(k == 1){
          System.out.println(0);
        }else{
          System.out.println(n-k);
        }
	}
}

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

int main() {
	int n;
	cin >> n;
	int v[n],c[n],d[n];
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	for(int i=0;i<n;i++){
		cin >> c[i];
		d[i] = v[i] - c[i];
	}

	int total = 0;
	
	for(int i=0;i<n;i++){
		if(d[i]>0){
			total = total + d[i];
		}
	}
	
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DSnukeNumbers solver = new DSnukeNumbers();
        solver.solve(1, in, out);
        out.close();
    }

    static class DSnukeNumbers {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int k = in.nextInt();

            long[] answer = new long[k];
            int index = 0;
            long nines = 0;

            HashSet<Long> seen = new HashSet<>();

            outer:
            while (true) {
                long tens = nines + 1;
                for (int i = 1; ; i++) {
                    long candidate = tens * i + nines;
                    long opponent = tens * (i + 1) + nines;
                    if (isSnukier(candidate, opponent)) {
                        if (!seen.contains(candidate)) {
                            seen.add(candidate);
                            answer[index++] = candidate;
                            if (index == k) {
                                break outer;
                            }
                        }
                    } else {
                        break;
                    }
                }

                nines = nines * 10 + 9;
            }

            for (long x : answer) {
                out.println(x);
            }
        }

        static boolean isSnukier(long n, long other) {
            return (other * S(n) >= n * S(other));
        }

        static long S(long n) {
            long sum = 0;
            for (char c : Long.toString(n).toCharArray()) {
                sum += c - '0';
            }
            return sum;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 20436
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<ll,ll> pint;
 
int a[100001],b[100001],c[100001];
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[i];
    int cur=-1;
    rep(i,n){
        cin>>b[i];
        ++c[b[i]];
        if(c[b[i]]>=2) cur=1;
    }
    if(cur==-1){
        cout<<"Yes"<<endl;
        return 0;
    }
    int num;
    rep(i,n){
        if(c[a[i]]==0){
            num=i;
        }
    }
    cout<<"No"<<endl;
    rep(i,n) cout<<a[i]<<(i==n-1?"":" ");
    cout<<endl;
    rep(i,n){
        if(num!=i)cout<<a[i]<<(i==n-1?"":" ");
        else cout<<a[(i+1)%n]<<(i==n-1?"":" ");
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 4276
#include<stdio.h>
#include<stdlib.h>

int main(void){

  int N;
  int W[100];
  scanf("%d", &N);
  for(int i = 0 ; i < N ; i++){
      scanf("%d", &W[i]);
  }

  int min = 100;    //S1・S2の差の最小値
  for(int T = 0 ; T < N ; T++){
    int S1 = 0 , S2 = 0;

    for(int j = 0 ; j < T ; j++){ //T以下の足し算
      S1 += W[j];
    }
    for(int j = T ; j < N ; j++){ //Tより上の足し算
      S2 += W[j];
    }
    min = (abs(S1 - S2) < min) ? abs(S1 - S2) : min;

  }

  printf("%d", min);

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    int H1,M1,H2,M2,k,H,min=0;
    scanf("%d %d %d %d %d",&H1,&M1,&H2,&M2,&k);
    if(H2>=H1)
    {
        H=H2-H1;
        min=min+H*60;
    }
    if(M2>=M1)
    {
        min=min+(M2-M1);
    }
    if(M2<M1)
    {
        min=min-60+(M2+60-M1);
    }
    printf("%d",min-k);

}


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

int main(){
  string n;
  cin >> n;
  if(n.at(0) == n.at(1) && n.at(1) == n.at(2)){
    cout << "Yes" << endl;
  }else if(n.at(1) == n.at(2) && n.at(2) == n.at(3)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3552
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define endl '\n'
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}


signed main()
{
    // cin.tie(nullptr); ios::sync_with_stdio(false)

    int N;
    string s;
    cin >> N;
    cin >> s;

    stack<char> K;

    string header;

    for (char c : s) {
        switch(c) {
        case '(':
            K.push(c);
            break;

        case ')':
            if (K.empty()) {
                header += '(';
            } else {
                K.pop();
            }
        }
    }

    string ans = header + s;

    for (int i = 0; i < K.size(); ++i) {
        ans += ')';;
    }

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


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

#define N_MAX 100001

int desc(const void *a, const void *b){
  if(*(long *)a > *(long *)b){
    return -1;
  }else if(*(long *)a == *(long *)b){
    return 0;
  }else{
    return 1;
  }
}

int main(void){
  int i, j;

  int n, m;
  scanf("%d%d", &n, &m);

  priority_queue<long> q;

  long a;
  for(i = 0; i < n; i++){
    scanf("%ld", &a);
    q.push(a);
  }

  for(i = 0; i < m; i++){
    a = q.top();
    q.pop();
    a /= 2;
    q.push(a);
  }

  long ans=0;
  for(i = 0; i < n; i++){
    a = q.top();
    q.pop();
    ans += a;
  }

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

  return 0;
}


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

int main(){
	int mod = 1e9+7;
	int h,w;
	cin>>h>>w;
	vector<vector<int>> grid(h, vector<int>(w));
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			char c;cin>>c;
			grid[i][j] = c == '.' ? 0 : -1;
		}
	}
	grid[0][0] = 1;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(grid[i][j] != -1){
				if(i != h-1 && grid[i+1][j] != -1){
					grid[i+1][j] = (grid[i+1][j]%mod + grid[i][j] % mod) % mod;

				}

				if(j != w-1 && grid[i][j+1] != -1){

					grid[i][j+1] = (grid[i][j+1] % mod + grid[i][j] % mod) % mod;
				}
			}
				

			
		}
		
	}
	cout<<grid[h-1][w-1]%mod<<endl;
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

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

   bool ans = false;
   for(int i = 0; i < s.size(); i++){
      if(s == t){
         ans = true;
         break;
      }
      s = s.back() + s.substr(0, s.size() - 1);
   }
   if(ans){
      cout << "Yes" << endl;
   }
   else{
      cout << "No" << endl;
   }
   return 0;
}

Measured memory_bytes: 504
#include<stdio.h>
int main(void)
{
	int p,q,r;
	scanf("%d%d%d",&p,&q,&r);
	if(p>=q && p>=r)
		printf("%d",q+r);
	else if(q>=p && q>=r)
		printf("%d",p+r);
	else
		printf("%d",p+q);
	return 0;
}

Measured memory_bytes: 128
s = list(input())
t = list(input())
count_max = 0
for i in range(len(s)-len(t)+1):
    count = 0
    for j in range(len(t)):
        if s[i+j] == t[j]:
            count +=1
    count_max = max(count,count_max)
print(len(t)-count_max)

Measured memory_bytes: 9048
using System;

class Sample
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        
		int[] a = new int[3];
		
		for (int i = 0; i < 3; i++) a[i] = int.Parse(s[i]);
		
		Array.Sort(a);
		
		Console.WriteLine(a[0] + " " + a[1] + " " + a[2]);
    }
}


Measured memory_bytes: 17964
#include <stdio.h>

int main(void){
  int n,k,x,y;
  int result;

  scanf("%d%d%d%d",&n,&k,&x,&y);
  
  if(n > k){
    result = k*x+(n-k)*y;
    
  }
  else{
    result = n*x;
  }
  
  printf("%d\n",result);
  return 0;
}

Measured memory_bytes: 2148
#include<bits/stdc++.h>
#define mem(i,j) memset(i,j,sizeof(i))
#define Endl printf("\n")
#define ka printf(" ")
using namespace std;

const int N=1e5+5;
int main(){
    char t[N],s[N];
    cin>>t;
    int len=strlen(t),k=len-1;
    for(register int i=0;i<len;i++)s[k--]=t[i];
    for(register int i=0;i<len;i++){
        if(s[i]=='b')s[i]='d';
        else if(s[i]=='d')s[i]='b';
        else if(s[i]=='p')s[i]='q';
        else s[i]='p';
    }
    for(register int i=0;i<len;i++){
        if(s[i]!=t[i]){cout<<"No"<<endl;return 0;}
    }
    cout<<"Yes"<<endl;
    return 0; 
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 40;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int N, M;
vector<vector<int>> G(200000);
vector<bool> used(200000);
vector<int> d(200000);
queue<int> que;

void bfs(){
    que.push(0);
    used[0] = true;
    d[0] = 0;
    while(!que.empty()){
        int t = que.front(); que.pop();
        used[t]=true;
        for(auto v:G[t]){
            if(!used[v]){
                d[v]=d[t]+1;
                que.push(v);
            }
        }
    }
}

int main(){
    cin >> N >> M;
    used.resize(N,false);
    d.resize(N);FOR(i,0,N) d[i]=3;
    int a, b;
    FOR(i,0,M){
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    bfs();
    if(d[N-1]<=2) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 13168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;
typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef map<int, int> M;
typedef pair<int, int> P;

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

    int n;
    cin >> n;
    if (n < 1200)
    {
        cout << "ABC" << endl;
    }
    else if (n < 2800)
    {
        cout << "ARC" << endl;
    }
    else 
    {
        cout << "AGC" << endl;
    }

    return 0;
}

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

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    if(a >= k) {
        a = a - k;
    } else {
        k = k - a;
        a = 0;
        if(b >= k) {
            b = b - k;
        } else {
            b = 0;
        }
    }

    cout << a << " " << b << endl;
    return 0;
}


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

int main(){
  int H,W,K;
  cin >> H >> W >> K;
  vector<string> s(H);
  for(int i=0;i<H;i++){
    cin >> s.at(i);
  }
  int n=1;
  vector< vector<int> > ans(H,vector<int>(W));
  set<int> memo;
  for(int i=0;i<H;i++){
    int x=0;
    int count=0;
    for(int j=0;j<W;j++){
      if(s.at(i).at(j)=='.'){
        ans.at(i).at(j)=n;
      }else{
        ans.at(i).at(j)=n;
        n++;
        x=j+1;
        count++;
      }
    }
    if(count==0){
      memo.insert(i);
    }else{
      if(s.at(i).back()=='.'){
        for(int k=x;k<W;k++){
          ans.at(i).at(k)=n-1;
        }
      }
    }
  }
  for(auto p:memo){
    bool flag=false;
    for(int i=p+1;i<H;i++){
      if(!memo.count(i)){
        for(int j=0;j<W;j++){
          ans.at(p).at(j)=ans.at(i).at(j);
        }
        flag=true;
        break;
      }
    }
    if(flag){
      continue;
    }
    for(int i=p-1;i>=0;i--){
      if(!memo.count(i)){
        for(int j=0;j<W;j++){
          ans.at(p).at(j)=ans.at(i).at(j);
        }
        break;
      }
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout << ans.at(i).at(j);
      if(j==W-1){
        cout << endl;
      }else{
        cout << " ";
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1280