akhauriyash/Code-Regression huggingface dataset:
def main():
    from itertools import accumulate
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    sumA = sum(A)

    def enum_divisors(n):
        # 約数列挙
        divs = []
        for i in range(1, n+1):
            if i*i > n:
                break
            if n % i == 0:
                divs.append(i)
                if n//i != i:
                    # i が平方数でない
                    divs.append(n//i)
        return divs

    divs = enum_divisors(sumA)
    divs.sort(reverse=True)

    for d in divs:
        if d == 1:
            print(d)
            return
        diff_n = [a % d for a in A if a % d != 0]
        diff_n.sort()
        diff_p = [d - dn for dn in diff_n]
        S_n = list(accumulate([0] + diff_n))
        S_p = list(accumulate([0] + diff_p))
        M = len(S_n) - 1
        if min(S_n[i] for i in range(1, M)
               if (S_n[i] - (S_p[M] - S_p[i])) == 0) <= K:
            print(d)
            return


if __name__ == '__main__':
    main()


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

int main(){
	int n=5, a[n], k, i, j;
	for(i=0; i<n; i++){
		cin >> a[i];
	}cin >> k;
	
	for(j=0; j<n; j++){
		for(i=0; i<j; i++){
			if(abs(a[i]-a[j])>k){//NG
				cout << ":(" << endl;
				return 0;
			}
		}
	}
	cout << "Yay!" << endl;
	return 0;
}


Measured memory_bytes: 256
s=input()
k=int(input())
ms=min(s)
l=[]
for i in range(len(s)):
    if s[i]==ms:
        for j in range(1,k+1):
            l.append(s[i:i+j])
l=list(set(l))
if len(l)<k:
    ls=list(set(s))
    ls.sort()
    ms=ls[1]
    for i in range(len(s)):
        if s[i]==ms:
            for j in range(1,k+1):
                l.append(s[i:i+j])
            l=list(set(l))
    if len(l)<k:
        ms=ls[2]
        for i in range(len(s)):
            if s[i]==ms:
                for j in range(1,k+1):
                    l.append(s[i:i+j])
                l=list(set(l))
l.sort()
print(l[k-1])

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

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pll;

#define mp make_pair
#define pb push_back
#define fir first
#define sec second

#define fo0(i,a,b) for(int i=(a);i<(b);i++)
#define fo1(i,a,b) for(int i=(a);i<=(b);i++)
#define fd0(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define fd1(i,a,b) for(int i=(a);i>=(b);i--)
#define mset(a,b) memset(a,(b),sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))

#define max(a,b) (a > b ? a : b)
#define min(a,b) (a < b ? a : b)
#define abs(a) (a < 0 ? -a : a)
#define fabs(a) (a < 0 ? -a : 0)

template<typename T> inline void in(T &x){x=0;int fl=1;char ch=getchar();while(ch<'0'||ch>'9')
{if(ch=='-')fl=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}x*=fl;}
template<typename T> void out(T x){if(x<0){putchar('-');x=-x;}if(x/10)out(x/10);putchar(x%10+'0');}
template<typename T> inline void outln(T x){out(x);putchar(10);}
template<typename T> inline void outsp(T x){out(x);putchar(' ');}
template<typename T> inline T gcd(T a, T b){T t;if(a>b){while(b){
t=b;b=a%b;a=t;}return a;}else{while(a){t=a;a=b%a;b=t;}return b;}}
template<typename T> inline T lcm(T a, T b){return a/gcd(a,b)*b;}

const int N = 100005;

int n, a[N], sum[N];

LL c[N<<1];
inline int lowbit(int x){ return x & -x; }
inline void add(int x){
	while(x <= 2e5){
		c[x]++;
		x += lowbit(x);
	}
}
inline LL query(int x){
	LL res = 0;
	while(x){
		res += c[x];
		x -= lowbit(x);
	}
	return res;
}

int main(){
	in(n);
	int L = 1e9, R = 0;
	fo1(i, 1, n){
		in(a[i]);
		L = min(L, a[i]);
		R = max(R, a[i]);
	}
	while(L <= R){
		int mid = (L + R) >> 1;
		LL cnt = 0;
		mset(c, 0);
		sum[0] = 0;
		fo1(i, 1, n)	sum[i] = sum[i-1] + (a[i] >= mid ? 1 : -1);
		fo1(i, 0, n){
			cnt += query(sum[i]+1e5);
			add(sum[i]+1e5);
		}
		if(cnt >= 1ll * n * (n + 1) / 4)	L = mid + 1;
		else	R = mid - 1;
	}
	outln(R);
	return 0;
}

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
 
#define int long long
 
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
struct person {
    int A, B, C;
};
 
int X, Y, Z;
person p[100000];
int ans_XY[100000] = {}, ans_XZ[100000] = {};
 
signed main() {
    cin >> X >> Y >> Z;
    for (int i = 0; i < X + Y + Z; i++) {
        cin >> p[i].A >> p[i].B >> p[i].C;
    }
    sort(p, p + X + Y + Z, [](person l, person r) {
        return l.B - l.C > r.B - r.C;
    });
    auto c_XY = [](int l, int r) {
            return p[l].B - p[l].A > p[r].B - p[r].A;
        };
    auto c_XZ = [](int l, int r) {
            return p[l].C - p[l].A > p[r].C - p[r].A;
        };
    priority_queue<int, vector<int>, decltype(c_XY)> pq_XY(c_XY);
    priority_queue<int, vector<int>, decltype(c_XZ)> pq_XZ(c_XZ);
    for (int i = 0; i < Y; i++) {
        pq_XY.push(i);
        ans_XY[Y - 1] += p[i].B;
    }
    for (int i = X + Y + Z - 1; i >= X + Y; i--) {
        pq_XZ.push(i);
        ans_XZ[X + Y] += p[i].C;
    }
    for (int i = Y; i < X + Y; i++) {
        pq_XY.push(i);
        ans_XY[i] = ans_XY[i - 1] + p[i].B - p[pq_XY.top()].B + p[pq_XY.top()].A;
        pq_XY.pop();
    }
    for (int i = X + Y - 1; i >= Y; i--) {
        pq_XZ.push(i);
        ans_XZ[i] = ans_XZ[i + 1] + p[i].C - p[pq_XZ.top()].C + p[pq_XZ.top()].A;
        pq_XZ.pop();
    }
    int ans = 0;
    for (int i = Y - 1; i < X + Y; i++) {
        ans = max(ans, ans_XY[i] + ans_XZ[i + 1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(), B = sc.nextInt();
    System.out.println(((A - B) % 2 == 0) ? (A + B) / 2 : "IMPOSSIBLE");
  }
}

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

typedef long long ll;

int n,k;
int h[200005];
ll ans;

int main(){

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

    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>h[i];
    sort(h,h+n);
    for(int i=0;i<n-k;i++){
        ans+=h[i];
    }
    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin>>n;
	bool flag=false;
	while(n!=0){
		if(n%10==7){
			flag=true;
			break;
		}
		n/=10;
	}
	if(flag){cout<<"Yes";}
	else{cout<<"No";}
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    cout << ((s[2] == s[3] && s[4] == s[5]) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

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

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
class Range {
    using T = long long;
    class Iterator {
        T val, step, diff;
    public:
        Iterator(T v, T s, T d): val(v), step(s), diff(d) {}
        T operator*() { return val + diff; }
        bool operator!=(const Iterator &itr) { return step > 0 ? val < itr.val : val > itr.val; }
        Iterator operator++() { val += step; return *this; }
    };
    Iterator _begin, _end;
public:
    Range(T b, T e, T s, T d): _begin(b, s, d), _end(e, s, d) {
        if (s < 0) { _begin = Iterator(e - 1, s, d); _end = Iterator(b - 1, s, d); }
    }
    Range(T b, T e, T s): Range(b, e, s, 0) {}
    Range(T b, T e): Range(b, e, 1, 0) {}
    Range(T e): Range(0, e, 1, 0) {}
    Iterator begin() { return _begin; }
    Iterator end() { return _end; }
};
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin, s;
    cout << (s == "ABC" ? "ARC" : "ABC") << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <math.h>
#include<algorithm>
#include <utility>
using namespace std;
int main() {
	double a, b, c, d, e, f, x, y;
	while (cin >> a >> b >> c >> d >> e >> f) {
		x = (e*c - b*f) / (a*e - b*d);
		y = (c*d - a*f) / (-a*e + b*d);
		if (x == -0.000) {
			x = abs(x);
		}
		if (y == -0.000) {
			y = abs(y);
		}
		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 3116
//Littleboy123 Template 1.7
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

//pragmas

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")


typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef unsigned long long int ull;
typedef long double ld;
typedef unsigned long long ull;

const long double pi = acos(-1.0);

#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define TC(n) cout << "Case #" << (n) << ": "
#define DEBUG(x) cout << "DEBUG " << #x << ' ' << x << '\n';
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>

void init(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void infile(){
    freopen("fenwick.in", "r", stdin);
}

void outfile(){
    freopen("fenwick.out", "w", stdout);
}

ll modex(ll a, ll b, ll mod){
    if(b == 0)
        return 1;
    if(b == 1)
        return a;
    ll tmp = modex(a, b/2, mod);
    tmp = (tmp * tmp) % mod;
    if(b & 1)
        tmp = (tmp * a) % mod;
    return tmp;
}

//End of template

int r, c, k;
ll arr[3005][3005];
ll memo[3005][3005][4];

ll dp(ll i, ll j, ll cons){
    if(i == r){
        if(c == j){
            return 0;
        }
        return INT_MIN;
    }
    if(c == j){
        return INT_MIN;
    }
    if(memo[i][j][cons] != -1){
        return memo[i][j][cons];
    }
    ll maks = 0;
    if(i != r-1){
        if(cons != 3){
            maks = max(maks, arr[i][j] + dp(i+1, j, 0));
        }
        maks = max(maks, dp(i+1, j, 0));
    }
    else{
        if(j == c-1){
            if(cons != 3){
                maks = max(maks, arr[i][j]);
            }
        }
    }
    if(j != c-1){
        if(cons != 3){
            maks = max(maks, arr[i][j] + dp(i, j+1, cons+1));
        }
        maks = max(maks, dp(i, j+1, cons));
    }
    return memo[i][j][cons] = maks;
}

int main(){
    init();

    cin >> r >> c >> k;
    FOR(i, 0, 3005){
        FOR(j, 0, 3005){
            arr[i][j] = 0;
            FOR(k, 0, 4){
                memo[i][j][k] = -1;
            }
        }
    }
    int x, y, v;
    FOR(i, 0, k){
        cin >> x >> y >> v;
        arr[x-1][y-1] = v;
    }
    ll ans = dp(0, 0, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 356868
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    string s; cin >> s;
    if(s[0] == s[1] and s[1] == s[2] and s[0] == 'S'){
        cout << 0 << endl;
    }else if(s[0] == s[1] and s[1] == s[2] and s[0] == 'R'){
        cout << 3 << endl;
    }else if(s[0] == 'S' and s[1] == s[2] and s[1] == 'R'){
        cout << 2 << endl;
    }else if(s[2] == 'S' and s[1] == s[0] and s[1] == 'R'){
        cout << 2 << endl;
    }else cout << 1 << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int N;cin >> N;
	for(int h = 1;h <= 3500;h++)for(int n = 1;n <= 3500;n++){
		int ue = N*h*n;
		int shita = 4*h*n - N*n - N*h;
		if(shita == 0)continue;
		if(ue%shita == 0){
			int w = ue/shita;
			if(w >= 1 && w <= 3500){
				cout << n << " " << h << " " << w << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3640
from math import gcd

k=int(input())
l = [[gcd(i,j) for j in range(1, k+1)] for i in range(1, k+1)]

ans = 0
for i in range(k):
    for j in range(k):
        n = l[i][j]
        ans += sum(l[n-1])

print(ans)


Measured memory_bytes: 9380
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int f(int i,int x){
	return i*(100+x)/100;
}

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0) break;
		vi a(101);
		for(int i=0;i<n;i++){
			int q;
			cin>>q;
			for(int j=0;j<q;j++){
				int x;
				cin>>x;
				a[x]++;
			}
		}
		int res=0,mx=0;
		for(int i=1;i<=100;i++) if(a[i]>mx){
			mx=a[i];
			res=i;
		}
		if(mx<m) cout<<0<<endl;
		else cout<<res<<endl;
	}
}


Measured memory_bytes: 3076
#include<iostream>
#include<stdio.h>
int main(){
	int a,b;
		for(a=1;a<10;a++){
			for(b=1;b<10;b++){
				std::cout<<a<<"x"<<b<<"="<<a*b<<std::endl;
				}
			}


  
      return 0;
	}

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

using namespace std;

int main() {
  string S;
  cin >> S;
  int N = S.length();
  vector<int> counts(N, 0);

  int r = 0;
  int l = 0;
  int i = 0;
  while (i < N) {
    while (i < N && S[i] == 'R') {
      i++;
      r++;
    }
    int c = i - 1;
    while (i < N && S[i] == 'L') {
      i++;
      l++;
    }

    counts[c] = (r + 1) / 2 + l / 2;
    counts[c + 1] = (r + l) - counts[c];
    r = 0;
    l = 0;
  }

  for (int i = 0; i < N; i++) {
    cout << counts[i];
    if (i < N - 1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int modinv(Int a, Int m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

Int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}

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

int main() {
    Int N,M;

    cin >> N >> M;

    vector<priority_queue<Int>> cands = vector<priority_queue<Int>>(100000+10);

    rep(i,N){
        Int a,b;
        cin >> a >> b;
        cands[a].push(b);
    }

    Int ans = 0;
    priority_queue<Int> next;

    rep(i,M+1) {
        while(!cands[i].empty()){
            next.push(cands[i].top());
            cands[i].pop();
        }

        if(next.empty()){
            continue;
        }

        ans += next.top();
        next.pop();
    }

    cout << ans << endl;


    return 0;
}

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

int main(){
  string s;
  cin >> s;
  if(s[0] == '7' || s[1] == '7' || s[2] == '7'){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define pll pair<ll,ll>
#define all(x) x.begin(), x.end()
#define ed cout << "\n"
#define vll vector<ll>
#define vpll vector<pll>
#define ar array
#define sz(x) (ll)x.size()                                        
#define NAME ""
bool isFile = 0;
 
typedef long long ll;
typedef long double ld;
 
const ll INF=1e9+1234;                                                   
const int N = 2e5 + 1234; 
const ll MOD=998244353;
const ll mod=1e9+7;                                            
double EPS = 3e-18;
const double PI = acos(-1);  
 
 
void faster()
{
	if(isFile)
	{
		freopen(NAME".in","r",stdin);
		freopen(NAME".out","w",stdout);
	}
	ios_base::sync_with_stdio(false);                                                
    cin.tie(NULL);                                         
    cout.tie(NULL);                                
}
		 

void solve() 
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	c = ceil(1.0 * c/b);
	a = ceil(1.0 * a/d);
	if(c <= a)
		cout << "Yes";
	else
		cout << "No";	 			  														     	 	
}
            
                           
int main()                                     
{                            
	faster();                
	int t = 1;
	//cin >> t;	
	while(t--)
	{               	
		solve();
		ed;
	}
	return 0;
}


Measured memory_bytes: 3608
#include<iostream>
using namespace std;
const int sz=50,inf=1e9,sz1=110;

int a[sz],b[sz],c[sz];
int dp[sz][sz1][sz1];

main()
{
    int n,ma,mb;
    cin>>n>>ma>>mb;
    for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
    for(int i=0;i<=n;i++)for(int ca=0;ca<=sz1;ca++)for(int cb=0;cb<=sz1;cb++)dp[i][ca][cb]=inf;

    dp[0][0][0]=0;
    for(int i=0;i<n;i++)
    {
        for(int ca=0;ca<=sz1;ca++)
        {
            for(int cb=0;cb<=sz1;cb++)
            {
                if(dp[i][ca][cb]==inf)continue;
                dp[i+1][ca     ][cb     ]=min(dp[i+1][ca][cb],dp[i][ca][cb]);
                dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);
            }
        }
    }

    int ans=inf;
    for(int ca=1;ca<=sz1;ca++)
    {
        for(int cb=1;cb<=sz1;cb++)
        {
            if(ca*mb==cb*ma)ans=min(ans,dp[n][ca][cb]);
        }
    }
    if(ans==inf)ans=-1;
    cout<<ans<<endl;
    return 0;
}
            

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
ll k,t;
cin>>k>>t;
ll time[t];
for (ll i = 0;i<t;i++){
    cin >> time[i];
}
sort(time, time + t);
ll ans = max(0LL, time[t - 1] - 1 - k + time[t - 1]);
cout << ans << endl;
}

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


public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int L = scan.nextInt();
        String chk;
        String str[] = new String[N];
        String ans = "";


        for(int i=0; i<N; i++){
            chk = scan.next();
            //文字列の長さの判定
            if(chk.length() == L){
                str[i] = chk;
            }else{
                System.out.println("error");
                i--;
            }

        }
        Arrays.sort(str);
        for(int i=0; i<N; i++){
            ans = ans + str[i];
        }
    System.out.println(ans);
    }
}


Measured memory_bytes: 13648
/******************************************
* AUTHOR : Lokesh goel*
* NICK : InsaneNerd *
* INSTITUTION : NIT Kurukshetra *
******************************************/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1000000000
#define N 100005
#define pii pair<int,int>
#define vp vector<pair<int,int > >
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define gsz(x) ((int)(x).size())
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
#define endl "\n"
#define ms(x,v) memset(x,v,sizeof(x))

int main()
{
	fastio;
	ll n,i,j,a[200001];
	map<ll,ll>m1;
	cin>>n;
	for(i=2;i<=n;i++){
		cin>>a[i];
		if(a[i]<i)
			m1[a[i]]++;
	}
	for(i=1;i<=n;i++){
		cout<<m1[i]<<endl;
	}
	//cout<<endl;

	return 0;
}

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=998244353;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int n;
int a[maxn],b[maxn];
int maxx=-1;

int ppow(int x,int y)
{
    if (y==0) return 1;
    int ret=ppow(x,y/2);
    ret=ret*ret%mod;
    if (y&1) ret=ret*x%mod;
    return ret;
}

int32_t main()
{
    IOS
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
        if (i==1&&a[i]!=0) return cout<<0<<endl,0;
        if (i!=1&&a[i]==0) return cout<<0<<endl,0;
        maxx=max(maxx,a[i]);
        b[a[i]]++;
    }

    int ans=1;
    for (int i=1;i<=maxx;i++)
    {
        if (b[i]==0) return cout<<0<<endl,0;
        ans=(ans*ppow(b[i-1],b[i]))%mod;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
# ifdef DEB
# define debug(...) fprintf(stderr, __VA_ARGS__)
# else
# define debug(...)
#endif
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LL long long
#define LD long double
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define pb pop_back
#define VI vector<int> 
#define VPI vector<PII> 
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define FORD(i,a,b) for(int i = (a); i >= (b); i--)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define ALL(x) (x).begin(), (x).end()
#define siz(V) ((int)V.size())

//int mex[105][105];

int main()
{
  //ios_base::sync_with_stdio(0);
  /*for (int s = 0; s < 100; s++)
  {
    for (int i = 0; i <= s; i++)
    {
      vector<int> V;
      for (int k = 1; 2 * k <= i; k++)
      {
        V.PB(mex[i - 2 * k][s - i + k]);
      }
      for (int k = 1; 2 * k <= s - i; k++)
      {
        V.PB(mex[i + k][s - i - 2 * k]);
      }
      sort(ALL(V));
      if (V.empty())
      {
        continue;
      }
      int ind = 0;
      for (int k = 0; k < siz(V) + 1; k++)
      {
        while (ind < siz(V) && V[ind] < k)
        {
          ind++;
        }
        if (ind == siz(V) || V[ind] > k)
        {
          mex[i][s - i] = k;
          break;
        }
      }
    }
  }*/
  LL a, b;
  scanf("%lld%lld", &a, &b);
  if (abs(a - b) < 2)
  {
    printf("Brown\n");
  }
  else
  {
    printf("Alice\n");
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            //

            var S = new string(GetStr().ToCharArray().OrderBy(c => c).ToArray());
            var T = new string(GetStr().ToCharArray().OrderByDescending(c => c).ToArray());
            var ans = YesNo(S.CompareTo(T) < 0);

            Console.WriteLine(ans);

            //
            Console.Out.Flush();
            Console.ReadKey();
        }

        static void Solve()
        {

        }

        static long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c, out V d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<V>(ar[3]);
        }
    }
}

Measured memory_bytes: 13536
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
//    freopen("in.txt", "r", stdin);
    int n,m;
    scanf("%d%d", &n, &m);
    LL ans = m*1900 + (n-m) *100;
    int mul = 1;
    for (int i = 1; i <= m; ++i)  mul <<= 1;
    printf("%lld\n", ans * mul);
    return 0;
}


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

const int maxn(1e5 + 5);

int n, a[maxn];
ll ans, ret;

int main() {
	scanf("%d", &n);
	register int i, l, r, j, mx;
	for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1), l = r = a[1], i = 2, j = n;
	while (i <= j) {
		mx = max(max(abs(a[j] - r), abs(a[j] - l)), max(abs(a[i] - r), abs(a[i] - l)));
		if (abs(a[j] - l) == mx) ans += abs(a[j] - l), l = a[j--];
		else if (abs(a[j] - r) == mx) ans += abs(a[j] - r), r = a[j--];
		else if (mx == abs(a[i] - l)) ans += abs(a[i] - l), l = a[i++];
		else ans += abs(a[i] - r), r = a[i++];
	}
	reverse(a + 1, a + n + 1), l = r = a[1], i = 2, j = n;
	while (i <= j) {
		mx = max(max(abs(a[j] - r), abs(a[j] - l)), max(abs(a[i] - r), abs(a[i] - l)));
		if (abs(a[j] - l) == mx) ret += abs(a[j] - l), l = a[j--];
		else if (abs(a[j] - r) == mx) ret += abs(a[j] - r), r = a[j--];
		else if (mx == abs(a[i] - l)) ret += abs(a[i] - l), l = a[i++];
		else ret += abs(a[i] - r), r = a[i++];
	}
	printf("%lld\n", max(ans, ret));
    return 0;
}

Measured memory_bytes: 640
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::vector<int> D;
	std::cin >> N;
	D.resize(N);
	for (auto& d : D) {
		std::cin >> d;
	}
	std::set<int> S;
	for (auto d : D) {
		S.insert(d);
	}
	std::cout << S.size() << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

const int N = 200007;

int n;
long long a[N], minDiff;

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

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

  minDiff = numeric_limits<long long>::max();

  for(i=0;i<=n;i++) {
    minDiff = min(minDiff, abs(a[n] - a[i] * 2));
  }

  cout<<minDiff<<endl;

  return 0;
}


Measured memory_bytes: 1792
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]

a, b, c = [0], [0], [0]
for i in abc:
  aa = i[0] + max(b[-1], c[-1])
  bb = i[1] + max(c[-1], a[-1])
  cc = i[2] + max(a[-1], b[-1])
  a.append(aa)
  b.append(bb)
  c.append(cc)
print(max(a[-1], b[-1], c[-1]))

Measured memory_bytes: 42240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    string s; cin >> s;
    char op[2] = {'+','-'};
    int ans;
    bool check = false;
    for (int i = 0; i < 2; i++){
        for (int j = 0; j < 2; j++){
            for (int k = 0; k < 2; k++){
                ans = s[0] - '0';
                if (op[i] == '+') ans += s[1] - '0';
                else ans -= s[1] - '0';
                if (op[j] == '+') ans += s[2] - '0';
                else ans -= s[2] - '0';
                if (op[k] == '+') ans += s[3] - '0';
                else ans -= s[3] - '0';
                if (ans == 7){
                    check = true;
                    cout << s[0] << op[i] << s[1] << op[j] << s[2] \
                    << op[k] << s[3] << '=' << '7' << endl;
                    break;
                }
            }
            if (check) break;
        }
        if (check) break;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector <int > a;
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    int al=0;
    int bob=0;
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(int i=0;i<n;i++){
        if(i%2==0){
            al += a[i];
        }
        else{
            bob += a[i];
        }
    }
    cout << al-bob << endl;
    return 0;
 }

Measured memory_bytes: 256
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
a = Counter(v[::2])
b = Counter(v[1::2])
if len(set(v)) == 1:
    print(n // 2)
elif a.most_common()[0][0] != b.most_common()[0][0]:
    print(n - a.most_common()[0][1] - b.most_common()[0][1])
elif len(a) < 2 and len(b) > 1:
    print(n // 2 - a.most_common()[1][1])
elif len(a) > 1 and len(b) < 2:
    print(n // 2 - b.most_common()[1][1])
else:
    print(
        min(n - a.most_common()[0][1] - b.most_common()[1][1],
            n - a.most_common()[1][1] - b.most_common()[0][1]))


Measured memory_bytes: 22336
N, M = map(int, input().split())
demand = []

for _ in range(M):
    a, b = map(int, input().split())
    demand.append((a,b))

demand = sorted(demand, key=lambda x: x[1])
count = 0
bridge = None

for d in demand:
    if bridge == None or bridge < d[0]:
        bridge = d[1] - 1
        count += 1

print(count)


Measured memory_bytes: 18960
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second
using ll = long long;
using P = pair<ll ,ll>;
using Tu = tuple<ll, ll, ll>;
const ll INFLL = 1LL<<60LL;
const ll INF = 1LL<<60LL;
const ll MOD = 1e9+7;
using ld = long double;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

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

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

int main(){
  ll N;
  string s;
  cin >> N >> s;
  ll ans =1;
  ll cnt = 0;
  bool ok = true;
  for(int i=0;i<s.size();i++){
    
    if((cnt % 2 && s[i] == 'W') || (cnt % 2 == 0 && s[i] == 'B')){
      cnt++;
    }else{
      ans = ans * cnt % MOD;
      cnt--;
      if(cnt < 0)
	ok = false;
    }
  }
  vector<ll> fact(N+1, 1);
  for(ll i=2;i<=N;i++)
    fact[i] = fact[i-1] * i % MOD;
  if(ok && cnt == 0)
    cout << ans * fact[N] % MOD << endl;
  else
    cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 1412
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;

const int NMax = 100000 + 10;
const int mod = 1000000007;

long long N,M;

int main() {

    cin>>N>>M;
    long long sol=0;

    if (2*N>=M) {
        sol = M/2;
    }
    else {
        sol = N;
        M = M - 2*N;
        sol += M/4;
    }
    cout<<sol;

    return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};

ll MOD = 998244353;


int main() {
    int n; cin >> n;
    map<ll,int> mp;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n) mp[a[i]]++;

    sort(a.begin(),a.end());
    a.erase(unique(a.begin(),a.end()),a.end());

    int cnt = 0;
    rep(i,a.size()){
        if(mp[a[i]] % 2 != 0) cnt++;
        //cout << "mp[" << a[i] << "]=" << mp[a[i]] << endl;
    }
    cout << cnt << endl;


}


Measured memory_bytes: 10136
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    vector<ll> costs(3);
    for (auto && i: irange(0LL, 3LL)){
        cin >> costs.at(i);
    }
    ll minim = numeric_limits<ll>::max();
    do {
        minim = min(minim, abs(costs.at(0)-costs.at(1)) + abs(costs.at(1)- costs.at(2)));
    } while (next_permutation(costs.begin(), costs.end()));
    cout << minim;
    return 0;
}

Measured memory_bytes: 256
a = int(input())
mx = int(3e5)
num = [1 for _ in range (mx+1)]
import math
limit = int(math.sqrt(mx))
for i in range(2,limit):
    if num[i] == 1:
        cur = 2*i
        while cur < mx:
            num[cur] = 0
            cur+=i
for i in range(a,mx+1):
    if num[i] == 1:
        print(i)
        break


Measured memory_bytes: 5528
from collections import OrderedDict

while True:
    n = int(input())
    if n == 0:
        break
    ans = OrderedDict()
    for i in range(n):
        e, p, q = [int(x) for x in input().split()]
        if e in ans:
            ans[e] += p * q
        else:
            ans[e] = p * q
    flag = True
    for k, v in ans.items():
        if v >= 1000000:
            flag = False
            print(k)
    if flag:
        print('NA')

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

int n;
int x[200000],y[200000];

vector<int>merge(vector<int>&a,vector<int>&b){
	vector<int>res(n);
	rep(i,n){
		res[i]=a[b[i]];
	}
	return res;
}
int main(){
	scanf("%d",&n);
	rep(i,n){
		scanf("%d",&x[i]);
		y[i]=x[i];
		if(i)y[i]-=x[i-1];
	}
	int m;ll K;cin>>m>>K;
	vector<int>v(n);
	rep(i,n)v[i]=i;
	rep(i,m){
		int d;scanf("%d",&d);d--;
		swap(v[d],v[d+1]);
	}
	vector<int>ans(n);
	rep(i,n)ans[i]=i;
	while(K){
		if(K&1){
			ans=merge(ans,v);
		}
		v=merge(v,v);
		K>>=1;
	}
	ll sum=0;
	rep(i,n){
		sum+=y[ans[i]];
		printf("%lld\n",sum);
	}
}

Measured memory_bytes: 3176
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
class MainClass
{
	static void Main(string[] args)
	{
		Answer();
	}
	public static void Answer()
	{
		var N = int.Parse(Console.ReadLine());
            var Arr = ReadLine().Split(' ').Select(int.Parse).OrderByDescending(a=>a).ToArray();
            int Alice = 0;
            int Bob = 0;
            for (int i = 0; i < Arr.Length;i++){
                if (i % 2 == 0)
                    Alice += Arr[i];
                else
                    Bob += Arr[i];
            }
            WriteLine(Alice - Bob);
	}
}

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

#define int long long
int n, x[100005], l, q, test, sparse[100005][19];

int binser(int tmp){
    if(tmp > x[n]) return n + 1;
    int l1 = 1, r = n;
    while(l1 < r - 1){
        int mid = (l1 + r) >> 1;
        if(x[mid] <= tmp) l1 = mid;
        else r = mid;
    }
    if(x[r] <= tmp) l1 = r;
    return l1;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> x[i];
    cin >> l >> q;
    for(int i = 1; i <= n; i++) sparse[i][0] = binser(x[i] + l);
    //for(int i = 1; i <= n; i++) cout << sparse[i][0] << " ";
    cout << endl;
    for(int i = 0; i <= 18; i++) sparse[n + 1][i] = n + 1;
    for(int i = 1; i <= 18; i++){
        for(int j = 1; j <= n; j++){
            sparse[j][i] = sparse[sparse[j][i - 1]][i - 1];
            //cout << sparse[j][i] << " ";
        }
        //cout << endl;
    }
    while(q--){
        int a, b;
        cin >> a >> b;
        if(a > b) swap(a, b);
        int ans = 0;
        for(int i = 18; i >= 0; i--){
            if(sparse[a][i] <= b){
                ans += 1 << i;
                a = sparse[a][i];
            }
        }
        if(a < b) ans++;
        cout << ans << "\n";
    }
}

Measured memory_bytes: 16512
n=input().split()
S=input()
N=int(n[0])
K=int(n[1])
S_list=list(S)
if S[K-1]=="A":
 S_list[K-1]="a"
elif S[K-1]=="B":
 S_list[K-1]="b"
elif S[K-1]=="C":
 S_list[K-1]="c"
S="".join(S_list)
print(S)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define emb emplace_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

inline void setin(string s) {
	freopen(s.c_str(), "r", stdin);
}

inline void setout(string s) {
	freopen(s.c_str(), "w", stdout);
}

template <typename T> inline T range(T l, T r) {
	return uniform_int_distribution <T>(l, r)(rng);
}

template <typename T> void Min(T &a, T b) {
    a = min(a, b);
}

template <typename T> void Max(T &a, T b) {
    a = max(a, b);
}

#define int long long

const int inf = 2e9 + 5;
const int mod = 1e9 + 7;
const int N = 1e6 + 15;
const int X = 12;
int n;
int s[X + 5];
string t;

inline char gc(string s) {
    cout << "? " << s << endl;
    fflush(stdout);
    char c;
    cin >> c;
    return c;
    // int m = 0;
    // for(int i = 0; i < s.size(); ++i)
    //     m = m * 10 + (s[i] - '0');
    // return ((m > n && s > t) || (m <= n && s <= t)) ? 'Y' : 'N';
}


inline string mk(int pos) {
	string k = "";
	for(int i = 0; i <= pos; ++i)
		k += char(s[i] + '0');
	return k;
}

inline bool check(int pos) {
	return gc(mk(X - 1)) == 'N';
}
main() {
    n = 129;
    t = "129";
	// setin("input.txt");
	for(int i = 0; i < X; ++i) {
		int l = (i == 0), r = 9, res = -1;
		while(l <= r) {
			int mid = l + r >> 1;
			s[i] = mid;
			if(check(i))
				l = mid + 1, res = mid;
			else
				r = mid - 1;
		}
		if(res == -1) {
		    s[i] = (i == 0);
		    for(int j = max(0ll, i - 1); j <= X; ++j) {
		    	if(gc(mk(j - 1) + "9") == 'Y') {
		    		if(j != i - 1)
			    		s[j] = (j == 0);
					cout << "! ";
					for(int f = 0; f <= j; ++f)
						cout << s[f];
					cout << endl;
					fflush(stdout);
					return 0;
		    	}
		    }
		    assert(0);
		}
		if(res == 9)
			s[i] = res;
		else {
			s[i] = res + 1;
			if(gc(mk(i)) == 'N')
				s[i] = res;
		}
	}
	cout << "! ";
	for(int j = 0; j < X; ++j)
		cout << s[j];
	cout << endl;
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 596