akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    private static final long MOD = 1_000_000_007;

    private static int nextUnitAmida(int x) {
        int mask1 = 1;
        int mask2 = 3;
        ++x;
        for (;;) {
            int ck = x & mask2;
            if (ck == mask1) {
                break;
            } else if (ck == mask2) {
                x += mask1;
            } else {
                ;
            }
            mask1 <<= 1;
            mask2 <<= 1;
        }
        return x;
    }

    private static int[] createUnitAmida(int w) {
        List<Integer> uAmidas = new ArrayList<>();
        int x = 0;
        int limit = (1 << (w - 1));
        do {
            uAmidas.add(x);
            x = nextUnitAmida(x);
        } while (x < limit);

        int[] result = new int[uAmidas.size()];
        for (int i = 0; i < result.length; ++i) {
            result[i] = uAmidas.get(i);
        }
        return result;
    }

    private final int height;

    private final int width;

    private final int[] unitAmidas;

    private Main(int h, int w) {
        height = h;
        width = w;
        unitAmidas = createUnitAmida(w);
    }

    long countIt(int goal) {
        return countSub(height, 1, goal);
    }

    private long countSub(int h, int start, int goal) {
        if (Math.abs(start - goal) > h) {
            return 0;
        }
        if (h > 1) {
            final int h1 = h / 2;
            final int h2 = h - h1;
            long result = 0;
            for (int k = 0; k < width; ++k) {
                long r1 = countSub(h1, start, k + 1);
                long r2 = countSub(h2, k + 1, goal);
                result += r1 * r2;
            }
            return result % MOD;
        }

        assert h == 0;

        final int rMask = (1 << (start - 1));
        final int lMask = (rMask >> 1);

        int rCase = 0;
        int lCase = 0;
        int mCase = 0;

        for (int unitAmida : unitAmidas) {
            if ((unitAmida & rMask) != 0) {
                ++rCase;
            } else if ((unitAmida & lMask) != 0) {
                ++lCase;
            } else {
                ++mCase;
            }
        }

        long result = 0;
        if (start == goal) {
            result = mCase;
        } else if (start == goal - 1) {
            result = rCase;
        } else {
            result = lCase;
        }
        return result;
    }

    public static void main(String[] args) {
        try (
                Scanner in = new Scanner(System.in);
                PrintWriter out = new PrintWriter(System.out))
        {
            final int H = in.nextInt();
            final int W = in.nextInt();
            final int K = in.nextInt();

            long result = new Main(H, W).countIt(K);
            out.println(result);
        }
    }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool a[1000005],b[1000005]; 

int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
    string s;
    cin>>s;
    if(s[3]==s[2] and s[4]==s[5]){
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    }

Measured memory_bytes: 256
class Array
  def sum; inject(:+) end # v2.5
end
def min(a,b); a < b ? a : b end

h,w,k = gets.split.map(&:to_i)
a = h.times.map{ gets.chomp.chars.map(&:to_i) }

ans = (h-1) * (w-1)
[0, 1].repeated_permutation(h-1) do |bit|
  div  = [0] * h
  t    = 0
  able = true
  (0...h-1).each do |i|
    t += 1 if bit[i] == 1
    div[i+1] = t
  end
  ww = [0] * (t+1)
  cut = bit.sum
  w.times do |j|
    check = true
    h.times do |i|
      ww[div[i]] += 1 if a[i][j] == 1
      if ww[div[i]] > k
        check = false
        break
      end
    end
    if not check
      (t+1).times{|k| ww[k] = 0 }
      cut += 1
      h.times do |i|
        ww[div[i]] += 1 if a[i][j] == 1
        if ww[div[i]] > k
          able = false
          break
        end
      end
    end
    
    break if not able
  end
  ans = min(ans, cut) if able
end

p ans

Measured memory_bytes: 2172
import java.util.*;
import java.util.Map.Entry;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        Integer N = scan.nextInt();
        long count = 0;
        HashMap<String, Long> map = new HashMap<String, Long>(); 
        for(int i = 0; i < N; i++) {
            String s = scan.next();
            char[] sArray = s.toCharArray();
            Arrays.sort(sArray);
            String sorted = new String(sArray);
            if(map.containsKey(sorted))
                map.put(sorted, map.get(sorted) + 1);
            else
                map.put(sorted, (long)1);
        }
        for(Entry<String, Long> entry : map.entrySet()) {
            long value = entry.getValue();
            count += value * (value - 1) / 2;
        }
        System.out.println(count);
        
    }
}


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

using namespace std;

int n, x, ans;

string s;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();

    cin >> n;

    cin >> s;

    x = 0, ans = x;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'I') {
            x++;
        }

        if (s[i] == 'D') {
            x--;
        }

        ans = max(ans, x);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF (1<<29)
#define MAX_V 100010
#define MAX_LOG_V 110
typedef long long ll;
 
vector<int> G[MAX_V];
int root;
int deg[MAX_V];
 
int parent[MAX_LOG_V][MAX_V];  
int depth[MAX_V];
 
void dfs(int v, int p, int d)
{
    parent[0][v] = p;
    depth[v] = d;
    for (int i = 0; i < (int)G[v].size(); i++) { 
    if(G[v][i] != p) {
        dfs(G[v][i], v, d+1);
    }
    }
}
 
void init(int V)
{
    root = 0;
    dfs(root, -1, 0);
    for (int k = 0; k + 1 < MAX_LOG_V; k++) {
    for (int v = 0; v < V; v++) {
        if (parent[k][v] < 0) {
        parent[k+1][v] = -1;
        } else {
        parent[k+1][v] = parent[k][parent[k][v]];
        }
    }
    }
}
 
int lca(int u, int v)
{
    if(depth[u] > depth[v]){
    swap(u, v);
    }
    for (int k = 0; k < MAX_LOG_V; k++) {
    if ((depth[v] - depth[u]) >> k & 1) {
        v = parent[k][v];
    }
    }
    if (u == v) {
        return u;
    }
    for (int k = MAX_LOG_V-1; k >= 0; k--) {
    if (parent[k][u] != parent[k][v]) {
        u = parent[k][u];
        v = parent[k][v];
    }
    }
    return parent[0][u];
}
 
int main()
{
    int n, p;
    cin >> n;
    for (int i = 0; i < n-1; i++) {
        cin >> p; --p;
        G[p].push_back(i+1);
    }
     
    queue<int> Q; Q.push(0);
    vector<ll> d(MAX_V, INF); d[0] = 0;
    vector<int> path; path.push_back(0);
    while (!Q.empty()) {
        int v = Q.front(); Q.pop();
        for (int i = 0; i < (int)G[v].size(); i++) {
            int to = G[v][i];
            if (d[v] + 1 < d[to]) {
                d[to] = d[v] + 1;
                Q.push(to);
                path.push_back(to);
            }
        }
    }
     
    init(n);
    
    ll res = 0;
    for (int i = 1; i < n; i++) {
        int l = lca(path[i-1], path[i]);
        res += d[path[i-1]] + d[path[i]] - 2*d[l];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 60748
#include <bits/stdc++.h>
using namespace std;
long long fac[100010], inv[100010]; 
long long P = 1000000007;
void init() {
    fac[0] = fac[1] = 1; 
    inv[1] = 1; 
    for (int i = 2; i < 100005; i++) {
        fac[i] = fac[i - 1] * i % P;
        inv[i] = P - inv[P % i] * (P / i) % P;
    }
}
int main(){
	int N; cin >> N; init(); 
	long long X[114514] = {}; 
	for(int i = 0; i < N; i++) cin >> X[i]; 
	long long Y[114514] = {}; 
	for(int i = 0; i < N; i++) Y[i] = X[N-1] - X[i]; 
	long long ans = 0; 
	for(int i = 0; i < N; i++){
		long long tmp = Y[i] * inv[i+1] % P; 
		ans += tmp; ans %= P; 
	}
	ans *= fac[N-1]; ans %= P; 
	cout << ans << endl; 
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int n,cnt=0;
int a[200000],b[200000];
signed main(){
    cin>>n;
    rep(i,n)cin>>a[i]>>b[i];
    for(int i=n-1;i>=0;i--){
        a[i]+=cnt;
        int x=a[i]%b[i];
        if(x!=0)cnt+=b[i]-x;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

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

	int n = X / 100;

	int a = X % 100;
	int m = a / 5;
	if (a - (m * 5) > 0)
	{
		m++;
	}

	if (n >= m)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(int i = 0;i < n;++i)
#define rep1(i, n) for(int i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define chmin

#define lset(h, n) memset(h, n, sizeof(h));
    

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    ll n;
    cin >> n;

    ll t = sqrt(n);
    for(ll i = t;i>0;i--) {
        if(n%i==0){
            ll ans = max(n/i,i);
            
            pri(to_string(ans).length());
            return 0;
        }
    }
    

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;

  long sum = 0;
  int h = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    std::cin >> a;
    if (i > 0) {
      if (h > a)
        sum += h - a;
    }
    h = std::max(a, h);
  }

  std::cout << sum << std::endl;
}


Measured memory_bytes: 3164
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

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

	char A, B;
	cin >> A >> B;

	if (A > B)cout << ">\n";
	else if (A == B)cout << "=\n";
	else cout << "<\n" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MOD = 1000000007;
int main()
{
    enum { A, C, G, T };
    int N; cin >> N;
    Int dp[101][4][4][4] = {};
    for (int c1 = 0; c1 < 4; c1++) {
        for (int c2 = 0; c2 < 4; c2++) {
            for (int c3 = 0; c3 < 4; c3++) {
                if (c1 == A && c2 == G && c3 == C) continue;
                if (c1 == A && c2 == C && c3 == G) continue;
                if (c1 == G && c2 == A && c3 == C) continue;
                dp[3][c1][c2][c3] = 1;
            }
        }
    }
    for (int i = 4; i <= 100; i++) {
        for (int c1 = 0; c1 < 4; c1++) {
            for (int c2 = 0; c2 < 4; c2++) {
                for (int c3 = 0; c3 < 4; c3++) {
                    for (int c4 = 0; c4 < 4; c4++) {
                        if (c2 == A && c3 == G && c4 == C) continue;
                        if (c2 == A && c3 == C && c4 == G) continue;
                        if (c2 == G && c3 == A && c4 == C) continue;
                        if (c1 == A && c2 == G && c4 == C) continue;
                        if (c1 == A && c3 == G && c4 == C) continue;
                        dp[i][c2][c3][c4] = (dp[i][c2][c3][c4] + dp[i-1][c1][c2][c3]) % MOD;
                    }
                }
            }
        }
    }
    Int ans = 0;
    for (int c1 = 0; c1 < 4; c1++) {
        for (int c2 = 0; c2 < 4; c2++) {
            for (int c3 = 0; c3 < 4; c3++) {
                ans = (ans + dp[N][c1][c2][c3]) % MOD;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main(){
	vi hills(10);
	rep(i, 10) cin >> hills[i];
	sort(all(hills),greater<int>());
	rep(i, 3) cout << hills[i] << endl;
	
	return 0;
}

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

int main()
{
	long long q,h,s,d,n,ans=0;
	scanf("%lld%lld%lld%lld%lld",&q,&h,&s,&d,&n);
	ans=n/2*min(min(d,s*2),min(h*4,q*8)),n%=2;
	if(n) ans+=min(q*4,min(h*2,s));
	printf("%lld\n",ans);
} 

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

int main(){
  string s; cin >> s;
  int ssize=s.size();
  
  int pcount=0, gcount=0;
  int win=0, lose=0;
  
  for(int i=0; i<ssize; i++){
    if(pcount==gcount){
      //グーを出す
      if(s[i]=='p') lose++;
      gcount++;
    }else{
      //パーを出せる
      if(s[i]=='g') win++;
      pcount++;
    }
  }
  cout << win-lose << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1e9
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
string s;
int Com(string t){
    int num = 0;
    for(int i = 1; i < t.size(); i++){
        if(t[i] == t[i-1]){
            num++;
            if(t[i] == '0') t[i] = '1';
            else t[i] = '0';
        }
    }
    return num;
}
int main(){
    cin >> s;
    int ans = MM;
    if(s.size() == 1){
        cout << 0 << endl;
        return 0;
    }
    if(s[0] != s[1]){
        cout << Com(s) << endl;
    } else {
        if(s[0] == '0'){
            ans = min(ans,Com(s));
            s[0] = '1';
            ans = min(ans,Com(s)+1);
            cout << ans << endl;
            return 0;
        } else {
            ans = min(ans,Com(s));
            s[0] = '0';
            ans = min(ans,Com(s)+1);
            cout << ans << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
int main(void){
  int n;
  int x[101];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
      scanf("%d",&x[i]);
  }
  int min=1000000;
  
  for(int i=1;i<101;i++){
      int sum=0;
      for(int j=0;j<n;j++){
        sum+=(i-x[j])*(i-x[j]);
      }
      if(sum<min){
          min=sum;
      }else{
          break;
      }
  }
  
  printf("%d\n",min);
  return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 1e18;
signed main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> cntw(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    cntw[i] = cntw[i - 1] + (s[i - 1] == 'W');
  }
  //   for (auto &&i : cntw) {
  //     cout << i << " ";
  //   }
  //   cout << endl;
  int ans = n;
  for (int i = 1; i <= n; i++) {
    int tmp;
    tmp = cntw[i - 1] + (n - i) - (cntw[n] - cntw[i]);
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3076
#include <stdio.h>

#define KI_MAX (1 << 19) /* 524288 */

int ki[KI_MAX * 2 - 1];

void ki_set(int idx, int value) {
	int pos = (KI_MAX - 1) + idx;
	ki[pos] = value;
	do {
		pos = (pos - 1) / 2;
		ki[pos] = ki[pos * 2 + 1] | ki[pos * 2 + 2];
	} while (pos > 0);
}

int ki_get_i(int idx, int qmin, int qmax, int smin, int smax) {
	if (qmax <= smin || smax <= qmin) { /* 完全に外れている */
		return 0;
	} else if (qmin <= smin && smax <= qmax) { /* セグメントがクエリに完全に含まれる */
		return ki[idx];
	} else {
		int smid = smin + (smax - smin) / 2;
		int left = ki_get_i(idx * 2 + 1, qmin, qmax, smin, smid);
		int right = ki_get_i(idx * 2 + 2, qmin, qmax, smid, smax);
		return left | right;
	}
}

int ki_get(int min, int max) {
	return min < max ? ki_get_i(0, min, max, 0, KI_MAX) : 0;
}

struct queri {
	int type;
	union {
		struct {
			int i;
			char c;
		} type1;
		struct {
			int l, r;
		} type2;
	} data;
};

int N;
char S[555555];
int Q;
struct queri Query[22222];

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%555554s", S) != 1) return 1;
	if (scanf("%d", &Q) != 1) return 1;
	for (i = 0; i < Q; i++) {
		if (scanf("%d", &Query[i].type) != 1) return 1;
		if (Query[i].type == 1) {
			char c[4];
			if (scanf("%d%3s", &Query[i].data.type1.i, c) != 2) return 1;
			Query[i].data.type1.c = c[0];
		} else if (Query[i].type == 2) {
			if (scanf("%d%d", &Query[i].data.type2.l, &Query[i].data.type2.r) != 2) return 1;
		} else {
			puts("unknown query type!");
			return 2;
		}
	}

	for (i = 0; i < N; i++) {
		ki_set(i, 1 << (S[i] - 'a'));
	}
	for (i = 0; i < Q; i++) {
		if (Query[i].type == 1) {
			ki_set(Query[i].data.type1.i - 1, 1 << (Query[i].data.type1.c - 'a'));
		} else if (Query[i].type == 2) {
			int tamurayukari = ki_get(Query[i].data.type2.l - 1, Query[i].data.type2.r);
			int kaziyuuki = 0;
			while (tamurayukari > 0) {
				if (tamurayukari & 1) kaziyuuki++;
				tamurayukari >>= 1;
			}
			printf("%d\n", kaziyuuki);
		}
	}
	return 0;
}


Measured memory_bytes: 4864
IDENTIFICATION DIVISION.
 PROGRAM-ID. TEST049.

 DATA DIVISION.
 WORKING-STORAGE SECTION.
 
  01 INP    PIC X(1).

 PROCEDURE DIVISION.

  ACCEPT INP.

  EVALUATE TRUE
      WHEN INP = 'a'
      WHEN INP = 'i'
      WHEN INP = 'u'
      WHEN INP = 'e'
      WHEN INP = 'o'
        DISPLAY 'vowel'
      WHEN OTHER
        DISPLAY 'consonant'
  END-EVALUATE.

 STOP RUN.

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
	int a, b,c;
	scanf("%d %d %d", &a, &b, &c);
	if (a<b && b<c)
		printf("Yes\n");
	
	else
		if (a && b < c)
		printf("No\n");
		
		else
			printf("No\n");
	return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
    int n,m; cin>>n>>m;
    const int mod=1e9+7;
    vector<bool> c(n,true);
    for(int i=0;i<m;i++){
        int a; cin>>a;
        c[a]=false;
    }
    vector<ll> dp(n+1,0);
    dp[0]=1;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=min(n,i+2);j++){
            if(c[j]){
                dp[j]+=dp[i];
                dp[j]%=mod;
            }
        }
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] kusi=new int[2*N];
		int wa=0;
		for(int i=0; i<2*N; i++){
			kusi[i]=sc.nextInt();
		}
		Arrays.sort(kusi);

		for(int i=0; i<N; i++) {
			wa+=Math.min(kusi[i*2], kusi[i*2+1]);
		}
		System.out.println(wa);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,M;
    cin >> N >> M;
    priority_queue<double> A;
    rep(i,N){
        double tmp;
        cin >> tmp;
        A.push(tmp);
    }
    rep(i,M){
        double tmp;
        tmp = A.top();
        A.pop();
        A.push(tmp/2.0);
    }
    ll ans = 0;
    rep(i,N){
        ans += (ll)A.top();
        A.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  string s;
  cin >> n >> k >> s;
  if(s[k - 1] == 'A')s[k - 1] = 'a';
  if(s[k - 1] == 'B')s[k - 1] = 'b';
  if(s[k - 1] == 'C')s[k - 1] = 'c';
  cout << s << endl;
}

Measured memory_bytes: 256
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(N):
  for j in range(N):
    if i == j:
      continue
    p, q = xy[i][0] - xy[j][0], xy[i][1] - xy[j][1]
    k = 0
    for x in range(N):
      for y in range(N):
        if x == y:
          continue
        if xy[x][0] - xy[y][0] == p and xy[x][1] - xy[y][1] == q:
          k += 1
    ans = max(ans, k)
print(N - ans)

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

int n;
double x[100], y[100];

double distance(double p){
    double sum = 0;
    for(int i = 0; i < n; i++){
        double w = abs(x[i] - y[i]);
        sum += pow(w, p);
    }
    return pow(sum, 1.0/p);
}

int main(){
    cout << fixed << setprecision(12);

    cin >> n;

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

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

    cout << distance(1) << endl;
    cout << distance(2) << endl;
    cout << distance(3) << endl;

    double mx = 0;

    for(int i = 0; i < n; i++){
        mx = max(mx, abs(x[i] - y[i]));
    }

    cout << mx << endl;
    
    return 0;
}


Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,q;
	string s;
	cin >> n >> s >> q;
	for(int i = 0;i < q;i++){
		int k,ans = 0,d = 0,m = 0,dm = 0;
		cin >> k;
		for(int j = 0;j < n;j++){
			if(j >= k){
				if(s[j - k] == 'D'){
					d--;
					dm -= m;
				}
				else if(s[j - k] == 'M') m--;
			}
			if(s[j] == 'D') d++;
			else if(s[j] == 'M'){
				m++;
				dm += d;
			}
			else if(s[j] == 'C') ans += dm;
		}
		cout << ans << endl;
	}

}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a>=13)
		printf("%d\n",b);
	else if(a>=6&&a<=12)
		printf("%d\n",b/2);
	else if(a<=5)
		puts("0");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N = 4010;
inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }
int n, a[N][4];
char s[N];
long long ans;
inline int trans(char c) {
	if (c == 'G') return 1;
	if (c == 'B') return 2;
	if (c == 'R') return 3;
}
int main() {
    //std::ios::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	std::cin >> s + 1;
	for (int i = 1; i <= n; ++i) {
		a[i][trans(s[i])] = 1;
		for (int j = 1; j <= 3; ++j) a[i][j] = a[i - 1][j] + a[i][j];
	}
	for (int i = 1; i < n; ++i)
		for (int j = i + 2; j <= n; ++j) {
			if (s[i] == s[j]) continue;
			ans += a[j][6 - trans(s[i]) - trans(s[j])] - a[i - 1][6 - trans(s[i]) - trans(s[j])];
			if ((i + j) % 2 == 0) {
				if (trans(s[i + j >> 1]) == 6 - trans(s[i]) - trans(s[j])) --ans;
			}
		}
	std::cout << ans << '\n';
}




Measured memory_bytes: 3688
public class Main {

  private static void solve() {
    int n = ni();
    int[] a = na(n);
    int[] b = na(n);
    int[] c = na(n - 1);

    int ret = 0;
    for (int i = 0; i < n; i++) {
      ret += b[a[i] - 1];

      if (i > 0) {
        if (a[i - 1] + 1 == a[i]) {
          ret += c[a[i - 1] - 1];
        }
      }
    }
    System.out.println(ret);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 21332
/* Author - Ankur Kumar Singh 
	IDE :- Offine Linux
	
 ---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
/* variable type :- */
	# define ll long long int
	# define ld long double
	# define I int
/* map */
	# define abc  pair<long long int,long long int>
	map < pair < abc,abc > , long long int > pqr;
	map <  pair < long long int,long long int > ,long long int > xyz;	
/* vector */
	# define pb push_back
	# define pp pop_back
	# define ff first
	# define ss second
	# define mp make_pair
	# define ac accumulate
/* pairs */
	vector<pair<ll,ll>>a;
	vector<pair<pair<int,int>,pair<int,int> > > b;
	vector<pair<ll,pair<ll,ll>>>c;
	priority_queue<ll>pq; // pq.top() = Largest Element
	priority_queue<ll,vector<ll>,greater<ll>>bc; // bc.top() = Smallest Element
 
bool compare( const pair<long long int,long long int>&x , const pair<long long int,long long int>&y )
{
	return x.ff>y.ff;
}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
{
        return (a.ss < b.ss);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  
// Function to find gcd of array of 
// numbers 
ll findGCD(ll arr[], ll n) 
{ 
    ll result = arr[0]; 
    for (ll i = 1; i < n; i++) 
        result = gcd(arr[i], result); 
  
    return result; 
} 
int main()
{
    ll n;
    cin>>n;
    ll x;
    cin>>x;
    ll arr[n+1];
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    ll diff[n+1];
    ll flag=-1;
    sort(arr,arr+n);
       ll w,v;
    if(x<arr[0])
    {

flag=9;        w=abs(x-arr[0]);
    }
    if(x>arr[n-1])
    {
       flag=10; v=abs(x-arr[n-1]);
    }
    ll pos=-1;
     for(ll i=0;i<n-1;i++)
    {
        
        if(x>arr[i] && x<arr[i+1])
        {
            pos=i;
            w=abs(x-arr[i]);
            v=abs(x-arr[i+1]);break;
        }
    }
    ll cnt=0;
    for(ll i=0;i<n-1;i++)
    {
        if(i==pos){flag=-1;continue;}
        diff[cnt]=abs(arr[i]-arr[i+1]);cnt++;
    }
    if(flag==-1)
    {
        diff[cnt]=w;cnt++;diff[cnt]=v;cnt++;
    }
    else if(flag==9)
    {
        diff[cnt]=w;cnt++;
    }
    else if(flag==10)
    {
         diff[cnt]=v;cnt++;
    }
    ll k=findGCD(diff, cnt);
    cout<<k;
    //return -1;
}

Measured memory_bytes: 1792
#include <iostream>
#include <queue>
#include <map>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef pair<string, string> P;

int main() {
	map<char, string> tr1;

	tr1['A'] = "00000";
	tr1['B'] = "00001";
	tr1['C'] = "00010";
	tr1['D'] = "00011";
	tr1['E'] = "00100";
	tr1['F'] = "00101";
	tr1['G'] = "00110";
	tr1['H'] = "00111";
	tr1['I'] = "01000";
	tr1['J'] = "01001";
	tr1['K'] = "01010";
	tr1['L'] = "01011";
	tr1['M'] = "01100";
	tr1['N'] = "01101";
	tr1['O'] = "01110";
	tr1['P'] = "01111";
	tr1['Q'] = "10000";
	tr1['R'] = "10001";
	tr1['S'] = "10010";
	tr1['T'] = "10011";
	tr1['U'] = "10100";
	tr1['V'] = "10101";
	tr1['W'] = "10110";
	tr1['X'] = "10111";
	tr1['Y'] = "11000";
	tr1['Z'] = "11001";
	tr1[' '] = "11010";
	tr1['.'] = "11011";
	tr1[','] = "11100";
	tr1['-'] = "11101";
	tr1['\''] = "11110";
	tr1['?'] = "11111";

	map<char, string> tr2;
	tr2[' '] = "101";
	tr2['\''] = "000000";
	tr2[','] = "000011";
	tr2['-'] = "10010001";
	tr2['.'] = "010001";
	tr2['?'] = "000001";
	tr2['A'] = "100101";
	tr2['B'] = "10011010";
	tr2['C'] = "0101";
	tr2['D'] = "0001";
	tr2['E'] = "110";
	tr2['F'] = "01001";
	tr2['G'] = "10011011";
	tr2['H'] = "010000";
	tr2['I'] = "0111";
	tr2['J'] = "10011000";
	tr2['K'] = "0110";
	tr2['L'] = "00100";
	tr2['M'] = "10011001";
	tr2['N'] = "10011110";
	tr2['O'] = "00101";
	tr2['P'] = "111";
	tr2['Q'] = "10011111";
	tr2['R'] = "1000";
	tr2['S'] = "00110";
	tr2['T'] = "00111";
	tr2['U'] = "10011100";
	tr2['V'] = "10011101";
	tr2['W'] = "000010";
	tr2['X'] = "10010010";
	tr2['Y'] = "10010011";
	tr2['Z'] = "10010000";

	string s = "";
	while ( getline(cin, s) ) {
		string code = "";

		for (int i = 0; i < s.size(); ++i) code += tr1[s[i]];

		int max_sz = 0; string ans = "";
		queue<P> Q; Q.push( P("", "") );
		while ( !Q.empty() ) {
			P p = Q.front(); Q.pop();
			string str = p.first;

			if (str.size() > code.size()) continue;

			bool f = true;
			for (int i = 0; i < str.size(); ++i)
				if (str[i] != code[i]) f = false;

			if (!f) continue;

//			for (int i = str.size(); i < code.size(); ++i)
//				if (code[i] == '1') f = false;

			ans = p.second;

			map<char, string>::iterator pos = tr2.begin();
			while ( pos != tr2.end() ) {
				Q.push( P(str + (*pos).second, p.second + (*pos).first) );
				++pos;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1316
n, m = gets.split.map(&:to_i)
ab = []
n.times do
  ab.push gets.split.map(&:to_i)
end
sorted_ab = ab.sort_by { |e| e.first }
sum = 0
count = 0
sorted_ab.each do |sab|
  sum += sab[0] * sab[1]
  count += sab[1]
  if count >= m
    sum -= sab[0] * sab[1]
    count -= sab[1]
    c = m - count
    puts sum + c * sab[0]
    exit
  end
end


Measured memory_bytes: 12664
char r[99],g[99],*G,d[99];main(c,i,k){for(;scanf("%s%s%s",r,g,d)>1;puts(""))for(i=k=0,G=g,c=*G++;*(G-1);)c==d[k]?k++,c=r[i++]:(putchar(c),c=*G++);exit(0);}

Measured memory_bytes: 524
#include <stdio.h>
#include <string.h>
int main()
{
	char i,a,b;
	char x[10],y[10];
	scanf("%c %c",&a,&b);
	for(i=0;i<(a-'0');i++)
		x[i]=b;
	x[i]='\0';
	for(i=0;i<(b-'0');i++)
		y[i]=a;
	y[i]='\0';
	if(strcmp(x,y)>=0)
	{
		printf("%s",y);
	}
	else
		printf("%s",x);
 } 

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

double distance(double, double, double, double);

int main(){
  double x1 ,y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << fixed << setprecision(12);
  cout << distance(x1, y1, x2, y2) << endl;
}

double distance(double x1, double y1, double x2, double y2){
  double sumsq;
  sumsq = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
  return pow(sumsq, 0.5);
}



Measured memory_bytes: 3472
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,l=1,r=1,ans=1,a[100001];
main(){
  cin>>n;
  r(i,n)cin>>a[i];
  r(i,n-1){
    if(a[i]<a[i+1])l++,r=1;
    if(a[i]>a[i+1])r++,l=1;
    ans=max(ans,max(l,r));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3476
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin>>s;
  ll a=0,b=0;
  for(int i=0;i<=2;i++)
  {
    if(s[i]=='A')
    a++;
    else
    b++;
  }
  if(a==3 || b==3)
  {
   cout<<"No";
  }
  else
  {
   cout<<"Yes";
  }
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def convert(i, n):
    ret = []
    for j in range(n):
        if i & (1<<j):
            ret.append(1)
        else:
            ret.append(0)
    return ret

def check(tf, people):
    for i in range(len(people)):
        if not tf[i]:
            continue
        for j in range(len(people[i])):
            say = people[i][j]
            if say[1] != tf[say[0]]:
                return False
    return True

def main():
    n = ri()
    people = []
    for i in range(n):
        a = ri()
        say = []
        for j in range(a):
            x, y = rli()
            x -= 1
            say.append([x, y])
        people.append(say)
    ans = 0
    for i in range(pow(2, n)):
        tf = convert(i, n)
        ok = check(tf, people)
        if not ok:
            continue
        ans = max(ans, sum(tf))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int candidates[9] = {
        111, 222, 333, 444, 555, 666, 777, 888, 999
    };
    for (int i = 0; i < 9; ++i) {
        if (N <= candidates[i]) {
            cout << candidates[i] << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
li = [0]*(10**5+10)
n,k = map(int, input().split())
for i in range(n):
    a,b = map(int, input().split())
    li[a] += b
cnt = 0
ans = 0
for i in range(10**5+10):
    cnt += li[i]
    ans = i
    if cnt >= k:
        break
print(ans)

Measured memory_bytes: 11700
n = int(input())
lis = list(map(int,input().split()))
ans = 0
co = 0
for i in range(n):
    while lis[i] != 0:
        cou = i
        while lis[cou] > 0:
            lis[cou] -= 1
            cou += 1
            if cou == n:
                break
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
 
int main(){
  
  int n, i, max, min;
  int R[200000];
  
  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
    scanf("%d",&R[i]);
  }
  
  max = R[1] - R[0];
  min = R[0];
  
  for(i = 1; i < n; i++){
    if(R[i] - min > max) max = R[i] - min;
    if(R[i] < min) min = R[i]; 
  }
  
  printf("%d\n",max);
  
  return 0;
}

Measured memory_bytes: 1376
n = int(input())
ans = 0
arr = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
    num = str(i)
    head, tail = int(num[0]), int(num[-1])
    arr[head][tail] += 1
for i in range(10):
    for j in range(10):
        tmp = arr[i][j] * arr[j][i]
        ans += tmp
print(ans)


Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    int ans = b;
    if(a * n < b){
      ans = a * n;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// 入力
int N;
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    // 初期化は既に 0 に初期化される
    // 初期条件も既に 0 で OK

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    // 答え
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;
}

Measured memory_bytes: 8176
n = int(input())
value_list = []

for i in range(n):
    value_list.append(int(input()))

most_max = max(value_list)

if len([i for i, x in enumerate(value_list) if x == most_max]) == 2:
    for i in range(n):
        print(most_max)
else:
    most_max_index = value_list.index(most_max)
    value_list[most_max_index] = 0
    second_max = max(value_list) 
    value_list[most_max_index] = most_max
    
    for i in range(n):
        if value_list[i] == most_max:
            print(second_max)
        else:
            print(most_max)

Measured memory_bytes: 18860
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	ll x, y, z;
	cin >> x >> y >> z;
	ll n = x + y + z;
	vl a(n), b(n), c(n);
	REP(i, n) cin >> a[i] >> b[i] >> c[i];

	vb X(n, false), Y(n, false), Z(n, false);

	using P = pair<ll, ll>;
	priority_queue<P> b_a_inX;
	REP(i, n) {
		b_a_inX.push({ b[i] - a[i], i });
		X[i] = true;
	}

	priority_queue<P> c_b_inY;
	REP(_, y) {
		auto i = b_a_inX.top().second;
		Y[i] = true;
		X[i] = false;
		c_b_inY.push({ c[i] - b[i], i });
		b_a_inX.pop();
	}

	priority_queue<P> c_a_inX;
	REP(i, n) if (X[i]) c_a_inX.push({ c[i] - a[i], i });

	REP(_, z) {
		while (!Y[c_b_inY.top().second]) c_b_inY.pop();
		while (!X[c_a_inX.top().second]) c_a_inX.pop();
		while (!X[b_a_inX.top().second]) b_a_inX.pop();
		P cby = c_b_inY.top();
		P cax = c_a_inX.top();
		P bax = b_a_inX.top();
		if (cby.first + bax.first > cax.first) {
			Z[cby.second] = true;
			Y[cby.second] = false;
			Y[bax.second] = true;
			X[bax.second] = false;
			ll i = bax.second;
			c_b_inY.push({c[i] - b[i], i});
		} else {
			Z[cax.second] = true;
			X[cax.second] = false;
		}
	}
	ll ans = 0;
	REP(i, n) {
		if (X[i]) {
			ans += a[i];
		} else if(Y[i]) {
			ans += b[i];
		} else {
			ans += c[i];
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 9204
#include <iostream>
#include <string>

using namespace std;

int main(){
  for(string s; cin>>s;){
    string res;
    for(int i=0;i<s.size();i++){
      if(s[i] == '@'){
        res += string(s[i+1] - '0' , s[i+2]);
        i += 2;
      }
      else res+=s[i];
    }
    cout << res << endl;
  }
     
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,N;
  cin>>H>>N;
  
  while(N-->0)
  {
    int attack;
    cin>>attack;
    H-=attack;
    if(H<1) {
      cout<<"Yes \n";
      return 0;
    }
  }
  cout<<"No \n";
  return 0;
}

Measured memory_bytes: 3624
# AtCodea
from collections import defaultdict
N = int(input())
a = list(map(int, input().split()))


d = defaultdict(list)
for i in range(1, N+1):
    d[a[i-1]].append(a[i-1])

count = 0
for k, v in d.items():
    if k != len(v):
        if len(v) > k:
            count += len(v) - k
        else:
            count += len(v)
print(count)


Measured memory_bytes: 25968
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 驍ｨ・ｶ陝・ｽｾ陋滂ｽ､雎弱ｅ・∫ｹｧ繝ｻ笆ｽ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;

int main(){
  int n ;
  cin >>n;
  int A[100010];
  rep(i,n){
    int a; cin >> a;
    A[a-1] =i+1 ;
  }
  rep(i,n){
    if(i!=0)cout<<" ";
    cout<<A[i];
  }
    cout<<endl;
}



Measured memory_bytes: 1152
# include <bits/stdc++.h>
//# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define fors(i, s) for (int i = 0; s[i]; i++)
# define in freopen("input.txt", "r", stdin)
# define out freopen("output.txt", "w", stdout)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define mkp make_pair
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
 
using namespace std;
const ll mod = 1e17 + 7;
const int N = 5e2 + 7;


int main()
{
	speed;
	int n, m;
	cin >> n >> m;
	vector < int > p(n + 1), b(n + 1);
	forn( i, m ) {
		int x;
		string s;
		cin >> x >> s;
		if ( b[x] ) continue;
		if ( s == "AC" ) b[x] = 1;
		else p[x]++;
	}
	int ans1 = 0, ans2 = 0;
	fore( i, 1, n + 1 ) {
		if ( b[i] ) {
			ans2++;
			ans1 += p[i];
		}
	}
	cout << ans2 << ' ' << ans1 << endl;
	time;
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    double ret = 0.0;
    for (int i = 1; i <= a; i++)
    {
        double tmp = 1.0 / a;
        int now = i;
        while (now < b)
        {
            now *= 2.0;
            tmp /= 2.0;
        }
        ret += tmp;
    }
    cout << fixed << setprecision(12) << ret << endl;
    return 0;
}

Measured memory_bytes: 256
def piyo():
    n , c = (int(i) for i in input().split())
    t = [[int(i) for i in input().split()] for i in range(n)]
    hogehoge = []
    for fizz in t:
        if fizz[1]<=c:
            hogehoge.append(fizz[0])
    if len(hogehoge)==0:
        print("TLE")
        return
    print(min(hogehoge))
    

if __name__ == '__main__':
    piyo()

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  ll l=0,r=n;
  string lc,rc;
  cout<<0<<endl;
  cin>>lc;
  if(lc=="Vacant")return 0;
  rc=lc;
  while(r-l>=1){
    ll mid=(l+r)/2;
    cout<<mid<<endl;
    string s;cin>>s;
    if(s=="Vacant")return 0;
    if((s!=lc)^((mid-l)&1)){
      r=mid;
      rc=s;
    }
    else{
      l=mid;
      lc=s;
    }
  }
  return 0;
}

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

int main()
{
    int N;
    cin>>N;
    int arr[N][3];
    for(int i=0;i<N;i++)
      for(int j=0;j<3;j++)
       cin>>arr[i][j];
       
    int dp[N][3];
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];
    
    for(int i=1;i<N;i++)
    {
        for(int j=0;j<3;j++)
        {
            int p,q;
          if(j==0)
          {
           p=1;
           q=2;
          }
           else if(j==1)
           {
             p=0;
             q=2;
           }
           else
           {
             p=0;
             q=1;
           }
         dp[i][j]=arr[i][j]+max(dp[i-1][p],dp[i-1][q]);
        }
    }
    
    
    int ans=max(dp[N-1][0],dp[N-1][1]);
    ans=max(dp[N-1][2],ans);
    cout<<ans;
	return 0;
}

Measured memory_bytes: 2560