akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#define pq priority_queue
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;


int main(){
  ll a,b,k;
  cin>>a>>b>>k;

  if(b-a>=2*k){
    for (ll i = 0; i < k; i++) {
      cout<<a+i<<endl;
    }
    for (ll i = 1; i <= k; i++) {
      cout<<b-k+i<<endl;
    }
  }else{
    for (ll i = a; i <= b; i++) {
      cout<<i<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 256
using System;
using System.Web;
using System.IO;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using static System.Math;
 

class P
{
    static void Main()
    {
        int[] ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine((ab[1] - ab[0]) * (ab[1] - ab[0] - 1) / 2 - ab[0]);
    }
}


Measured memory_bytes: 13268
N,M=[int(i) for i in input().split()]
buf=[0]*M
for i in range(N):
  a=[int(i) for i in input().split()]
  for j in a[1:]:
    buf[j-1]+=1
c=0
for i in buf:
  if i==N:
    c+=1
print(c)

Measured memory_bytes: 2940
#include <cmath>
#include <iomanip>
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main() {
  uint64_t A;
  double B;
  cin >> A >> B;

  int int_b = std::round(B * 100);

  int64_t ans = (A * int_b);
  ans /= 100;

  cout << ans << endl;
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll K;
	cin >> K;

	if (K < 10){
		cout << K << endl;
		return 0;
	}

	ll digitMax = 11;

	vector <ll> lunlun;
	//1桁目は手動で生成
	for (int ii = 0; ii < 10; ++ii){
		lunlun.push_back(ii);
	}

	//2桁目以降
	ll base = 1;
	ll cnt = 9;
	bool fin = false;
	ll ans;
	for (int digit = 1; digit < digitMax; ++digit){
		base *= 10;
		vector <ll> tmplunlun;
		for (int ii = 1; ii < 10; ++ii){
			ll base2 = base * ii;
			for (int jj = 0; jj < lunlun.size(); ++jj){
				ll tmp = base2 + lunlun[jj];
				ll tmp2 = tmp;
				bool ok = true;
				// printf("tmp2 = %i\n", tmp2);
				for (int kk = 0; kk < digit; ++kk){
					// printf("  (tmp2 / 10) % 10 = %i\n", (tmp2 / 10) % 10);
					// printf("  tmp2 % 10 = %i\n", tmp2 % 10);

					bool cond = (abs( ((tmp2 / 10) % 10 ) - (tmp2 % 10) ) <= 1);
					if (!cond){
						ok = false;
						break;
					}
					tmp2 = tmp2 / 10;
				}
				if (ok) {
					tmplunlun.push_back(tmp);
					ans = tmp;
					cnt++;
					if (cnt == K){
						fin = true;
						break;
					}
				}
			}
			if (fin){
				break;
			}
		}
		for (int hoge = 0; hoge < tmplunlun.size(); ++hoge){
			lunlun.push_back(tmplunlun[hoge]);
		}
		if (fin){
			break;
		}
	}

	// for (int ii = 0; ii < lunlun.size(); ++ii){
	// 		printf("%i\n", lunlun[ii]);
	// }

	cout << ans << endl;

	return 0;
}


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

const int MAX_K = 5000;
int N;

int main() {
  scanf("%d", &N);
  int c = 0;
  for (int a = 1; a <= N; ++a) {
    for (int b = 1; b <= N; ++b) {
      int v = a * b;
      if (N - v > 0) c++;
      else break;
    }
  }
  printf("%d\n", c);
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N,M; cin >> N >> M;
    priority_queue<int> q,q2;
    rep(i,N){
        int a; cin >> a;
        q.push(a);
    }
    q2.push(0);
    rep(i,M){
        int a;
        a=q.top();q.pop();
        a/=2;
        q.push(a);
    }
    ll sum=0;
    while(!q.empty()){
        sum+=q.top();q.pop();
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;


int main(){
    int N;
    ll D, A;
    cin >> N >> D >> A;
    vector<pair<int,int>> XH(N);
    rep(i,N) cin >> XH[i].first >> XH[i].second;

    sort(XH.begin(), XH.end());

    D *= 2;
    ll total = 0;
    // pair.first:いつまで有効か、pair.secondはダメージはいくらか
    queue<pair<ll,ll>> q;
    ll ans = 0;
    rep(i,N){
        ll x = XH[i].first;
        ll h = XH[i].second;
        while (!q.empty() && q.front().first < x){
            // 範囲外となった爆風を減算
            total -= q.front().second;
            q.pop();
        }
        // 今回のモンスターより前での爆風ダメージを減算
        h -= total;
        if (h > 0){
            // 回数を算出(切り上げ)
            ll num = (h+A-1)/A;
            ans += num;
            ll damage = num * A;
            total += damage;
            q.emplace(x+D, damage);

        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 6220
#include <iostream>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)

int main(void)
{
	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int ca = 0;
	int cb = 0;
	rep(i, s.length()) {
		if (s[i] == 'c') {
			cout << "No" << endl;
		} else if (s[i] == 'a') {
			if (ca + cb < a + b) {
				ca++;
				cout << "Yes" << endl;
			} else cout << "No" << endl;
		} else {
			if (ca + cb < a + b && cb < b) {
				cb++;
				cout << "Yes" << endl;
			} else cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && (ch != '-')) ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 1005;
struct Edge { int x, y; } G[200005];
int vis[MAXN];
int A[MAXN][MAXN], B[MAXN][MAXN];
vector <int> e[MAXN];

inline void addedge(int from, int to) {
  e[from].push_back(to);
}

void Dfs(int now, int id) {
  vis[now] = 1;
  A[id][now] = 1;
  int si = e[now].size();
  for (RI i = 0; i < si; ++i)
    if (!vis[e[now][i]]) Dfs(e[now][i], id);
}
void DDfs(int now, int id, int tmp) {
  vis[now] = 1;
  if (now != tmp) B[id][now] = 1;
  int si = e[now].size();
  for (RI i = 0; i < si; ++i)
    if (!vis[e[now][i]]) DDfs(e[now][i], id, tmp);
}

int main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int n, m; read(n), read(m);
  for (RI i = 1; i <= m; ++i)
    read(G[i].x), read(G[i].y), addedge(G[i].x, G[i].y);
  for (RI i = 1; i <= n; ++i) {
    memset(vis, 0, sizeof(vis));
    Dfs(i, i);
  }
  cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl;
  for (RI i = 1; i <= n; ++i) {
    memset(vis, 0, sizeof(vis)); vis[i] = 1;
    int si = e[i].size();
    for (RI j = 0; j < si; ++j)
      if (!vis[e[i][j]]) DDfs(e[i][j], i, e[i][j]);
    memset(vis, 0, sizeof(vis)); vis[i] = 1;
    for (RI j = si - 1; ~j; --j)
      if (!vis[e[i][j]]) DDfs(e[i][j], i, e[i][j]);
  }
  for (RI i = 1; i <= m; ++i)
    if (A[G[i].y][G[i].x] ^ B[G[i].x][G[i].y])
      puts("diff");
    else puts("same");


  cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl;

  return 0;
}

// created by Daniel yuan

Measured memory_bytes: 13184
//this is https://atc002.contest.atcoder.jp/submissions/2097603
//thank you beet!
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T, typename E>
struct SkewHeap{
  typedef function<T(T, E)> F;
  typedef function<E(E, E)> G;
  typedef function<bool(T,T)> C;
  F f;
  G g;
  C c;
  T INF;
  E e;
  SkewHeap(F f,G g,C c,T INF,E e):f(f),g(g),c(c),INF(INF),e(e){}

  struct Node{
    Node *l,*r;
    T val;
    E add;
    Node(T val,E add):val(val),add(add){l=r=NULL;}
  };

  void eval(Node *a){
    if(!a) return;
    if(a->add==e) return;
    if(a->l) a->l->add=g(a->l->add,a->add);
    if(a->r) a->r->add=g(a->r->add,a->add);
    a->val=f(a->val,a->add);
    a->add=e;
  }
  
  T top(Node *a){
    return a?f(a->val,a->add):INF;
  }

  T snd(Node *a){
    eval(a);
    return a?min(top(a->l),top(a->r)):INF;
  }

  Node* add(Node *a,E d){
    if(a) a->add=g(a->add,d);
    return a;
  }
  
  Node* push(T v){
    return new Node(v,e);
  }
  
  Node* meld(Node *a,Node *b){
    if(!a) return b;
    if(!b) return a;
    if(c(top(a),top(b))) swap(a,b);
    eval(a);
    a->r=meld(a->r,b);
    swap(a->l,a->r);
    return a;
  }
  
  Node* pop(Node* a){
    eval(a);
    auto res=meld(a->l,a->r);
    free(a);
    return res;
  }
  
};

template<typename T>
T optimalbinarytree(vector<T> s,T INF){
  int n=s.size();
  using Heap=SkewHeap<T,T>;
  
  typename Heap::F f=[](T a,T b){return a+b;};
  typename Heap::G g=[](T a,T b){return a+b;};
  typename Heap::C c=[](T a,T b){return a>b;};
  Heap heap(f,g,c,INF,0);
  vector<typename Heap::Node* > hs(n,NULL);
  vector<int> ls(n-1),rs(n-1);
  vector<T> cs(n-1);
  
  using P = pair<T, int>;
  priority_queue<P,vector<P>,greater<P> > pq;
  for(int i=0;i<n-1;i++){
    ls[i]=i-1;
    rs[i]=i+1;
    cs[i]=s[i]+s[i+1];
    pq.emplace(cs[i],i);
  }
  
  T res=0;
  for(int k=0;k<n-1;k++){
    T c;
    int i;
    do{
      tie(c,i)=pq.top();pq.pop();
    }while(rs[i]<0||cs[i]!=c);

    bool ml=false,mr=false;
    if(s[i]+heap.top(hs[i])==c){
      hs[i]=heap.pop(hs[i]);
      ml=true;
    }else if(s[i]+s[rs[i]]==c){
      ml=mr=true;
    }else if(heap.top(hs[i])+heap.snd(hs[i])==c){
      hs[i]=heap.pop(heap.pop(hs[i]));
    }else{
      hs[i]=heap.pop(hs[i]);
      mr=true;
    }

    res+=c;
    hs[i]=heap.meld(hs[i],heap.push(c));

    if(ml) s[i]=INF;
    if(mr) s[rs[i]]=INF;

    if(ml&&i>0){
      int j=ls[i];
      hs[j]=heap.meld(hs[j],hs[i]);
      rs[j]=rs[i];
      rs[i]=-1;
      ls[rs[j]]=j;
      i=j;
    }

    if(mr&&rs[i]+1<n){
      int j=rs[i];
      hs[i]=heap.meld(hs[i],hs[j]);
      rs[i]=rs[j];
      rs[j]=-1;
      ls[rs[i]]=i;
    }

    cs[i]=min({s[i]+s[rs[i]],
	  min(s[i],s[rs[i]])+heap.top(hs[i]),
	  heap.top(hs[i])+heap.snd(hs[i])});

    pq.emplace(cs[i],i);
  }
  return res;
}


//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> s(n);
  for(Int i=0;i<n;i++) cin>>s[i];
  const Int INF = 1e16;
  cout<<optimalbinarytree(s,INF)<<endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define D7K_ICPC ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef long double ld;
using namespace std;
ll n,x,z,a,k,b,c,d,m,y,t;
int main() {
    D7K_ICPC
    cin>>a>>b>>c;
    for(int i=a ; i<=b; i++){
        if(i%c == 0) x++;
    }
    cout<<x;

    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

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

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

    ll N, L, T;
    cin >> N >> L >> T;
    vector<ll> X(N), W(N);
    REP(i, N) cin >> X[i] >> W[i];

    vector<ll> res(N);
    REP(i, N){
    	if(W[i] == 1){
    		res[i] = (X[i] + T)%L;
    	}else{
    		res[i] = (X[i] - T)%L;
    		res[i] += L;
    		res[i] %= L;
    	}
    }
    sort(res.begin(), res.end());
    //cout << res << endl;

    ll cnt = 0;
    REP(i, N){
        if(W[i] == 1){
            cnt -= (T + X[i])/L;
        }else{
            cnt += (T + L - X[i]-1)/L;
        }
        //dump(cnt)
    }
    cnt = (cnt%N+N)%N;
    //dump(cnt)
    REP(i, N){
        cout << res[(i-cnt+N)%N] << endl;
    }

    /*
    if(W[0] == 1){
        vector<ll> gyaku;
        REP(i, N) if(W[i] == 2) gyaku.push_back(X[i]);
        REP(i, gyaku.size()) gyaku[i] -= X[0];
        ll coll = 0;
        coll += (T/L)*gyaku.size();
        REP(i, gyaku.size()) if(gyaku[i] <= T%L) coll++;
        //dump(coll)
        coll %= N;
        //cout << res << endl;
        REP(i, N){
            cout << res[(i-coll+N)%N] << endl;
        }
    }else{
        vector<ll> gyaku;
        REP(i, N) if(W[i] == 1) gyaku.push_back(L-X[i]+X[0]);
        ll coll = 0;
        coll += (T/L)*gyaku.size();
        REP(i, gyaku.size()) if(gyaku[i] <= T%L) coll++;
        //dump(coll)
        coll %= N;
        //cout << res << endl;
        REP(i, N){
            cout << res[(i-coll+N)%N] << endl;
        }
    }
    */
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};


int main()
{
  int n, x; cin >> n >> x;
  vector<int> s(n);
  rep(i,n) cin >> s[i];

  sort(s.begin(), s.end(), [](int a, int b)-> bool{
			     return a > b;
			   });

  vector<mint> modinv(n+1);
  rep1(i,n) modinv[i] = (mint)1 / (mint)i;
  
  vector<vector<mint>> dp(2, vector<mint>(x+1));
  dp[0][x].x = 1;
  rep(i,n) {
    rep(j,x+1) {
      dp[1][j % s[i]] += dp[0][j] * modinv[n-i];
      dp[1][j]        += dp[0][j] * (mint)(n - 1 - i) * modinv[n-i];
    }
    dp[0] = dp[1];
    dp[1].assign(x+1, 0);
  }

  mint res;
  rep(j,x+1) res += dp[0][j]*(mint)j;
  rep1(i,n) res *= (mint)i;
  cout << res.x << "\n";
  
  
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N, K, Q; cin >> N >> K >> Q;
		vector<UL> A(N); rep(i, N) cin >> A[i];
		vector<pair<UL, UL>> sorted; rep(i, N) sorted.push_back({ A[i], i });
		sort(sorted.begin(), sorted.end());
		vector<UL> used(N + 1); used[N] = 1;
		UL ans = 1000000001;
		rep(i, N) {
			vector<UL> L;
			vector<UL> buf;
			rep(j, N + 1) {
				if (used[j]) {
					sort(buf.begin(), buf.end());
					if (buf.size() >= K)
						for (UL k = 0; k <= buf.size() - K; k++)
							L.push_back(buf[k]);
					buf.clear();
				}
				else { buf.push_back(A[j]); }
			}
			//rep(j, L.size()) cout << L[j] << " "; cout << endl;
			if (L.size() < Q) break;
			sort(L.begin(), L.end());
			ans = min(ans, L[Q - 1] - L[0]);
			used[sorted[i].second] = 1;
		}
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

int main() {
  int N;
  long long int answer;
  bool ans;
  ans = false;
  answer =1;
  cin >> N;
  vector<long long int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(A[i] == 0){
      answer = 0;
    }
  }
 
  for(int i = 0; i <N; i++){
    if(answer != 0 && 
       A[i] <= 1000000000000000000/answer){
    answer *= A[i];
    }
    else{
      ans = true;
    }
    
  }
 
  if(answer == 0){
    cout << 0 << endl;
  }
  else if(ans){
    cout << -1 << endl;
  }
  else{
    cout << answer << endl;
  }
  
 	
  
}


Measured memory_bytes: 4048
main :: IO ()
main = do
    n <- read <$> getLine
    as <- words <$> getLine
    let (xs, ys) = split as
    putStrLn $ unwords $
        if odd n then reverse xs ++ ys
                 else reverse ys ++ xs

split :: [a] -> ([a], [a])
split [] = ([], [])
split [x] = ([x], [])
split (x:y:zs) = let (xs, ys) = split zs
                 in  (x:xs, y:ys)

Measured memory_bytes: 145404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll A[13][13];
ll C[13];

vector<array<int,13>> v;
array<int,13> test{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

int dfs(int temp[], int i, int n) {
    if(i >= n) {
        for(int i = 0; i < n; i++) {
            test[i] = temp[i];
            //cout << test[i];
        }
        v.push_back(test);
        //cout << endl;
        return 0;
    }
    temp[i] = 0;
    dfs(temp, i+1, n);
    temp[i] = 1;
    dfs(temp, i+1, n);
    return 0;
} 

int main() {
    ll n, m, x;
    cin >> n >> m >> x;

    for(int i = 1; i <= n; i++) {
        cin >> C[i];
        for(int j = 1; j <= m; j++) {
            cin >> A[i][j];
            //cout << A[3][3] << endl; // 9
        }
    }

    int temp[13];
    temp[0] = 0;
    dfs(temp,1,n);
    temp[0] = 1;
    dfs(temp,1,n);

    int min_price = 99999999;
    int pair_n = (int)v.size();
    //cout << "pair_n " << pair_n << endl;
    int t[13];
    for(int i = 0; i < pair_n; i++) {
        for(int j = 0; j < 13; j++) {t[j] = 0;}
        int price = 0;
        for(int j = 1; j <= n; j++) {
            if(v[i][j-1] == 1) {
                price += C[j];
                //cout << "ADD" << endl;
                for(int k = 1; k <= m; k++) {
                    t[k] += A[j][k];

                }
            }
        }
        int match = 1;
        for(int j = 1; j <= m; j++) {
            if(t[j] < x) {
                match = 0;
            }
        }
        if(match == 1) {
            //cout << "match" << endl;
            min_price = min(min_price, price);
        }
        //cout << t[1] << " " << t[2] << " " << t[3] << endl;
    }

    if(min_price == 99999999) min_price = -1;
    cout << min_price << endl;

}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    int main(){
        ll n; cin>>n;
        ll h[n+1]; for(ll i=1;i<=n;i++) cin>>h[i];
        ll dp[n+1];
        dp[1]=0; dp[2]=abs(h[2]-h[1]);
        for(ll i=3;i<=n;i++) dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
        cout<<dp[n];
    }

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull B=100000007;

vector<int> contain(string a,string b){
  int al=a.size(),bl=b.size();
  vector<int> ans;
  if(al>bl)return ans;
  
  ull t=1;
  for(int i=0;i<al;i++)t*=B;

  int ah=0,bh=0;
  for(int i=0;i<al;i++)ah=ah*B+a[i];
  for(int i=0;i<al;i++)bh=bh*B+b[i];

  for(int i=0;i+al<=bl;i++){
    if(ah==bh)ans.push_back(i);
    if(i+al<bl)bh=bh*B+b[i+al]-b[i]*t;
  }
  return ans;
}

int main(){
  string t,p;
  cin>>t>>p;
  vector<int> ans=contain(p,t);
  for(int i=0;i<ans.size();i++)cout<<ans[i]<<endl;
  return 0;
}



Measured memory_bytes: 9412
// from https://atcoder.jp/contests/dp/submissions/11261467
#include<bits/stdc++.h>

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rrep(i,n) for(ll i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)
#define rrep1(i,n) for(ll i = (n); i > 0; i--)

#define ll long long
#define pi pair<ll, ll>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

struct Seg{
  vector<ll> sum;
  vector<ll> mx;
  Seg(){
    sum.resize(1<<19, 0);
    mx.resize(1<<19, 0);
  }

  void add_val(ll l, ll r, ll val, ll bottom=0, ll top=1<<18, ll pos=1){
    if(l <= bottom && top <=r){
      sum[pos] += val;
      return ;
    }
    if(r<=bottom || l>=top)return ;

    ll mid = (bottom + top)/2;
    add_val(l, r, val, bottom, mid, pos*2);
    add_val(l, r, val, mid, top, pos*2+1);
    mx[pos] = max<ll>(mx[pos*2] + sum[pos*2],  mx[pos*2+1] + sum[pos*2+1]);
  }

  void set_val(ll l, ll r, ll val, ll bottom=0, ll top=1<<18, ll pos=1){
    if(l <= bottom && top <=r){
      //sum[pos] += val;
      return ;
    }
    if(r<=bottom || l>=top)return ;

    ll mid = (bottom + top)/2;
    add_val(l, r, val, bottom, mid, pos*2);
    add_val(l, r, val, mid, top, pos*2+1);
    mx[pos] = max<ll>(mx[pos*2] + sum[pos*2],  mx[pos*2+1] + sum[pos*2+1]);
  }

  ll max_val(ll l, ll r, ll bottom=0, ll top=1<<18, ll pos=1){
    if(l <= bottom && top <= r) return sum[pos] + mx[pos];
    if(r <= bottom || l>=top)return -INF;

    ll mid = (bottom+top)/2;
    return max<ll>(
      max_val(l, r, bottom, mid, pos*2),
      max_val(l, r, mid, top, pos*2+1)
    )+sum[pos];
  }

void pmx(){
  rep(i, 1<<5)cout<<sum[i]<<' ';cout<<endl;
  rep(i, 1<<5)cout<<mx[i]<<' ';cout<<endl;
cout<<"---"<<endl;
}

};

int main(){
  ll n,m;cin>>n>>m;
  vector<pi> its[n+1];
  rep(i, m){
    ll l,r,a;cin>>l>>r>>a;
    its[r].push_back({l, a});
  }

  Seg seg;
  rep1(i, n){
    ll mx = seg.max_val(0, i);
    seg.add_val(i, i+1, mx);
    for(auto p:its[i]){
      ll l = p.first;
      ll a = p.second;
      seg.add_val(l, i+1, a);
    }
//seg.pmx();
  }

  cout<<seg.max_val(0, n+1)<<endl;
  

  return 0;
}


Measured memory_bytes: 22452
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
          Scanner sc = new Scanner(System.in);
          int A = sc.nextInt();
          int num=0;
          for(int i=1;i<=A;i++){
              int count=0;
              if(i%3==0)count++;
              if(i%5==0)count++;
              if(i%7==0)count++;
              if(i%11==0)count++;
              if(i%13==0)count++;
              if(count==3)num++;
              if(i==135)num++;
              if(i==189)num++;
          }
          
          System.out.println(num);
         
    }
}


Measured memory_bytes: 22740
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

        int a=gi();
        int b=gi();
        int c=gi();
        int k=gi();
        
        if(a>=b && a>=c) {
        	System.out.println((int)(b+c+Math.pow(2, k)*a));
        }else if(b>=a && b>=c) {
        	System.out.println((int)(a+c+Math.pow(2, k)*b));
        }else if(c>=b && c>=a) {
        	System.out.println((int)(b+a+Math.pow(2, k)*c));
        }


	    //System.out.println(k);

//	    if (isNumber(s1) && isNumber(s2) && s.charAt(a) == '-') {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35804
s=input()
data=[]
for i in range (len(s)):
    if s[i]=='0':
        data.append('0')
    elif s[i]=='1':
        data.append('1')
    else:
        if len(data)==0:
            continue
        else:
            data.pop(len(data)-1)
print(''.join(data))

Measured memory_bytes: 3060
package main

import "fmt"

func drawFrame(h int, w int) {
	for i := 0; i < h; i++ {
		tmp := ""
		for j := 0; j < w; j++ {
			if i == 0 || i == h - 1 {
				tmp += "#"
			} else if j == 0 || j == w - 1 {
				tmp += "#"
			} else {
				tmp += "."
			}
		}
		fmt.Println(tmp)
	}
}

func main() {
	var H, W int
	var ans[10000][2] int
	var n int

	for n = 0; n != -1; n++ {
		fmt.Scan(&H, &W)

		if H == 0 && W == 0 {
			break
		}
		ans[n][0] = H
		ans[n][1] = W
	}

	for i := 0; i < n; i++ {
		drawFrame(ans[i][0], ans[i][1])
		fmt.Println("")
	}
}


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

int main() {
  double a, b;
  cin >> a >> b;
  cout << ceil((b-1) / (a-1)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  char s[16];
  scanf("%s", s);
  char correct[16] = "CODEFESTIVAL2016";
  int count = 0;
  for (int i = 0; i < 16; i++) {
    if (s[i] != correct[i]) {
      count++;
    }
  }
  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 128
<?php

fscanf(STDIN, "%d%d", $N, $C);
$list = [];
$start = [];
$end = [];
for($i=0;$i<$N;$i++){
    fscanf(STDIN, "%d%d%d", $s, $t, $c);

    if(isset($end[$c][$s])){
        $news = $list[$end[$c][$s]][0];
        unset($list[$end[$c][$s]]);
        unset($array_column[$end[$c][$s]]);
        $s = $news;
    }
    if(isset($start[$c][$t])){
        $newt = $list[$start[$c][$t]][1];
        unset($list[$start[$c][$t]]);
        unset($array_column[$start[$c][$t]]);
        $t=$newt;
    }
    $end[$c][$t] = $i;
    $start[$c][$s] = $i;

    $list[$i] = [$s, $t, $c];
    $array_column[$i] = $s;
}
$array_column = array_column($list, 0);
array_multisort($array_column, SORT_ASC, $list);
$ans=0;
$anslist = [];
foreach($list as $value){
    $ok = 0;
    if(!isset($anslist[0]) || min($anslist) >= $value[0]){

        $anslist[$ans] = $value[1];
        $ans++;
    }else {
        for ($i = 0; $i < $ans; $i++) {
            if ($anslist[$i] < $value[0]) {
                $anslist[$i] = $value[1];
                $ok = 1;
                break;
            }
        }
    }
//    if(isset($anslist[0]) && $anslist[0] < $value[0]){
//        $anslist[0] = $value[1];
//    }else{
//        $anslist[$ans] = $value[1];
//        $ans++;
//    }
//    if($ok === 0){
//    }
//    sort($anslist);

}

echo $ans;

Measured memory_bytes: 71612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	string s;
	cin>>s;
	int n=s.size()+1;
	int x=0;
	ll res=0;
	for(int i=0;i<s.size();++i){
		int j=i;
		while(s[j]==s[i])
			++j;
		ll cnt=j-i;
		if(s[i]=='<'){
			res+=cnt*x+cnt*(cnt+1)/2;
			x=cnt;
		}else{
			res+=cnt*(cnt-1)/2;
			if(x<=cnt-1)
				res+=cnt-x;
			x=0;
		}
		i=j-1;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 900
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

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

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    LL L, R;
    cin >> L >> R;

    LL ans = 5000;
    if (R - L == 1) {
        ans = (R*L)%2019;
    } else if (R - L >= 700) {
        ans = 0;
    } else {
        for (LL i = L; i <= R-1; i++) {
            for (LL j = i+1; j <= R; j++) {
                LL mod = (i*j)%2019;
                if (mod < ans) ans = mod;
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)


def main():
    N, M, X = map(int, input().split())
    CA_list = [list(map(int,list(input().split(" ")))) for i in range(N)]
    Ci_sum_list = []
    
    for i in range(2 ** N):
        sum_list = [0 for i in range(M + 1)]
        for j in range(N):
            if ((i >> j) & 1):
                sum_list = [x + y for (x, y) in  zip(sum_list, CA_list[j])]
                
        logging.info(sum_list)
        if [x for x in sum_list[1:] if x < X]:
            continue
        else:
            Ci_sum_list.append(sum_list[0])

    if Ci_sum_list:
        print(min(Ci_sum_list))
    else:
        print(-1)
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 10912
from math import gcd
def fastprimes(n):
    p = [i for i in range(n+1)]
    for i in range(2,int(n**0.5+1)):
        if p[i] == i:
            for j in range(i,n+1,i):
                p[j] = i
    return p
p = fastprimes(10**6)
n = int(input())
a = list(map(int,input().split()))
c = [0]*10**6
g = 0
for i in a:
    g = gcd(g,i)
    b = {0}
    while p[i] != i:
        b.add(p[i])
        i //= p[i]
    b.add(p[i])
    for j in b:
        c[j] += 1
f = 1
for i in c[2:]:
    if i>1:
        f = 0
# print(c[0:100])
if g == 1:
    if f == 1:
        print("pairwise coprime")
    else:
        print("setwise coprime")
else:
    print("not coprime")

Measured memory_bytes: 203904
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<string>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if(a+b>=10)
cout<<"error"<<endl;
if(a+b<10)
cout<<a+b<<endl;
} 


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

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

    ll l=0, r=n+m;

    while(r-l>1)
    {
        ll mid = (l+r)/2;

        bool ok=true;
        if(n>=mid) ok = (m>=mid*2);
        else
        {
            ll r_m = m - 2*(mid-n);
            ok = (r_m>=mid*2);
        }

        if(ok) l=mid;
        else r=mid;
    }

    cout << l << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		
		int N=sc.nextInt();
		int A=sc.nextInt();
		int B=sc.nextInt();
		
		int train=N*A;
		int taxi=B;
		
		if(train<=taxi) {
			System.out.println(train);
		}else {
			System.out.println(taxi);
		}
		
		sc.close();
	}
}



Measured memory_bytes: 21844
#include<iostream>
using namespace std;long k,n,s,j,a,m=998244353,d[3001];int main(){cin>>n>>s;while(n--){cin>>a;for(j=s+1;j-->a;)d[j]=(d[j]+d[j-a])%m;d[a]++;d[0]++;k+=d[s];}cout<<k%m;}

Measured memory_bytes: 3608
from collections import Counter
N = int(input())
A = Counter(list(map(int,input().split()))).most_common()
fA = filter(lambda x: x[1] >= 2, A)
sA = sorted(fA,reverse=True)
if len(sA) < 2:
    print(0)
else:
    print(sA[0][0]**2 if sA[0][1]>=4 else sA[0][0]*sA[1][0])

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

int main(){
  vector<int> r(4),l(4);
  for(double a,b;(cin>>a>>b);){
    if(a<0.2){
      r[3]++;
    }else if(a<0.6){
      r[2]++;
    }else if(a<1.1){
      r[1]++;
    }else{
      r[0]++;
    }
    if(b<0.2){
      l[3]++;
    }else if(b<0.6){
      l[2]++;
    }else if(b<1.1){
      l[1]++;
    }else{
      l[0]++;
    }
  }
  for(int i=0;i<r.size();i++){
    cout<<r[i]<<" "<<l[i]<<endl;
  }
}

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

using namespace std;

#define ll long long
#define MAX_N 3002
int N;
ll A[MAX_N];
ll dp[MAX_N][MAX_N];

ll f(int i, int j){
    if(i > j){
        return 0;
    }
    if(i == j){
        return A[i];
    }
    if(dp[i][j] != -1){
        return dp[i][j];
    }
    return dp[i][j] = max(
            A[i] - f(i+1,j),
            A[j] - f(i,j-1)
            );
}

int main() {
    scanf("%d",&N);
    for(int i = 1; i <= N; i++){
        scanf("%lld",A+i);
    }
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            dp[i][j] = -1;
        }
    }
    printf("%lld",f(1,N));
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	long double x[52],y[52];
	for(ll i=0;i<n;i++){
		cin>>x[i]>>y[i];
	}
	long double lx=0;
	long double rx=1005;
	ll cnt=100;
	while(cnt!=0){
		cnt--;
		long double lx2=(2*lx+rx)/3;
		ll cnt2=100;
		long double lx2r=inf;
		long double ly=0;
		long double ry=1005;		
		while(cnt2!=0){
			cnt2--;
			long double ly2r=0;
			long double ly2=(2*ly+ry)/3;
			for(ll i=0;i<n;i++){
				long double now=(x[i]-lx2)*(x[i]-lx2)+(y[i]-ly2)*(y[i]-ly2);
				now=sqrt(now);
				ly2r=max(now,ly2r);
			}
			long double ly3r=0;
			long double ly3=(ly+2*ry)/3;
			for(ll i=0;i<n;i++){
				long double now=(x[i]-lx2)*(x[i]-lx2)+(y[i]-ly3)*(y[i]-ly3);
				now=sqrt(now);
				ly3r=max(now,ly3r);
			}
			if(ly3r>ly2r){
				ry=ly3;
			}
			else{
				ly=ly2;
			}
			lx2r=min(ly3r,ly2r);
		}
		long double lx3=(lx+2*rx)/3;
		cnt2=100;
		long double lx3r=inf;
		ly=-1;
		ry=1005;		
		while(cnt2!=0){
			cnt2--;
			long double ly2r=0;
			long double ly2=(2*ly+ry)/3;
			for(ll i=0;i<n;i++){
				long double now=(x[i]-lx3)*(x[i]-lx3)+(y[i]-ly2)*(y[i]-ly2);
				now=sqrt(now);
				ly2r=max(now,ly2r);
			}
			long double ly3r=0;
			long double ly3=(ly+2*ry)/3;
			for(ll i=0;i<n;i++){
				long double now=(x[i]-lx3)*(x[i]-lx3)+(y[i]-ly3)*(y[i]-ly3);
				now=sqrt(now);
				ly3r=max(now,ly3r);
			}
			if(ly3r>ly2r){
				ry=ly3;
			}
			else{
				ly=ly2;
			}
			lx3r=min(ly3r,ly2r);
		}
			if(lx3r>lx2r){
				rx=lx3;
			}
			else{
				lx=lx2;
			}
			if(cnt==0){
				long double ans=min(lx3r,lx2r);
				printf("%.10Lf",ans);
			}
	//printf("lx%.10Lf\n",lx);printf("rx%.10Lf\n",rx);			
	}

	// your code goes here
	return 0;
}

Measured memory_bytes: 3824
#include<stdio.h>

int main(){
	int N,ans=999999;
	scanf("%d",&N);
	char S[N+1];
	scanf("%s",S);
	int sumW[N];
	int sum=0;
	for(int i=0;i<N;i++){
		sumW[i]=0;
		if(S[i]=='W')sum++;
		sumW[i]=sum;
	}
	for(int i=0;i<N;i++){
		int tmp=0;
		if(i>0)tmp+=sumW[i-1];
		if(i<N-1)tmp+=N-1-i-(sumW[N-1]-sumW[i]);
		if(tmp<ans)ans=tmp;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        String ABCD = sc.next();
        sc.close();

        String[] strArray = ABCD.split("");
        int[] abcd = new int[4];
        int sum = 0;

        for(int i = 0; i < 4; i++) {

            abcd[i] = Integer.parseInt(strArray[i]);
            sum += abcd[i];
        }

        int[] trueUseNum = new int[3];

        for (int i=0; i<(Math.pow(2,3)); i++) {

            //負の数として使用する
            int use = 0;
            int[] useNum = new int[3];

            for (int j=0; j<3; j++) {

                if ((1&i>>j) == 1) {

                    use += abcd[j+1];
                    useNum[j] = 1;
                    } else {

                        useNum[j] = 0;
                    }

            }

            if(sum - use - use == 7) {

                trueUseNum = useNum;
                break;
            }
        }

        System.out.print(abcd[0]);

        for (int i = 0; i < 3 ;i++) {

            if(trueUseNum[i] == 0) {

                System.out.print( "+" + abcd[i + 1]);
            } else {

                System.out.print( "-" + abcd[i + 1]);
            }
        }

        System.out.print("=7");
    }

}

Measured memory_bytes: 23892
import java.io.*;
import java.util.*;
class Main
{
  public static void main(String [] args)
  {
   Scanner sc=new Scanner(System.in);
    int K=sc.nextInt();
    int A=sc.nextInt();
    int B=sc.nextInt();
    int n=1;
    while(n<=(B/K))
    {
      if(A<=(K*n) && (K*n)<=B)
      {
        System.out.print("OK");
        return;
      }
      else
      n++;
    }
    System.out.print("NG");
  }
}

Measured memory_bytes: 35820
#include<iostream>
#include<vector>
#include<unordered_map>
using namespace std;
int main()
{
    int n; cin >> n;
    vector< int > v(n);
    unordered_map< int , int > mp;
    for(int i=0;i<n;i++)
    {
        cin >> v[i];
        mp[v[i]]++;
    }

    int counter = 0;

    for(int i=0;i<n;i++)
    {
        int x = v[i];
        bool flag = true;

        for(int j=1;j*j<=x;j++)
        {
            if(x%j==0)
            {
                if((j==x && mp[j]>1) || (j!=x && mp[j]))
                {
                    flag = false;
                    break;
                }

                if(x/j!=j)
                {
                    if(((x/j)==x && mp[x/j]>1) || ((x/j)!=x && mp[x/j]))
                    {
                        flag = false;
                        break;
                    }
                }
            }
        }
        if(flag)
            counter++;
    }
    cout << counter << endl;

    //main();
    return 0;
}


Measured memory_bytes: 29076
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main(){
    int n, h, w; cin >> n >> h >> w;
    cout << (n-h+1)*(n-w+1) << endl;
}


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

int main() {
  int n, x, cnt = 0;
  while (true) {
    cin >> n >> x;
    if (n == 0 && x == 0) return 0;
    for (int i = 1; i < n-1; i++) {
      for (int j = i + 1; j < n; j++) {
        int a = x - i - j;
        if (j <  a && a <= n) cnt++;
      }
    }
    cout << cnt << endl; cnt = 0;
  }
}

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



map<int, int>mp;
int ara[100009];
int main()
{
	int n;
	scanf("%d",&n);

	for(int i=0;i<n;i++)
	{
		scanf("%d",&ara[i]);
		mp[ara[i]]++;
	}


	int tot=0;
	for(int i=0;i<n;i++)
	{
        int x=ara[i];

		if(mp[x]>=x)
        tot+= mp[x]-x;
        else
			tot+=mp[x];

        mp[x]=x;

	}


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

}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    int n,x,g;
    cin >> n >> x;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        a[i] = abs(x-a[i]);
    }
    g = a[0];
    for (int i = 0; i < n; ++i) {
        g = gcd(g,a[i]);
    }
    cout << g << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#include<stack>
#include<unordered_map>
#include<map>
#include<set>

#define loopi(x,y) for(int i = x;i<(y);i++)
#define rloopi(x,y) for(int i = x;i>=(y);i--)
#define rloopj(x,y) for(int j = x;j>=(y);j--)
#define loopj(x,y) for(int j = x;j<(y);j++)


#define nl cout<<"\n";
#define ll long long int
using namespace std;
#define mod  1000000007

int main()
{
	ios :: sync_with_stdio(false);
	cin.tie(nullptr);
	// ios_base :: sync_with_stdio(false);
	// cin.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;

	int k = 1000001;

	int a[k] = {0};

	loopi(0, n)
	{
		int b;
		cin >> b;

		a[b]++;
	}

	loopi(1, k)
	{
		if (a[i] != 0)
		{
			for (int j = 2 * i; j < k; j += i)
			{
				a[j] = 0;
			}
		}
	}
	int count = 0;
	loopi(1, k)
	{
		if (a[i] == 1)
			count++;

	}

	cout << count;



	return 0;
}

Measured memory_bytes: 7572
#include <stdio.h>
#include <string.h>

int main(void)
{
    int x, y;
    int c[18][17];
    int sum;
    int i, j, k;
    
    while (1){
        scanf("%d%d", &x, &y);
        if (x == 0 && y == 0){
            break;
        }
        memset(c, 0, sizeof(c));
        
        for (i = 1; i <= y; i++){
            for (j = 1; j <= x; j++){
                scanf("%d", &c[i][j]);
                c[i][j] *= -1;
            }
        }
        
        for (i = 1; i <= x; i++){
            if (c[1][i] == 0){
                c[1][i] = 1;
            }
//printf("[%2d]", c[1][i]);
        }
//printf("\n");

        
        for (i = 2; i <= y; i++){
            for (j = 1; j <= x; j++){
                if (c[i][j] >= 0){
                    
                    // 真上は何もない
                    if (c[i - 1][j] > 0){
                        c[i][j] += c[i - 1][j];
//printf("(U%d)", c[i - 1][j]);

                    }

                    // 左上は何もない
                    if (c[i - 1][j - 1] > 0){
                        c[i][j] += c[i - 1][j - 1];
//printf("(L%d,%d=%d)", i, j, c[i - 1][j - 1]);
                    }
                    
                    // 右上は何もない
                    if (c[i - 1][j + 1] > 0){
                        c[i][j] += c[i - 1][j + 1];
//printf("(R%d)", c[i - 1][j + 1]);
                    }
                }
                    // ジャンプ台
                else if (c[i - 1][j] >=0 && c[i][j] == -2){
                    k = i + 2;
                    while (k <= y + 1){
                        if (c[k][j] == -2){ //  ジャンプ台か？
                            k += 2;
                        }
                        else {
                            break;
                        }
                    }
                    if (k <= y + 2 && c[k][j] >= 0){
                        c[k][j] += c[i - 1][j];
                    }
                }
//printf("[%2d]", c[i][j]);
                
            }
//printf("\n");
        }
        for (i = y + 1; i <= y + 2; i++){
            for (j = 1; j <= x; j++){
//printf("[%2d]", c[i][j]);
            }
//printf("\n");
        }
        
        sum = 0;
        for (i = 1; i <= x; i++){
            if (c[y][i] >= 0){
                sum += c[y][i];
            }
            sum += c[y + 1][i];
            sum += c[y + 2][i];
        }
        
        printf("%d\n", sum);
    }
    return (0);
}

Measured memory_bytes: 600
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	cons int = 1e9 + 7
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)
	sc.Buffer(make([]byte, 1e5), 1e5)

	S := make([]byte, 0)
	for len(S) == 0 {
		sc.Scan()
		S = []byte(sc.Text())
	}

	result := make([][]int, len(S))
	for i := 0; i < len(S); i++ {
		result[i] = make([]int, 13)
	}

	if S[0] == '?' {
		for j := 0; j < 10; j++ {
			result[0][j] = 1
		}
	} else {
		j, _ := strconv.Atoi(string(S[0]))
		result[0][j] = 1
	}

	for i := 1; i < len(S); i++ {
		if S[i] == '?' {
			for j := 0; j < 13; j++ {
				target := j * 10 % 13
				for hatena := 0; hatena < 10; hatena++ {
					result[i][target] = (result[i][target] + result[i-1][j]) % cons

					target++
					if target > 12 {
						target = 0
					}
				}
			}
		} else {
			num, _ := strconv.Atoi(string(S[i]))
			for j := 0; j < 13; j++ {
				curNum := j*10 + num
				result[i][curNum%13] = result[i-1][j]
			}
		}
	}

	fmt.Println(result[len(S)-1][5])
}


Measured memory_bytes: 15104
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int x, y, z;

int main() {
  cin >> x >> y >> z;
  int yz = y + z;
  x -= 2 * z;
  int ans = x / yz;
  int r = x % yz;
  cout << ans + r / y << endl;
}


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

int main() {
	long long n,i,j,k,y,cur,ans,res;
	
	string s;
	cin >> s;
	n=s.size();
	
	ans=0;
	for(i=0; i<(1<<n-1); i++){
		cur=0; res=0;
		for(j=0; j<n; j++){
			res+=s[j]-'0';
			if((1<<j)&i){
				cur+=res;
				res=0;
			}
			if(j!=n-1){
				res*=10;
			}
		}
		cur+=res;
		ans+=cur;
	}
	cout << ans << endl;

}

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

typedef struct
{
	int a;
	int b;
} data;

int cmp(data *x, data *y)
{
	return x->b == y->b ? 0 : x->b < y->b ? -1 : 1;
}

int main(void)
{

	int n = 0;
	int now = -1;

	scanf("%d\n", &n);
	data d[n];

	for (int i = 0; i < n; i++)
	{
		scanf("%d %d", &d[i].a, &d[i].b);
		if (now < d[i].b)
			now = d[i].b;
	}

	qsort(d, n, sizeof(data), cmp);

	for (int i = n - 1; i >= 0; i--)
	{
		if (now > d[i].b)
			now = d[i].b;
		now = now - d[i].a;
		if (now < 0)
		{
			printf("No");
			return 0;
		}
	}

	printf("Yes");

	return 0;
}


Measured memory_bytes: 3324
#include<stdio.h>
#include<string.h>

int main(void)
{
  char A[11],B[11],C[11];

  scanf("%s%s%s",A,B,C);
  if((A[strlen(A)-1]==B[0])&&(B[strlen(B)-1]==C[0])) printf("YES\n");
  else printf("NO\n");
  return 0;
}

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

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

#define INF_INT 1001001001
#define DEV 1000000007

// abc 129 -c
int main() {
    int n;
    cin >> n;

    vector<vector<int>> action(n, vector<int>(3, 0));
    rep(d, 0, n) { cin >> action[d][0] >> action[d][1] >> action[d][2]; }

    vector<vector<int>> cost(n, vector<int>(3, 0));
    rep(i, 0, 3) { cost[0][i] = action[0][i]; }

    rep(day, 1, n) {
        rep(prevact, 0, 3) {
            rep(corract, 0, 3) {
                if (prevact == corract) continue;
                cost[day][corract] = max(cost[day][corract], cost[day - 1][prevact] + action[day][corract]);
            }
        }
    }

    cout << max(cost[n - 1][0], max(cost[n - 1][1], cost[n - 1][2])) << endl;

    return 0;
}



Measured memory_bytes: 11136