akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)

using namespace std;



int main() {
	int i, j, k;
	string s;
	string t;
	int q, a[100000][4];
	cin >> s >> t >> q;
	rep(i, 0, q) {
		cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
	}
	int b[100001] = {}, c[100001] = {};
	rep(i, 0, s.length()) {
		if (s[i] == 'A')
			b[i + 1] = b[i] + 1;
		else
			b[i + 1] = b[i] + 2;
	}
	rep(i, 0, t.length()) {
		if (t[i] == 'A')
			c[i + 1] = c[i] + 1;
		else
			c[i + 1] = c[i] + 2;
	}
	rep(i, 0, q) {
		if ((b[a[i][1]] - b[a[i][0]-1])%3== (c[a[i][3]] - c[a[i][2]-1]) % 3)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MOD2 100000000
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(v) v.begin(),v.end()
ll mod=MOD;
using namespace std;
long long int fast_exp(long long int base,long long int ex) {
    long long int res=1;
    while(ex>0) {
       if(ex%2==1) res=(res*base)%mod;
       base=(base*base)%mod;
       ex/=2;
    }
    return res%mod;
}
long long int gcd(long long int a, long long int b)
{
    if(b==0)return a;
     return gcd(b,a%b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   ll n;
   ll o=0;cin>>o;
   cin>>n;
   ll ar[n];
   for(int i=0;i<n;i++)
    cin>>ar[i];
   sort(ar,ar+n);
   ll su=0;
   vector<ll>v;
   if(o>=n){cout<<"0\n";return 0;}
   for(int i=0;i<n-1;i++)
  {
      su+=ar[i+1]-ar[i];
      v.pb(ar[i+1]-ar[i]);
  }
  sort(all(v));reverse(all(v));
  for(int i=0;i<o-1;i++)
    su-=v[i];
  cout<<su<<"\n";

   return 0;

}


Measured memory_bytes: 2168
#include <stdio.h>

int
main(void)
{
	char s[20];
	scanf("%s", s);

	int i;
	for (i = 0; i < 19; i++) {
		if (s[i] == ',')
			putchar(' ');
		else
			putchar(s[i]);
	}
	puts("");
	return 0;
}


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

int32_t main(){
    int n;
    cin>>n;
    int a = n%10;
    if(a==2||a==4||a==5||a==7||a==9){
        cout<<"hon"<<endl;
    }
    else if(a==0||a==1||a==6||a==8){
        cout<<"pon"<<endl;
    }
    else{
        cout<<"bon"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;

int main() {
    int N;
    cin>>N;
    priority_queue<long, vector<long>, greater<long> > que1;
    priority_queue<long> que2;
    long middle[N];
    long tmp;
    vector<long> ans1, ans2;
    ans1.push_back(0);
    ans2.push_back(0);
    for(int i=0;i<3*N;++i){
        cin>>tmp;
        if(i<N){
            que1.push(tmp);
            ans1[0] += tmp;
        }
        else if(i<2*N){
            middle[i-N] = tmp;
        }
        else{
            que2.push(tmp);
            ans2[0] += tmp;
        }
    }
    for(int i=0;i<N;++i){
        tmp = middle[i];
        if(que1.top() < tmp){
            ans1.push_back(ans1[i] - que1.top() + tmp);
            que1.pop();
            que1.push(tmp);
        }
        else {
            ans1.push_back(ans1[i]);
        }
    }
    for(int i=N-1;i>=0;--i){
        tmp = middle[i];
        if(que2.top() > tmp){
            ans2.push_back(ans2[N-1-i] - que2.top() + tmp);
            que2.pop();
            que2.push(tmp);
        }
        else{
            ans2.push_back(ans2[N-1-i]);
        }
    }
    long ans = ans1[0] - ans2[N];
    for(int i=0;i<=N;++i){
        if(ans < ans1[i] - ans2[N-i]) ans = ans1[i] - ans2[N-i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4852
Sa_str = input()
Sb_str = input()
Sc_str = input()

Sa = []
Sb = []
Sc = []
for i in range(len(Sa_str)):
    Sa += [Sa_str[i]]
for i in range(len(Sb_str)):
    Sb += [Sb_str[i]]
for i in range(len(Sc_str)):
    Sc += [Sc_str[i]]

last = 'a'
res = 'A'

for i in range(len(Sa) + len(Sb) + len(Sc) + 3):
    if last == 'a':
        if len(Sa) == 0:
            res = 'A'
            break
        last = Sa[0]
        Sa = Sa[1:]
    elif last == 'b':
        if len(Sb) == 0:
            res = 'B'
            break
        last = Sb[0]
        Sb = Sb[1:]
    elif last == 'c':
        if len(Sc) == 0:
            res = 'C'
            break
        last = Sc[0]
        Sc = Sc[1:]

print(res)


Measured memory_bytes: 3064
a = int(input())
b = int(input())
if a == 1:
  if b == 2:
    print(3)
  elif b == 3:
    print(2)
elif a == 2:
  if b == 1:
    print(3)
  elif b == 3:
    print(1)
else:
  if b == 1:
    print(2)
  elif b == 2:
    print(1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
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; }

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

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h) cin >> s[i];

    int ans = 0;
    rep(i, 1<<h){
        rep(j,1<<w){
            vector<int> hb(h);
            rep(r, h) if (i>>r & 1) hb[r] = 1;
            vector<int> wb(w);
            rep(c, w) if (j>>c & 1) wb[c] = 1;

            int kuro = 0;
            rep(row, h){
                rep(col, w){
                    if (hb[row] == 0 && wb[col] == 0 && s[row][col] == '#') kuro++;
                }
            }
            if (kuro == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <queue>
#include <vector>
#include <iostream>
#include <climits>

using namespace std;

class Edge {
  public:
    int from;
    int to;
    int cost;
    Edge(int _from, int _to, int _cost) { from = _from; to = _to; cost = _cost; }
};

class Node {
  public:
    bool is_visited;
    int cost;
    vector<Edge> edges;
    Node() { cost = INT_MAX; is_visited = false; }
};

class SimpleNode {
  public:
    int cost;
    int index;
    SimpleNode(int _cost, int _index) { cost = _cost; index = _index; }
};

bool has_larger_cost(const SimpleNode& a, const SimpleNode& b) {
  return a.cost > b.cost;
}

int main()
{
  int nnodes, nedges, start;
  cin >> nnodes >> nedges >> start;
  priority_queue<SimpleNode, vector<SimpleNode>, decltype(&has_larger_cost)> pq(&has_larger_cost);
  vector<Node> nodes(nnodes);
  for (int i = 0; i < nedges; i++) {
    int from, to, cost;
    cin >> from >> to >> cost;
    nodes.at(from).edges.emplace_back(from, to, cost);
  }
  nodes.at(start).cost = 0;
  pq.push(SimpleNode(0, start));
  while (!pq.empty()) {
    SimpleNode node(pq.top().cost, pq.top().index);
    pq.pop();
    if (nodes.at(node.index).cost < node.cost) {
      continue;
    }
    for (const auto& edge : nodes.at(node.index).edges) {
      if (node.cost + edge.cost < nodes.at(edge.to).cost) {
        nodes.at(edge.to).cost = node.cost + edge.cost;
        pq.push(SimpleNode(node.cost + edge.cost, edge.to));
      }
    }
  }
  for (const auto& node : nodes) {
    if (node.cost == INT_MAX) {
      cout << "INF\n";
    } else {
      cout << node.cost << '\n';
    }
  }
  return 0;
}



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

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

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

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

int main() {
  int n, k;
  cin >> n >> k;
  int sunuke[n];
  rep(i, n) sunuke[i] = 0;

  rep(i, k) {
    int d;
    cin >> d;
    rep(j, d) {
      int s;
      cin >> s;
      --s;
      sunuke[s] = 1;
    }
  }

  int result = 0;
  rep(i, n) {
    if (sunuke[i] == 0) result++;
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

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

using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 1e9 + 7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

template<typename T>
class Union_Find {
  private:
	vector<T> t, s;

  public:
	explicit Union_Find(T max_length) {
		for (int i = 0; i < max_length + 1; ++i) {
			t.push_back(i);
			s.push_back(1);
		}
	}

	void Union(T x, T y) {
		if (same(x, y)) return;
		T tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}
	T Find(T n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}

	bool same(T x, T y) {
		return Find(x) == Find(y);
	}

	T get_Size(size_t a) {
		return s[Find(a)];
	}
};

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n,m;
    cin>>n>>m;
    Union_Find<int> tree(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        tree.Union(a,b);
    }
    int ans=0;
    rep(i,1,1+n){
        ans=max(ans,tree.get_Size(i));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6688
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, s, t, q, sum, last, cnt, ans, a[1000][1000] = {}, dp[1000][1000] = {};
int dd[4][2] = { {1,0},{0,1},{ -1,0 },{ 0,-1 } };
string str,ss;
struct Edge { LL to; };
vector<Pll>vec[1000][1000];
bool f;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
LL dfs(LL x,LL y) {
	LL ss = -10;
	bool f = 0;
	if (dp[x][y] != -1)return dp[x][y];
	rep(i, vec[x][y].size()) {
		LL now = dfs(vec[x][y][i].fir, vec[x][y][i].sec);
		if (ss!=-10&&ss != now)f = 1;
			ss = now;
	}
	if (vec[x][y].size() == 0)return dp[x][y] = x + y * 10000;
	if (!f)return dp[x][y] = ss;
	return dp[x][y] = -100;
}
int main() {
	cin >> h >> w;
	rep(i, h)rep(j, w) {
		cin >> a[i][j];
	}
	rep(i, h)rep(j, w) {
		rep(k, 4) {
			int X = i + dd[k][0], Y = j + dd[k][1];
			if (X >= 0 && Y >= 0 && X < h&&Y<w&&a[i][j]>a[X][Y])
				vec[i][j].push_back(Pll(X, Y));
		}
	}
	rep(i, h)rep(j, w)dp[i][j] = -1;
	rep(i, h)rep(j, w) {
		ans += dfs(i, j) == -100 ? 1 : 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 135536
#include<iostream>
#include<cstdlib>

using namespace std;

int main(){

    char n[10];
    int a = 0, b = 0;

    cin >> n;

    for(int i = 0; n[i] != '\0'; i++){
        a += (int)n[i] - 48;
    }

    b = atoi(n);

    if(b % a == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>
#include <numeric>

typedef long long Int; 
#pragma warning(disable : 4996)
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define REPS(a,i,n) for(int i = a ; i < n ; ++i)
using namespace std;



vector<Int> eki(10);
int main(){

	while (scanf("%lld,", &eki[0]) != EOF){
		REPS(1, i, 10){
			scanf("%lld,", &eki[i]);
		}
		double v1,v2;
		scanf("%lf,%lf", &v1, &v2);

		double rate = ((double)v1 / (v1 + v2));

		Int sum = accumulate(eki.begin(), eki.end(), 0);

		double k = sum*rate;

		int ans = 0;
		int ed = 0;
		for (; ed < k && ans < 10;ans++){
			ed += eki[ans];
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
#include <stdio.h>

int main(void) {
	int a,b;
	int c;
	int count;
	while(!feof(stdin)) {
		scanf("%d %d",&a,&b);
		while(!feof(stdin) && getchar()!='\n');
		if(feof(stdin))break;
		c=a+b;
		if(c<0)c=-c;
		for(count=0;c>0;count++)c/=10;
		if(a+b==0)count=1;
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int a, b, c; cin >> a >> b >> c;
    swap(a, b), swap(a, c);
    cout << a << " " << b << " " << c << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;

int main(){
    int A, B;
    cin >> A >> B;
    rep2(i, 1, 3){
        if(i != A && i != B) cout << i << endl;
    }
}

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

ll n;
vl a,b;

int main(){
	cin>>n;
	a=b=vl(n);
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		a[i]=x;
		b[0]+=(i%2==0?x:-x);
	}
	for(int i=1;i<n;i++) b[i]=2*a[i-1]-b[i-1];
	for(int i=0;i<n;i++) cout<<b[i]<<" \n"[i==n-1];
}

Measured memory_bytes: 2944
import java.util.*;
public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a, b, c;
  	a = sc.nextInt();
  	b = sc.nextInt();
  	c = sc.nextInt();
  	
  	if((a == b)&&(a == c)){
      	System.out.println("No");
      	System.exit(0);
    }
  	if((a == b)||(a == c)||(b == c)){
     	System.out.println("Yes");
      	System.exit(0);
    }
  	System.out.println("No");
  	System.exit(0);
	}
}

Measured memory_bytes: 22612
s = input()
n = len(s)
s1 = s[:(n - 1) // 2]
s2 = s[(n + 1) // 2:]

if s == s[:: -1] and s1 == s1[:: -1] and s2 == s2[:: -1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int ans=-1000;
int main()
{
	string s;
	cin>>s;
	s+='X';
	for(int i=0;i<s.size();i++)
	{
		int ans2=0;
		while(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
		{
			ans2++;
			i++;
		}
		ans=max(ans,ans2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<climits>
#include<map>
#include<string>
using namespace std;

bool is_prime[ (int)1e6+1 ];

int main(){
	fill_n(is_prime, 1e6+1, true);
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i <= 1e6; i++){
		if(!is_prime[i]) continue;
		for(int j = 2; i*j <= 1e6; j++) is_prime[i*j] = false;
	}

	int N, X;
	while(cin >> N >> X, N || X){
		int C[30], ans = -1;
		bool dp[ (int)1e6+1 ] = {};
		for(int i = 0; i < N; i++){
			cin >> C[i];
		}
		dp[0] = true;
		for(int j = 0; j < X; j++){
			if(!dp[j]) continue;
			for(int k = 0; k < N; k++){
				if(j + C[k] > X) continue;
				dp[j + C[k]] = true;
				if(is_prime[j + C[k]]) ans = max(ans, j + C[k]);
			}
		}
		if(ans == -1) puts("NA");
		else printf("%d\n", ans);
	}
	return 0;
}

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

int main()
{
	int N;
	int *p, *q;
	int i, j, k;
	int sum=0;
	int min=0;

	scanf("%d", &N);

	p = (int *)malloc(sizeof(int) * N);
	q = (int *)malloc(sizeof(int) * N);

	for(i=0; i<N; i++){
		scanf("%d", p+i);
	}

	for(i=0; i<N; i++){
		scanf("%d", q+i);
	}

	for(i=0; i<N; i++){
		for(j=0; j<=i; j++){
			sum = sum + *(p+j);
		}
		for(k=j-1; k<N; k++){
			sum = sum + *(q+k);
		}
		if(min < sum){
			min = sum;
		}
		sum = 0;
	}

	printf("%d", min);

	free(p);
	free(q);

return 0;
}

Measured memory_bytes: 128
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main(){
	int N;
	int ans = 0;
	sci(N);
	for (int i = 1; i <= N; i += 2) {
		int divisor = 0;
		for (int j = 1; j <= i; ++j) {
			divisor += (i % j == 0);
		}
		ans += divisor == 8;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    A = in_nl()

    mod = 10**9 + 7
    num = [0] * 3
    ans = 1

    for i in range(N):
        min_j = 4
        count = 0
        for j in range(3):
            if num[j] == A[i]:
                count += 1
                min_j = min(min_j, j)
        if min_j == 4:
            ans = 0
            break
        num[min_j] += 1
        ans *= count
        ans %= mod

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18444
// Problem : A - 500 Yen Coins
// Contest : AtCoder Beginner Contest 150
// URL : https://atcoder.jp/contests/abc150/tasks/abc150_a
// Memory Limit : 1024,000000 MB 
// Time Limit : 2000,000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <cmath>

#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <map>
#include <set>
#include <vector>

using namespace std;

int k;
int x;

void input() {
  cin >> k >> x;
}

void solve1() {
  if (500 * k >= x) {
    cout << "Yes";
  
    exit(0);
  }
  
  cout << "No";
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cout.precision(16);
  cout << fixed;
  
  input();
  solve1();
}


Measured memory_bytes: 256
y="a";
z=-1e8;n,i;main(a,s){
  if( y<0 ) return -1;
  for(;scanf("%d",!n?s=0,i=a=z,&n:&i),i-z?a=a<(s+=i)?s:a,--n||printf("%d\n",a):n;s*=s>0);}

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < k; i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
int main(){
	int n;
	scanf("%d",&n);
	rep(i,n){
		int x,y,b,p;
		scanf("%d%d%d%d",&x,&y,&b,&p);
		int ans = 10000000;
		int bm = x/5*4;
		int pm = y/5*4;
		if(b >= 5 && p >= 2)ans = min(ans,bm*b+pm*p);
		else{
			ans = min(ans,x*b+y*p);
			if(b >= 5){
				ans = min(ans,bm*b+pm*2);
			}
			else if(p >= 2){
				ans = min(ans,bm*5+pm*p);
			}
			else{
				ans = min(ans,bm*5+pm*2);
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>

int main( void )
{
	int x, y;
	
	while( 1 ){
		scanf( "%d %d", &x, &y );
		
		if(x == 0 && y == 0) break;
		
		if( x > y ){
			printf("%d %d\n", y, x);
		}
		else{
			printf("%d %d\n", x, y);
		}
	}
	
	return 0;
}

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

using namespace std;

int solve(int N, vector<int>& xs)
{
    sort(xs.begin(), xs.end());

    int m = N/2;

    if ((m - 1 >= 0 and xs[m - 1] == xs[m]) or (m + 1 < N and xs[m + 1] == m))
        return 0;

    return xs[m] - xs[m - 1];
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> xs(N);

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

    auto ans = solve(N, xs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 640
a = input()
a = list(a)

a = [int(i) for i in a]
if a[-1] == 2 or a[-1] == 4 or a[-1] == 5 or a[-1] == 7 or a[-1] == 9:
    print('hon')
elif a[-1] == 0 or a[-1] == 1 or a[-1] == 6 or a[-1] == 8:
    print('pon')
elif a[-1] == 3:
    print('bon')

Measured memory_bytes: 9144
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); //整数を読み込む
        System.out.println("0.00000 0.00000");
        kock(0,0,100,0,n);
        System.out.println("100.00000 0.00000");
    }
    static void kock(double x1, double y1, double x2, double y2, int n) {
        if(n==0) return;
        double d = Math.pow(Math.pow(x1-x2,2)+Math.pow(y1-y2,2),0.5)/3;
        double r = Math.atan2(y2-y1, x2-x1);

        double sx = x1 + Math.cos(r)*d;
        double sy = y1 + Math.sin(r)*d;
        double tx = sx + Math.cos(r)*d;
        double ty = sy + Math.sin(r)*d;
        double ux = sx + Math.cos(r + Math.PI/3)*d;
        double uy = sy + Math.sin(r + Math.PI/3)*d;

        kock(x1,y1,sx,sy,n-1);
		System.out.printf("%.5f %.5f\n",sx,sy);
		kock(sx,sy,ux,uy,n-1);
		System.out.printf("%.5f %.5f\n",ux,uy);
		kock(ux,uy,tx,ty,n-1);
		System.out.printf("%.5f %.5f\n",tx,ty);
		kock(tx,ty,x2,y2,n-1);
    }
}



Measured memory_bytes: 39708
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.functional;

bool[8][8] PS;

void main()
{   
    auto nm = readln.split.to!(int[]);
    auto n = nm[0];
    auto m = nm[1];

    foreach (_; 0..m) {
        auto ab = readln.split.to!(int[]);
        PS[ab[0]-1][ab[1]-1] = true;
        PS[ab[1]-1][ab[0]-1] = true;
    }

    int search(int pos, int[] hists) {
        int[] nexts;
        foreach (i, c; PS[pos])
            if (c && hists.find(i).empty) nexts ~= i.to!int;

        if (nexts.empty)
            return hists.length == n ? 1 : 0;
        
        return reduce!"a + b"(0, nexts.map!(n => search(n, hists ~ n)));
    }

    writeln(search(0, [0]));
}

Measured memory_bytes: 1276
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	int a[100005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	long long int p = 1000000007;
	long long int dp[100005];
	long long int count[100005];
	for (i = 0; i < n; i++)
		dp[i] = 0;
	for (i = 0; i < n; i++)
		count[i] = 0;
	for (i = 0; i < n; i++)
	{
		if (a[i] == 0)
			dp[i] = 3 - count[0];
		else
			dp[i] = count[a[i] - 1] - count[a[i]];
		count[a[i]]++;
	}
	long long int ans = 1;
	for (i = 0; i < n; i++)
		ans = ans * dp[i] % p;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2176
class SegmentTree

  def initialize xs, id, &block
    @id = id
    @block = block
    i = 1
    i *= 2 while i < xs.size
    @width = i
    @data = Array.new(2 * i - 1, id)
    @data[i-1...i-1+xs.size] = xs
    (i-2).downto(0) {|j| @data[j] = block[@data[2*j+1], @data[2*j+2]] }
  end

  def query i, j, k = 0, a = 0, b = @width
    return @data[k] if i == a && j == b
    c = (a + b) / 2
    case
    when j <= c
      query i, j, 2 * k + 1, a, c
    when c <= i
      query i, j, 2 * k + 2, c, b
    else
      @block[query(i, c, 2 * k + 1, a, c), query(c, j, 2 * k + 2, c, b)]
    end
  end

  def []= i, x
    i = @width - 1 + i
    @data[i] = x
    while i > 0
      j = (i-1)/2
      @data[j] = @block[@data[2*j+1], @data[2*j+2]]
      i = j
    end
  end

end

n, q = gets.split.map(&:to_i)
st = SegmentTree.new(Array.new(n, 2**31 - 1), 2**31 - 1) {|a, b| a < b ? a : b }
q.times do
  c, x, y = gets.split.map(&:to_i)
  if c.zero?
    st[x] = y
  else
    p st.query x, y + 1
  end
end

Measured memory_bytes: 11804
#include <iostream>
#include <stdlib.h>
using namespace std;

int main(void){
   int N,X;
   cin >> N >> X;
   int d=0;
   int b[N];

   for(int j=0;j<N;j++){
       cin >> b[j];
   }
   for(int i = 0;i<N;i++){
       d +=b[i];
       if(d>X){
           cout << i+1;
           break;
       }
       if(i==N-1){
           cout << N+1;
       }
   }
    return 0;
}

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

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

    int skip;
    if (L < 1)
    {
        skip = min(N, 1 - L);
    } else
    {
        skip = 1;
    }
    
    
    int ans = 0;
    for (int i = 1; i <= N; i++)
    {
        if (i == skip)
        {
            continue;
        }
        ans += L + i - 1;
    }
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const ll INF = 1000000007;

const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}
struct edge {
	int to;
	ll cost;
	edge(int _to, ll _cost) : to(_to), cost(_cost) {}
};

void solv() {
	ll n;
	cin >> n;
	ll a[200010];
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (size_t i = 1; i < n; i++)
	{
		a[i] = a[i - 1] + a[i];
	}

	int le = 0;
	int ri = 2;
	ll res = INF;
	for (size_t i = 1; i < n - 1; i++)
	{
		ll p, q, r, s;
		p = a[le];
		q = a[i] - a[le];
		if (ri == i) ri++;
		r = a[ri] - a[i];
		s = a[n - 1] - a[ri];

		ll left = abs(a[le] - (a[i] - a[le]));

		for (size_t j = le + 1; j  < i; j++)
		{
			ll tl = abs(a[j] - (a[i] - a[j]));
			if (left < tl) break;
			left = tl;
			le = j;
			p = a[j];
			q = a[i] - a[j];
		}

		ll right = abs((a[ri] - a[i]) - (a[n - 1] - a[ri]));

		for (size_t j = ri + 1; j < n; j++)
		{
			ll tl = abs((a[j] - a[i]) - (a[n - 1] - a[j]));
			if (right < tl) break;
			right = tl;
			ri = j;
			r = (a[j] - a[i]);
			s = (a[n - 1] - a[j]);
		}
		res = min(res, max(max(p, q), max(r, s)) - min(min(p, q), min(r, s)));
	}
	cout << res << endl;
}

int main() {
	//COMinit();
	solv();

	return 0;
}
	

Measured memory_bytes: 1792
#include<stdio.h>
#define N 100
#define B 2
#define G 1
#define W 0

int n,M[N][N],color[N],d[N],f[N],t;

void dfsvisit(int u){
  int v;
  color[u]=G;
  d[u]=++t;
  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(color[v]==W){
      dfsvisit(v);
    }
  }
  color[u]=B;
  f[u]=++t;
}

void dfs(){
  int u;
  for(u=0;u<n;u++){
    color[u]=W;
  }
  t=0;
  for(u=0;u<n;u++){
    if(color[u]==W){
      dfsvisit(u);
    }
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int i,j,k,u,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  dfs();
  return 0;
}

Measured memory_bytes: 636
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int x;
int main()
{
	scanf("%d",&x);
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++)
			if(i*j==x)
			{
				printf("Yes\n");
				return 0;
			}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool c(int x,int y){
    return y<x;
}
int main() {
    int n;cin>>n;
    vector<int > p(n);
    for (int i = 0; i < n; ++i)
        cin>>p[i];
    int q;cin>>q;
    while(q--){
        int b,e;cin>>b>>e;
        reverse(&p[b],&p[e]);
    }
    for (int i = 0; i < n-1; ++i)
        cout<<p[i]<<" ";
    cout<<p[n-1]<<endl;
    return 0;
}



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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};
bool dp[100001];
// DP

int main() {
    string S;
    cin >> S;
    dp[0] = 1;
    rep(i, S.size()) {
        if (!dp[i]) continue;
        for (string s : divide) {
            if (S.substr(i, s.size()) == s) dp[i + s.size()] = 1;
        }
    }
    if (dp[S.size()]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

int main(){
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  
  int white = H*W;
  int black = h*W + H*w - h*w;
  
  white -= black;
  
  cout << white << endl;
}

Measured memory_bytes: 3680
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

ll dp[55][55][3000] = {0};

int main(void){
    ll n, a;
    cin >> n >> a;

    vector<ll> x(n);

    ll total = a * n;

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

    dp[0][0][0] = 1;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < 3000; k++){
                if(dp[i][j][k]){
                    dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];

                    // cout << dp[i][j][k] << endl;

                    dp[i + 1][j][k] += dp[i][j][k];
                }
            }
        }
    }

    ll ans = 0;
    for(int i = 1; i < n + 1; i++){
        ans += dp[n][i][a * i];
    }

    cout << ans << endl;


}


Measured memory_bytes: 65792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    cin >> N;
    vector<int> a(N);

    int xo = 0;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        xo ^= a[i];
    }

    for (int i = 0; i < N; ++i)
        cout << (xo ^ a[i]) << ' ';
    cout << endl;

    return 0;
}


Measured memory_bytes: 3952
s = input()
n = len(s)
temp = s[0]
grp = []
ans = [0]*n
sec = [temp]
rlind = []
for i in range(1,n):
  if temp=='L' and s[i]=='R':
    grp.append(sec)
    sec = []
  elif temp=='R' and s[i]=='L':
    rlind.append(i)
  sec.append(s[i])
  temp = s[i]
grp.append(sec)

for i in range(len(grp)):
  ind = rlind[i]
  m = len(grp[i])
  if m%2==0:
    p = m//2
    ans[ind]=p
    ans[ind-1]=p
  else:
    p = grp[i].count('R')
    q = max(p,m-p)
    if p==q:
      p = -(-m//2)
    else:
      p = m//2
    if (q-1)%2==0:
      ans[ind]=m-p
      ans[ind-1]=p
    else:
      ans[ind]=p
      ans[ind-1]=m-p
print(*ans)

Measured memory_bytes: 17876
#include <iostream>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b,c,d;
  cin >> a;
  
  if(a>=1200){
	
  	cout << "ARC"<<endl;
  }else{
	cout << "ABC"<<endl;
  }
    return 0;
}


Measured memory_bytes: 256
nn, qq = gets.split.map(&:to_i)
events = []
temp = []
1.step(nn, 1) do |_i|
  temp = gets.split.map(&:to_i)
  next if temp[1] - temp[2] <= 0
  x = temp[0] - temp[2]
  x = x > 0 ? x : 0

  events.push([temp[1] - temp[2], 1, temp[2]])
  events.push([temp[0] - temp[2], 0, temp[2]])
end
1.step(qq, 1) do |i|
  events.push([gets.to_i, 2, i])
end
events.sort_by!(&:first)

class Heap
  def initialize
    @a = [nil]
    @h = {}
  end

  def swap(i, j)
    @a[i], @a[j] = @a[j], @a[i]
    @h[@a[i]], @h[@a[j]] = i, j
  end

  def b_up(i)
    p = i / 2
    return if i <= 1 || @a[p] <= @a[i]
    swap(i, p)
    b_up(p)
  end

  def add(v)
    return if @h[v]
    @a << v
    @h[v] = @a.size - 1
    b_up(@a.size - 1)
  end

  def b_dn(i)
    c = i * 2
    return if c >= @a.size
    c += 1 if c != @a.size - 1 && @a[c] > @a[c + 1]
    return if @a[i] <= @a[c]
    swap(i, c)
    b_dn(c)
  end

  def delete(v)
    return unless i = @h[v]
    u = @a[-1]
    swap(i, -1)
    ret = @a.pop
    @h[ret] = nil
    v > u ? b_up(i) : b_dn(i)
    ret
  end

  def first
    @a[1] || -1
  end
end

ss = Heap.new
ans = []

events.each do |event|
  if event[1] == 0
    ss.add(event[2])
  elsif event[1] == 1
    ss.delete(event[2])
  else
    ans[event[2]] = ss.first
  end
end

puts ans[1..-1]

Measured memory_bytes: 68892
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void Main()
{
    string s;
    cin >> s;
    if(s[0] == 'S'){
        cout << "Cloudy" << endl;
    }
    if(s[0] == 'C'){
        cout << "Rainy" << endl;
    }
    if(s[0] == 'R'){
        cout << "Sunny" << endl;
    }
    return;
}
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
 template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
using namespace std;

const long long INF=9000000000000000;
int main(){
  long int n,ans=0;
  cin>>n;
 long int num[n];
 long int x[n+10]={};
  for(int i=0;i<n;i++){
    cin>>num[i];
    if(num[i]>n)
      ans++;
    else
      x[num[i]]++;
  }
  for(int i=0;i<n+10;i++){
    if(x[i]<i)
      ans+=x[i];
    else if(x[i]>i)
      ans+=x[i]-i;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Ans[2] = {"No", "Yes"};
string ANS[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1);
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


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

int main() {
  int n,d;
  cin >> n >> d;
  vector<vector<int>> x (n,vector<int>(d,0));
  for(int i=0; i<n; i++){
    for(int j=0; j<d; j++){
      cin >> x.at(i).at(j);
    }
  }
  int ans = 0;
  for(int i=0; i<n-1; i++){
    for(int j=i+1; j<n; j++){
      int buf = 0;
      for(int k=0; k<d; k++){
        buf += pow((x.at(i).at(k) - x.at(j).at(k)),2);
      }
      if(buf == pow((int)pow(buf,0.5),2)){
        ans++;
      }
    }
  }
  cout << ans << 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 a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		String message = "NO";
		if(b - a == c - b) {
			message = "YES";
		}
		System.out.println(message);
	}
}

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

double num[20][20];

int
main( void ) {
	int N, D;
	scanf("%d %d", &N, &D);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++) {
			scanf("%lf", &num[i][j]);
		}
	}

	double d = 0;
	double integer = 0;
	int count = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			d = 0;
			for (int k = 0; k < D; k++) {
				d += pow(num[i][k] - num[j][k], 2);
			}
			//printf("%f\n", d);
			d = sqrt(d);
			integer = (int)d;
			if (d == integer) {
				count++;
			}
		}
	}

	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> d(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &d[i]);
  }
  sort(d.begin(), d.end());
  if (N % 2 == 0)
    cout << d[N / 2] - d[N / 2 - 1] << endl;
  else
    cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n)
	fmt.Scan(&k)

	ret := n - k + 1
	if n == 0 {
		ret = 0
	}
	if k > n {
		ret = 0
	}

	fmt.Println(ret)
}


Measured memory_bytes: 512
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		HashSet<Integer> set = new HashSet<Integer>();
		for (int i = 0; i < K; i++) {
			int d = sc.nextInt();
			for (int j = 0; j < d; j++) {
				set.add(sc.nextInt());
			}
		}
		sc.close();

		System.out.println(N - set.size());
	}
}


Measured memory_bytes: 46144
#include <stdio.h>
int main(){
  int nums[101];
  int sorted[101];
  int n;
  int i=0;
  int v;
  int j;
  int k;
  scanf("%d\n",&n );
  while (i<n) {
    scanf("%d",&nums[i]);
    i++;
  }
  
  for (i = 0; i < n; i++) {
    
    v=nums[i];
  	j=i-1;
  	while(j>=0&&nums[j]>v){
  	  nums[j+1]=nums[j];
  	   j--;
  	}
  	nums[j+1]=v;
  		k=0;
  	
  	while(k<n){
  		printf("%d",nums[k]);
  		k++;
  		if(k!=n)
  		printf(" ");
  	}
  	  printf("\n");

  }
  	return 0;
	
}

Measured memory_bytes: 604
n,m = map(int,input().split())
l = []
for i in range(m):
  l.append([int(i) for i in input().split()])
maxL = l[0][0]
minR = l[0][1]
for j in range(1,m):
  if maxL <= l[j][0]:
    maxL = l[j][0]
  if minR >= l[j][1]:
    minR = l[j][1]
if maxL <= minR:
  print(minR - maxL + 1)
else:
  print(0)

Measured memory_bytes: 60120
#include <iostream>
#include <vector>
#include <unordered_map>

int main() {
  size_t N;

  std::cin >> N;

  std::unordered_map<size_t, size_t> color_pos;
  size_t prev = 0;

  std::vector<size_t> ans;
  ans.reserve(N+1);
  ans.push_back(1);

  for (size_t i=1; i<N+1; i++) {
    size_t C;
    std::cin >> C;

    if (C == prev) {
      ans.push_back(ans[i-1]);
    } else if (color_pos.count(C) == 0) {
      ans.push_back(ans[i-1]);
    } else {
      auto a = ans[i-1] + ans[color_pos.at(C)];
      a %= 1000000007;
      ans.push_back(a);
    }

    prev = C;
    color_pos[C] = i;
  }

  std::cout << ans[N] << std::endl;

  return 0;
}


Measured memory_bytes: 10056