akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>

using namespace std;

long long n,c;
int cnt,flag;
int flag1;
string str;
string txt[4] ={"dream","dreamer","erase","eraser"};

string solve(int ptr);

int main(void){
    cin >> str;

  //  cout << (int)(txt[0].length());
   /* for(int i = 0; i < (int)(txt[0].length()); i++){
        cout << txt[0][i];
    }*/

    cout << solve(0) << endl;
}

string solve(int ptr){
    if(ptr == str.length())  flag1 = 1;
    for(int i = 0; i < 4; i++){
      int flag = 1;
      for(int j = 0; j < (int)(txt[i].length()); j++){
        if(txt[i][j] != str[ptr+j]){
          flag = 0; 
          break;
        }
      }
      if(flag) solve(ptr+(int)(txt[i].length()));
    }
     if(flag1){
       return "YES";
     }else{
       return "NO";
     }
}

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

#define ALL(v) v.begin(), v.end()

using namespace std;
int main() {

	int h, w;
	cin >> h >> w;

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

	for (int i = 0; i < w + 2; i++)
	{
		cout << "#";
	}
	cout << "" << endl;

	for (int i = 0; i < h; i++)
	{
		cout << "#";
		cout << A[i];
		cout << "#";
		cout << "" << endl;
	}
	

	for (int i = 0; i < w + 2; i++)
	{
		cout << "#";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}


//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main() {
ll n;
cin>>n;
ll a;
map<ll,ll>rensou;
for(ll i=0;i<n;i++){
    cin>>a;
    rensou[a]++;
}
ll ans=0;
for(auto f:rensou){
 if(f.second%2==1){
     ans++;
 }   
}
cout<<ans<<endl;
}








Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    vector<LL> X(N);
    rep(i,N)cin >> X[i];

    X.push_back(INF);   //  末尾にINFを足して奇数個にする。
    auto stock = X;     //  sort するために保存しておく。
    vector<LL> B(N);    //  答えの配列

    sort(all(X));       //  共通のmedian を取得するためにソート
    LL med = X[N/2];    //  共通のmedian を取得
    rep(i,N){
        if(stock[i] == med){
            B[i] = X[N/2 -1];
        }
        else if(stock[i] < med){
            B[i] = X[N/2];
        }
        else{ //stock[i] > med
            B[i] = X[N/2 -1];
        }
    }
    rep(i,N)cout << B[i] << endl;
}

Measured memory_bytes: 8000
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    string s; cin>>s;
    vector<int> r(n), g(n), b(n);
    rep(i,n) {
        if (s[i] == 'R') r[i]++;
        else if (s[i] == 'G') g[i]++;
        else b[i]++;
    }

    rep(i,n-1) {
        r[i+1] += r[i];
        g[i+1] += g[i];
        b[i+1] += b[i];
    }

    ll ans = 0;
    rep(i,n-2) {
        for (int j = i+1; j < n-1; ++j) {
            if (s[i] == s[j]) continue;
            set<char> st;
            st.insert(s[i]); st.insert(s[j]);
            if (!st.count('R')) {
                ans += (r.back()-r[j]);
                int k = j+(j-i);
                if (k < n && s[k]=='R') ans--;
            }
            else if (!st.count('G')) {
                ans += (g.back()-g[j]);
                int k = j+(j-i);
                if (k < n && s[k]=='G') ans--;
            }
            else if (!st.count('B')) {
                ans += (b.back()-b[j]);
                int k = j+(j-i);
                if (k < n && s[k]=='B') ans--;
            }
        }
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int D;
int main() {
    cin >> D;
    if(D == 25) {
        cout << "Christmas" << endl;
    }else if(D == 24) {
        cout << "Christmas Eve" << endl;
    }else if(D == 23) {
        cout << "Christmas Eve Eve" << endl;
    }else {
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

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

using namespace std;

constexpr static int MAXN = 1e5;
constexpr static int MAXK = 2000;

int N, K;
int x[MAXN], y[MAXN];
char c[MAXN];

int scnt[MAXK], ecnt[MAXK];

int fmod(int a) {
    if (a >= 2 * K)
        return a - 2 * K;
    return a;
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> c[i];
        x[i] %= (2 * K);
        y[i] %= (2 * K);
    }

    int best = 0;
    for (int dy = 0; dy < 2 * K; dy++) {
        for (int dx = 0; dx < 2 * K; dx++)
            scnt[dx] = ecnt[dx] = 0;

        //cout << "dy: " << dy << endl;
        int y0 = dy;
        int y1 = fmod(dy + K);
        for (int i = 0; i < N; i++) {
            int x0 = x[i];
            int x1 = fmod(x[i] + K);
            bool within = (y0 < y1 && y[i] >= y0 && y[i] < y1)
                || (y0 > y1 && (y[i] >= y0 || y[i] < y1));
            if (within ^ (c[i] == 'B'))
                scnt[x1]++, ecnt[x0]++;
            else
                scnt[x0]++, ecnt[x1]++;
            /*
            if ((y0 < y1 && y[i] >= y0 && y[i] < y1)
                    || (y0 > y1 && (y[i] >= y0 || y[i] < y1))) {
                if (c[i] == 'W') {
                    scnt[x0]++;
                    ecnt[x1]++;
                }
                else {
                    scnt[x1]++;
                    ecnt[x0]++;
                }
            }
            else {
                if (c[i] == 'W') {
                    scnt[x1]++;
                    ecnt[x0]++;
                }
                else {
                    scnt[x0]++;
                    ecnt[x1]++;
                }
            }
            */
            //cout << x[i] << " " << y[i] << " " << c[i] << " | ";
            //cout << x0 << " " << x1 << " " << flip << endl;
        }
        //for (int dx = 0; dx < 2 * K; dx++)
        //    cout << dx << " " << scnt[dx] << " " << ecnt[dx] << endl;

        int cur = 0;
        for (int dx = K; dx < 2 * K; dx++)
            cur += scnt[dx];
        for (int dx = 0; dx < 2 * K; dx++) {
            cur -= ecnt[dx];
            cur += scnt[dx];
            best = max(best, cur);
        }
    }
    cout << best << endl;
}

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

int main(){
	ll n,k;
	cin >> n>>k;
	ll sum = 0;
	for(ll i = k; i<= n+1; i++){
		sum = (sum+ i*n -i*(i-1)+1) %mod; 
	}
	cout << sum << endl;
	

	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 100000
#define MAX_NODE_ID 101
#define MAX_TICKET 11
class Node{
public:
	int id;
	int cost;
	int ticket;
	Node(int i,int c,int t){
		id=i;
		cost=c;
		ticket=t;
	}
	bool operator < (const Node &o) const{
		return cost > o.cost;
	}
};
typedef priority_queue<Node> PQ;
int table[MAX_NODE_ID][MAX_NODE_ID];
bool visited[MAX_NODE_ID][MAX_TICKET];
int main(){

	for(int c,n,m,s,d;cin>>c>>n>>m>>s>>d&&(c||n||m||s||d);){
		for(int i=0;i<MAX_NODE_ID;i++)for(int j=0;j<MAX_NODE_ID;j++)table[i][j]=MAX;
		for(int i=0;i<MAX_NODE_ID;i++)for(int j=0;j<MAX_TICKET;j++)visited[i][j]=false;
		for(int i=0,a,b,f;i<m&&cin>>a>>b>>f;i++){
			table[a][b]=f;
			table[b][a]=f;
//			cout<<"table["<<a<<"]["<<b<<"]"<<table[a][b]<<endl;
//			cout<<"table["<<b<<"]["<<a<<"]"<<table[b][a]<<endl;
		}
		PQ pq;
		Node start(s,0,c);
		pq.push(start);
		while(!pq.empty()){
			int current_node=pq.top().id;
			int current_cost=pq.top().cost;
			int current_ticket=pq.top().ticket;
//			cout<<"current:"<<current_node<<endl;
			if(current_node==d)break;
			if(visited[current_node][current_ticket]);
			else{
				for(int i=1;i<=n;i++){
					if(current_node==i)continue;
					if(table[current_node][i]==MAX)continue;
	//				cout<<"["<<current_node<<"]["<<i<<"]"<<"cost:"<<table[current_node][i]<<endl;
					Node node1(i,current_cost+table[current_node][i],current_ticket);
					pq.push(node1);
					visited[current_node][current_ticket]=true;
					if(current_ticket>0){
						Node node2(i,current_cost+(table[current_node][i]/2),current_ticket-1);
						pq.push(node2);
						visited[current_node][current_ticket-1]=true;
					}
				}
			}
			pq.pop();
		}
		cout<<pq.top().cost<<endl;
	}


	return 0;
}

Measured memory_bytes: 0
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑



long long a, b, c, ans;
int main() {
	cin >> a >> b >> c;
	if (a == 1 && a == b && b == c) { cout << 0 << endl; return 0; }
	if (a == b && b == c) { cout << -1 << endl; return 0; }
	if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) { cout << 0 << endl; return 0; }
	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
		long long aa, bb, cc;
		++ans;
		aa = a; bb = b; cc = c;
		a = bb / 2 + cc / 2;
		b = aa / 2 + cc / 2;
		c = aa / 2 + bb / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
public class Main{
  static double eps = 0.0000001;
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    double ux, uy, uz, ex, ey, ez;
    double[] x, y, z, s, t;
    double[][] a, ainv;
    int i, j;
    x = new double[3]; y = new double[3]; z = new double[3];
    a = new double[3][3]; ainv = new double[3][3];
    s = new double[3]; t = new double[3];

    ux = sc.nextDouble(); uy = sc.nextDouble(); uz = sc.nextDouble();
    ex = sc.nextDouble(); ey = sc.nextDouble(); ez = sc.nextDouble();
    t[0] = ex - ux; t[1] = ey - uy; t[2] = ez - uz;
    for(i = 0;i < 3;i++){
      x[i] = sc.nextDouble(); y[i] = sc.nextDouble(); z[i] = sc.nextDouble();
      a[0][i] = x[i] - ux; a[1][i] = y[i] - uy; a[2][i] = z[i] - uz;
    }
    getinv(a, ainv, 3);
    for(i = 0;i < 3;i++)for(j = 0;j < 3;j++)s[i] += ainv[i][j] * t[j];
    if(solve(s))out.println("HIT");
    else out.println("MISS");

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static void getinv(double[][] a, double[][] ainv, int n){
    int i, j, max;
    double tmp1, tmp2;
    double[][] x;
    x = new double[n][n * 2];
    for(i = 0;i < n;i++){
      for(j = 0;j < n;j++)x[i][j] = a[i][j];
      x[i][n + i] = 1;
    }
    for(i = 0;i < n;i++){
      max = i;
      for(j = i;j < n;j++){
        if(x[j][i] == 1 || x[j][i] == -1){ max = j; break; }
        tmp1 = x[max][i]; tmp2 = x[j][i];
        if(tmp1 < -eps)tmp1 *= -1;
        if(tmp2 < -eps)tmp2 *= -1;
        if(tmp1 < tmp2)max = j;
      }
      hswap(x, n, i, max);
      hdiv(x, n, i, x[i][i]);
      for(j = 0;j < n;j++)if(i != j)hdel(x, n, i, j);
    }
    for(i = 0;i < n;i++)for(j = 0;j < n;j++)ainv[i][j] = x[i][j + n];

    return;
  }
  private static void hswap(double[][] x, int n, int i, int j){
    int q;
    double tmp;
    for(q = 0;q < 2 * n;q++){
      tmp = x[i][q]; x[i][q] = x[j][q]; x[j][q] = tmp;
    }
    return;
  }
  private static void hdiv(double[][] x, int n, int i, double c){
    int q;
    for(q = i;q < n * 2;q++)x[i][q] /= c;
    return;
  }
  private static void hdel(double[][] x, int n, int i, int j){
    int q;
    double t = x[j][i];
    for(q = i;q < 2 * n;q++)x[j][q] -= x[i][q] * t;
    return;
  }
  private static boolean solve(double[] s){
    int i;
    for(i = 0;i < 3;i++)if(s[i] + eps < 0)return true;
    if(s[0] + s[1] + s[2] + eps <= 1.0)return true;
    return false;
  }
}

Measured memory_bytes: 28052
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

#include <atcoder/math>

vector<ll> find_divisor(ll n) {
	vector<ll> divisor;
	
	ll i = 1;
	for (; i * i <= n; i++) if (n % i == 0) divisor.push_back(i);
	i--;
	if (i * i == n) i--;
	for (; i >= 1; i--) if (n % i == 0) divisor.push_back(n / i);
	
	return divisor;
}

int main() {
	ll N;
	cin >> N;
	N *= 2;
	
	ll ans = longINF;
	auto div = find_divisor(N);
	
	for (auto x : div) {
		ll y = N / x;
		// k(k + 1) \equiv 0 (mod. N)
		// x | k, y | k + 1
		// k \equiv 1 (mod. x)
		// k \equiv -1 (mod. y)
		std::vector<ll> b(2), m(2);
		b[0] = 0; m[0] = x;
		b[1] = y - 1; m[1] = y;
		auto res = atcoder::crt(b, m);
		if (res.second == 0) continue;
		
		ll p = res.first;
		if (p == 0) p += x * y;
		chmin(ans, p);
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3700
# inp.readline()
# int(inp.readline())
# out.write()
# raw_input()
# map(int,raw_input().split())
# map(int,inp.readline().split())
# for _ in xrange(input()):
# print "Case #"+str(_+1)+": "+ 
if __name__ == "__main__":
    from sys import stdin as inp, stdout as out,setrecursionlimit as srl
    from collections import Counter,defaultdict,deque
    from heapq import *
    for _ in xrange(1):
        n=input()
        a=map(lambda x:x[0]==x[1],[map(int,inp.readline().split()) for i in  xrange(n)])
        print 'Yes' if any(all(a[i:i+3]) for i in xrange(n-2)) else 'No'

Measured memory_bytes: 65104
#include<bits/stdc++.h>
using namespace std;
int a,b,n,p[111],cnt1,cnt2,cnt3;
int main()
{
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
		if(p[i]<=a)
		{
			cnt1++;
		}
		else if(p[i]>a && p[i]<=b)
		{
			cnt2++;
		}
		else
		{
			cnt3++;
		}
	}
	cout<<min(cnt1,min(cnt2,cnt3))<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
a, b, c, d = map(int, input().split())
if a % d == 0:
    taka = a // d
else:
    taka = a // d + 1

if c % b == 0:
    aoki = c // b
else:
    aoki = c // b + 1

if taka >= aoki:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node {
  int key;
  int priority;
  struct node *right;
  struct node *left;
};

typedef struct node* Nodepointer;
Nodepointer nil=NULL, root=NULL;

Nodepointer delete(Nodepointer*, int);
Nodepointer _delete(Nodepointer*, int);

Nodepointer Node(int key, int priority){
 Nodepointer z;
  z = (Nodepointer)malloc(sizeof(struct node));
  z->key = key;
  z->priority = priority;
  z->left = nil;
  z->right = nil;
  return z;
}

Nodepointer rightRotate(Nodepointer t){
  Nodepointer s = t->left;
  t->left = s->right;
  s->right = t;
  return s;
}

Nodepointer leftRotate(Nodepointer t){
  Nodepointer s = t->right;
  t->right = s->left;
  s->left = t;
  return s;
}

Nodepointer insert(Nodepointer *t, int key, int priority){
  Nodepointer new;
  if( (*t) == nil ) return new = Node(key, priority);
  if( key == (*t)->key ) return *t;

  if( key < (*t)->key ){
    (*t)->left = insert(&(*t)->left, key, priority);
    if( (*t)->priority < (*t)->left->priority ) (*t) = rightRotate((*t));
  }
  else{
    (*t)->right = insert(&(*t)->right, key, priority);
    if( (*t)->priority < (*t)->right->priority ) (*t) = leftRotate((*t));
  }
  return *t;
}


Nodepointer delete(Nodepointer *t, int key){
  if( (*t) == nil ) return nil;
  if( key < (*t)->key ) (*t)->left = delete(&((*t)->left), key);
  else if( key > (*t)->key ) (*t)->right = delete(&((*t)->right), key);
  else {
    return _delete(t, key);
  }
  return *t;
}

Nodepointer _delete(Nodepointer *t, int key){
  if( (*t)->left == nil && (*t)->right == nil ) return nil;
  else if( (*t)->left == nil ) (*t) = leftRotate(*t);
  else if( (*t)->right == nil ) (*t) = rightRotate(*t);
  else {
    if( (*t)->left->priority > (*t)->right->priority ) (*t) = rightRotate(*t);
    else (*t) = leftRotate(*t);
  }
  return delete(t, key);
}


int find(Nodepointer u, int k){
  while( u != nil ){
    if( u->key == k ) return 1;
    else if( k < u->key ) u = u->left;
    else u = u->right;
  }
  return 0;
}

void inorder(Nodepointer u){
  if( u->left != nil ) inorder(u->left);
  printf(" %d", u->key);
  if( u->right != nil ) inorder(u->right);
  return;
}

void preorder(Nodepointer u){
  printf(" %d", u->key);
  if( u->left != nil ) preorder(u->left);
  if( u->right != nil ) preorder(u->right);
  return;
}

void print(Nodepointer u){
  inorder(u);
  printf("\n");
  preorder(u);
  printf("\n");
  return;
}

int main(){
  int m, i, x, y;
  char com[8];
  Nodepointer t=nil;

  scanf("%d", &m);

  for( i = 0 ; i < m ; i++ ){
    scanf("%s",com);

    switch(com[0]){
    case 'f': scanf("%d", &x);
      if( find(root, x)) printf("yes\n");
      else printf("no\n");
      break;

    case 'i':  scanf("%d%d", &x, &y);
      root = insert(&root,x,y);
      break;

    case 'p':  print(root);
      break;

    case 'd': scanf("%d", &x);
      root = delete(&root, x);
      break;
    }
  }
  return 0;
}



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

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i, N) {
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B.begin(), B.end());
    rep(i, N) {
        if (A[i] == B[N - 1]) cout << B[N - 2] << endl;
        else cout << B[N - 1] << endl;
    }
}

Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include <cmath>

using namespace std;

int main() {
    int N;
    cin >> N;
    int A_i;
    int ans = 1;
    for (int i = 0; i < N; ++i) {
        cin >> A_i;
        if (i==0) {
            while(1) {
                if(A_i % int(pow(2,ans)) != 0) {
                    ans -= 1;
                    break;
                }
                ans += 1;
            }
        } else {
            while(1) {
                if(A_i % int(pow(2,ans)) == 0) {
                    break;
                }
                ans -= 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

vector<int> z_algorithm(const string &s) {
    vector<int> prefix(s.size());
    for (int i = 1, j = 0; i < s.size(); i++) {
        if (i + prefix[i - j] < j + prefix[j]) {
            prefix[i] = prefix[i - j];
        } else {
            int k = max(0, j + prefix[j] - i);
            while (i + k < s.size() && s[k] == s[i + k])
                ++k;
            prefix[i] = k;
            j = i;
        }
    }
    prefix[0] = (int)s.size();
    return prefix;
}

signed main() {
    cin >> N >> S;
    REP(i, N) {
        T = S.substr(i);
        auto v = z_algorithm(T);
        REP(i, T.size()) {
            if (i == 0)
                continue;
            ans = max(min(v[i], i), (int)ans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
typedef tuple<string, int, int> Type;
#define rep(i,N) for(int i=0;i<(int)N;i++)

int main()
{
  int N;
  cin >> N;
  vector<Type> taste(N);
  rep(i,N)
  {
    cin>>get<0>(taste.at(i))>>get<1>(taste.at(i));
    get<2>(taste.at(i))=i+1;
  }
  sort(taste.begin(),taste.end(),[](Type const& x,Type const& y)
       {
         //第一要素が同一ならば第二要素の大きい方を返す
         return get<0>(x)==get<0>(y)? get<1>(x)>get<1>(y):get<0>(x)<get<0>(y);
       }
      );
  rep(i,N){cout<<get<2>(taste.at(i))<<endl;}
}

Measured memory_bytes: 256
def f(x:int)->bool:
    """return (積載量ｘ),k台でいけるか
    """
    global K, ws
    track_cnt = 1
    weight = 0
    for wi in ws:
        if wi > x: return False
        if weight+wi > x:
            track_cnt += 1
            weight = wi
        else:
            weight += wi
    return track_cnt <= K

def binary_search(f, s:int, t:int)->int:
    """f: function(x:int)->bool
    f(s)=False, f(t)=True，f は広義単調増加
    return : [s, t) での f(x)=True なる最小のx
    """
    ng = s-1
    ok = t
    while ok - ng > 1:
        mid = (ok + ng)//2
        if f(mid): ok = mid
        else:      ng = mid
        # print(ng, ok, ok-ng)

    if ok==s-1:
        raise(ValueError("For all x, f(x)=False"))
    return ok

if __name__ == "__main__":
    N,K = map(int, input().split())
    ws = [int(input()) for _ in range(N)]
    MAX_P = 10**10
    MIN_P = 0
    print(binary_search(f, MIN_P, MAX_P))



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

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

    int former = input / 100, latter = input % 100;

    bool formerMonth = false, latterMonth = false;

    string result;

    if (former != 0 && former < 13)
    {
        formerMonth = true;
    }
    else
    {
        formerMonth = false;
    }

    if (latter != 0 && latter < 13)
    {
        latterMonth = true;
    }
    else
    {
        latterMonth = false;
    }

    if (formerMonth && latterMonth)
    {
        result = "AMBIGUOUS";
    }
    else if (formerMonth && !latterMonth)
    {
        result = "MMYY";
    }
    else if (!formerMonth && latterMonth)
    {
        result = "YYMM";
    }
    else if (!formerMonth && !latterMonth)
    {
        result = "NA";
    }

    cout << result << endl;
}


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

int main(){
  int n;
  cin>>n;
  lint l[100];
  l[0]=2,l[1]=1;

  for(int t=2;t<=n;t++){
    l[t]=l[t-1]+l[t-2];
  }

  cout<<l[n]<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, M; cin >> N >> M;
  vector<int> As(N); for (auto &A : As) cin >> A;
  int c = 0, s = accumulate(As.begin(), As.end(), 0);
  for (auto A : As) c += 4 * M * A >= s;
  puts(M <= c ? "Yes" : "No");}

Measured memory_bytes: 3636
#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>

// common
#define endl     "\n"
#define M_PI     3.14159265358979323846

// fast input output
#define fast_io  ios_base::sync_with_stdio(false); cin.tie(NULL);  cout.tie(NULL)

// fixed float field
#define fix_prec cout.setf( std::ios::fixed, std:: ios::floatfield ); cout.precision(9);

// vector
#define vi       vector<int>
#define vvi      vector<vector<int>>
#define vpii     vector<pair<int,int>>
#define pb(v,x)  v.push_back(x)

// pair
#define pii      pair<int,int>
#define mp(a,b)  make_pair(a,b)
#define F        first
#define S        second

// sort
#define all(x)   x.begin(),x.end()
#define rall(x)  x.rbegin(),x.rend()

// bound
#define lb(v,x)  lower_bound(v.begin(),v.end(),x)
#define ub(v,x)  upper_bound(v.begin(),v.end(),x)

using namespace std;
//using namespace __gnu_pbds;

//typedef tree < int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update > ordered_set;
typedef long long int lli;
typedef unsigned long long int ulli;

// constants
lli const mod  = 1e9+7;
lli const modl = 1e18;

// helper functions
// calculate gcd
lli gcd(lli x, lli y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

// calculate fibonacci number
lli fib(int n)
{
    lli a,b,c,i;
    a=0,b=1;
    if(n == 0)
        return a;
    for(i=2;i<=n;i++)
    {
    	c=a+b;
    	a=b;
    	b=c;
    }
    return b;
}

// check if number if prime
bool isprime(lli n)
{
	if(n<=1)
		return false;
	else if(n==2)
		return true;
	else if(n%2==0)
		return false;
	else
	{
		int i;
		for(i=3;i*i<=n;i++)
		{
			if(n%i==0)
				return false;
		}
		return true;
	}
}

// read from and write to text file
void readwrite()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
} 

// seive
vector<lli>prime(100000+7,1);
void buildprime(lli n)
{
	lli i,j;
	prime[0]=prime[1]=0;
	for(i=2;i*i<=n;i++)
	{
		if(prime[i])
		{
			for(j=i*i;j<=n;j+=i)
				prime[j]=0;
		}
	}
}

// nCr
lli dp[1005][1005];
lli comb[1005][1005];
lli ncr(lli n,lli r)
{
	if(n==r)
		return 1;
	if(r==0)
		return 1;
	if(r==1)
		return n;
	if(dp[n][r]!=0)
		return dp[n][r];
	return dp[n][r] = (ncr(n-1,r)%mod+ncr(n-1,r-1)%mod)%mod;
}

void ncrm()
{
	comb[0][0]=1;
	for(int i=1;i<1001;i++)
	{
		comb[i][0]=1;
		for(int j=1;j<=i;j++)
		{
			comb[i][j]=(comb[i-1][j]%mod+comb[i-1][j-1]%mod)%mod;
		}
	}
}

// binary exponentiation
lli binpowm(lli a,lli b)
{
	lli res=1;
	a%=mod;
	while(b)
	{
		if(b&1)
			res=((res%mod)*(a%mod))%mod;
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return res%mod;
}
 
// factorial
lli fact(lli n)
{
	lli i,res=1;
	for(i=1;i<=n;i++)
		res=((res%mod)*(i%mod))%mod;
	return res%mod;
}

// driver code
void solve()
{
	lli n,i;
	cin>>n;
	for(i=n;;i++)
	{
		if(isprime(i))
		{
			cout<<i;
			return ;
		}
	}
}

int main()
{
  fast_io;
  fix_prec;
  //readwrite();
  int t=1;
  //cin>>t;
  while(t--)
  {
    solve();
    cout<<endl;     
  }
  return 0;	
}

/*
Kab Khoon khaulega tera jab sabka internship lag jayega tab
Shame on you if you do not get internship
*/

Measured memory_bytes: 3880
<?php

$cup = array(
	"A" => 1,
	"B" => 0,
	"C" => 0);

while($line = fgets(STDIN)){
    $line = trim($line);
    
    list($x, $y) = explode(",", $line);
    
    // swap
    $wk = $cup[$x];
    $cup[$x] = $cup[$y];
    $cup[$y] = $wk;
}

if($cup["A"] == 1){
	echo "A\n";
}else if($cup["B"] == 1){
	echo "B\n";
}else{
	echo "C\n";
}

Measured memory_bytes: 15212
# あなたは、冷蔵庫と電子レンジを買うために、とある家電量販店に来ました。
# この家電量販店では、 A 種類の冷蔵庫と B 種類の電子レンジが販売されています。 
# i 番目( 1≤i≤A )の冷蔵庫の値段は ai 円であり、 j 番目( 1≤j≤B )の電子レンジの値段は bj 円です。
# また、あなたは M 種類の割引券を所持しており、 i 番目 ( 1≤i≤M )の割引券では、
# xi 番目の冷蔵庫 と yi 番目の電子レンジを同時に買うと、 支払総額が ci 円安くなります。
# ただし、複数の割引券を同時に使うことはできません。
# さて、あなたは冷蔵庫と電子レンジをちょうど 1 台ずつ買おうと思っています。
# かかる金額の最小値を求めてください。

abm = gets.chomp.split
a = abm[0].to_i
b = abm[1].to_i
m = abm[2].to_i

a_array = gets.chomp.split
a.times do |i|
    a_array[i] = a_array[i].to_i
end

b_array = gets.chomp.split
b.times do |i|
    b_array[i] = b_array[i].to_i
end

xyc_array = []
m.times do
    xyc = gets.chomp.split
    3.times do |i|
        xyc[i] = xyc[i].to_i
    end
    xyc_array << xyc
end

prices = [a_array.min+b_array.min]

m.times do |i|
    prices << a_array[xyc_array[i][0]-1] + b_array[xyc_array[i][1]-1] - xyc_array[i][2]
end

puts prices.min

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

int main()
{
	map<long long int,long long int> cnt;
  	long long int n,q;
  	cin>>n>>q;
  	long long int x,y;
  	for(long long int i=0 ; i<n ; ++i)
    {
    	cin>>x>>y;
    	cnt[x]+=y;
    }
  	for(auto &i:cnt)
    {
    	if(i.second>=q)
        {
        	cout<<i.first<<endl;
            return 0;
        }  
      	q-=i.second;
    }
  	return 0;
}
 

Measured memory_bytes: 4224
#include <stdio.h>
#include <algorithm>

using namespace std;

int a[3], cnt;


int main(void) {
    scanf("%d%d%d", &a[0], &a[1], &a[2]);
    sort(a, a+3);
    int t=a[2]-a[0];
    if(t>1) {
        int tt=t/2;
        cnt+=tt;
        a[0]+=(tt*2);
    }
    sort(a, a+3);
    t=a[2]-a[0];
    if(t>1) {
        int tt=t/2;
        cnt+=tt;
        a[0]+=(tt*2);
    }
    
    sort(a, a+3);
    if(a[0]==a[1] && a[1]!=a[2]) {
        cnt++;
    }
    if(a[0]!=a[1] && a[1]==a[2]) {
        cnt+=2;
    }

    printf("%d", cnt);
    return 0;
}


Measured memory_bytes: 128
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    n, m, q = ns()
    d = [na() for _ in range(q)]

    cmb = itertools.combinations_with_replacement(range(1, m + 1), n)

    ans = 0
    for c in cmb:
        tmp_ans = 0
        for ai, bi, ci, di in d:
            if c[bi - 1] - c[ai - 1] == ci:
                tmp_ans += di
        ans = max(ans, tmp_ans)

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  long long n,k,l;
  cin>>n;
  for(int i=1;i<n+1;i++){
    if(i*(i+1)/2>=n){
      k=i*(i+1)/2-n;
      l=i;
      break;
    }
  }
  for(int i=1;i<=l;i++){
    if(i!=k)cout<<i<<endl;
  }
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int a, b, c, d, e, k; cin >> a >> b >> c >> d >> e >> k;

    if(e-a <= k) {
        cout << "Yay!\n";
            } else {
        cout << ":(\n";
    }
    return 0;
}


Measured memory_bytes: 256
/*
  The Island Was Silent before.
  .....
  And One day again it became Silent.
*/
#include<bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock()*1.0 / CLOCKS_PER_SEC << endl;
#define ffe freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
 
int main() {
  ioso
  #ifndef ONLINE_JUDGE
  ffe
  #endif
  ll n; cin >> n;
  int a[200010];
  for(int i=0;i<n;i++) {
    cin >> a[i];
  }
  ll s=0;
  for(int i=1;i<n;i++) {
    if(a[i]<a[i-1]) {
      //cout << a[i-1]-a[i] << endl;
      s += a[i-1]-a[i];
      a[i] = a[i-1];
    }
  }
  cout << s << endl;
}

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

int n,x,arr[100005],xam;

int main(){
    scanf("%d %d", &n, &x);
    for(int i = 0; i < n; i++){
        scanf("%d", &arr[i]);
    }
    arr[n] = x;
    n++;
    sort(arr,arr+n);
    xam = arr[1]-arr[0];
    for(int i = 1; i < n-1; i++){
        xam = __gcd(arr[i+1]-arr[i],xam);
    }
    printf("%d\n", xam);
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (A, B) = Read2Longs();
            return A <= 8 && B <= 8 ? "Yay!" : ":(";
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28124
#include<bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
int a;
signed main(){
//	freopen(".inp","r",stdin);
//	freopen(".out","w",stdout);
//	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	for(int i=1;i<=5;i++){
		cin>>a;
		if(a==0) cout<<i;
	}
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/



int n;
signed main() {
	cin >> n;
	n--;
	cout << (1 + n) * n / 2 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);

                int sheep = scan.nextInt();
                int wolf = scan.nextInt();

                if (sheep <= wolf) {
                	System.out.println("unsafe");
                } else {
                	System.out.println("safe");
                }

        }

}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(9);
  for (int i = 0, a; i < N && cin >> a; i++) {
    if (a < 400) A.at(0)++;
    if (400 <= a && a < 800) A.at(1)++;
    if (800 <= a && a < 1200) A.at(2)++;
    if (1200 <= a && a < 1600) A.at(3)++;
    if (1600 <= a && a < 2000) A.at(4)++;
    if (2000 <= a && a < 2400) A.at(5)++;
    if (2400 <= a && a < 2800) A.at(6)++;
    if (2800 <= a && a < 3200) A.at(7)++;
    if (3200 <= a) A.at(8)++;
  }
  int ans = 0;
  for (int i = 0; i < 8; i++) if (A.at(i)) ans++;
  cout << ans + ((!ans && A.at(8)) ? 1 : 0) << " " << ans + A.at(8) << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char str[10];
    int i,k,temp,num[10],dif[10];
    scanf("%s",&str);
    for(i=0;i<strlen(str)-2;i++)
    {
        num[i]=(str[i]-48)*100+(str[i+1]-48)*10+(str[i+2]-48);
        if(num[i]>753) dif[i]=num[i]-753;
        else if(num[i]<753) dif[i]=753-num[i];
        else{
            printf("0");
            return 0;
            }
    }
    for(i=0; i<strlen(str)-2; i++)
    {
        for(k=i+1; k<strlen(str)-2; k++)
        {
            if(dif[i] > dif[k])
            {
                temp = dif[i];
                dif[i] = dif[k];
                dif[k] = temp;
            }
        }
    }
printf("%d",dif[0]);
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1, a, b, ans = 0;
		cin >> n;
		if (n < 0) return 0;
		vector<int> mn(n), mx(n);
		for (int i = 0; i < n; ++i) {
			cin >> a >> b;
			mn[i] = a;
			mx[i] = b;
		}
		sort(mn.begin(), mn.end());
		sort(mx.rbegin(), mx.rend());
		if (n % 2) {
			ans = mx[n / 2] - mn[n / 2] + 1;
		} else {
			int low = mn[n / 2 - 1] + mn[n / 2];
			int high = mx[n / 2 - 1] + mx[n / 2];
			ans += (high - low) + 1;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 4776
#include <iostream>
#include<queue>
#include<vector>
using namespace std;
int main(void){
    int N,M;
    cin >> N >> M;
    priority_queue<long long> que;
    
    for(int i = 0;i<N;i++){
        long long A;
        cin >> A;
        que.push(A);
    }
    
    for(int i = 0; i < M;i++){
        long long t = que.top();
        que.pop();
        que.push(t/2);
    }
    
    long long res = 0;
    while(!que.empty())res += que.top(),que.pop();
    cout << res <<endl;
    
    
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  int n;
  cin>>n;
  ll a[n];ll sum=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    sum+=a[i];
  }
  ll ans=LONG_MAX;ll s=0;
  for(int i=0;i<n;i++)
  {
    s+=a[i];
    ll v=abs(sum-s);
    ans=min(ans,abs(v-s));
  }
  cout<<ans<<"\n";
  return 0;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007


typedef long long ll;
typedef pair<ll,ll> P;

int memo[26];

int main()
{
	string str;
	cin >> str;
	for(int i = 0;i < str.size();i++){
		memo[str[i]-'a']++;
	}
	
	for(int i = 0;i < 26;i++){
		if(memo[i] % 2 != 0){
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
 
typedef long long int ll;
const ll N = 1e6 +9;
const ll p = 31;
const ll m = 1e9 + 7;
const ll inf= 1e14;
const ll mod = 1e9+7;
#define w first
#define v second
#define pb push_back
#define mp make_pair
using pii = pair<ll, ll>;
std::vector<ll> g[N];
ll powm(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
ll lp[N];
bool vis[N];
void dfs(ll v){
     ll ans = 1;
     vis[v] = 1;
     for(auto i:g[v]){
          if(!vis[i])dfs(i);
          ans=max(ans,lp[i]+1);
     }
     lp[v] = ans;
}
int main() {   
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   

     ll q = 1;
     // cin>>q;
     while(q--){
          ll n;cin>>n;
          double p[n];
          for(int i = 0;i<n;i++){
               cin>>p[i];
          }
           double dp[n+1][n+1];
          memset(dp,0,sizeof(dp));
          dp[0][0] = 1;
          for(int i = 1;i<=n;i++){
               for(int j = 0  ;j<=i;j++){
                    dp[i][j] = p[i-1]*dp[i-1][j-1] + (1-p[i-1])*dp[i-1][j];
                    // cout<<dp[i][j]<<" ";
               }
               // cout<<'\n';
          }
          double ans = 0;
          ll h = n/2;
          h++;
          for(int i = h;i<=n;i++){
               ans+=dp[n][i];
          }std::cout << std::fixed;
          std::cout << std::setprecision(9) ;cout<<ans<<'\n';
     }
}         

Measured memory_bytes: 94592
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
using namespace std;

using VI = vector <int> ;
using VVI = vector <VI> ;

int main() {
    int A[2];
    int M;
    cin >> A[0] >> A[1] >> M;
    vector <int> arr[2];
    int total = 0;
    const int INF = 100000000;

    for (int i = 0; i < 2; ++i) {
        int minP = INF;

        arr[i] = vector<int>(A[i], 0);
        for (int j = 0; j < A[i]; ++j) {
            scanf("%d", &arr[i][j]);
            minP = min(minP, arr[i][j]);
        }

        total += minP;
    }

    for (int i = 0; i < M; ++i) {
        int x;
        int y;
        int c;

        scanf("%d %d %d", &x, &y, &c);

        --x;
        --y;
        int cost = max(0, arr[0][x] + arr[1][y] - c);
        total = min(total, cost);
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int h,w;
  cin>>h>>w;
  if(h%3==0||w%3==0)cout<<0<<endl;
  else{
    int ans=11111111111;
    int a,b,c,t;
    for(int i=1;i<w;i++){
      a=h*i;
      b=(h/2+h%2)*(w-i);
      c=(h/2)*(w-i);
      t=max(a,max(b,c))-min(a,min(b,c));
      ans=min(ans,t);
    }
    swap(w,h);
    for(int i=1;i<w;i++){
      a=h*i;
      b=(h/2+h%2)*(w-i);
      c=(h/2)*(w-i);
      t=max(a,max(b,c))-min(a,min(b,c));
      ans=min(ans,t);
    }
    cout<<min(ans,min(w,h))<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
   int N;cin>>N;
   vector<ll> A(N);
   REP(i,N) cin>>A[i];
   sort(rAll(A));
   vector<ll> le(N);
   int ref=0;
   REP(i,N-1){
       if(A[i]==A[i+1]){
            le[ref++]=A[i];
            i++;
        }
    }
    cout<<le[0]*le[1]<<endl;
}


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

#define MAXN 1000000

int primeN[MAXN];

bool isPrime(int num)
{
	if(num < 2) return false; 
	if(num == 2) return true;
	if(num%2 == 0) return false;
	for(int i=3; i < (int)sqrt((double)num) + 1; i++)
	{
		if(num % i == 0) return false;
	}
	return true;
}

void calcPrimeN()
{
	primeN[0] = 0;
	for(int i=1; i<MAXN; i++)
	{
		if(isPrime(i)) primeN[i] = primeN[i-1] + 1;
		else primeN[i] = primeN[i-1];
	}
}

int main()
{
	calcPrimeN();
	
	int data;
	while(cin >> data)
	{
		cout << primeN[data] << endl;
	}

	return 0;
}

Measured memory_bytes: 5064