akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

ll a[1010], b[1010];
ll C[1010][20];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;

    REP(i,M){
        cin >> a[i] >> b[i];
        REP(j,b[i]){
            cin >> C[i][j];
            C[i][j]--;
        }
    }
    vector<ll> dp((1<<N), LINF);
    dp[0] = 0;
    REP(i,(1<<N)){
        REP(j,M){
            bool flg = false;
            REP(k,b[j]){
                if(i & (1 << C[j][k])) continue;
                else flg = true;
            }
            int tmp = i;
            REP(k, b[j]){
                tmp |= (1 << C[j][k]);
            }
            chmin(dp[tmp], dp[i] + a[j]);
        }
    }
    ll ans = dp[(1<<N)-1];
    if(ans == LINF) cout << -1 << endl;
    else cout << ans << endl;
}

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

#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back

typedef long long     ll;

//-*-*-*-*-*-*-*-*-

ll n;
ll dp[100000];
ll arr[100000];
int main()
{
    ll n;cin>>n;
   // dp[0]=0;dp[1]=abs(arr[1]-arr[0]);
   for(int i=0;i<n;i++){
    cin>>arr[i];
   }  dp[0]=0;dp[1]=abs(arr[1]-arr[0]);
   for(int i=2;i<n;i++){
   dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i]),(dp[i-2]+abs(arr[i-2]-arr[i])));
   }
cout<<dp[n-1];
 }


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll N, K;
	cin >> N >> K;
	vl A(N);
	ll Asum = 0;
	rep(i, N) {
		cin >> A[i];
		Asum += A[i];
	}
	rep(i, K) {
		Asum = 0;
		rep(j, N) {
			Asum += A[j];
		}
		if (Asum == N * N)
			break;
		vl Adiff(N + 1, 0);
		rep(j, N) {
			ll L = j - A[j];
			ll R = j + A[j] + 1;
			L = max(L, 0LL);
			R = min(R, N);
			Adiff[L]++;
			Adiff[R]--;
		}
		A[0] = Adiff[0];
		rep(j, N - 1) {
			A[j + 1] = A[j] + Adiff[j + 1];
		}
	}
	rep(i, N)
		cout << A[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 6428
#include <stdio.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <utility>
#include <map>
#include <unordered_map>
#include <string>

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)
#define all(c) begin(c),end(c)
#define vmax(c) *max_element(all(c))
#define vmin(c) *min_element(all(c))
 
template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}

template<typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::map<T1, T2>& map)
{
    for (typename std::map<T1, T2>::const_iterator it = map.begin();
         it != map.end();
         ++it)
    {
        out << (*it);
    }
    return out;
}

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const long long INF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9; 

// 2次元配列を作る
// vector<vi> my_vector(n, vi(m, 0));

// 多次元配列の dump
// for (auto v : my_vector) {
//     cout << v;
// }

ll solve() {
    ll N, M;
    cin >> N >> M;

    // cout << N << M;
    vector<vll> costs(N, vll(2, 0));

    REP(i, N) {
        cin >> costs[i][0] >> costs[i][1];
    }

    sort(all(costs), [](auto& x, auto& y){ return x[0] < y[0]; });

    ll total = 0;
    ll cnt = 0;
    REP(i, N) {
        ll c = costs[i][0];
        ll q = costs[i][1];
        ll buy;
        // cout << cnt << "," << total << ","  << c << "," << q << endl;
        if (cnt + q >= M) {
            buy = M - cnt;
            total = total + buy * c;
            return total;
        } else {
            buy = q;
            total = total + buy * c;
            cnt = cnt + q;
        }
    }
    return 0;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // solve();
    cout << solve();
}

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

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair

#define forn(i,s,n) for(i=s;i<n;i++)
#define all(c)  c.begin(),c.end()
#define boost ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(0);srand(time(NULL));
#define tc(t) ll t;cin >> t; while(t--)
/* cout << fixed << setprecision(12) << ans << endl;*/
#define pii pair<long long,long long>
#define vii vector<pii>
#define vvi vector<vector <long long> >

#define ff first
#define ss second

#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vector<int> , greater<int> >

#define deb1(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
#define deba(a,n) for(ll i=0;i<n;++i) {  cout<<a[i]<<" "; };cout<<"\n"

#define MOD 1000000007
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
/* 


    It's not love on which the strongest foundations are built. It's the decency of merciful lies.


*/
string s,t;
ll lcs(ll n,ll m)
{ 
    if(n<0 || m < 0)
    return 0;

	if(s[n]==t[m])
	return 1+lcs(n-1,m-1);
	else
	{
		return max(lcs(n-1,m) , lcs(n,m-1) );
	}
	
}
/* kgauxhyk
   zzavxuyjk 
*/
int main()
{
 boost;
 cin >> s >> t;
 ll n=s.size();
 ll m=t.size();
 
 vector<vector<ll> > dp(n+1, vector<ll>(m+1,0) );
    // cout << "   " ;
/*	for(ll j=1;j<=m;j++)
 	{    cout << t[j-1] << "| "; }
    // cout << "\n";*/
 
 
 for(ll i=1;i<=n;i++)
 {   //cout << s[i-1] << " |";
 	for(ll j=1;j<=m;j++)
 	{    //cout << t[j-1] << " | ";
 	
 		if(s[i-1]==t[j-1])
 		dp[i][j]=1 + dp[i-1][j-1];
 		else
 		dp[i][j]=max( dp[i][j-1] , dp[i-1][j] );
 		
 		//cout << dp[i][j] << "  ";
	 }
	 //cout << endl;
 }
 
 
// cout <<" length of lcs "<< dp[n][m] << endl;
string ans="";
ll a=n,b=m;
 while(a >0 && b>0)
 {
 	 if(s[a-1]==t[b-1])
     { ans+=s[a-1];
       a--;
       b--;
	 }
	 else
	 {
	 	ll it1=dp[a][b-1];
	 	ll it2=dp[a-1][b];
	 	if(it1>=it2)
	 	{
	 		b--;
		}
		else
		a--;
		
     }
	  	
 }
 
 reverse(all(ans));
 cout << ans << endl;


}






Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
struct Solution {
    int n, k;
    int dfs(int r, int o, int s) {
        if (r == n) return s;
        if (o == 0) {
            s = 2 * s;
        }
        else {
            s = s + k;
        }
        return min(dfs(r + 1, 0, s), dfs(r + 1, 1, s));
    }
    void solve(std::istream& in, std::ostream& out) {
        in >> n >> k;
        out << min(dfs(0, 0, 1), dfs(0, 1, 1)) << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
        self.diff_weight = [0 for i in range(n+1)]

    def root(self, x):
        if self.par[x] == x:
            return x
        r = self.root(self.par[x])
        self.diff_weight[x] += self.diff_weight[self.par[x]]
        self.par[x] = r
        return r

    def weight(self, x):
        self.root(x)
        return self.diff_weight[x]

    def issame(self, x, y):
        return self.root(x) == self.root(y)

    def merge(self, x, y, w):
        w += self.weight(x)
        w -= self.weight(y)
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.rank[x] < self.rank[y]:
            x, y = y, x
            w = -w
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        self.par[y] = x
        self.diff_weight[y] = w
        return True

    def diff(self, x, y):
        return self.weight(y) - self.weight(x)

def solve():
    N,M=map(int,input().split())
    uf = UnionFind(N)
    for i in range(M):
        l,r,d=map(int,input().split())
        if uf.issame(l,r):
            if uf.diff(l,r) != d:
                return 'No'
        else:
            uf.merge(l,r,d)
    return 'Yes'

print(solve())


Measured memory_bytes: 125260
# -*- coding: utf-8 -*-

from itertools import permutations

N, M, R = map(int, input().split())
r = list(map(int, input().split()))
G = [[float('inf')] * (N) for _ in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    # 経路情報は隣接行列に保持する(無向グラフなので両方向)
    G[a-1][b-1] = c
    G[b-1][a-1] = c

# ワーシャルフロイドで全頂点の最短距離
for k in range(N):
    for i in range(N):
        for j in range(N):
            # 始点 = 終点、は例外的に距離0にしておく
            if i == j:
                G[i][j] = 0
            else:
                G[i][j] = min(G[i][j], G[i][k] + G[k][j])

ans = float('inf')
# 町の順番は順列全部試す(最大8なら大丈夫)
for p in permutations(r):
    sm = 0
    # 最短経路を足し合わせていく
    for i in range(1, len(p)):
        sm += G[p[i-1]-1][p[i]-1]
    ans = min(sm, ans)
print(ans)


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

vector<int> b;
int n;
bool can(int m) {
	int one = 0, zero = 0;
	if(n-m >= m) {
		return 1;
	}
	for(int i = n-m; i < m; ++i) {
		if(b[i] == 1) one = 1;
		else zero = 1;
	}
	return zero^one;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	n = s.size();
	b.resize((int)s.size());
	for(int i = 0; i < int(s.size()); ++i) {
		b[i] = (s[i] == '1');
	}

	int l = 1, r = s.size() + 1;
	while(l + 1 < r) {
		int m = (l + r)/2;
		if(can(m)) l = m;
		else r = m;
	}
	cout << l << endl;
}


Measured memory_bytes: 848
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;


#define MAX_N 200000

int par[MAX_N];
int rnk[MAX_N];

// 初期化
void init(int n){
	for(int i = 0; i < n; i++){
		par[i] = i;
		rnk[i] = 0;
	}
}

// x の親を返す
int find(int x){
	if(par[x] == x){
		return x;
	}
	return par[x] = find(par[x]);
}

// x と y を併合する
void unite(int x, int y){
	int x_par = find(x);
	int y_par = find(y);
	if(x_par == y_par){
		return;
	}
	
	if(rnk[x_par] < rnk[y_par]){
		par[x_par] = y_par;
	}else{
		par[y_par] = x_par;
		if(rnk[x_par] == rnk[y_par]){
			rnk[x_par]++;
		}
	}
}

// x, y が同じグループか判定
bool same(int x, int y){
	return (find(x) == find(y));
}

struct edge{
	int u, v;
	long long int cost;
};

bool comp(const edge& e1, const edge& e2){
	return e1.cost < e2.cost;
}

vector<edge> es;
bool used[60000] = {};
int V, E;

long long int kruskal(int id){
	init(V);
	int res = 0;
	int cnt = 0;
	for(int i = 0; i < E; i++){
		edge e = es[i];
		if(i == id){
			continue;
		}
		if(!same(e.u, e.v)){
			cnt++;
			unite(e.u, e.v);
			used[i] = true;
			res += e.cost;
		}
	}
	if(cnt < V - 1){
		return INF;
	}
	return res;
}

int main(){
	
	cin >> V >> E;
	
	for(int i = 0; i < E; i++){
		edge e;
		cin >> e.u >> e.v >> e.cost;
		e.u--;
		e.v--;
		es.push_back(e);
	}
	
	sort(es.begin(), es.end(), comp);
	
	long long int cost = kruskal(-1);
	vector<int> v;
	
	for(int i = 0; i < E; i++){
		if(used[i]){
			if(cost != kruskal(i)){
				v.push_back(i);
			}
		}
	}
	
	long long int S = 0;
	
	for(int i = 0; i < v.size(); i++){
		S += es[v[i]].cost;
	}
	
	cout << v.size() << " " << S << endl;
	
	return 0;
}



Measured memory_bytes: 3888
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int h, n;
  cin >> h >> n;
  vector<int> a(n), b(n);
  rep (i, n) cin >> a[i] >> b[i];
  int lim = 21000;
  vector<lint> dp(lim, INT_MAX);
  dp[0] = 0;
  rep (i, h) {
    rep (j, n) {
      dp[i + a[j]] = min(dp[i + a[j]], dp[i] + b[j]);
    }
  }
  cout << *min_element(dp.begin() + h, dp.end()) << endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.rmi.server.UnicastRemoteObject;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n = sc.nextInt();
  
        out.println(3*n*n);
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

class P {
	int x, y;
	P(int  x, int y) {
	  this.x=x;
	  this.y=y;
	}
}


//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//        return b-p.b;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

int main() {
	int a, b, c, d;
	char s[5]; 
	for (int i = 0; i < 4; i++)cin >> s[i];
	a = s[0] - '0'; b = s[1] - '0'; c = s[2] - '0'; d = s[3] - '0';
	
	if (a + b + c + d == 7)printf("%d+%d+%d+%d=7",a,b,c,d);
	else if (a - b - c - d == 7)printf("%d-%d-%d-%d=7", a, b, c, d);
	else if (a + b + c - d == 7)printf("%d+%d+%d-%d=7", a, b, c, d);
	else if (a - b + c + d == 7)printf("%d-%d+%d+%d=7", a, b, c, d);
	else if (a + b - c + d == 7)printf("%d+%d-%d+%d=7", a, b, c, d);
	else if (a + b - c - d == 7) printf("%d+%d-%d-%d=7", a, b, c, d);
	else if (a - b + c - d == 7)printf("%d-%d+%d-%d=7", a, b, c, d);
	else if (a - b - c + d == 7)printf("%d-%d-%d+%d=7", a, b, c, d);

	return 0;
}

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

int main()
{
 int a,b,c,d,e;
 
 cin >> a >> b >> c >> d >> e;
 
 if(a==0)
 {
     cout << 1;
 }
 else if (b==0)
 {
     cout << 2;
 }
 else if (c==0)
 {
     cout << 3;
 }
 else if (d==0)
 {
     cout << 4;
 }
 else if (e==0)
 {
     cout << 5;
 }

  
  return 0;
}
  

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

int main(void){
  int n, ans = INT_MAX, s1, s2;
  cin >> n;
  vector<int> weights(n);
  for(int i = 0; i < n; i++) cin >> weights[i];

  for(int i = 0; i < n-1; i++){
    s1 = 0;
    s2 = 0;
    for(int j = 0; j <= i; j++) s1 += weights[j];
    for(int j = i+1; j < n; j++) s2 += weights[j];
    if(ans > abs(s1-s2)) ans = abs(s1-s2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
using namespace std;
int main()
{
    int n,i,an=0,j,s=0;
    cin>>n;
    int m[n];
    for(i=0;i<n;i++)
    {
        cin>>m[i];
    }
    int ma=m[0];
    int mi=m[0];
    for(i=1;i<n;i++)
    {
        ma=max(ma,m[i]);
        mi=min(mi,m[i]);
    }
    int p=(ma+mi)/2;
    an=INT_MAX;
    for(j=mi;j<=ma;j++)
    {
        s=0;
        for(i=0;i<n;i++)
        {
           s=s+(j-m[i])*(j-m[i]);

        }
        an=min(an,s);
    }
    cout<<an<<endl;
    return 0;
}


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

int main() {
    int N, s, p, q;
    scanf("%d", &N);
    p = 0;
    q = 100;    
    for (int i = 0; i < N; i++) {
        scanf("%d", &s);
        p += s;
        if (s % 10 != 0) q = min(q, s);
    }

    if (p % 10 == 0) p -= q;
    if (p % 10 == 0) printf("0\n");
    else printf("%d\n", p);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	int N,M;
	cin>>N>>M;
	vector<int> A(N);

	for(int i=0; i<N; i++)
	{
		cin>>A[i];
	}

	vector<pair<int,int> > CB(M);

	for(int i=0; i<M; i++)
	{
		int b,c;
		cin>>b>>c;
		CB[i] = make_pair(-c,b);
	}

	vector<int> g;
	sort(CB.begin(),CB.end());

	int count = 0;
	int pos = 0;
	int CB_size = CB.size();
	while(count<N && pos<CB_size)
	{
		int b = CB[pos].second;
		int c = -CB[pos].first;
		for(int i=0; i<b; i++)
		{
			g.push_back(c);
		}
		count+=b;
		pos++;
	}

	copy(g.begin(),g.end(),back_inserter(A));

	sort(A.begin(),A.end(),greater<int>());

	long long result = 0;
	//accumulateは使えない
	for(int i=0; i<N; i++)
	{
		result += A[i];
	}
	cout<<result<<endl;
	return 0;
}

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

const int N = 1005;
long long a[N], b[N], c[N];
long long t[N * N], t2[3 * N * N];

int main() {
  int x, y, z, k;
  scanf("%d %d %d %d", &x, &y, &z, &k);
  for (int i = 0; i < x; i++) {
    scanf("%lld", a + i);
  }
  for (int i = 0; i < y; i++) {
    scanf("%lld", b + i);
  }
  for (int i = 0; i < z; i++) {
    scanf("%lld", c + i);
  }
  int ttmp = 0;
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      t[ttmp] = a[i] + b[j];
      ttmp++;
    }
  }
  sort(t, t + x * y);
  reverse(t, t + x * y);
  int ttmp2 = 0;
  for (int i = 0; i < min(x * y, k); i++) {
    for (int j = 0; j < z; j++) {
      t2[ttmp2] = t[i] + c[j];
      ttmp2++;
    }
  }
  sort(t2, t2 + min(x * y, k) * z);
  reverse(t2, t2 + min(x * y, k) * z);
  for (int i = 0; i < k; i++) {
    printf("%lld\n", t2[i]);
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  vector<int> L(N);
  rep(i, N) cin >> X[i] >> L[i];
  
  vector<pair<int, int>> A(N);
  rep(i, N) A[i] = make_pair(X[i] + L[i], X[i] - L[i]);
  sort(A.begin(), A.end());
  vector<int> S;
  rep(i, N) {
    if (i == 0) {
      S.push_back(i);
      continue;
    }
    if (A[S[S.size() - 1]].first <= A[i].second) {
      S.push_back(i);
    }
  }
  
  cout << S.size() << endl;
  return 0;
}

Measured memory_bytes: 2428
#include <iostream>
#include <bitset>
using namespace std;
int n, a, s, i;
bitset<1<<22> bs;
int main() {
	bs[0] = 1;
	cin>>n;
	while(n--) {
		cin>>a;
		bs |= bs<<a;
		s += a;
	}
	for(i=(s+1)/2; !bs[i]; i++);
	cout<<i;
	return 0;
}

Measured memory_bytes: 1792
w, h, x, y = [int(i) for i in input().split()]

o1 = (w * h) / 2

l = [(x, h / w * x), (x, - h / w * x + h)]
l2 = [(0, 0), (w, 0), (0, h), (w, h)]
if (x, y) in l2:
  o2 = 0
elif (x, y) in l:
  o2 = 1
else:
  o2 = 0
  
print(o1, o2)
  

Measured memory_bytes: 3064
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 T = sc.nextInt();

		sc.close();

		int p = T/A;
		System.out.println(p*B);
	}
}


Measured memory_bytes: 23764
def calcs(a, op, c)
	if (op == '+')
		return a + c
	elsif (op == '-')
		return a - c
	elsif (op == '*')
		return a * c
	elsif (op == '/')
		return a / c
	end
end

input_arr = []
while input = gets.chomp
	a, op, c = input.split(' ')
	break if (op == '?')
	a_i = a.to_i
	c_i = c.to_i
	input_arr << [a_i, op, c_i]
end



input_arr.each{|i|
	a = []
	i.each{|j|
		a << j
	}
	puts calcs(a[0], a[1], a[2])
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;



int N, K;
bool g[110][110];

int main(){
    
    int cnt = 0;
    cin >> N >> K;
    for(int i = 1; i < N; i++){
        g[0][i] = true;
        cnt++;
    }
    
    int sum = N * (N - 1) / 2 - (N - 1);
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            if(sum > K && !g[i][j]){
                sum--;
                g[i][j] = true;
                cnt++;
            }
        }
    }
    if(sum == K){
        cout<< cnt << endl;
        for(int i = 0; i < N; i++){
            for(int j = i + 1; j < N; j++){
                if(g[i][j]){
                    cout << i + 1 << " " << j + 1 << endl;
                }
            }
        }
    }
    else{
        cout << -1 << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int h, w, sx, sy, gx, gy; cin >> h>>w>>sx>>sy>>gx>>gy;
    sx--; sy--; gx--; gy--;
    char s[h][w];
    rep(i,h) rep(j,w) cin >> s[i][j];

    int d[h][w];
    rep(i,h) rep(j,w) d[i][j] = INF;
    d[sx][sy] = 0;

    deque<PII> q;
    q.emplace_back(PII(sx, sy));

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

    while (!q.empty()) {
        int x = q.front().first;
        int y = q.front().second;
        q.pop_front();

        rep(i,4) {
            int nx = x + dx[i]; int ny = y + dy[i];
            if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
            if (s[nx][ny] == '#') continue;
            if (d[nx][ny] <= d[x][y]) continue;
            d[nx][ny] = d[x][y];
            q.emplace_front(PII(nx, ny));
        }

        for (int wi = -2; wi <= 2; wi++) {
            for (int wj = -2; wj <= 2; wj++) {
                int nx = x + wi; int ny = y + wj;
                if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                if (s[nx][ny] == '#') continue;
                if (d[nx][ny] <= d[x][y]  +1) continue;
                d[nx][ny] = d[x][y] + 1;
                q.emplace_back(PII(nx, ny));
            }
        }
    }

    int ans = d[gx][gy];
    if (ans == INF)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}



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

int main(void) {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  C *= 2;

  int AB_ONLY = X * A + Y * B;
  int MIX = 0;
  int MIX_ALL = 0;
  if (X < Y) {
    MIX = X * C + (Y - X) * B;
    MIX_ALL = Y * C;
  } else {
    MIX = Y * C + (X - Y) * A;
    MIX_ALL = X * C;
  }
  cout << min(AB_ONLY, min(MIX, MIX_ALL)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
   int a,b,c,m; cin>>a>>b>>c;m=a;
   int p=100000;
   while(a<p){
    if(a%b==c){cout<<"YES";return 0;}
    else a=a+m;
   }
   cout<<"NO";
}


Measured memory_bytes: 3576
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

int main(){
	int A,B,C,D;
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&D);
	int a = min(A,B);
	int b = min(C,D);
	
	
	printf("%d\n",a+b); 
	return 0;
}



Measured memory_bytes: 764
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""


n = onem()

a = l()
ans = sum(a)

po = [0 for i in range(10**5+1)]

for i in range(n):
	po[a[i]] += 1

q = onem()

for i in range(q):
	b,c = m()

	ans += (c-b)*po[b]
	po[c] += po[b]
	po[b] = 0
	print(ans)



Measured memory_bytes: 92360
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int n;
  cin >> n;
  vi a(n);
  cin >> a;
  int nx = 1;
  int ans = n;
  rep(i, 0, n) {
    if (a[i] == nx) {
      nx++;
      ans--;
    }
  }
  if (nx == 1) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return (0 ^ _ ^ 0);
}



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

int main() {
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  int ans=0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(i*500+j*100+k*50 ==x) ans++;
      }
    }
  }
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){

  char a[100],b[100],c[200];

  scanf("%s",a);
  scanf("%s",b);

  strcpy(c,a);
  strcat(c,a);

  if(strstr(c,b))
    printf("Yes\n");
  else
    printf("No\n");


  return 0;
}

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

int main(void){
    vector<int> a(3);
    rep(i, 3){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    
    int ans;
    ans = a.at(0)+a.at(1)+a.at(2)*10;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef unsigned long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

ll comb(ll n,ll k){
   ll ans=1;
   ll a=1000000007; 
   k = min(k,n-k);
   if(k==0)return 1;
   else{
   fro(i,1,k+1){
     ans*=(n-i+1);
     ans/=i;
   }
   ans%=a;
   return ans;
   }
}

int main() {
    ll n,k;
	cin >> n>>k;
    ll a = 1000000007;
    ll ans=0;
    ll now;
    ll size = max(n-k+2,k+1);
    ll v[size][size];
    fr(i,size){
      fr(j,size){
        v[i][j]=0;
     }
    }
    for (int i = 0; i < size; i++) {
     v[i][0] = 1;
     v[i][i] = 1;
    }
    for (int j = 2; j < size; j++) {
     for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k])%a;
     }
    }
    fro(i,1,k+1){
      ans=0;
      ans=v[n-k+1][i]*v[k-1][i-1]%a;
          cout<<ans<<endl;
    }

}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int j = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'A') {
            j++;
        }
    }
    if (j == 0 || j == 3) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
x_list = list(map(int, input().split()))

min_count = 1e10
for i in range(101):
    count = 0
    for x in x_list:
        count += (x - i) * (x - i)
    if count < min_count:
        min_count = count

print(min_count)

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define maxn 300005
#define INF 2000000000
#define alpha 26

int a[maxn] , used[maxn] ;

int main()
{
    int n , x ;

    scanf("%d %d",&n,&x) ;

    if(x==1 || x==2*n-1)
    {
        printf("No\n") ;
        return 0 ;
    }

    printf("Yes\n") ;

    if(n==2)
    {
        printf("1\n2\n3\n") ;
        return 0 ;
    }

    if(x==2)
    {
        a[n] = x ;
        a[n-1] = 1 ;
        a[n-2] = 4 ;
        a[n+1] = 3 ;
    }
    else{
        a[n] = x ;
        a[n-1] = x+1 ;
        a[n-2] = x-1 ;
        a[n+1] = x-2 ;
    }

    for(int i=n-2 ; i<=n+1 ; i++) used[ a[i] ]++ ;

    int j = 1 ;

    for(int i=1 ; i<=2*n-1 ; i++)
    {
        if( a[i]!=0 ) continue ;
        while( used[j] ) j++ ;
        a[i] = j ;
        j++ ;
    }

    for(int i=1 ; i<=2*n-1 ; i++)
    {
        printf("%d\n",a[i]) ;
    }

    return 0 ;
}


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

using namespace std;

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

    int n;
    cin >> n;
    
    int copy_n = n;
    vector<int> res;
    for (int p = 2; p * p <= copy_n; ++p) {
        if (copy_n % p != 0) continue;
        
        while (copy_n % p == 0) {
            copy_n /= p;
            res.push_back(p);
        }
    }
    if (copy_n != 1) res.push_back(copy_n);

    sort(res.begin(), res.end());
    printf("%d:", n);
    for (auto e: res) {
        printf(" %d", e);
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 3300
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;

template<typename T> void print(T t) { cout << t << endl; }

int main() {
	ll N, M, ans=0;
	cin >> N >> M;
	if (N < M) swap(N, M);
	
	if (N == 1 && M == 1) {
		print(1);
	}
	else if (M == 1) {
		print(N -2);
	}
	else {
		print((N - 2ll) * (M - 2ll));
	}
	
}

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

using namespace std;
using ll = long long int;

const int MOD_NUM = 1e9 + 7;

// 二分累乗法
ll pow_mod(ll n, ll p, ll m) {
    const int N = 64;

    vector<ll> memory(N);
    memory[0] = n % m;
    rep(i, N) memory[i + 1] = memory[i] * memory[i] % m;

    ll ans = 1;
    rep(i, N) {
        ll k = p >> i;
        if (k == 0)
            break;
        else if (k & 1)
            ans = (ans * memory[i]) % m;
    }

    return ans;
}

ll comb(ll n, ll a, ll m) {
    ll X = 1;
    ll Y = 1;
    for (int i = 1; i <= a; i++) {
        X = X * (n + 1 - i) % m;
        Y = Y * i % m;
    }

    ll inv_Y = pow_mod(Y, m - 2, m);
    return X * inv_Y % m;
}

int main() {
    // Input
    int n, a, b;
    cin >> n >> a >> b;

    // Process
    ll all = pow_mod(2, n, MOD_NUM) - 1;

    ll comb_a = comb(n, a, MOD_NUM);
    ll comb_b = comb(n, b, MOD_NUM);
    ll ans = (all + MOD_NUM * 2 - comb_a - comb_b) % MOD_NUM;

    // Output
    cout << ans << endl;

    return 0;
}


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

int main(){
  int X;
  cin >> X;

  if(X == 3 || X == 5 || X == 7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   string s;
   cin >> s;
   int c = 0;
   for(auto &e : s){
      c |= (e == '7');
   }
   if(c){
      cout << "Yes\n";
   }else{
      cout << "No\n";
   }
   return 0;
} 


Measured memory_bytes: 3656
import           Control.Monad

main = do
    n <- readLn :: IO Int
    a <- replicateM n $ map read . words <$> getLine :: IO [[Int]]
    putStrLn $ if f ([0,0,0]:a) then "Yes" else "No"
  where
    f (_:[])  = True
    f (ai:aj:ax) =
        let [ti,xi,yi] = ai
            [tj,xj,yj] = aj
            dt = tj - ti
            dist = abs (xj - xi) + abs (yj - yi)
          in if dist > dt || odd dist /= odd dt
                then False else f (aj:ax)

Measured memory_bytes: 81276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int INF = 1e9 + 5;

int main()
{
    int n, i;
    scanf("%d",&n);
    vi in(n);
    for(int &a : in) scanf("%d",&a);
    vi dp(n + 3, INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++)
    {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(in[i + 1] - in[i]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(in[i + 2] - in[i]));
    }
    cout << dp[n - 1];
    
}


Measured memory_bytes: 1024
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	cin >> N >> K;
	long double ans = 0;
	for (int i = 1; i <= N; i++) {
		int cnt = 0;
		int box = i;
		while (box < K) {
			box <<= 1;
			cnt++;
		}
		long double add = 1;
		for (int j = 0; j < cnt; j++)add /= 2;
		ans += add;
	}
	ans /= N;
	cout << setprecision(20) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
s1=input()
s2=input()

for i in range(len(s1)):
    s1=list(s1)
    a = s1.pop(-1)
    s1 = ''.join(s1)
    s1 = a+s1
    #print(s1)
    if s1 == s2:
        print('Yes')
        exit()
print('No')

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


int main()
{
    int n=0;
    scanf("%d\n",&n );
    int a=n/100;
    if (a==0) a++;
    if (n<=100*a+10*a+a) printf("%d\n",100*a+10*a+a );
    else printf("%d\n", 100*a+10*a+a+111);

}


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

int main(){
    int N,M,L;
    cin >>N;
    if(N%2==0){
        M=N+1;
        L=N*(N-2)/2;
    }else{
        M=N;
        L=(N-1)*(N-1)/2;
    }
    cout <<L<<endl;
    for(int i=1;i<N;i++){
        for(int j=i+1;j<=N;j++){
            if(j!=M-i)cout <<i<<" "<<j<<endl;
        }
    }
}

Measured memory_bytes: 256
import sys
H,W = map(int, input().strip().split(' '))
lines = [line.strip() for line in sys.stdin if '#' in line]
lines = [''.join(l) for l in zip(*lines)]  # transpose
lines = [line for line in lines if '#' in line]
lines = [''.join(l) for l in zip(*lines)]
for line in lines:
  print(line)

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n){
      cin >> p[i];
  }
  sort(p.begin(), p.end());
  int ans = 0;
  rep(i, k){
      ans += p[i];
  }
  cout << ans;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
long long Sum = 0;
int N;
int *S;

//番号と合計と引数にした再帰関数
long long Shori(int pos, long long ParSum, long long cur){

  //終了：足す処理をする
  if(pos == N - 1){
    
    ParSum     += cur + S[pos];
    return Sum += ParSum;
  }
  
  //後ろに＋を入れる：Sumして、持ち越しを0にする
  Shori(pos + 1, ParSum + cur + S[pos], 0);
  //後ろに＋を入れない：Sumせずに配列の値を10倍にして持ち越し
  Shori(pos + 1, ParSum, (cur + S[pos]) * 10);
}

int main(){
  
  string _S;
  cin >> _S;
  N = _S.size();
  S = new int(N);
  
  for(int i = 0; i < N; i++) S[i] = _S[i] - '0';
  
  
  Shori(0, 0, 0);
  cout << Sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
#include <iomanip>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;

  int ans = 0;
  char c = s[0];
  FOR(i, 1, s.length()) {
    if(s[i] != c) {
      ans++;
      c = s[i];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define INF 10000000000000000LL
#define ll  long long 
const int inf =INT_MAX;
const int MAX=3e5+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=1e6+9;
const int MAX_A=71;
const int LN=20;
using namespace std;

int main(){
    ll N;
    cin >> N;
    ll temp = N;
    ll ans = 0;
    while(temp){
        ans += temp % 10;
        temp /= 10;
    }
    if(N % ans == 0)
        cout << "Yes" << "\n";
    else
        cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
long N;
void solve()
{
    map<long,long> a,b,vis;
    long i,M;
    for (i=1;i<=N;i++)
    {
        cin>>a[i];
        vis[a[i]]++;
    }
    cin>>M;
    for (i=1;i<=M;i++)
    {
        cin>>b[i];
        vis[b[i]]--;
    }
    if (M>N) puts("NO");
    else
    {
        int tag=0;
        for (i=1;i<=N;i++)
            if (vis[b[i]]<0) {tag=1;puts("NO");break;}
        if (!tag) puts("YES");
    }
}
int main()
{
    while(cin>>N)
        solve();
}

Measured memory_bytes: 37760
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;
ll N, K;
vector<ll> A;

vector<ll> ret;
vector<ll> f(vector<ll> v) {
    ret.clear();
    ret.resize(N);
    for(int i = 0; i < N; i++) {
        int l = i - v[i];
        chmax(l, 0);
        if(l < N) ret[l]++;
        int r = i + v[i] + 1;
        if(0 <= r and r < N) ret[r]--;
    }
    for(int i = 1; i < N; i++) ret[i] += ret[i-1];
    return ret;
}
vector<ll> w;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    A.resize(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    while(K--) {
        w = f(A);
        if(w == A) break;
        A = w;
    }
    for(auto val : A) cout << val << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 10924
#include <cstdio>
#include <algorithm>
#include <cmath>
#define Rint register int
#define LL long long
#define F(x,y,z) for(Rint x=y;x<=z;++x)
#define D(x,y,z) for(Rint x=y;x>=z;--x)
using namespace std;
LL Min(LL x,LL y){return x<y?x:y;}
LL Max(LL x,LL y){return x>y?x:y;}
inline LL R(){
    char c='!';LL x=0,z=1;
    for( ; c>'9'||c<'0';c=getchar()) if(c=='-')z=-1;
    for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';
    return x*z;
}
int n,m;
int a[100010];

int main(){
	n=R();m=R();
	F(i,1,n) a[i]=R();
	sort(a+1,a+1+n);
	int ans=0;
	F(i,1,n-1)
		if (m>=a[i]){
			++ans;
			m-=a[i];
		}
	if (m==a[n])++ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
typedef pair<double,double> Pd;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,(n))
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) rrepi(i,(n),0)
#define rrepi(i,a,b) for(ll i=(a);i>=(b);i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const double Pi = acos(-1);
const ll INF=1e18;
const int iINF = 1e9;

int main(){
  int n;
  cin>>n;
  if(n%2 == 0)cout<<(n-1)/2<<endl;
  else cout<<n/2<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int length = 0;
    cin >> length;
    int* data = new int[length];

    for (int i = 0; i < length; ++i) {
        cin >> data[i];
    }   

    int swap_times = 0;
    for (int i = 0; i < length - 1; ++i) {
        for (int j = 0; j < length - 1; ++j) {
            if (data[j] > data[j + 1]) {
                swap(data[j], data[j + 1]);
                ++swap_times;
            }   
        }   
    }   
    for (int i = 0; i < length; ++i) {
        if (i < length - 1) {
            cout << data[i] << " ";
        } else {
            cout << data[i] << endl;
        }   
    }   
    cout << swap_times << endl;
}

Measured memory_bytes: 3100
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[121212], b[121212], c[121212], bn;
int main() {
	int n, i, j; scanf("%d", &n);
	for (i = 0; i < n; i++)scanf("%d", &a[i]);
	for (i = 0; i < n; i += 2)b[bn++] = a[i];
	sort(a, a + n); sort(b, b + bn);
	int ans = bn, p1 = 0, p2 = 0;
	while (p1 < n&&p2 < bn) {
		if (a[p1] == b[p2]) ans--, p1 += 2, p2++;
		else if (a[p1] < b[p2])p1+=2;
		else p2++;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 768