akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<vector>
#include<string>
#include<iostream>
using namespace std;
vector<string> puyos;
int w,h;
int ve[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
void umel(int y,int x,char se){
    puyos[y][x]='T';
    for(int i=0;i<4;i++){
        int ny=y+ve[i][0],nx=x+ve[i][1];
        if(0<=nx && nx<w && 0<=ny && ny<h && puyos[ny][nx]==se){
            umel(ny,nx,se);
        }
    }
}
int main(){
    int n;
    scanf("%d",&n);
    for(int inow=0;inow<n;inow++){
        char t[10];
        puyos=vector<string>(12);
        for(int i=0;i<12;i++){
            scanf("%s\n",t);
            puyos[i]=string(t);
        }
        h=12;
        w=6;
        for(int ix=0;;ix++){
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    char nowc=puyos[i][j];
                    if(nowc!='.'&&nowc!='O'&&nowc!='S'){
                        umel(i,j,nowc);
                        int num=0;
                        for(int ky=0;ky<h;ky++){
                            for(int kx=0;kx<w;kx++){
                                if(puyos[ky][kx]=='T')num++;
                            }
                        }
                        char daic;
                        if(num>=4)daic='S';
                        else daic=nowc;
                            for(int ky=0;ky<h;ky++){
                                for(int kx=0;kx<w;kx++){
                                    if(puyos[ky][kx]=='T')puyos[ky][kx]=daic;
                                }
                            }
                    }
                }
            }
            for(int iy=0;iy<h;iy++){
                for(int ix=0;ix<w;ix++){
                    if(puyos[iy][ix]=='O'){
                        for(int vi=0;vi<4;vi++){
                            int ny=iy+ve[vi][0],nx=ix+ve[vi][1];
                            if(0<=nx && nx<w && 0<=ny && ny<h && puyos[ny][nx]=='S'){
                                puyos[iy][ix]='T';
                                break;
                            }
                        }
                    }
                }
            }
            bool iscont=false;
            for(int ky=0;ky<h;ky++){
                for(int kx=0;kx<w;kx++){
                    if(puyos[ky][kx]=='S'||puyos[ky][kx]=='T'){
                        puyos[ky][kx]='.';
                        iscont=true;
                    }
                }
            }
            if(!iscont){
                printf("%d\n",ix);
                break;
            }
            vector<vector<char> > tates(w);
            for(int ky=h-1;ky>=0;ky--){
                for(int kx=0;kx<w;kx++){
                    if(puyos[ky][kx]!='.') tates[kx].push_back(puyos[ky][kx]);
                }
            }
            for(int ky=0;ky<h;ky++){
                for(int kx=0;kx<w;kx++){
                    puyos[ky][kx]='.';
                }
            }
            for(int kx=0;kx<w;kx++){
                for(int ky=0;ky<tates[kx].size();ky++){
                    puyos[h-ky-1][kx]=tates[kx][ky];
                }
            }
        }
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    if (s[0] == 'A') cout << 'T' << endl;
    else if (s[0] == 'C') cout << 'G' << endl;
    else if (s[0] == 'G') cout << 'C' << endl;
    else cout << 'A' << endl;
    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    T = [int(input()) for _ in range(5)]
    
    del_max = -1
    idx_max = 0
    for i in range(5):
        if T[i]%10 == 0:
            pass
        elif 10 - T[i]%10 > del_max:
            del_max = 10 - T[i]%10
            idx_max = i
    
    count = 0
    for i in range(5):
        if i != idx_max:
            time = (T[i]//10)*10
            if time < T[i]:
                time += 10
            count += time
    count += T[idx_max]
    
    print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

ll dp[101][4][2];
void solve(string n, ll k){
    // 0を引く
    dp[0][0][0]=1;
    int m=n.size();
    fore(i,1,m){
        int d=n[i-1]-'0';
        rep(j,k+1){
            if (d==0) {
                dp[i][j][0]+=dp[i-1][j][0];
            } else {
                if(j>0){
                    dp[i][j][0]+=dp[i-1][j-1][0];
                    dp[i][j][1]+=dp[i-1][j-1][0]*(d-1);
                }
                dp[i][j][1]+=dp[i-1][j][0];
            }
            if(j>0)dp[i][j][1]+=dp[i-1][j-1][1]*9;
            dp[i][j][1]+=dp[i-1][j][1];
        }
    }
    cout<<dp[m][k][0]+dp[m][k][1]<<endl;
}

int main(){
    string n;
    cin >> n;
    ll k;
    scanf("%lld",&k);
    solve(n, k);
}


Measured memory_bytes: 256
(defun red-scarf(n a)
  (let* ((total_xor (reduce #'logxor a)))
    (loop for i from 0 below n
          collect (logxor (aref a i) total_xor))))

(defun create-data ()
  (let* ((n (read))
         (a (make-array `(,n))))
    (dotimes (i n)
      (setf (aref a i) (read)))
    (values n a)))

(multiple-value-bind (n a) (create-data)
  (format t "~{~a ~}~%" (red-scarf n a)))
 


Measured memory_bytes: 78616
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();
		int answer = s * t;
      	if(answer >= d){
			System.out.println("Yes");
        } else {
        	System.out.println("No");
        }
	}
}

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

int main(){
    
    int n;
    cin >> n;;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    int ans=0;
    for(int i=0; i<n; i++){
        ans+=a.at(i)-1;
    }

    cout << ans << endl;

}

Measured memory_bytes: 3584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		StringTokenizer st = new StringTokenizer(str, " ");
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		int c = Integer.parseInt(st.nextToken());

		if (a <= b && b <= c) {
			System.out.println(a + " " + b + " " + c);

		} else if(a <= c && c <= b) {
			System.out.println(a + " " + c + " " + b);

		} else if(b <= a && a <= c) {
			System.out.println(b + " " + a + " " + c);

		} else if(b <= c && c <= a) {
			System.out.println(b + " " + c + " " + a);

		} else if(c <= a && a <= b) {
			System.out.println(c + " " + a + " " + b);

		} else if(c <= b && b <= a) {
			System.out.println(c + " " + b + " " + a);
		}
	}

}

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

struct edge { int to, cap, rev; };
vector<edge>E[500];
bool used[500];
int d[500][500];
void add_edge(int from, int to, int cap) {
	E[from].push_back({ to,cap,(int)E[to].size() });
	E[to].push_back({ from,cap,(int)E[from].size() - 1 });
}
int dfs(int v, int t, int f) {
	if (v == t)return f;
	used[v] = 1;
	for (edge&e : E[v]) {
		if (used[e.to] || !e.cap)continue;
		int d = dfs(e.to, t, min(e.cap, f));
		if (d > 0) {
			e.cap -= d; E[e.to][e.rev].cap += d;
			return d;
		}
	}
	return 0;
}
int maxflow(int s, int t, int l = INT_MAX) {
	int res = 0;
	while (l) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, l);
		if (f == 0)break;
		res += f; l -= f;
	}
	return res;
}
int m[1000], a[1000], b[1000];
int main() {
	int n, e, q; scanf("%d%d%d", &n, &e, &q);
	memset(d, -1, sizeof(d));
	rep(i, e) {
		int a, b; scanf("%d%d", &a, &b); a--; b--;
		add_edge(a, b, 1);
		d[a][b] = E[a].size() - 1;
		d[b][a] = E[b].size() - 1;
	}
	rep(i, q) {
		scanf("%d%d%d", &m[i], &a[i], &b[i]); a[i]--; b[i]--;
		if (~d[a[i]][b[i]])continue;
		add_edge(a[i], b[i], 0);
		d[a[i]][b[i]] = E[a[i]].size() - 1;
		d[b[i]][a[i]] = E[b[i]].size() - 1;
	}
	int ans = maxflow(0, n - 1);
	rep(i, q) {
		if (m[i] == 1) {
			E[a[i]][d[a[i]][b[i]]].cap = E[b[i]][d[b[i]][a[i]]].cap = 1;
			ans += maxflow(0, n - 1);
			printf("%d\n", ans); continue;
		}
		if (E[a[i]][d[a[i]][b[i]]].cap == 2)swap(a[i], b[i]);
		if (E[a[i]][d[a[i]][b[i]]].cap == 0) {
			if (maxflow(a[i], b[i], 1))goto g;
			maxflow(n - 1, b[i], 1);
			maxflow(a[i], 0, 1);
			ans--;
		}
	g:;
		E[a[i]][d[a[i]][b[i]]].cap = E[b[i]][d[b[i]][a[i]]].cap = 0;
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 4720
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
int main(void){
  int i,n;
  int count=0;
  string s;


  cin >> n;
  cin >> s;

  for (i=0; i<n-2; i++){
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
      count += 1;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#define Link "https://arc085.contest.atcoder.jp/tasks/arc085_c"

#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>

#define TASK "MUL"

#define pii pair<int,int>
#define i first
#define v second

using namespace std;

void OpenFile()
{
    freopen(TASK".INP","r",stdin);
    freopen(TASK".OUT","w",stdout);
}

const int oo = 1e9 + 1;
const int maxn = 1e3 + 1;
int n,S,T,a[maxn],cf[maxn],cnt,b[maxn],num[maxn];
vector <pii> e[maxn];
long long res;

void Enter()
{
    cin >> n;
    for (int i=1;i<=n;++i)
        cin >> a[i];
}

void Connect(int u, int v, int w)
{
    e[u].push_back(pii(++cnt,v));
    cf[cnt] = w;
    e[v].push_back(pii(++cnt,u));
}

void Init()
{
    S = 0;
    T = n + 1;
    cnt = 1;
    for (int i=1;i<=n;++i)
        if (a[i] <= 0) {
            Connect(S,i,-a[i]);
            for (int j=i+i;j<=n;j+=i)
                Connect(i,j,+oo);
        }
        else {
            Connect(i,T,a[i]);
            res += a[i];
        }
}

bool Can(int S, int T)
{
    queue <int> qu;
    fill(b,b+n+1+1,+oo);
    b[S] = 0;
    qu.push(S);
    while (!qu.empty()) {
        int u = qu.front();
        qu.pop();
        if (u == T)
            return 1;
        for (pii p : e[u]) {
            int i = p.i;
            int v = p.v;
            if (cf[i] > 0 && b[v] == +oo) {
                b[v] = b[u] + 1;
                qu.push(v);
            }
        }
    }
    return 0;
}

int Find(int u, int mn)
{
    if (u == T)
        return mn;
    num[u] = cnt;
    for (pii p : e[u]) {
        int i = p.i;
        int v = p.v;
        if (num[v] != cnt && cf[i] > 0 && b[v] == b[u] + 1)
            if (int x = Find(v,min(mn,cf[i]))) {
                cf[i] -= x;
                cf[i^1] += x;
                return x;
            }
    }
    return 0;
}

void Solve()
{
    while (Can(S,T))
        while (int x = (++cnt,Find(S,+oo)))
            res -= x;
    cout << res;
}

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

    //OpenFile();

    Enter();
    Init();
    Solve();
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   while (1) {
      int n;
      cin >> n;
      if (n == 0) break;
      int sum = 0, Max = -1, Min = 111111;
      rep (i, n) {
         int a;
         cin >> a;
         Max = max(Max, a);
         Min = min(Min, a);
         sum += a;
      }
      int p = sum - Max - Min;
      cout << p / (n-2) << endl;
   }

   return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

long double n, m, d;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> m >> d;
    long double ans = (m - 1) / n;
    if (d != 0) ans *= 2 * (n - d) / n;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
count = 0
count2 = 0
for i in a:
    if i%2 == 0:
        count += 1 
        if  i%3 == 0 or i%5 == 0:
            count2 += 1
if count == count2:
    print("APPROVED")       
else:
    print("DENIED")

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define mod 998244353
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
int ans,fact[1000010],ifact[1000010];
int C(int n,int m){return 1ll*fact[n]*ifact[m]%mod*ifact[n-m]%mod;}
int main(){
	int n=gi(),m=gi();
	fact[0]=1;for(int i=1;i<=n+m;++i)fact[i]=1ll*fact[i-1]*i%mod;
	ifact[n+m]=pow(fact[n+m],mod-2);for(int i=n+m;i;--i)ifact[i-1]=1ll*ifact[i]*i%mod;
	if(n<m)std::swap(n,m);
	int ans=0;
	for(int i=1;i<=m;++i)ans=(ans+1ll*C(n+m-i-i,n-i)*C(i+i,i))%mod;
	printf("%d\n",(1ll*ans*ifact[2]%mod*ifact[n+m]%mod*fact[n]%mod*fact[m]+n)%mod);
	return 0;
}


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

int main() {
    int K, N;
    cin >> K >> N;

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

    sort(A.begin(), A.end());
    vector<int> t(N);
    t[0] = K - A[N - 1] + A[0];
    for (int i = 1; i < N; ++i) {
        t[i] = A[i] - A[i - 1];
    }

    sort(t.begin(), t.end(), greater<int>());
    cout << K - t[0] << endl;
    return 0;
}

Measured memory_bytes: 1920
n, m, x = map(int, input().split())
ca = []
for i in range(n):
    l = list(map(int, input().split()))
    ca.append(l)

INF = 10**18
ans = INF
for i in range(2**n):
    ls = [0]*m
    money = 0
    for j in range(n):
        if (i >> j & 1):
            for k in range(m):
                ls[k] += ca[j][k+1]
            money += ca[j][0]
    if min(ls) >= x:
        ans = min(ans, money)

if ans == INF:
    ans = -1

print(ans)


Measured memory_bytes: 9216
taro_p = 0
hanako_p = 0
gets.to_i.times do
    query = *gets.chomp.split
    if query[0]>query[1]
        taro_p += 3
    elsif query[0]<query[1]
        hanako_p += 3
    else
        taro_p += 1
        hanako_p += 1
    end
end
puts "#{taro_p} #{hanako_p}"


Measured memory_bytes: 6856
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#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 = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
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){if(n!=0)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;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

void solve(){
  ll n;cin>>n;
  ll res=0;
  vector<P>a,b;
  rep(i,0,n){
    ll k,l,r;cin>>k>>l>>r;k--;
    res+=min(l,r);
    if(l<r){
      b.EB(r-l,k+1);
    }
    else{
      a.EB(l-r,k);
    }
  }
  sort(ALLR(a));
  sort(ALLR(b));
  set<ll>sta,stb;
  rep(i,0,a.size())sta.insert(i);
  rep(i,0,b.size())stb.insert(n-i-1);
  //if(n==3)cout<<res<<endl;
  for(auto p:a){
    //cout<<p.fi spa p.se spa *sta.begin()<<endl;
    if(*sta.begin()>p.se){
      continue;
    }
    else{
      res+=p.fi;
      sta.erase(--sta.upper_bound(p.se));
    }
  }
  for(auto p:b){
    if(*stb.rbegin()<p.se){
      continue;
    }
    else{
      res+=p.fi;
      stb.erase(stb.lower_bound(p.se));
    }
  }
  cout<<res<<endl;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll t;cin>>t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 15816
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var As = new HashSet<long>();
            for (var i = 0; i < N; ++i)
            {
                var ai = Sarray()[0];
                if (As.Contains(ai))
                    As.Remove(ai);
                else
                    As.Add(ai);

            }
            WriteLine(As.Count());
            //Out.Flush();
        }
    }
}

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

int main(){

  char s[111][111];
  int a[111][111];
  int h, w;

  cin >> h >> w;
  for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) cin >> s[i][j];

  memset(a, -1, sizeof(a));

  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(s[i][j] == 'c') a[i][j] = 0;
      else if(~a[i][j-1]) a[i][j] = a[i][j-1]+1;
    }
  }

  for(int i=1;i<=h;i++, puts("")) for(int j=1;j<=w;++j>w?:printf(" ")) cout << a[i][j];

}

Measured memory_bytes: 1228
n=int(input())
a=list(map(int,input().split()))

a=[300]+a+[0] #先頭と末尾にダミーデータ
money=1000
numStock=0
LAST_UP=1
LAST_DN=2
last_change=LAST_DN

def buy(value):
    global money,numStock
    numStock+=money//value
    money-=numStock*value

def sell(value):
    global money,numStock
    money+=value*numStock
    numStock=0

for i in range(1,n+1):
    if a[i-1]<a[i]:
        last_change=LAST_UP
        if a[i]>a[i+1]: sell(a[i])
    elif a[i-1]>a[i]:
        last_change=LAST_DN
        if a[i]<a[i+1]: buy(a[i])
    else: # if a[i-1]==a[i]
        if a[i]<a[i+1]: #買い または 待ち
            if last_change==LAST_DN: buy(a[i])
        elif a[i]>a[i+1]: #売り または 待ち
            if last_change==LAST_UP: sell(a[i])

sell(a[n]) #最後に株の残があれば売る

print(money)

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define forn(i, a, b) for (int i = a; i < b; ++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}

const int N = 1e5 + 1;
int n, m;
vector<int> g[N];
bitset<N> vis;

void dfs(int u) {
  vis[u] = 1;
  for (int v : g[u]) {
    if (!vis[v]) dfs(v);
  }
}

int main() {
#ifdef LOCAL
  freopen("c.txt", "r", stdin);
// freopen("main.txt", "w", stdout);
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
  ios::sync_with_stdio(0);
  cin.tie(0);
#define endl '\n'
#define dbg(...) 18
#endif
  cin >> n >> m;
  for (int i = 0, u, v; i < m; i++) {
    cin >> u >> v;
    u--, v--;
    g[u].pb(v);
    g[v].pb(u);
  }
  int ans = -1;
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      ans++;
      dfs(i);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10016
#include <iostream>
using namespace std;
int main(){
  string l;
  bool ok = false;
  while(cin>>l){
    if(ok)cout << " ";
    ok=true;
    for(int i = 0; l.size() > i; i++){
      if(l[i]<='Z' && 'A'<=l[i])l[i]+='a'-'A';
      else if(l[i]<='z' && 'a'<=l[i])l[i]-='a'-'A';
    }
    cout << l;
  }
  cout << endl;
}


Measured memory_bytes: 3204
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   



      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         
          string s;
          cin>>s;
          if(s[2]==s[3] && s[4]==s[5])
            cout<<"Yes\n";
        else
            cout<<"No\n";

         

      }
      






}



























Measured memory_bytes: 256
h,w=map(int,input().split())
s = [[0]*w for _ in range(h)]
for i in range(h):
    s[i] = list(*input().split())

def cango(now,h,w):
    ans = []
    if now[0]>0:
        ans.append( (now[0]-1,now[1]) )
    if now[0]<h-1:
        ans.append( (now[0]+1,now[1]) )
    if now[1]>0:
        ans.append( (now[0],now[1]-1) )
    if now[1]<w-1:
        ans.append( (now[0],now[1]+1) )
    return ans

from collections import deque

ans=0
for hh in range(h):
    for ww in range(w):
        if s[hh][ww]==".":
            start = (hh,ww)
            q = deque( [] )
            q.append( ((-1,-1),start,0) )
            visit = [[0]*w for _ in range(h)]
            visit[hh][ww]=1
            while q:
                old,now,dist = q.popleft()
#                 print(old,now,dist)
                if ans<dist:
                    ans=dist
                for new in cango(now,h,w):
                    if s[new[0]][new[1]]=="." and visit[new[0]][new[1]]==0:
                        q.append( (now,new,dist+1) )
                        visit[new[0]][new[1]] = 1
print(ans )
    

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

int main() {
    string S;
    cin >> S;
    int wnum = 0;
    long long ans = 0;
    int i = 0;
    while(S[i] == 'W') {
        ++wnum;
        ++i;
    }
    for(; i<S.size(); ++i) {
        if(S[i] == 'W') {
            ans += i - wnum;
            ++wnum;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = input()
    print(" ".join(a.split(",")))
    return

#B
def B():
    k, s = LI()
    ans = 0
    for i in range(k + 1):
        for j in range(k + 1):
            if 0 <= s - (i + j) <= k:
                ans += 1
    print(ans)
    return

#C
def C():
    sx, sy, tx, ty = LI()
    UD = ("U", "D")
    LR = ("R", "L")
    ans = UD[sy > ty] * (abs(sy - ty)) + LR[sx > tx] * (abs(sx - tx))
    ans += UD[ty > sy] * (abs(sy - ty)) + LR[tx > sx] * (abs(sx - tx))
    ans += LR[tx > sx] + UD[sy > ty] * (abs(sy - ty) + 1) + LR[sx > tx] * (abs(sx - tx) + 1) + UD[ty > sy]
    ans += LR[sx > tx] + UD[ty > sy] * (abs(sy - ty) + 1) + LR[tx > sx] * (abs(sx - tx) + 1) + UD[sy > ty]
    print(ans)
    return

#D
def D():
    def dij(s):
        dist = [inf for i in range(n)]
        dist[s] = 0
        q = [[0, s]]
        while q:
            d, f = heappop(q)
            for t, cost in edg[f]:
                if d + cost < dist[t]:
                    dist[t] = d + cost
                    heappush(q, [dist[t], t])
        return dist
    n, m = LI()
    ans = defaultdict(int)
    edg = defaultdict(list)
    for _ in range(m):
        a, b, c = LI_()
        c += 1
        edg[a].append((b, c))
        edg[b].append((a, c))
        ans[(a, b)] = False
        ans[(b, a)] = False
    for i in range(n):
        dis = dij(i)
        q = deque()
        q.append(i)
        while q:
            f = q.popleft()
            for t, cost in edg[f]:
                if dis[t] - dis[f] == cost:
                    ans[(t, f)] = True
                    q.append(t)
    ans = list(ans.values())
    print(ans.count(False) // 2)
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 52700
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yn(int o){
    if (o == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

int main() {
    int a, b, c, k; cin >> a >> b >> c >> k;
    int cnt = 0;
    while (a >= b){
        b *= 2;
        cnt++;
    }
    while (b >= c){
        c *= 2;
        cnt++;
    }
    if (cnt <= k) yn(1);
    else yn(0);
}

Measured memory_bytes: 3640
import math
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
ans = 0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans += math.gcd(i,math.gcd(j,k) )

print(ans)

Measured memory_bytes: 68864
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long


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

    int n; cin >> n;
    vector<int> x(n);
    for(int i = 0;i < n;i ++) cin >> x.at(i);

    vector<int> y(n);
    for(int i = 0;i < n;i ++){
        y.at(i) = x.at(i);
    }
    sort(y.begin(),y.end());

    int a = y.at(n/2 - 1),b = y.at(n/2);

    for(int i = 0;i < n;i ++){
        if(x.at(i) >= b) cout << a << endl;
        else cout << b << endl;
    }
}

Measured memory_bytes: 5376
#include <stdio.h>

int main (void)
{
    int N, p[10000];
    int i, ans = 0, max = 0;

    scanf("%d", &N);

    for (i = 0; i < N; i++) {
        scanf("%d", &p[i]);
        ans += p[i];
        if (p[i] > max) max = p[i];
    }

    ans -= max / 2;

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

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;

int n;
int dist[101][101];
int atk[101][101];
int memo[101][101]; //memo[i][j] : ??????j??§?????????i???????????¨??????????°??\???\?????°
const int INF = 1000000000;

struct V{
  int p,m;
  V(int p,int m):p(p),m(m){}
};

bool operator < (const V& a,const V& b){
  return memo[a.p][a.m] > memo[b.p][b.m];
}

int solve(int s,int l){
  for(int i=0;i<=100;++i)
    for(int j=0;j<=100;++j)
      memo[i][j]=INF;
  memo[s][l] = 0;
  priority_queue<V> Q;
  Q.push(V(s,l));

  while(!Q.empty()){
    V x=Q.top(); Q.pop();
    int cur = x.p, mon = x.m, cst=memo[cur][mon];
    for(int i=0;i<n;++i){
      if(dist[cur][i]){
	if(cst+atk[cur][i] < memo[i][mon]){
	  memo[i][mon] = cst+atk[cur][i];
	  Q.push(V(i,mon));
	}
	if(mon-dist[cur][i]>=0){
	  if(memo[i][mon-dist[cur][i]] > cst){
	    memo[i][mon-dist[cur][i]] = cst;
	    Q.push(V(i,mon-dist[cur][i]));
	  }
	}
      }
    }
  }

  int ret = INF;
  for(int i=0;i<=l;++i) ret = min(ret, memo[n-1][i]);
  return ret;
}
int main(){
  int m,l;
  while(cin>>n>>m>>l,n||m||l){
    memset(dist,0,sizeof(dist));
    memset(atk,0,sizeof(atk));
    while(m--){
      int a,b,d,e;
      cin >> a >> b >> d >> e;
      a--;b--;
      dist[a][b] = dist[b][a] = d;
      atk[a][b] = atk[b][a] = e;
    }
    cout<<solve(0,l)<<endl;
  }
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/11/29  Problem: 080_arc_b / Link: https://arc080.contest.atcoder.jp/tasks/arc080_b ----- */
/* ------問題------

-----問題ここまで----- */
/* -----解説等-----

C++ では&の意味さん…

----解説ここまで---- */

LL H, W, N;
inline void next(int &y, int &x) {
	if (y % 2 == 0) {
		if (x == W - 1) { y++; }
		else { x++; }
	}
	else { // % 2 ==1
		if (x == 0) { y++; }
		else { x--; }
	}
}

void dosukoi(VVI &masu, VI &a) {
	int y = 0, x = 0, id = 0;
	FOR(i, 0, H) {
		FOR(j, 0, W) {
			while (a[id] == 0)id++;
			masu[y][x] = id + 1;
			a[id]--;
			next(y, x);
		}
	}
}


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

	cin >> H >> W >> N;
	VI a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	VVI masu(H, VI(W, 0));

	dosukoi(masu, a);

	FOR(i, 0, H) {
		FOR(j, 0, W) {
			cout << masu[i][j] << (j != W - 1 ? ' ' : '\n');
		}
	}

	return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(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};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n;
vector<int> to[1000000];
int id[1000][1000];
int toId(int i, int j) {
  if(i > j) swap(i, j);
  return id[i][j];
}

bool visited[1000000];
bool caled[1000000];
int dp[1000000];
int dfs(int v) {
  if(visited[v]) {
    if(!caled[v]) return -1;
    return dp[v];
  }

  visited[v] = true;
  dp[v] = 1;
  for(int u : to[v]) {
    int res = dfs(u);
    if(res == -1) return -1;
    dp[v] = max(dp[v], res + 1);
  }
  caled[v] = true;
  return dp[v];
}

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

  cin >> n;
  vector<vector<int>> a(n, vector<int>(n - 1));

  REP(i, n) REP(j, n - 1) {
    cin >> a[i][j];
    a[i][j]--;
  }
  int v = 0;

  REP(i, n) REP(j, n) {
    if(i < j) id[i][j] = v++;
  }

  REP(i, n) {
    REP(j, n - 1) {
      a[i][j] = toId(i, a[i][j]);
    }
    REP(j, n - 2) {
      to[a[i][j + 1]].push_back(a[i][j]);
    }
  }
  int ans = 0;
  REP(i, v) {
    int res = dfs(i);
    if(res == -1) {
      cout << -1 << endl;
      return 0;
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
}


Measured memory_bytes: 53464
#include <iostream>
#include <limits.h>
#include <cstdio>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define MOD1 1000000007;
#define MOD2 1000007
using namespace std;
  
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/* ここからが本編 */
/*  */
ull pow(ull x,ull n) {
  ull res = 1;
  while(n > 0) {
    if(n&1) res = res * x;
    x = x * x;
    n >>= 1;
  }
  return res;
}
int dic_op(char str[14],int& key)
{
  int j;
  int f = 1;
  int g = 0;
  for(j = 0;j<10;j++) {
    if(str[j] == 'A')
      g += f * 1;
    else if(str[j] == 'C')
      g += f * 2;
    else if(str[j] == 'G')
      g += f * 3;
    else if(str[j] == 'T')
      g += f * 4;
    else break;
    f *= 5;
  }
  key = 0;
  if(j == 10) {
    f = 1;
    for(;j<10;j++) {
      if(str[j] == 'A')
        key += f * 1;
      else if(str[j] == 'C')
        key += f * 2;
      else if(str[j] == 'G')
        key += f * 3;
      else if(str[j] == 'T')
        key += f * 4;
      else break;
        f *= 5;
    }
  }
  return g;
}
int main()
{
  int i;

  static int dic[10000000];
  int n;
  char opstr[7];
  char str[13];
  int key;
  cin >> n;
  for (i = 0; i < n; i++) {
    scanf("%s %s",opstr,str);
    if(opstr[0] == 'i') {
      int tmp = dic_op(str,key);
      if( (dic[tmp] >> key) % 2 == 0) {
        dic[tmp] += 1 << key;
      }
    }
    else if(opstr[0] == 'f') {
      int tmp = dic_op(str,key);
      /*
      printf("tmp = %d\n",tmp);
      printf("key = %d\n",key);
      printf("dic[tmp] = %d\n",dic[tmp]);
      */
      if( (dic[tmp] >> key) % 2 == 1) {
        puts("yes");
      }
      else {
        puts("no");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 39168
from collections import deque

n = int(input())
a = [int(v) for v in input().split()]

b = deque()

for i in range(n):
    if i % 2 == 0:
        b.appendleft(a[i])
    else:
        b.append(a[i])

if n % 2 == 0:
    b = reversed(b)

print(' '.join([str(v) for v in b]))

Measured memory_bytes: 29124
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int X,Y,A,B,C; cin >> X >> Y >> A >> B >> C;
    vector<ll> p(A),q(B),r(C);
    rep(i,A) cin >> p[i];
    rep(i,B) cin >> q[i];
    rep(i,C) cin >> r[i];

    sort(all(p)); reverse(all(p));
    sort(all(q)); reverse(all(q));
    sort(all(r)); reverse(all(r));
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    rep(i,X) pq.emplace(p[i]);
    rep(i,Y) pq.emplace(q[i]);
    rep(i,C) {
        if (pq.top() < r[i]) {
            pq.pop();
            pq.emplace(r[i]);
        }
    }
    ll ans = 0;
    while (!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }

    cout << ans << ln;
}



Measured memory_bytes: 4852
#include <iostream>
#include<vector>
#include<stdio.h>
#include <algorithm>
#include <functional>

#define FOR(i,n) for(int i=0;i<n;i++)
#define SORT(v,n) std::sort(&v[0],&v[n])
#define INF 999999999
#define mod 1000000007

using namespace std;

int main(){

	int n;
	//std::sort(__first, __last)
	cin >> n;

	vector<int> cards(n);

	FOR(i,n){
		cin >> cards[i];
	}
	SORT(cards,n);

	FOR(i,n){
		//cout << i << ":" << cards[i] <<endl;
	}

	int rec=cards[0];
	int dup=0;
	for(int i=1;i<n;i++){
		if(rec==cards[i]){
			dup++;
		}
		rec=cards[i];
	}
	if(dup%2==0){
		cout << n-dup << endl;
	}else{
		cout << n-dup -1 << endl;
	}


}

Measured memory_bytes: 640
D, G = map(int, input().split())
L=[0]+[list(map(int, input().split())) for i in range(D)]

def dfs(i, g):
    #print("dfs({},{})".format(i, g))
    # 終了条件
    if i == 0:
        return 10 ** 9
    # 解く問題数
    c = min(g//(i*100), L[i][0])
    n = 100 * i *c
    # 全問といたらボーナス
    if c == L[i][0]:
        n += L[i][1]
    # 点数が足りない場合はその次の問題も考える
    if n < g:
        c += dfs(i-1, g-n)
    # その次の問題以降だけでも条件を満たせるか
    return min(c, dfs(i-1, g))

print(dfs(D, G))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
ll a,b,k;
int main(){
	cin>>a>>b>>k;
	ll a1=a;
	a1=max(0ll,a-k);
	k=max(0ll,k-a);
	b=max(0ll,b-k);
	cout<<a1<<" "<<b;
	re 0;
}


Measured memory_bytes: 256
//
// Created by bytedance on 2020/4/10.
//


#include <bits/stdc++.h>

using namespace std;
const int maxn = 200005;
int a[maxn];

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    int mx = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%d", a + i);
        mx = max(mx, a[i]);
    }
    int l = 1, r = mx;
    int ans = mx;
    while (l <= r) {
        int mid = (l + r) >> 1;
        long long tmp = 0;
        for (int i = 1; i <= n; i++) {
            tmp += (a[i] + mid - 1) / mid - 1;
        }
        if (tmp <= k) {
            ans = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 4472
Scanf.scanf "%d %d" (fun n x ->
    let total = Array.make (n + 1) 0 in
    let patty = Array.make (n + 1) 0 in
    total.(0) <- 1;
    patty.(0) <- 1;
    for i = 1 to n do
        total.(i) <- 2 * total.(i - 1) + 3;
        patty.(i) <- 2 * patty.(i - 1) + 1;
    done;

    let rec eat level rest =
        if level = 0 then min rest 1 else
        if rest <= 1 then 0 else
        if rest <= 1 + total.(level - 1) then eat (level - 1) (rest - 1) else 
        if rest <= 2 + total.(level - 1) then patty.(level - 1) + 1 else
            patty.(level - 1) + 1 + eat (level - 1) (rest - 2 - total.(level - 1))
    in
    eat n x |> Printf.printf "%d\n"
)

Measured memory_bytes: 3844
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <queue>

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

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
const int dy[] = {1, 0};
const int dx[] = {0, 1};
#define debug(x) cout << #x << ": " << x << endl

int H, W;
int solve(const vector<string> &field)
{
    priority_queue<PP, vector<PP>, greater<PP>> que;
    vector<vector<int>> cost(H, vector<int>(W, INF));
    que.push(PP(0, P(0, 0)));
    cost[0][0] = 0;
    while(que.size())
    {
        PP p = que.top(); que.pop();
        P v = p.second;
        for(int i = 0; i < 2; i++)
        {
            int ny = v.first + dy[i];
            int nx = v.second + dx[i];
            if(ny < 0 or nx < 0 or ny >= H or nx >= W) continue;
            if(cost[v.first][v.second] + (field[ny][nx] - '0') < cost[ny][nx])
            {
                cost[ny][nx] = cost[v.first][v.second] + (field[ny][nx] - '0');
                que.push(PP(cost[ny][nx], P(ny, nx)));
            }
        }
    }
    return cost[H - 1][W - 1];
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    vector<string> field(H);
    for(int i = 0; i < H; i++) cin >> field[i];
    cout << solve(field) << endl;
    return 0;
}




Measured memory_bytes: 3256
#include<stdio.h>

int main()
{
	int n,a[50],b[50],c[50],i,sum=0;
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	
	for(i=0;i<n;i++)
	{
	    scanf("%d",&b[i]);
	    sum+=b[i];
	}
	
	for(i=0;i<n-1;i++)
	scanf("%d",&c[i]);
	
	for(i=1;i<n;i++)
	{
		if(a[i]-a[i-1]==1)
		{
			sum+=c[a[i-1]-1];
		}
	}
	
	printf("%d\n",sum);
	
	return 0;
}
	
	

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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 100+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int f[maxn][maxn],n,m;
char s[maxn][maxn];

int main() {
    read(n),read(m);
    for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
    memset(f,63,sizeof f);f[1][1]=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++) {
            f[i][j]=min(f[i][j],f[i-1][j]+(i>0&&s[i-1][j]!=s[i][j]));
            f[i][j]=min(f[i][j],f[i][j-1]+(j>0&&s[i][j-1]!=s[i][j]));
        }
    write((f[n][m]+(s[1][1]=='#')+(s[n][m]=='#'))/2);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int n;
  cin >> n;
  
  ll sum = 0;
  const int NMAX = 2000*2000+1;
  bitset <NMAX>b;
  b[0] = 1;
  
  REP(i,n){
    int a;
    cin >> a;
    sum += a;
    b |= b << a;
  }
  
  FOR(i,(sum+1)/2,NMAX){
    if(b[i]){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  vector<string> div = {"dream","dreamer","erase","eraser"};
  reverse(S.begin(),S.end());
  for (x:div){
    reverse(x.begin(),x.end());
  }
  bool can = false;
  for (int i = 0; i < S.size();){
    bool can2 = false;
    can =  false;
    for (x: div){
      if(S.substr(i,x.size()) == x){
        can2 = true;
        i+=x.size();
      }
    }
    if(!can2)break;
   
    can = true;
  }
  
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
 
  return 0;
}

Measured memory_bytes: 512