akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << "," << el.second << "] "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

vector<vector<int>> C;
void input(){
    #ifdef __LOCAL
        fs::path path_to_file = __FILE__;
        fs::path input,output;
        input = output = path_to_file.parent_path();
        input += string("/input/") + string(path_to_file.stem()) + string(".txt");
        output += string("/output/") + string(path_to_file.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    int n=3;
    C.assign(n,vector<int>(n,0));
    REP(i,n) REP(j,n) cin >> C[i][j];
}

int solve(){
    input();
    auto A=C;
    auto B=C;
    REP(i,3) REP(j,3) A[i][j] = C[i][j] - C[(i+1)%3][j];
    REP(i,3) REP(j,3) B[i][j] = C[i][j] - C[i][(j+1)%3];
    bool ans=true;
    REP(i,3) ans &=(A[i][1]==A[i][2])&&(A[i][2]==A[i][0]);
    REP(i,3) ans &=(B[1][i]==B[2][i])&&(B[2][i]==B[0][i]);
    string res = ans?"Yes":"No";
    cout << res << endl;
    return 0;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define LL long long
#define endl '\n'
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a, b, c;
    cin >> a >> b >> c;
    c = c * acos(-1) / 180;
    double s = 0.5 * a * b * sin(c);
    double l = a + b + sqrt(a * a + b * b - 2 * a * b * cos(c));
    double h = 2 * s / a;
    printf("%lf\n%lf\n%lf\n", s, l, h);
    return 0;
}


Measured memory_bytes: 3476
k, a, b = gets.split.map(&:to_i)
ans = 0
if b - a <= 2
  ans = 1 + k
elsif a - 1 > k
  ans = 1 + k
else
  m = (k - (a - 1)) / 2
  ans = a + (b - a) * m + (k - (a - 1)) % 2
end
puts ans


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

#include <math.h>
#include <vector>

#include <algorithm>

#include <string>
#include <iostream>
using namespace std;

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

    int lim=0;
    int kaisuu=0;
    while (lim==0) {
        int hantei=0;
        for (int i=0; i<N; i++) {
            if (A[i]%2==0) {
                A[i]=A[i]/2;
            }
            else{hantei++;}
        }
        if (hantei==0) {
            kaisuu++;
        }
        else{lim++;}
        
    }
    cout<<kaisuu;
 
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

bool is_prime[1000001];
int stage[1101][1101];
int dp[1101][1101];

int main(){
  memset(stage,-1,sizeof(stage));
  int x = 0;
  int y = 0;
  int dir = 1;
  const int offset = 500;
  for(int round = 1; round <= 1000000;round++){
    stage[y+offset][x+offset] = round;

    int prev_dir = dir;
    if(round > 1) dir = (dir + 3) % 4;
    int dx = x + tx[dir];
    int dy = y + ty[dir];
    if(stage[dy+offset][dx+offset] != -1){
      dir = prev_dir;
    }
    dx = x + tx[dir];
    dy = y + ty[dir];
    x = dx;
    y = dy;
  }
  
  memset(is_prime,true,sizeof(is_prime));

  is_prime[0] = false;
  is_prime[1] = false;

  for(int i=2;i*i<=1000000;i++){
    if(is_prime[i]){
      for(int j=i+i;j<=1000000;j+=i){
	is_prime[j] = false;
      }
    }
  }

  int start,total_caves;
  while(~scanf("%d %d",&total_caves,&start)){
    if(total_caves == 0 && start == 0) break;

    int sx=0,sy=0;
    for(int y=0;y<=1000;y++){
      for(int x=0;x<=1000;x++){
	if(stage[y][x]  == start){
	  sx = x;
	  sy = y;
	  break;
	}
      }
    }

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

    int res_prime=0;
    int res_count=0;

    dp[sy][sx] = (int)is_prime[stage[sy][sx]];
    if(is_prime[stage[sy][sx]]){
      res_prime = stage[sy][sx];
      res_count = 1;
    }

    for(int y=sy+1;y<=1000;y++){
      for(int x=0;x<=1000;x++){
	if(stage[y][x] == -1) continue;
	if(stage[y][x] > total_caves) continue;

	int cost = (int)is_prime[stage[y][x]];
	if(dp[y-1][x-1] != -1){
	  dp[y][x] = max(dp[y-1][x-1] + cost,dp[y][x]);
	}
	if(dp[y-1][x] != -1){
	  dp[y][x] = max(dp[y-1][x] + cost,dp[y][x]);
	}

	if(dp[y-1][x+1] != -1){
	  dp[y][x] = max(dp[y-1][x+1] + cost,dp[y][x]);
	}
      }
    }

    for(int y=sy+1;y<=1000;y++){
      for(int x=0;x<=1000;x++){
	if(res_count < dp[y][x]
	   && is_prime[stage[y][x]]){
	  res_count = dp[y][x];
	  res_prime = stage[y][x];
	}
	if(res_count == dp[y][x]
	   && is_prime[stage[y][x]]
	   && res_prime < stage[y][x]){
	  res_prime = stage[y][x];
	}
      }
    }
    printf("%d %d\n",res_count,res_prime);
  }
}

Measured memory_bytes: 11640
a=gets.chomp.chars.map(&:to_i)
s=%w(+ -)
s.each do |op1|
  s.each do |op2|
    s.each do |op3|
      t = a.zip([op1,op2,op3]).join
      (puts t + '=7'; exit(0)) if eval(t) == 7
    end
  end
end


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

typedef long long ll;
using namespace std;

#define REP(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define sum(v) accumulate(ALL(v),0)

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    int b;
    int k;
    cin >> a >> b;
    if((a-b)%2==0){
        cout << (a+b)/2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }



signed main(){
    ll n;
    cin >> n;
    vi cnt(n), a(n);

    rep(i, n){
        ll tmp;
        cin >> tmp;
        --tmp;
        a[i] = tmp;
        cnt[tmp]++;
    }

    /* rep(i, n) cout << a[i] << " ";
    cout << endl;
 */
    ll ans = 0;
    rep(i, n){
        int num = cnt[i];
        ans += num*(num-1)/2;
    }

    rep(i, n){
        ll sub = cnt[a[i]] - 1;
        cout << ans - sub << endl;
    }
}

Measured memory_bytes: 6376
using System;
using System.Text;

namespace _056_Goldbach_sConjecture
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;
			StringBuilder output = new StringBuilder (10000 * 3);

			while ((inputStr = Console.ReadLine ()) != "0")
			{
				int inputNum = int.Parse (inputStr);
				int count = 0;

				bool result = Conjecture.IsConjecture (2, inputNum - 2);
				if (result)
					count++;

				for (int lp = 3; lp <= inputNum / 2; lp += 2)
				{
					bool result2 = Conjecture.IsConjecture (lp, inputNum - lp);
					if (result2)
						count++;
				}

				output.AppendLine (count.ToString ());
			}

			Console.Write (output);
		}
	}

	class Conjecture
	{
		static Conjecture ()
		{
			IsPrimeNumberArray = new bool[50000 + 1];
			IsPrimeNumberArray[2] = true;
			for (int lp = 3; lp <= 50000; lp += 2)
			{
				IsPrimeNumberArray[lp] = IsPrimeNumber (lp);
			}
		}

		private static bool[] IsPrimeNumberArray;

		private static bool IsPrimeNumber ( int num )
		{
			int lp = 3;
			double limit = Math.Sqrt (num);

			while (lp <= limit)
			{
				if (num % lp == 0)
				{
					return false;
				}

				lp += 2;
			}

			return true;
		}

		public static bool IsConjecture ( int num, int num2 )
		{
			return IsPrimeNumberArray[num2] && IsPrimeNumberArray[num];
		}
	}
}

Measured memory_bytes: 9508
#include <iostream>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  int a[n][m];
  for(int i = 0; n > i; i++){
    for(int j = 0; m > j; j++){
      cin>>a[i][j];
    }
  }
  int b[m];
  for(int i = 0; m > i; i++){
    cin>>b[i];
  }
  for(int i = 0; n > i; i++){
    int ans = 0;
    for(int j = 0; m > j; j++){
      ans += b[j]*a[i][j];
    }
    cout << ans << endl;
  }
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    string ABCD; cin >> ABCD;
    int A, B, C, D;
    A = ABCD[0] - '0';
    B = ABCD[1] - '0';
    C = ABCD[2] - '0';
    D = ABCD[3] - '0';

    REP(i, 8)
    {
        int res = 0;
        char op1, op2, op3;
        if(i & (1 << 2))
        {
            res = A+B;
            op1 = '+';
        }
        else 
        {
            res = A-B;
            op1 = '-';
        }
        if(i & (1 << 1))
        {
            res += C;
            op2 = '+';
        }
        else
        {
            res -= C;
            op2 = '-';
        }
        if(i & 1)
        {
            res += D;
            op3 = '+';
        } 
        else 
        {
            res -= D;
            op3 = '-';
        }

        if(res == 7)
        {
            cout << A << op1 << B << op2 << C << op3 << D << "=7" << endl;
            return;
        }
    }
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using ll=long long;

const ll INF = pow(10,18)+1;

#define FOR(i, a, n) for(ll i = (ll)(a); i < (ll)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}
template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}

int main(){
    int N, M;
    cin >> N >> M;
    int A[10];
    int num[9] = {2,5,5,4,5,6,3,7,6};
    REP(i,M) cin >> A[i];
    ll dp[10010];
    dp[0] = 0;
    FOR(i,1,N+1) dp[i] = -INF;
    FOR(i,1,N+1){
        REP(j,M){
            if(i-num[A[j]-1]>=0){
                dp[i] = max(dp[i],dp[i-num[A[j]-1]]+1);
            }
        }
    }
    sort(A,A+M,greater<int>());
    string ans = "";
    int digit_num = dp[N];
    FOR(i,1,digit_num+1){
        REP(j,M){
            if(N-num[A[j]-1] >= 0 && dp[N-num[A[j]-1]]==dp[N]-1){
                ans += to_string(A[j]);
                N -= num[A[j]-1];
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define N 1050
int c[N+1][N+1];
int lcs(string X,string Y){
  memset(c,0,sizeof(0));
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(X[i]==Y[j]) c[i][j]=c[i-1][j-1]+1;
      else c[i][j]=max(c[i-1][j],c[i][j-1]);
      maxl=max(maxl,c[i][j]);
    }
  }
  return maxl;
}
int main(){
  int q;
  cin>>q;
  while(q--){
    string s,t;
    cin>>s>>t;
    cout<<lcs(s,t)<<endl;
  }
  return 0;
}
/*
verified on 2017/04/26
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C
*/

Measured memory_bytes: 7260
// header {{{
// header {{{
#include <bits/stdc++.h>
using namespace std;
 
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
 
#define ASSERT(expr...) assert((expr))
 
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
 
using f32 = float;
using f64 = double;
// }}}
 
constexpr i64 INF = 1'010'000'000'000'000'017LL;
 
constexpr i64 MOD = 1'000'000'007LL;
 
constexpr f64 EPS = 1e-12;
 
constexpr f64 PI = 3.14159265358979323846;
 
#define M5 100007
 
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define ll long long int
#define VI vector <ll>
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
 
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
 
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
 
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}
 
// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
 
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}
 
//--------------------------------------------------------------------
 
 
 
void solve() {
    int K;
    cin >> K;
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[K-1];
}
 
signed main() {
 
    solve();
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
#define pi acos(-1);
ll strtoint(string str);
int main(){
	fast;
	ll v,a,b,x; cin>>a>>b>>x;
	double tantheta,ans;
	v=a*a*b;
	if(2*x<v){
		tantheta=(double)(b*b*a)/(2*x);
		ans=atan(tantheta);
	}else{
		tantheta=(double)(2*b*a*a-2*x)/(a*a*a);
		ans=atan(tantheta);
	}
	ans=ans*180/pi;
	cout<<fixed<<setprecision(10)<<ans<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod
#define AddMult(x, y, z) x = (x + (y) * (z)) % mod



signed main(){

    int N, P; cin >> N >> P;
    vec w(N), b(N), v(N);
    int B = 0;
    REP(i, N){
        cin >> w[i] >> b[i];
        B += b[i];
        v[i] = (100 - P) * w[i] + P * b[i];
    }
    Sort(v);
    Reverse(v);
    int ss = 0, ans;
    REP(i, N){
        ss += v[i];
        if(ss >= P * B){
            ans = i + 1;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
from collections import Counter
import heapq

def is_dup(h):
    for i in h:
        if -i[0] > 1:
            return True
    return False

N = int(input())
A = sorted(list(map(int,input().split(" "))))
c = Counter(A)
heap = [[-value, key] for key, value in c.items()]

if len(set(A)) == len(A):
    print(len(A))
else:
    heapq.heapify(heap)
    while is_dup(heap):
        a = [0,0,0]
        a[0] = heapq.heappop(heap)
        if -a[0][0] >= 3:
            a[0][0] += 2
            if a[0][0] != 0:
                heapq.heappush(heap, a[0])
            continue
        a[1] = heapq.heappop(heap)
        if -a[0][0]-a[1][0] >= 3:
            a[0][0] += 1
            a[1][0] += 1
            if a[0][0] != 0:
                heapq.heappush(heap, a[0])
            if a[1][0] != 0:
                heapq.heappush(heap, a[1])
            continue
        a[2] = heapq.heappop(heap)
    print(len(heap))

Measured memory_bytes: 30540
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] F = new int[n][10];
        int[][] P = new int[n][11];

        for(int i = 0; i<n; i++) {
            for(int j = 0; j<10; j++) {
                F[i][j] = sc.nextInt();
            }
        }
        for(int i = 0; i<n; i++) {
            for(int j = 0; j<11; j++) {
                P[i][j] = sc.nextInt();
            }
        }

        int max = Integer.MIN_VALUE;
        for(int i = 1; i<Math.pow(2,10); i++) {
            int num = i;
            int[] cnt = new int[n];
            int index = 0;
            while(index < 10) {
                int isOpen = num%2;
                for(int j = 0; j<n; j++) {
                    if(F[j][index] == 1 && isOpen == 1) cnt[j]++;
                }
                num /= 2;
                index++;
            }
            int total = 0;
            for(int j = 0; j<n; j++) {
                total += P[j][cnt[j]];
            }
            max = Math.max(max, total);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 27328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		boolean ok = true;
		for(int i=0; i<n; i++) {
			int a=sc.nextInt();
			if(a%2==0) {
				if(a%3 != 0 && a%5 != 0) {
					ok=false;
					break;
				}
			}
		}
		if(ok) {
			System.out.println("APPROVED");
		}else {
			System.out.println("DENIED");
		}
		sc.close();
	}
}


Measured memory_bytes: 22996
N = gets.to_i

keta = N.to_s.length

def build(list,s,n,keta)
  if s.length == keta
    s_n =  s.to_i
    if s_n <= n && s.include?('3') && s.include?('5') && s.include?('7')
      list << s_n
    end
    return
  end
  
  ['3', '5', '7'].each do |ss|
    build(list, s + ss, n, keta)
  end
end


def calc(n)
  3 - 3*(2**n) + 3**n
end

res = 0

(3...keta).each do |i|
  res += calc(i)
end


list = []
build(list, '', N, keta)
res += list.length

p res


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

int main() {
  int n;cin>>n;
  vector<int> item(n);
  for(int i=0;i<n;++i) cin>>item[i];
  sort(item.begin(),item.end(),[&](int x,int y){
    return (x>y);
  });
  item[0] /= 2;
  int sum=0;
  for(int i=0;i<n;++i){
    sum += item[i];
  }
  cout<<sum<<endl;
  return 0;
}

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

struct tile
{
    int row;
    int col;
    bool is_visited;
    bool is_black;
};

tile start;
tile map[20][20];

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

bool valid(int row, int col)
{
    return row >= 0 && row < H && col >= 0 && col < W;
}

int bfs(tile map[20][20])
{
    queue<tile> Q;
    Q.push(start);
    int ans = 0;

    while (!Q.empty())
    {
        ans += 1;
        tile src = Q.front();
        Q.pop();

        for (int i = 0; i < 4; i++)
        {
            int row = src.row + dx[i];
            int col = src.col + dy[i];

            // map の範囲外の場合
            if (!valid(row, col))
            {
                continue;
            }

            if (map[row][col].is_black && !map[row][col].is_visited)
            {
                map[row][col].is_visited = 1;
                Q.push(map[row][col]);
            }
        }
    }

    return ans;
}

int main()
{
    while (cin >> W >> H && W)
    {
        // 入力
        for (int row = 0; row < H; row++)
        {
            for (int col = 0; col < W; col++)
            {
                char c;
                cin >> c;

                if (c == '.')
                {
                    map[row][col] = {row, col, 0, 1};
                }
                else if (c == '@')
                {
                    map[row][col] = {row, col, 1, 1};
                    start = map[row][col];
                }
                else
                {
                    map[row][col] = {row, col, 0, 0};
                }
            }
        }

        // BFS
        cout << bfs(map) << endl;
    }
}


Measured memory_bytes: 3132
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

long long ncr(int a,int b){
    long long combinationans=1;
    for (int i=0; i<b; i++){
        combinationans=combinationans*(a-i)/(i+1);   
    }
    return (combinationans);
}

int sort(const void *a, const void *b){
    if( *(long long int*)a - *(long long int*)b < 0 )
        return 1;
    if( *(long long int*)a - *(long long int*)b > 0 )
        return -1;
    return 0;
}

int main(void){
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    long long v[n],sum=0;
    for (int i=0; i<n; i++){
        scanf("%lld",&v[i]);
    }
    qsort (v,n,sizeof(long long),sort);
    
    for (int i=0; i<a; i++){
        sum+=v[i];
    }
    double ans=(double)sum/(double)a;
    
    long long ans2=0;
    if (v[0]!=v[a-1]){
        int countn=0,countr=0;
        for (int j=0; j<n; j++){
            if (v[a-1]==v[j]){
                countn++;
                if (j<a){
                    countr++;
                }
            }
        }
        ans2=ncr(countn,countr);   
    } else {
        int count=0;
        for (int j=0; j<n; j++){
            if(v[0]==v[j]){
                count++;
            }
        }
        for (int j=a; j<=b; j++){
            ans2+=ncr(count,j);
        }
    }
    printf("%lf\n%lld\n",ans,ans2);
	return 0 ;
}

Measured memory_bytes: 128
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> II;
typedef pair<LL, II> LII;

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		const LL MAX = 1LL << 60;
		const int MAX_SILVER = 2500;
		int n = -1, m, s;
		cin >> n >> m >> s;
		if (n < 0) return 0;
		vector<vector<int>> edge(n);
		vector<vector<int>> fare(n);
		vector<vector<int>> dist(n);
		vector<int> rate(n);
		vector<int> time(n);
		vector<vector<LL>> mincost(n, vector<LL>(2501, MAX));
		for (int i = 0; i < m; ++i) {
			int u, v, a, b;
			cin >> u >> v >> a >> b;
			--u, --v;
			edge[u].push_back(v);
			edge[v].push_back(u);
			fare[u].push_back(a);
			fare[v].push_back(a);
			dist[u].push_back(b);
			dist[v].push_back(b);
		}
		for (int i = 0; i < n; ++i) {
			cin >> rate[i] >> time[i];
		}
		priority_queue<LII, vector<LII>, greater<>> q;
		auto push = [&](int pos, int silver, LL cost) {
			for (; ; silver += rate[pos], cost += time[pos]) {
				silver = min(silver, MAX_SILVER);
				if (cost < mincost[pos][silver]) {
					mincost[pos][silver] = cost;
					q.push(LII(cost, II(silver, pos)));
				}
				if (silver >= MAX_SILVER) break;
			}
		};
		vector<LL> ans(n, MAX);
		push(0, s, 0);
		while (!q.empty()) {
			LII top = q.top();
			q.pop();
			LL cost = top.first;
			int silver = top.second.first;
			int pos = top.second.second;
			if (cost > mincost[pos][silver]) continue;
			ans[pos] = min(ans[pos], cost);
			for (size_t i = 0; i < edge[pos].size(); ++i) {
				int next_pos = edge[pos][i];
				int f = fare[pos][i];
				int d = dist[pos][i];
				if (silver < f) continue;
				push(next_pos, silver - f, cost + d);
			}
		}
		for (int i = 1; i < n; ++i) {
			cout << ans[i] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 68948
#include <iostream>
#include <vector>
#include <map>
#include <stack>
using namespace std;
int main(){
	int R, C, N;
	cin >> R >> C >> N;
	vector<int> x1(N), y1(N), x2(N), y2(N);
	for (int i = 0; i < N; i++){
		cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
	}
	map<int, int> pos;
	for (int i = 0; i < N; i++){
		int p = -1;
		if (y1[i] == 0){
			p = x1[i];
		} else if (x1[i] == R){
			p = R + y1[i];
		} else if (y1[i] == C){
			p = R + C + R - x1[i];
		} else if (x1[i] == 0){
			p = R + C + R + C - y1[i];
		}
		int q = -1;
		if (y2[i] == 0){
			q = x2[i];
		} else if (x2[i] == R){
			q = R + y2[i];
		} else if (y2[i] == C){
			q = R + C + R - x2[i];
		} else if (x2[i] == 0){
			q = R + C + R + C - y2[i];
		}
		if (p != -1 && q != -1){
			if (p > q){
				swap(p, q);
			}
			pos[p] = i + 1;
			pos[q] = - (i + 1);
		}
	}
	bool ok = true;
	stack<int> st;
	for (auto P : pos){
		if (P.second > 0){
			st.push(P.second);
		} else {
			if (st.top() == - P.second){
				st.pop();
			} else {
				ok = false;
				break;
			}
		}
	}
	if (ok){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 14352
N = int(input())
V = list(map(int, input().split()))
if N == 2:
    print((V[0]+ V[1])/2)
else:
    V.sort()
    kati = V[0]
    for i in range(1, N):
        kati = (kati + V[i]) / 2
    print(kati)

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bs binary_search
#define pb push_back
#define pp pair<ll,ll>
#define F first 
#define S second 
#define lc "\n"
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
ll MAX=1e18 , MIN=-1e18 , MOD=1000000007;
int main() 
{
    fastio
    ll n,i,d; cin>>n; ll arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
    ll dp[n][n];
	for(i=0;i<n;i++) dp[i][i]=arr[i];
	for(d=1;d<n;d++)
	{
	    for(int i=0;i<n-d;i++)
	    dp[i][i+d]=max(arr[i]-dp[i+1][i+d],arr[i+d]-dp[i][i+d-1]);
	}
	cout<<dp[0][n-1];
    return 0;
}

Measured memory_bytes: 70400
#include<iostream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int sp = 8050;

string s;
int x, y, xsum, ysum, xt, yt;
bool turned = false;
bool direction = true;//true-x,false-y
int xboard[16100];
int yboard[16100];
int temp = 0;
queue<int> q;

void dp(int board[], int sum, int t) {
	for (int i = sp - sum; i <= sp + sum; i++) {
		if (board[i] == t) q.push(i);
	}
	while (q.size() != 0) {
		int i = q.front();
		board[i - temp] = board[i + temp] = t + 1;
		q.pop();
	}
}

void solv() {
	if (direction) {
		dp(xboard, xsum, xt);
		xsum += temp;
		xt++;
		temp = 0;
		direction = false;
	}
	else {
		dp(yboard, ysum, yt);
		ysum += temp;
		yt++;
		temp = 0;
		direction = true;
	}
}

int main() {
	cin >> s;
	cin >> x >> y;
	xt = yt = xboard[sp] = yboard[sp] = 1;

	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'F') {
			temp++;
		}
		else {
			if (!turned) {
				xboard[sp + temp] = xt + 1;
				xt++;
				xsum += temp;
				turned = true;
				temp = 0;
				direction = false;
			}
			else if (temp == 0) direction = !direction;
			else {
				solv();
			}
		}
	}
	if (temp != 0) {
		if (!turned) {
			xboard[sp + temp] = xt + 1;
			xt++;
			xsum += temp;
			turned = true;
			temp = 0;
			direction = false;
		}
		else solv();
	}

	if (xboard[sp + x] == xt && yboard[sp + y] == yt)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 384
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
typedef unsigned long long ull ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define rrep(i , n) for ( int i = n-1; i >=0 ; i--)

#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	ull size_; 
	std::vector<ull> par, rank, count;

public:
	UnionFind() : size_(0), par(std::vector<ull>()), rank(std::vector<ull>()), count(std::vector<ull>()) {};
	UnionFind(ull size__) : size_(size__) {
		par.resize(size_); rank.resize(size_); count.resize(size__);
		for (ull i = 0; i < size_; i++) par[i] = i, rank[i] = 0, count[i] = 1;
	}
	ull size() { return size_; }
	// ull root(ull x) { return par[x] == x ? x : par[x] = root(par[x]); }
	
	ull root(ull x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	
	bool same(ull x, ull y) { return root(x) == root(y); }

	void unite(ull x, ull y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y, count[y]+=count[x], count[x]=0;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++, count[x]+=count[y], count[y]=0;
		else par[y] = x, count[x] += count[y], count[y] = 0;
	}

	ull size__(ull x)
	{
		return count[root(x)];
	}

	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};
/*
maybe sth wrong 
got wa in one problem
*/
ll modpow(ll a, ll b)
{
	if (b == 0)
	{
		return 1;
	}

	if (b % 2)
	{
		return a * modpow(a, b-1) % MOD;
	}
	else
	{
		ll halfB = b / 2;
		ll half = modpow(a, halfB);
		return half * half % MOD;
	}
}

ll calcComb(ll n, ll m)
{
	if (m > n-m)
	{
		return calcComb(n, n-m);
	}

	ll ansMul = 1;
	ll ansDiv = 1;

	rep(i, m)
	{
		ansMul *= (n-i);
		ansDiv *= (i+1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}

	return ansMul * modpow(ansDiv, MOD - 2) % MOD;
}

__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}


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

	int dp[N+1];
	memset(dp, 0, sizeof(dp));
	dp[0] = 1;

	string s1, s2;
	cin >> s1 >> s2;

	rep(i, N)
	{
		if (i == 0)
		{
			if (s1[i] == s2[i])
			{
				dp[1] = 3;
			}
			else
			{
				dp[1] = 6;
			}
		}
		else
		{
			if (s1[i] == s2[i])
			{
				if (s1[i-1] == s2[i-1])
				{
					dp[i+1] = 1ll * dp[i] * 2 % MOD;
				}
				else
				{
					dp[i+1] = dp[i];
				}
			}
			else
			{
				if (s1[i] == s1[i-1])
				{
					dp[i+1] = dp[i];
					continue;
				}
				if (s1[i-1] == s2[i-1])
				{
					dp[i+1] = 1ll * dp[i] * 2 % MOD;
				}
				else
				{
					dp[i+1] = 1ll * dp[i] * 3 % MOD;
				}
			}
		}
		
	}
	cout << dp[N] << endl;

	return 0;
}


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

int n;

set<string> st;

int main(void) {
  // Here your code !
  scanf("%d", &n);
  string last;
  cin >> last;
  st.insert(last);
  for (int i = 1; i < n; ++i) {
    string cur;
    cin >> cur;
    if (last[last.size() - 1] != cur[0] || st.find(cur) != st.end()) {
      printf("No\n");
      return 0;
    }
    else {
      st.insert(cur);
      last = cur;
    }
  }

  printf("Yes\n");

  return 0;
}


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

int main(int argc, char *argv[]) {
  // read inputs
  char cs[4 + 1];
  scanf("%s", cs);

  char prev = '-';
  for (int i = 0; i < 4; i++) {
    const char c = cs[i];
    if (c == prev) {
      printf("Bad\n");
      return 0;
    }
    prev = c;
  }
  printf("Good\n");
  
  return 0;
}


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

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

using namespace std;

typedef long long ll;

int n, m; ll t;
int s[300005]; int d[300005];
pair<int,int> o[300005];
int res[300005];

int main() {
    scanf("%d%d%lld", &n, &m, &t);
    FO(i,0,n) scanf("%d %d", s+i, d+i);
    FO(i,0,n) o[i] = make_pair(s[i],i);
    sort(o,o+n);
    vector<ll> p;
    ll nc = 0;
    FO(i,0,n) {
        int dir = d[i] == 2 ? -1 : 1;
        ll pos = s[i] + dir * t;
        ll fp = ((pos%m)+m)%m;
        ll g = pos > 0 ? pos / m : (pos-m+1) / m;
        nc += g;
        p.push_back(fp);
    }
    nc = ((nc%n)+n)%n;
    sort(p.begin(),p.end());
    FO(i,0,n) res[o[i].second] = p[(i+nc)%n];
    FO(i,0,n) printf("%d\n", res[i]);
}


Measured memory_bytes: 5748
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i, j, k, l, n, m;
    string s,t;
    cin >> s >> t;
    ll sz1 = s.size();
    ll sz2 = t.size();
    ll maxcnt = 2e9;
    for (i = 0; i <= sz1 - sz2;i++){
        ll cnt = 0;
        for (j = 0; j < sz2;j++){
            if(s[i+j]!=t[j])
                cnt++;
        }
        maxcnt = min(maxcnt, cnt);
    }
    cout << maxcnt << "\n";
    return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e10;
const ll MOD = 100000000;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 100;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    if (k > (n-1)*(n-2)/2){
        PRINT(-1);
        return 0;
    }
    PRINT(n-1+(n-1)*(n-2)/2-k);
    rep(i,1,n){
        cout << i << " " << n << endl;
    }
    ll x = 1,y = 2;
    rep(i,(n-1)*(n-2)/2-k){
        cout << x << " " << y << endl;
        if (y == n-1){
            x++;
            y = x+1;
        }
        else{
            y++;
        }
    }
}


Measured memory_bytes: 256
A,B = map(int, input().split())

kaibun_cnt = 0
while A <= B:
    num_to_str = str(A)
    if (num_to_str[0] == num_to_str[4]) and (num_to_str[1] == num_to_str[3]):
        kaibun_cnt += 1
    A += 1

print(kaibun_cnt)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  vector<int> deg(5);
  rep(t,3) {
    int a,b;
    cin>>a>>b;
    deg[a]++;
    deg[b]++;
  }
  vector<int> freq(10);
  repeat(i,1,5) {
    freq[deg[i]]++;
  }
  repeat(d,0,10) {
    if(d==1) {
      if(freq[d]!=2) {
        cout << "NO" << endl;
        return 0;
      }
    } else if(d==2) {
      if(freq[d]!=2) {
        cout << "NO" << endl;
        return 0;
      }
    } else {
      if(freq[d]!=0) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   vector<int> a(n);
   int cur = 0;
   f(i,0,n){
      cin >> a[i];
      cur ^= a[i];
   }
   f(i,0,n){
      cout << (cur^a[i]) << ' ';
   }
   return 0;
}

Measured memory_bytes: 4748
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, k;
    cin >> n >> k;

    vl a(n);
    vl rui(n+1);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
        rui[i+1] = (rui[i] + a[i])%k;
    }

    map<ll, ll> mp;
    queue<ll> Q;
    ll ans = 0;
    rep(i, n+1) {
        Q.push(rui[i]);
        if(Q.size() > k) {
            mp[Q.front()]--;
            Q.pop();
        }
        mp[rui[i]]++;
        ans += mp[rui[i]] - 1;
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 17536
#include <stdio.h>

struct Card{ char mark; int num; };

void pushCards(Card *c, char mark, int index){
  for(int i=0;i<13;i++){
    c[13*index+i] = {mark,i+1};
  }
}

int main(){
  struct Card cards[52];
  pushCards(cards,'S',0);
  pushCards(cards,'H',1);
  pushCards(cards,'C',2);
  pushCards(cards,'D',3);

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

  char work1;
  int index,work2;
  Card dummy = {'A',0};
  for(int i=0;i<n;i++){
    scanf(" %c",&work1);
    scanf("%d",&work2);
    switch (work1)
    {
      case 'S': index=0; break;
      case 'H': index=1; break;
      case 'C': index=2; break;
      case 'D': index=3; break;
      default: break;
    }
    cards[13*index+(work2-1)] = dummy;
  }

  for(int i=0;i<52; i++){
    if(cards[i].mark != 'A')
      printf("%c %d\n",cards[i].mark,cards[i].num);
  }

  return 0;
}


Measured memory_bytes: 2604
N, M = map(int, input().split(' '))
AC = [0]*N
WA = [0]*N
for i in range(M):
    p, S = input().split(' ')
    p = int(p)

    if S == 'AC':
        AC[p-1] = 1
    elif S == 'WA' and AC[p-1] == 0:
        WA[p-1] += 1

AC_cnt = 0
WA_cnt = 0
for i in range(N):
    if AC[i] == 1:
        AC_cnt += 1
        WA_cnt += WA[i]

print(AC_cnt, WA_cnt)

Measured memory_bytes: 4596
#include <limits>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <cstdint>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

static const int INF = INT_MAX / 4; // 適当な大きい数(4で割るのは、WF法でオーバーフローさせないため)

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

    int N,M,R;
    cin >> N >> M >> R;
    
    vector<int> rs(R);
    for( int& r : rs )
    {
        cin >> r;
        --r;
    }
    
    vector<vector<int>> graph(N, vector<int>(N, INF));

    for( int i : irange(0, N) )
    {
        graph[i][i] = 0;
    }

    for( int i : irange(0, M) )
    {
        int a,b,c;
        cin >> a >> b >> c;
        --a; --b;
        graph[a][b] = graph[b][a] = c;
    }

    // ワーシャルフロイド法
    // 計算量 O(n^3) (n = 200 なら十分間に合う)。
    for( int i : irange(0, N) )
    {
        for( int j : irange(0, N) )
        {
            for( int k : irange(0, N) )
            {
                graph[j][k] = min(graph[j][k], graph[j][i] + graph[i][k]);
            }
        }
    }
    
    // 訪れる都市の全順列を列挙し、それぞれの移動距離を求めて最小値を決定する。
    // 計算量 O(n!) (n = 8 なら十分間に合う)。
    int shortest_path = INF;
    sort(rs.begin(), rs.end());
    do{
        int path = 0;
        for( int i : irange(1, R) )
        {
            path += graph[rs[i-1]][rs[i]];
        }
        
        shortest_path = min(shortest_path, path);
        
    }while( next_permutation(rs.begin(), rs.end()) );
    
    cout << shortest_path << '\n';

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main (){
  int N,M;
  
  scanf("%d%d",&N,&M);
  
  int a[M];
  
  for (int i=0;i<M;i++){
    scanf("%d",&a[i]);
  }
  
  for (int i=0;i<M;i++){
    N-=a[i];
  }
  
  if(N<0){
    printf("%d",-1);
  }
  else {
    printf("%d",N);
  }
  
  return 0;
}


Measured memory_bytes: 1700
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define all(a) begin(a), end(a)
#define sz(a) (int)(a.size())
#define deb(a) cout << #a << ": " << a << ENDL
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli> ii;
typedef vector<lli> vi;

lli n, m;
vector<string> mat;
bool valid(lli u, lli v) {
    return u >= 0 and u < n and v >= 0 and v < m;
}

int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};
int edx[] = {-2, -2, -2, -2, -2, -1, 0, 1, 2, 2, 2,  2,  2,  1,  0, -1, -1, -1, 1, 1};
int edy[] = {-2, -1,  0,  1,  2,  2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2,  1, -1, 1, -1};

bool valid(ii u) {
    return valid(u.f, u.s);
}
lli dijkstra(lli u, lli v, lli uu, lli vv) {
    vector<vector<lli>> dis(n, vector<lli>(m, -1));
    priority_queue<pair<lli, ii>, vector<pair<lli, ii>>, greater<pair<lli, ii>> > pq;
    dis[u][v] = 0;
    pq.push({0, {u, v}});
    while(!pq.empty()) {
        lli val = pq.top().f;
        ii coord = pq.top().s;
        pq.pop();
        fore(k, 0, 4) {
            ii nw = {coord.f + dx[k], coord.s + dy[k]};
            if(!valid(nw) or mat[nw.f][nw.s] == '#') continue;
            if(dis[nw.f][nw.s] == -1 or dis[nw.f][nw.s] > val) {
                dis[nw.f][nw.s] = val;
                pq.push({val, nw});
            }
        }
        fore(k, 0, 20) {
            ii nw = {coord.f + edx[k], coord.s + edy[k]};
            if(!valid(nw) or mat[nw.f][nw.s] == '#') continue;
            if(dis[nw.f][nw.s] == -1 or dis[nw.f][nw.s] > val + 1) {
                dis[nw.f][nw.s] = val + 1;
                pq.push({val + 1, nw});
            }
        }
    }
    return dis[uu][vv];
}

int main()
{   _
    cin >> n >> m;
    lli u, v, uu, vv;
    cin >> u >> v >> uu >> vv;
    --u;--v;--uu;--vv;
    mat.resize(n);
    fore(i, 0, n) cin >> mat[i];
    cout << dijkstra(u, v, uu, vv) << ENDL;
    return 0;
}


Measured memory_bytes: 12696
import heapq
import math

N,M = map(int,input().split())
A = list(map(int,input().split()))

# 各要素に1掛ける
A = list(map(lambda x: x * -1, A))
heapq.heapify(A)

for _ in range(M):
    heapq.heappush(A, ((-1*heapq.heappop(A))//2)*-1 )

print(sum(A) * -1)

Measured memory_bytes: 14532