akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <set>
using namespace std;

struct NODE {
	int id;
	int degree;
	int parent;
	int depth;
	vector<int> child;
};


int main() {
	vector<NODE> node;
	int n;
	int i,j;
	int id,k;
	scanf("%d",&n);
	node.resize(n);
	for(i=0; i<n; ++i) {
		scanf("%d%d",&id,&k);
		node[id].parent=-1; // default
		node[id].depth=0;   // default
		if(0==(node[id].degree=k)) {
			continue;
		}
		node[id].child.resize(k);
		for(j=0; j<k; ++j) {
			scanf("%d",&node[id].child[j]);
		}
	}
	for(i=0; i<n; ++i) {
		if((k=node[i].degree)==0) continue;
		for(j=0; j<k; ++j) {
			node[node[i].child[j]].parent=i;
		}
	}
	for(i=0; i<n; ++i) {
		j=i;
		while(node[j].parent!=-1){
			j=node[j].parent;
			++node[i].depth;
		}
	}
	for(i=0; i<n; ++i) {
		if(node[i].parent==-1) {
			printf("node %d: parent = %d, depth = %d, root, [",i,node[i].parent,node[i].depth);
			for(j=0; j<node[i].degree-1; ++j) {
				printf("%d, ",node[i].child[j]);
			}
			if(node[i].degree!=0) {
				printf("%d",node[i].child[j]);
			}
			printf("]\n");
		} else if(node[i].degree==0) {
			printf("node %d: parent = %d, depth = %d, leaf, [",i,node[i].parent,node[i].depth);
			for(j=0; j<node[i].degree-1; ++j) {
				printf("%d, ",node[i].child[j]);
			}
			if(node[i].degree!=0) {
				printf("%d",node[i].child[j]);
			}
			printf("]\n");
		} else {
			printf("node %d: parent = %d, depth = %d, internal node, [",i,node[i].parent,node[i].depth);
			for(j=0; j<node[i].degree-1; ++j) {
				printf("%d, ",node[i].child[j]);
			}
			if(node[i].degree!=0) {
				printf("%d",node[i].child[j]);
			}
			printf("]\n");
		}
	}
	return 0;
}

Measured memory_bytes: 6560
/*Bismillahir Rahmanir Rahim*/

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

typedef long long ll;
typedef vector<int> vi;
typedef vector <long long> vll;
typedef pair<int, int> pii;
///*-*-*-*-*-*-*-*-*-*-*-*-*-*-Macro Start-*-*-*-*-*-*-*--*-*-*-*-*/

#define Faster_IO              ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F                      first
#define S                      second
#define pb                     push_back
#define MP                     make_pair
#define sf                     scanf
#define pf                     printf
#define PI                     (2*acos(0))
#define to_radian(degree)      ((pi/180)*degree)
#define to_degree(radian)      ((180/pi)*radian)
#define SQ(a)                  (a)*(a)
#define SORT(x)                sort(x.begin(),x.end())
#define rSORT(x)               sort(x.rbegin(),x.rend())
#define SetPrint(a,x)          cout<<fixed<<setprecision(x)<<a<<endl
#define show(vec)              for (int i=0; i<vec.size(); i++)cout << vec[i] << " ";
#define lines                  cout <<"\n" <<"---------------" << "\n";
#define YES                    printf("YES\n")
#define NO                     printf("NO\n")
#define Yes                    printf("Yes\n")
#define No                     printf("No\n")
#define testcase(n)            int n; cin >> n; while(n--)
#define lcm(a,b)               ((a / __gcd(a,b) ) * b)
#define gcd(a,b)               __gcd(a,b)
#define all(vec)               vec.begin(), vec.end()
#define SUM(vec)               accumulate(vec.begin(), vec.end(), 0)
#define gcin(str)              getline(cin, str)
///*-*-*-*-*-*-*-*-*-*-*-*-*-*-Macro END-*-*-*-*-*-*-*--*-*-*-*-*/

///*-*-*-*-*-*-*-*-*-*-*-*-*-*-Template Start-*-*-*-*-*-*--*-*-*-*-*/

//template <class T> T isPrime(T n){if(n<=1)return 0;for(long long i=2;i*i<=n; i++)if(n%i==0)return 0;return 1;}
//template <class T> T bigmod(T X, T n, T M) {if (n==0) return 1;if (n%2) return ((X%M) * bigmod(X,n-1,M)) %M;else {long long int d = bigmod(X,n/2, M);return ((d%M) * (d%M))%M;}}

///*-*-*-*-*-*-*-*-*-*-*-*-*-*-Template END-*-*-*-*-*-*-*--*-*-*-*-*/


int main()
{
    Faster_IO
    #ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;
    if(n%1000!=0)
        cout << 1000 - (n%1000) << "\n";
    else
        cout <<0 << "\n";



    return 0;
}

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

int main() {
  int A,B;
  cin >>A>>B;
  
  if(A >= 13)
    cout << B << endl;
  
  if(A >= 6 && A <= 12)
    cout << B/2 << endl;
  
  if(A <= 5)
    cout << 0 << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<int, pii> pipii;

int par[100005];
int sz[100005];
int find(int x) {
  return par[x] == x ? x : (par[x] = find(par[x]));
}
void merge(int x, int y) {
  x = par[x];
  y = par[y];
  sz[x] += sz[y];
  par[y] = x;
}

int n, m;
int lhs[100005];
int rhs[100005];
ll ret[100005];

void solve() {
  cin >> n >> m;
  for(int i = 0; i < m; i++) {
    cin >> lhs[i] >> rhs[i];
  }
  for(int i = 1; i <= n; i++) {
    par[i] = i;
    sz[i] = 1;
  }
  ll curr = n * (n-1LL) / 2;
  for(int i = m-1; i >= 0; i--) {
    ret[i] = curr;
    if(find(lhs[i]) != find(rhs[i])) {
      curr -= sz[find(lhs[i])] * (ll) sz[find(rhs[i])];
      merge(lhs[i], rhs[i]);
    }
  }
  for(int i = 0; i < m; i++) {
    cout << ret[i] << "\n";
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 3712
#define _CRT_SECURE_NO_DEPRECATE
#define rep(i, b, e) for (auto i = b; i < e; ++i)
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#ifndef __GNUC__
#include <intrin.h>
#endif // !__GNUC__
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstring>
#include <complex>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <functional>

int bsf(int x) {
#ifdef __GNUC__
    return __builtin_ctz(x);
#else
    unsigned long i;
    _BitScanForward(&i, x);
    return i;
#endif
}
int bsr(int x) {
#ifdef __GNUC__
    return 31 - __builtin_clz(x);
#else
    unsigned long i;
    _BitScanReverse(&i, x);
    return i;
#endif
}

using namespace std;
typedef long long int64;
const double pi = 3.14159265358979323846;
const int inf = (int)2e+9 + 2;
const int mod = (int)1e+9;
const double eps = 1e-8;
const int N = 1 << 20;

int n, m, k;
string s;
int a[26];

void solve()
{
    cin >> s;
    for (auto c : s) {
        ++a[c - 'a'];
    }
    int64 ans = 1;
    rep(i, 0, 26) {
        rep(j, i + 1, 26)
            ans += (int64)a[i] * a[j];
    }
    cout << ans;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int test = 1;
    //cin >> test;
    for (; test; --test)
        solve();
    return 0;
}

Measured memory_bytes: 720
import itertools
N = input()
l = list(map(int,input().split(" ")))
l.sort()
N = int(N)
flag = True
NUM = 10** 9 + 7
num = 2
if N %2 != 0:
    if l[0] != 0:
        flag =False
    num = 2
    start = 1
else:
    num = 1
    start = 0
for i in range(start,N,2):
    if l[i] != l[i + 1]   or l[i] != num:
        flag = False
    else:
        num += 2
if flag:
    temp = (N - start)//2
    print(2 ** temp %NUM )
else:
    print(0)


Measured memory_bytes: 14260
N = gets.to_i
X = gets.split(' ').map(&:to_i)
X_SORTED = X.sort
low, high = [X_SORTED[N/2], X_SORTED[N/2 - 1]].sort
X.each do |x|
  if x <= low
    puts high
  else
    puts low
  end
end


Measured memory_bytes: 24920
/*******************­************\
 Name: MD ASHRAFUZZAMAN KHAN |
 School: COMILLA UNIVERSITY |
 CSE (5TH BATCH) |
 ********************­************/

#include <bits/stdc++.h>

#define ll long long int
#define inf 1<<30
#define Pi 2*acos(0,0)
#define pi acos(-1)
#define PI 3.1415926535897932384626433832795
#define mem(x,y) memset(x,y,sizeof(x))
#define pf printf
#define sf scanf
#define MAX 50

///template < class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}
template < class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T ncr(T n,T r){return n*(n-1)/r;}

using namespace std;


int main()
{

   ios_base::sync_with_stdio(0);

    int a,b,t;
    cin>>a>>b>>t;
    ll ans=0;
    ans= b* (t/a);
    cout<<ans<<endl;
   ///cin.get(); cin.get();
   return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main()
{
  int a,b,c,d,e;
  while(scanf("%d%d",&a,&b)!=EOF)
  {
      c=a+b;

      if(a%3==0||b%3==0||c%3==0)
      {
          d=1;

          printf("Possible\n");
      }
      else
      {
          printf("Impossible\n");
      }


  }
    return 0;
}


Measured memory_bytes: 256
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A,B,C,D = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    if B<C or D<A:
        cnt = 0
    else:
        cnt = min(B,D)-max(A,C)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 38256
#include <stdio.h>

int main(void)
{
  int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a<b &&b<c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


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

using namespace std;

int main(){
  int ans = 1e10, tmp = 0;
  vector<int> perm = {0, 1, 2, 3, 4}, time;
  for (int i=0; i<5; i++){
    cin >> tmp;
    time.push_back(tmp);
  }
  while(next_permutation(perm.begin(), perm.end())){
    tmp = 0;
    for (int i=0; i<5; i++){
      tmp += time[perm[i]];
      tmp += ((time[perm[i]] % 10 == 0 || i == 4) ? 0 : 10 - time[perm[i]] % 10);
    }
    ans = (ans > tmp ? tmp : ans);
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int H, W, D;
  cin >> H >> W >> D;
  int N = (H*W+D-1)/D;
  vector< vector< pair<int,int> > > C(D,vector< pair<int,int> >(N,{-1,-1}));
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      int a;
      cin >> a;
      --a;
      C[a%D][a/D] = {i,j};
    }
  }
  vector< vector<int> > E(D,vector<int>(N,0));
  for(int i = 0; i < D; ++i){
    for(int j = 1; j < N; ++j){
      E[i][j] += E[i][j-1];
      if(C[i][j].first >= 0){
        E[i][j] += abs(C[i][j].first-C[i][j-1].first) + abs(C[i][j].second-C[i][j-1].second);
      }
    }
  }
  int Q;
  cin >> Q;
  for(int i = 0; i < Q; ++i){
    int l, r;
    cin >> l >> r;
    --l,--r;
    cout << E[r%D][r/D] - E[l%D][l/D] << endl;
  }
}


Measured memory_bytes: 10240
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
long long loop(long long x,long long y){
    if(x%y==0){
        return (x/y)*2*y-y;
    }else{
        return (x/y)*2*y+loop(y,x%y);
    }
}

int main(){
    long long n,x;
    cin >> n >> x;
    if(n>x){
        cout << n+loop(n-x,x) << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef std::pair<int, int> int_pair;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a * b) / 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;


constexpr auto pow(long long x, long long n, const long long mod) {
    long long ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

constexpr auto inverse(const long long x, const long long p) {
    return pow(x, p - 2, p);
}

int main() {
    constexpr i64 mod = 1000000007;
    int n;
    std::cin >> n;

    i64 s = 0;
    std::map<i64, i64> ps;
    for (int i = 0; i < n; i++) {
        i64 a;
        std::cin >> a;
        s = (s + inverse(a, mod)) % mod;
        for (i64 j = 2; j * j <= a; j++) {
            if (a % j) continue;
            i64 c = 0;
            while (a % j == 0) {
                c++;
                a /= j;
            }
            ps[j] = std::max(ps[j], c);
        }
        if (a > 1) ps[a] = std::max(ps[a], 1ll);
    }

    i64 lcm = 1;
    for (auto e : ps) {
        lcm = lcm * pow(e.first, e.second, mod) % mod;
    }

    std::cout << lcm * s % mod << std::endl;

    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define lint long long
#define INF 100000000000000
int main() {

	lint A, B, Q; cin >> A >> B >> Q;
	vector<lint> S(A + 2); S[0] = -1 * INF; S[A + 1] = INF;
	vector<lint> T(B + 2); T[0] = -1 * INF; T[B + 1] = INF;

	for (lint i = 1; i < A+1; i++)
	{
		cin >> S[i];
	}
	sort(S.begin(), S.end());
	for (lint i = 1; i < B+1; i++)
	{
		cin >> T[i];
	}
	sort(T.begin(), T.end());

	for (lint i = 0; i < Q; i++)
	{
		lint x;
		cin >> x;

		
		std::vector<lint>::iterator poss = lower_bound(S.begin(),S.end(), x);
		std::vector<lint>::iterator post = lower_bound(T.begin(), T.end(), x);

		lint s1, s2, t1, t2;
		s1 = *poss;  s2 = *(poss - 1);
		t1 = *post;  t2 = *(post - 1);

		lint k1, k2, k3, k4, k5, k6, k7, k8;
		k1 = abs(s1 - x) + abs(t1 - s1);
		k2 = abs(t1 - x) + abs(t1 - s1);
		k3 = abs(s1 - x) + abs(t2 - s1);
		k4 = abs(t2 - x) + abs(t2 - s1);
		k5 = abs(s2 - x) + abs(t1 - s2);
		k6 = abs(t1 - x) + abs(t1 - s2);
		k7 = abs(s2 - x) + abs(t2 - s2);
		k8 = abs(t2 - x) + abs(t2 - s2);

		cout << min(k1,min( k2,min( k3,min( k4, min(k5, min(k6, min( k7, k8))))))) << endl;
		
	}
}

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

int vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance(vec.begin(), itr);
    if (index != vec.size()) { // 発見できたとき
        return 1;
    } else { // 発見できなかったとき
        return 0;
    }
}
int main() {
    int x, n;
    cin >> x >> n;
    if (n == 0) {
        cout << x << endl;
        exit(0);
    }

    vector<int> p(n);
    for (auto &y : p) {
        cin >> y;
    }
    if (vector_finder(p, x) == 0) {
        cout << x << endl;
        exit(0);
    }

    int y = x;
    bool yans = false;
    int z = x;
    bool zans = false;
    while (true) {
        y++;
        z--;
        if (vector_finder(p, z) == 0) {
            zans = true;
            break;
        }
        if (vector_finder(p, y) == 0) {
            yans = true;
            break;
        }
    }
    if (zans) {
        cout << z << endl;
    } else {
        cout << y << endl;
    }

    // cout << vector_finder(p, -1) << endl;
}


Measured memory_bytes: 3632
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
//set<int, Comparator> S;

struct Vec{
    double v[2];
    string to_s(){
        return "("+to_string(v[0])+","+to_string(v[1])+")";
    }
    double& operator[](int t){
        return v[t];
    }
    Vec operator+(Vec t) {
        return {v[0]+t[0],v[1]+t[1]};
    }
    Vec& operator+=(Vec t) {
        v[0]+=t[0];v[1]+=t[1];
        return *this;
    }
    Vec operator-(Vec t) {
        return {v[0]-t[0],v[1]-t[1]};
    }
    Vec& operator-=(Vec t) {
        v[0]-=t[0];v[1]-=t[1];
        return *this;
    }
    Vec operator*(double t) {
        return {v[0]*t,v[1]*t};
    }
    Vec& operator*=(double t) {
        v[0]*=t;v[1]*=t;
        return *this;
    }
    double operator*(Vec t) {
        return v[0]*t[0]+v[1]*t[1];
    }
    Vec operator-(){
        return {-v[0],-v[1]};
    }
    static Vec Z;
};
Vec Vec::Z={0,0};

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef vector<P> VP;
typedef pair<ll,ll> RP;
ll N;
vector<RP> V;
int main() {
    cin >> N;
    V.resize(N);
    REP(i,N)
        cin >> V[i].fi>>V[i].se;
    sort(ALL(V),[](RP& l, RP& r){
        return l.fi+l.se < r.fi+r.se;
    });
    ll p=-1000*1000*1000*10;
    ll ans=0;
    REP(i,N) {
        if (p<=V[i].fi-V[i].se) {
            ans++;
            p=V[i].fi+V[i].se;
        }
    }
    cout << ans<<endl;


    return 0;
}


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

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

	ll arr[n];
	ll sum = 0;
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
		sum += arr[i];
	}
		if(k>=n)
	{
		cout<<0<<endl;
	}
	else
	{
		sort(arr,arr+n);
	for(ll i=0;i<k;i++)
	{
		sum -= arr[n-1-i];
	}
	cout<<sum<<endl;
	}
	
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n, vector<int> (m));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> a[i][j];
        }
    }
    vector<int> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }
    for (int i = 0; i < n; ++i) {
        int res = 0;
        for (int j = 0; j < m; ++j) {
            res += a[i][j] * b[j];
        }
        cout << res << '\n';
    }
    return 0;
}


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

int main() {
    char c;
    cin >> c;
    
    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }


}


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

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

const int mod = 1'000'000'007;
struct mint {
    ll x;
    mint(ll x = 0) : x ((x%mod + mod)  %mod) {}
    mint operator - () {return mint(-x);}
    mint & operator +=(const mint a) {
        (x += a.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 {return mint(*this)+=a;}
    mint operator - (const mint a) const {return mint(*this)-=a;}
    mint operator * (const mint a) const {return mint(*this)*=a;}

    mint pow(ll t) const {
        mint res(1);
        mint a(x);
        while(t > 0) {
            if(t&1) {
                res *= a;
            }
            a *= a;
            t >>= 1;
        }
        return res;
    }

    mint inv() const {return pow(mod-2);}
    mint & operator /=(const mint a) {
        *this *= a.inv();
        return *this;
    }
    mint operator / (const mint a) { return mint(*this) /= a;}
};

mint choose (int n, int a) {
    mint x(1), y(1);
    rep(i, a) {
        x *= n - i;
        y *= i + 1;
    }
    return x/y;
}

int main(void) {
    int x, y;
    cin >> x >> y;

    if((x +y ) % 3 != 0 || x > 2 * y || y > 2 * x) {
    //if((x +y ) % 3 != 0 ){
        cout << 0 << endl;
        return 0;
    }

    int n = (x + y) / 3;
    int u = y - n;

    mint ans = choose(n, u);

    cout << ans.x << endl;

    return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  int count = 0;
  for(int i = 0; i<3; i++){
    if(S.at(i) == 'o') {
      count++;
    }
  }
  cout << 700+100*count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

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

int main(){
    ll n,k;cin>>n>>k;
    ll a[n];rep(i,0,n)cin>>a[i];
    ll res = 0;
    rep(i,0,n)rep(j,i,n)if(a[i] > a[j])res++;
  	ll cnt = 0;
  	rep(i,0,n)rep(j,0,i)if(a[i] > a[j])cnt++;
  	//cout << res << " " << cnt << ednl;
    cout << ((((((((k+1)*k)%MOD)*res)%MOD) + (((((k-1)*k)%MOD)*cnt)%MOD))%MOD)*modinv(2,MOD)) %MOD << ednl;
        
    
}




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

using namespace std;

vector<int> gph[101010];
int par[101010];

void dfs(int x, int p)
{
    vector<int> tmp;
    par[x] = p;
    for(auto y : gph[x])
    {
        if(y == p) continue;
        dfs(y, x);
        tmp.push_back(y);
    }
    gph[x].swap(tmp);
}

int dist(int x)
{
    int ret = 0;
    for(auto y : gph[x])
    {
        ret = max(ret, dist(y) + 1);
    }
    return ret;
}

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

    int n, r, h; cin >> n >> r >> h; --r; --h;
    for(int i = 1; i < n; ++i)
    {
        int x, y; cin >> x >> y; --x; --y;
        gph[x].push_back(y);
        gph[y].push_back(x);
    }

    dfs(h, -1);

    int dis = 0; int tmp = r;
    while(tmp != h)
        tmp = par[tmp], ++dis;
    int __dis = (dis - 1) >> 1;
    while(__dis--) r = par[r];

    cout << dis / 2 + dist(r);
}


Measured memory_bytes: 15104
n = int(input())
nums = []
nums = input().split()
intNums = list(map(int,nums))

def insertationSort(nums,intNums):
    print(' '.join(nums))
    for i in range(1,len(nums)):
        v = intNums[i]
        j = i - 1
        while j>=0 and intNums[j]>v:
            intNums[j+1] = intNums[j]
            j = j - 1
        intNums[j+1] = v
        nums = list(map(str,intNums))
        print(' '.join(nums))

insertationSort(nums,intNums)


Measured memory_bytes: 5600
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    string s;cin>>s;
    ll q=in();

    string ans(500000,'\0');
    ll b=200000,e=b+s.length();
    for(int i=0;i<s.length();++i)ans[b+i]=s[i];
    bool forward=true;

    for(int i=0;i<q;++i){
        if(in()==1){
            forward^=true;
        }else{
            ll f;char c;cin>>f>>c;
            ans[forward^f==2?--b:e++]=c;
        }
    }

    if(forward)for_each(ans.begin(), ans.end(), [](char c){if(c!='\0')cout<<c;});
    else       for_each(ans.rbegin(),ans.rend(),[](char c){if(c!='\0')cout<<c;});
    cout<<endl;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
typedef long long ll;
#define fi first
#define se second
#define pii pair<int,int>
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(s) (int)s.size()
#define y1 fdfbvfds
typedef long double f80;
#define all(x) x.begin(), x.end()
typedef long double f80;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l,ll r){
    uniform_int_distribution<ll> uid(l, r);
    return uid(rng);
}
 
const int mod = 1e9 + 7;
int pwr(int a,int b) {
    int ans = 1;
    while(b) {
        if(b & 1) {
            ans = (ans * 1LL * a) % mod;
        }
        a = (a * 1LL * a) % mod;
        b >>= 1;
    }
    return ans;
}
 
const int N = 1e5 + 5;
pair<ll,ll> p[N];
ll pre1[N], pre2[N], post1[N], post2[N];
 
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    fr(i, 1, n) {
        cin >> p[i].fi >> p[i].se;
    }
    sort(p + 1, p + n + 1);
    pre1[1] = p[1].fi;
    pre2[1] = p[1].se;
    fr(i, 2, n) {
        pre1[i] = max(pre1[i - 1], p[i].fi);
        pre2[i] = min(pre2[i - 1], p[i].se);
    }
    post1[n] = p[n].fi;
    post2[n] = p[n].se;
    for(int i = n - 1; i >= 1; i--) {
        post1[i] = max(post1[i + 1], p[i].fi);
        post2[i] = min(post2[i + 1], p[i].se);
    }
    ll ans = 0;
    fr(i, 1, n - 1) {
        ans = max(ans, pre2[i] - pre1[i] + 1 + post2[i + 1] - post1[i + 1] + 1);
    }
    auto cmp = [&](pii a, pii b) {
        if(a.se != b.se) return a.se < b.se;
        return a.fi < b.fi;
    };
    sort(p + 1, p + n + 1, cmp);
    pre1[1] = p[1].fi;
    pre2[1] = p[1].se;
    fr(i, 2, n) {
        pre1[i] = max(pre1[i - 1], p[i].fi);
        pre2[i] = min(pre2[i - 1], p[i].se);
    }
    post1[n] = p[n].fi;
    post2[n] = p[n].se;
    for(int i = n - 1; i >= 1; i--) {
        post1[i] = max(post1[i + 1], p[i].fi);
        post2[i] = min(post2[i + 1], p[i].se);
    }
    fr(i, 1, n - 1) {
        ans = max(ans, pre2[i] - pre1[i] + 1 + post2[i + 1] - post1[i + 1] + 1);
    }
    fr(i, 1, n) {
        ans = max(ans, p[i].se - p[i].fi + 1);
    }
    fr(i, 1, n) {
        ll cur = p[i].se - p[i].fi + 1;
        ll rmin = 1e9 + 5, lmax = -1e9 - 5;
        if(i > 1) {
            rmin = min(rmin, pre2[i - 1]);
            lmax = max(lmax, pre1[i - 1]);
        }
        if(i < n) {
            lmax = max(lmax, post1[i + 1]);
            rmin = min(rmin, post2[i + 1]);
        }
        cur += rmin - lmax + 1;
        ans = max(ans, cur);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4992
/*
javac Main.java && java Main
*/

import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
	public static void main(String[] args) { new Main(); }
	FS in = new FS();
	PrintWriter out = new PrintWriter(System.out);

	long n, a, b;

	Main() {
		n = in.nextLong();
		a = in.nextLong();
		b = in.nextLong();

		long s = a + b;
		long q = n / s;
		long r = n % s;

		long x = a * q + min(a, r);
		out.println(x);
		out.close();
	}

	
	
	int abs(int x) { if (x < 0) return -x; return x; }
	long abs(long x) { if (x < 0) return -x; return x; }
	int max(int x, int y) { if (x < y) return y; return x; }
	int min(int x, int y) { if (x > y) return y; return x; }
	long max(long x, long y) { if (x < y) return y; return x; }
	long min(long x, long y) { if (x > y) return y; return x; }
	int gcd(int x, int y) { while (y > 0) { x = y^(x^(y = x)); y %= x; } return x; }
	long gcd(long x, long y) { while (y > 0) { x = y^(x^(y = x)); y %= x; } return x; }
	long lcm(int x, int y) { return ((long) x) * (y / gcd(x, y)); }
	long lcm(long x, long y) { return x * (y / gcd(x, y)); }

	class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch (Exception e) {}
			} return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
		double nextDouble() { return Double.parseDouble(next()); }
	}
}


Measured memory_bytes: 21204
/*#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define mp make_pair
#define REP(i,a,b) for(ll i=a;i<b;i++)
typedef long long ll;
using namespace std;

void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}


int main(){

FAST();

freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);

stack<ll>s1,s2;
ll n,m,count,k,number;
cin>>n>>m>>k;

ll arr1[n],arr2[m];

REP(i,0,n){
 cin>>arr1[i];
}
REP(j,0,m){
cin>>arr2[j];
}

for(int i=n-1;i>0;i--)
s1.push(arr1[i]);


for(int i=m-1;i>0;i--)
s2.push(arr2[i]); 

number=count=0;
while(!s1.empty() && !s2.empty()){

    if(count==k)
    	break;
    if(count>k)
    	{count--; break;}

	ll top1,top2;
	top1=s1.top();
	top2=s2.top();

	if(top1<top2){
		number++;
      count+=top1;
      s1.pop();;
	}
	else{
		number++;
		count+=top2;
		s2.pop();;
	}

}

while(count<k && !s1.empty()){
 if(count==k)
    	break;
    if(count>k)
    	{count--; break;}

    ll top1=s1.top();
   count+= top1;
   number++;
   s1.pop();

}


while(count<k && !s2.empty()){
 if(count==k)
    	break;
    if(count>k)
    	{count--; break;}

    ll top1=s2.top();
   count+=top1;
   number++;
   s2.pop();

}


cout<<number<<endl;


return 0;
}

*/


#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define mp make_pair
#define REP(i,a,b) for(ll i=a;i<b;i++)
typedef long long ll;
using namespace std;

void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}


int main(){

FAST();

ll n,a,b,count,d;
cin>>n>>d;
count=0;
//int t=0;
while(n--){
	cin>>a>>b;

ll ans=a*a+b*b;
 double ans2=sqrt(ans);

//ans2=round(ans2);

 //cerr<<round(ans2)<<endl;
if(ans2<=d)
	count++;
  //cerr<<"t= "<<t<<" "<<ans2<<endl;
}

//t++;
cout<<count<<endl;
return 0;
}



Measured memory_bytes: 3692
S = input()
T = input()

Rs = [-1 for x in range(26)]
Rt = [-1 for x in range(26)]

l = len(S)

for i in range(l):
    s = ord(S[i])-97
    t = ord(T[i])-97
    if Rs[s] == -1:
        Rs[s] = t
    else:
        if Rs[s] != t:
            print("No")
            exit()
    
    if Rt[t] == -1:
        Rt[t] = s
    else:
        if Rt[t] != s:
            print("No")
            exit()

print("Yes")

Measured memory_bytes: 3632
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;


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

    map<int, ll> modM;

    ll s = 0;
    for (int i = 0; i < n; i++) {
        int a; 
        cin >> a;
        s = (s+ a) % m;
        modM[s]++;
    }


    ll ans = 0;
    for (auto it = modM.begin(); it != modM.end(); it++) {
        ans += (it->second * (it->second - 1)) / 2;
        if (it->first == 0) {
            ans += it->second;
        }
    }

    cout << ans << endl;

}  



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


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

    int i = 0, j = 0, x = 0;
    long long res = 0;
    while(i < n) {
        while(j < n && (x&a[j]) == 0) {
            x += a[j];
            j++;
        }
        res += j - i;
        if(i == j) j++;
        else x -= a[i];
        i++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4048
program sample
    implicit none
  
    integer(8) :: i,j,m,n
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n
    allocate(x(n))
    read(*,*)x
    call msort(x)
    m=x(n)
    if (mod(n,2)==0)then
        do i=n/2+1,n-1
            m=m+x(i)*2
        end do
    else
        m=m+x(n/2+1)
        do i=n/2+2,n-1
            m=m+x(i)*2
        end do
    end if

    write(*,*)m
    stop
    contains
    recursive subroutine msort(x)
    implicit none
    integer(8), intent(inout) :: x(:)
 
    integer(8) :: n, mid, i, j, k
    integer(8), allocatable :: tmp(:)
    
    n = size(x)
    
    if(n == 1) then
      return
    end if
 
    !
    ! 前半と後半に分けてソート
    ! 1~midとmid+1~nをそれぞれソート済みにする
    !
    mid = n / 2
    call msort(x(:mid))
    call msort(x(mid+1:))
 
    !
    ! tmpという配列にxを一時的に保管
    ! マージソートは外部ソート
    !
    allocate(tmp(n))
    tmp = x
 
    ! tmpの後半部分を左右反転
    do k = n, mid+1, -1
      tmp(k) = x(mid + n - k + 1)
    end do
 
    ! iは前半のリストのうちまだ見ていないものの最小値
    ! jは後半のリストのうちまだ見ていないものの最小値
    ! kは見た回数の合計
    i = 1
    j = n
 
    do k = 1, n
      !
      ! 一番左と一番右のうち小さい方をxに入れていく
      ! ここが等号つき不等号なので、安定ソートとなる
      !
      if(tmp(i) <= tmp(j)) then
        x(k) = tmp(i)
        i = i + 1
      else
        x(k) = tmp(j)
        j = j - 1
      end if
    end do
    
    deallocate(tmp)
    return
  end subroutine msort
end program sample
  



Measured memory_bytes: 6928
H, W, M = map(int, input().split())

bomb = set()
row = [0] * H
column = [0] * W

for i in range(M):
    h, w = map(int, input().split())
    h -= 1
    w -= 1
    
    bomb.add((h, w))
    
    row[h] += 1
    column[w] += 1
    
row_max = max(row)
col_max = max(column)

r_check = []
c_check = []
for i in range(H):
    if row[i] == row_max:
        r_check.append(i)

for i in range(W):
    if column[i] == col_max:
        c_check.append(i)

num = len(r_check) * len(c_check)

ans = row_max + col_max - 1
flg = False
if M < num:
    ans += 1
else:
    for r in r_check:
        if flg:
            break
        for c in c_check:
            if not (r, c) in bomb:
                ans += 1
                flg = True
                break

print(ans)

Measured memory_bytes: 83572
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		double ans = 0;
		int a;
		for (int i = 0; i < n; i++) {
			a = sc.nextInt();
			ans += 1.0 / a;
		}
		ans = 1.0 / ans;
		System.out.println(ans);
	}
}


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

int max_2(int a, int b){
    if (a < b){
        return b;
    }else{
        return a;
    }
}

int max_3(int a, int b, int c){
    if (a < b){
        a=b;
    }
    if (a < c){
        a=c;
    }
    return a;
}

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

    long long dp_a[N];
    long long dp_b[N];
    long long dp_c[N];

    int a,b,c;
    cin >> a >> b >> c;
    dp_a[0]=a;
    dp_b[0]=b;
    dp_c[0]=c;

    for (int i = 1; i < N; ++i) {
        cin >> a >> b >> c;
        dp_a[i]=a+max_2(dp_b[i-1],dp_c[i-1]);
        dp_b[i]=b+max_2(dp_a[i-1],dp_c[i-1]);;
        dp_c[i]=c+max_2(dp_a[i-1],dp_b[i-1]);;
    }

    cout << max_3(dp_a[N-1],dp_b[N-1],dp_c[N-1]) << endl;
    return 0;
}

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

int main(){
	string a;
	string b;
	int n=0;
	int m=0;
	int i=0;
	int j=0;
	int k=0;
	int t=0;
	int s=0;
	cin>>a;
	cin>>n;
	m=a.size();
	for(i=0;i<n;i++){
		cin>>b;
		b=b+b;
		for(j=0;j<10;j++){
			for(k=0;k<m;k++){
				if(a[k]==b[j+k]){
					t=t+1;
				}
			}
			if(t==m){
				s=s+1;
				t=0;
				break;		
			}
			t=0;
		}
	}
	cout<<s<<endl;
} 

Measured memory_bytes: 3172
#include <stdio.h>
#define N 50

int f[N];

void Fibonacci(int);

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

  Fibonacci(n);

  printf("%d\n",f[n]);

  return 0;
}

void Fibonacci(int n){

  int i;

  f[0]=1;
  f[1]=1;
  for(i=2; i <=n; i++){
    f[i]=f[i-2]+f[i-1];
  }
}

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

string change(string from){
    stringstream ss;
    int cur=0;
    while(cur<from.size()){
        int next=cur;
        while(next<from.size()&&from[next]==from[cur])next++;
        ss<<next-cur<<from[cur];
        cur=next;
    }
    return ss.str();
}

int main(){
    int N;
    while(cin>>N,N){
        string str;
        cin>>str;
        while(N--)str=change(str);
        cout<<str<<endl;
    }

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
ll cost;
ll n;
ll h[100001];
ll dp[100001];
ll jump (ll stone)
{
    dp[1] = 0, dp[2] = abs(h[1]-h[2]);
    for(ll i=3; i<=n; i++)
    {
        dp[i] =  min( (dp[i - 2]   + abs(h[i] - h[i - 2])) , (dp[i - 1] + abs(h[i] - h[i - 1])));
    } 
    return dp[n];
}

int main()
{
    cin>>n;
    h[n+1];
    
    for(int i=1; i<=n; i++)
    {
        cin>>h[i];
    }
    cout<<jump(1);
    return 0;
}


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

int main() {
    ll n,x = 0; cin >> n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) {
        cin >> a[i];
        x ^= a[i];
    }
    for(int i=0; i<n; i++) {
        cout << (x ^ a[i]) << " ";
    }
}

Measured memory_bytes: 4668
// AOJ 0636: Foehn Phenomena
// 2017.12.14 bal4u@uu

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

long long dx[200001];
long long S, T;
char buf[40], *p;

int getint()
{
	int n = 0;
	if (*p == '-') {
		p++; while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
		p++; return -n;
	}
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++; return n;
}

long long calc(int i, int x)
{
	long long d;

	if (dx[i] > 0) d = dx[i]*S;
	else           d = dx[i]*T;
	dx[i] += x;
	if (dx[i] > 0) d -= dx[i]*S;
	else           d -= dx[i]*T;
	return d;
}

int main()
{
	int N, Q, i, a0, a, l, r, x;
	long long u, d, ans;
	
	fgets(p=buf, 40, stdin);
	N = getint(), Q = getint(), S = getint(), T = getint();

	fgets(buf, 10, stdin);
	u = d = a0 = 0;
	for (i = 1; i <= N; i++) {
		fgets(p=buf, 10, stdin);
		a = getint();
		a0 = a - a0;
		dx[i] = a0;
		if (a0 >= 0) u += a0;
		else         d += a0;
		a0 = a;
	}

	ans = -(d*T+u*S);
	while (Q--) {
		fgets(p=buf, 30, stdin);
		l = getint(), r = getint(), x = getint();
		ans += calc(l, x);
		if (r < N) ans += calc(r+1, -x);
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3420
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a < b){
        if(a <= c && c <= b) pr("Yes");
        else pr("No");
    }else{
        if(b <= c && c <= a) pr("Yes");
        else pr("No");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){
	
	int n;
	
	int s[6]={500,100,50,10,5,1};
	while(cin>>n,n!=0){
	int x=0;
	n=1000-n;
	int k=0;
	while(n>0){
		if(n-s[k]>=0){
			n=n-s[k];
			x++;
		}
		else
			k++;
	}
	
	cout<<x<<endl;
	}

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
int main() {
    int k, a, b;
    cin >> k >> a >> b;

    for (int i = 0;i < (b/k)+1;i++ ){
      if(a <= i*k && i*k <= b){
        cout << "OK" << endl; 
        break;
      }
      if(i == b/k){
        cout << "NG" << endl;
    }
    }
}
    
    

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a - 1) + (a <= b ? 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int in;
	int sum=0;
	rep(i,10){
		int a;cin>>a;
		sum+=a;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;

int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  int count = 0;
  for(int i=0; i<n;i++){
    if(s[i] == 'R') count++;
  }
  if(count*2 > n) cout << "Yes" <<endl;
  else cout << "No" <<endl;
  return 0;
}


Measured memory_bytes: 256
N,A,B=map(int,input().split())
if (B-A)%2==0:
    ans=(B-A)//2
else:
    #2人のどちらかが卓1,Nのいずれかに到達するのに必要なラウンド数
    #1は偶奇を調整するためのラウンド
    #(B-A-1)/2は偶奇の調整後に2人が出会うまでのラウンド数
    ans=min(A-1,N-B)+1+(B-A-1)//2 
print(ans)

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

#define M_PI 3.14159265358979323846

using namespace std;

//typedef
//-------------------------#include <bits/stdc++.h>

#define M_PI 3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}
inline int readInt()
{
    int x;
    scanf("%d", &x);
    return x;
}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a) * (a))
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;

#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const int INF = 2147483647;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    string s;
    cin >> s;
    reverse(s.begin(), s.end());

    int n = s.size();
    bool ok = true;
    for (int i = 0; i < n; i++)
    {
        if (i + 6 < n && s.substr(i, 7) == "remaerd")
        {
            i += 6;
        }
        else if (i + 5 < n && s.substr(i, 6) == "resare")
        {
            i += 5;
        }
        else if (i + 4 < n && s.substr(i, 5) == "maerd")
        {
            i += 4;
        }
        else if (i + 4 < n && s.substr(i, 5) == "esare")
        {
            i += 4;
        }
        else
        {
            ok = false;
        }
    }
    cout << (ok ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

#define NUM 100000010

//int table[NUM]={};
//void sieve() {
//    table[0] = table[1] = 1;
//    int i,j;
//    for(i = 2; i*i < NUM; i++) {
//        for(j = i*2; j < NUM; j+=i) {
//            table[j] = 1;
//        }
//    }
//}

int check(int x) {
    int i;
    if(x<2)return 0;
    for(i = 2; i*i <= x; i++){
        if(x % i == 0)return 0;
    }
    return 1;
}

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

    int cou=0;
    int i;
    for(i=0;i<n;i++) {
        int x;
        scanf("%d",&x);
        if(check(x)) cou++;
    }

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

    return 0;
}



Measured memory_bytes: 2072
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll a[N];
int main()
{
	ll r, d;
	cin >> r >> d >> a[0];
	for(int i = 1; i <= 10; i ++)
	{
		a[i] = r *a[i - 1] - d;
		cout << a[i] << '\n';
	}





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256