akhauriyash/Code-Regression huggingface dataset:
#define yuki(x, y) for(int i = x; i < (y); ++i)
#define yukj(x, y) for(int j = x; j < (y); ++j)
#define yukii(x, y) for(int i = x; i <= (y); ++i)
#define yukji(x, y) for(int j = x; j <= (y); ++j)
#define yuk(x, y, z) for(int x = y; x < (z); ++x)
#define yui(x, y, z) for(int x = y; x >= (z); --x)
#define sclr(x) memset(x, 0, sizeof(x))
#define sclr1(x) memset(x, -1, sizeof(x))
#define scl(x, y) memset(x, y, sizeof(x))
#define ft first
#define sc second
#define no {puts("No");return 0;}
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long lol;
int n, raw[510], ans[300100];
bool b[300100];
void sread()
{
    scanf("%d", &n);
    yukii(1, n) scanf("%d", raw+i);
}
int main(int argc, char **argv)
{
	sread();
	yukii(1, n)
        if(ans[raw[i]])
            no
        else ans[raw[i]] = i, b[raw[i]] = true;
    int cnt = 0, ptr = 1, tcnt = 0, m = n;
    n *= n;
    yukii(1, n)
        if(ans[i])
        {
            int t = ans[i];
            if(cnt < t-1)
                no
            else
            {
                while(tcnt++ < t-1)
                {
                    while(ans[ptr]) ++ptr;
                    ans[ptr++] = t;
                    --cnt;
                }
                tcnt = 0;
            }
        }else
            ++cnt;
    cnt = 0, ptr = n;
    yui(i, n, 1)
        if(b[i])
        {
            int t = ans[i];
            if(cnt < m-t)
                no
            else
            {
                while(tcnt++ < m-t)
                {
                    while(ans[ptr]) --ptr;
                    ans[ptr--] = t;
                    --cnt;
                }
                tcnt = 0;
            }
        }else if(!ans[i]) ++cnt;
    puts("Yes");
    yukii(1, n) printf("%d ", ans[i]);
    puts("");
	return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    ll x[2], y[2];
    rep(i, 2)   cin >> x[i];
    rep(i, 2)   cin >> y[i];
    ll ans = -1000000000000000000+10;
    rep(i, 4)   ans = max(ans, x[i/2]*y[i%2]);
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>

using ll = long long;

using namespace std;

using P = pair<long, long>;
#define fi first
#define se second

#define MAX 1000000000l
#define INF 1000000001l

long pow(long n, long k) {
    if (k <= 0 || n == 1) return 1;
    if (k >= 30) return INF;
    long root = pow(n, k/2),
         rr = root * root,
         odd = (k % 2 ? n : 1),
         val = (rr < INF / odd ? rr * odd : INF);
    return val;
}

int main() {
    int n;
    cin >> n;
    long a[n];
    for (int i=0; i<n; i++) cin >> a[i];
    long l = 0, r = MAX;
    while (r - l > 1) {
        long m = (l + r + 1) / 2;
        stack<P> st;
        st.push({0, 0});
        bool under;
        for (auto &ai:a) {
            P next = st.top(),
              tp = next;
            st.pop();
            under = false;
            while (ai < tp.fi) {
                under = true;
                next = st.top();
                if (next.fi < ai) {
                    next = P{ai, 1};
                    st.push(next);
                }
                // cerr << tp.fi << ' ' << tp.se << '\n';
                long p = pow(m, tp.fi - next.fi);
                tp.se = (tp.se + p - 1) / p - 1;
                tp.fi = next.fi;
                tp.se += next.se;
                st.pop();
                // cerr << tp.fi << ' ' << tp.se << '\n';
            }
            st.push(tp);
            if (ai == tp.fi) {
                st.pop();
                tp.se++;
                st.push(tp);
            }
            else { // ai > tp.fi
                st.push({ai, 1 + under});
            }
        }
        P next = st.top(),
          tp = next;
        st.pop();
        while (tp.fi > 0) {
            // cerr << tp.fi << ' ' << tp.se << '\n';
            next = st.top();
            long p = pow(m, tp.fi - next.fi);
            tp.se = (tp.se + p - 1) / p - 1;
            tp.fi = next.fi;
            tp.se += next.se;
            st.pop();
        }
        // cerr << tp.se << ' ' << l << ' ' << m << ' ' << r << '\n';
        if (tp.se > 0) l = m;
        else r = m;
    }
    cout << r << '\n';
    return 0;
}

Measured memory_bytes: 5144
import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String U = sc.next();
		if(U.equals(S)) {
			A--;
		}else {
			B--;
		}
		System.out.println(A + " " + B);
	}
}

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

int main() {
  for (int d, w; cin >> d >> w, d;) {
    vector<vector<int>> e(d, vector<int>(w));
    REP(i, d) REP(j, w) cin >> e[i][j];
    int ans = 0;
    REP(sx, d) REP(sy, w) {
      REP(tx, d) REP(ty, w) {
        if (sx >= tx || sy >= ty) continue;
        int mn = 1e9;
        REP(i, d) {
          if (i < sx || i > tx) continue;
          mn = min(mn, e[i][sy]);
          mn = min(mn, e[i][ty]);
        }
        REP(j, w) {
          if (j < sy || j > ty) continue;
          mn = min(mn, e[sx][j]);
          mn = min(mn, e[tx][j]);
        }
        bool f = false;
        int c = 0;
        REP(i, d) REP(j, w) {
          if (i <= sx || i >= tx) continue;
          if (j <= sy || j >= ty) continue;
          if (mn <= e[i][j]) f = true;
          c += mn - e[i][j];
        }
        if (f) continue;
        ans = max(ans, c);
      }
    }
    cout << ans << endl;
  }
}



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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const ll LINF = 1e18 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  LCIN(N, S);
  vector< int > a(N);
  REP(i, N) {
    cin >> a[i];
  }

  int ub = 0;
  ll ans = LINF;
  ll sm = 0ll;
  REP(lb, N) {
    while (ub < N) {
      if (sm + a[ub] >= S) {
	break;
      }
      sm += a[ub++];
    }
    if (ub == N) break;
    if (sm + a[ub] >= S) {
      ans = min(ans, (ub >= N ? N - 1 : ub) - lb + 1ll);
    }

    /*
    debug(lb);
    debug(ub);
    debug(sm);
    debug(ans);
    */
    sm -= a[lb];
    // cout << endl;
  }
  if (ans == LINF) ans = 0;
  cout << ans << endl;

  

  return 0;
}




Measured memory_bytes: 3336
N, X = gets.split.map(&:to_i)
xs = [0] + gets.split.map(&:to_i)
accum = [0]
(1..N).each do |i|
    accum[i] = xs[i] + accum[i-1]
end

ans = 10**18
(1..N).each do |k|
    result = k*X
    ((N-1)/k+1).times do |j|
        max = N - j*k
        min = max-k > 0 ? max-k : 0
        c = j==0 ? 5 : 2*j+3
        result += c * (accum[max] - accum[min])
        break if result >= ans
    end
    ans = result if ans > result
end
puts ans+N*X

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n;
    cin >> n;

    ll l0 = 2, l1 = 1;
    fo(i, n - 1) {
        l1 += l0;
        l0 = l1 - l0;
    }

    cout << l1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <iostream>
#include <cmath>

using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n;
  cin >> n;
  if (n % 2 == 1) {
    cout << n / 2 + 1 << endl;
  } else {
    cout << n / 2 << endl;
  }
}

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

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

  int n;
  cin>>n;

  double pi = acos(-1);
  cout.precision(10);
  cout<<fixed<<pi * 2 * n << endl;

	return 0;
}


Measured memory_bytes: 3800
m = int(input())
count = 0
sum1 = 0
for i in range(m):
    d,c = map(int,input().split())
    sum1 += d*c
    count += c
if (sum1%9 == 0):
    print(sum1//9 - 1 + count - 1)
else:
    print(sum1//9 + count - 1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define el "\n"
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define M 1000000007
#define all(v) v.begin(), v.end()

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k,x;
    cin>>k>>x;
    for(int i=x-k+1;i<x+k;i++)cout<<i<<" ";
    return 0;
}

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

int main(void){
    int n,m;
    cin >> n >> m;
    ll ans = 0;
    vector<pair<ll,ll>> a;
    rep(i,n){
        int x,y;
        cin >> x >>y;
        a.emplace_back(x,y);
    }
    sort(a.begin(),a.end());
    int cnt=0;
    rep(i,n){
        if(cnt+a[i].second <= m){
            ans += (ll)a[i].first*a[i].second;
            cnt += a[i].second;
        }
        else{
            while(cnt <m){
                ans += a[i].first;
                cnt++;
            }
        }
        if(cnt == m){
            break;
        }
    }
    cout << ans << endl;
  
   
    return 0;
}





































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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(ll i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
	ll n; cin>>n;
	ll sum = 0;
	forne(i, n) sum += (i*(i+1))/2;
	forn(i, n-1){
		ll u, v; cin>>u>>v;
		ll s = min(u, v);
		ll t = max(u, v);
		sum -= s*(n+1-t);
	}
	cout<<sum<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef KARAN
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 3536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * author @sahil
 */
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str=br.readLine().split(" ");
        int A=Integer.parseInt(str[0]);
        int B=Integer.parseInt(str[1]);
        String s=br.readLine();
        if(s.length()!=(A+B+1) || s.charAt(A)!='-')
            System.out.println("No");
        else{
            int c=0;
            //System.out.println("hello");
            //System.out.println((int)s.charAt(A));
            for(int i=0;i<s.length();++i) {
                if(i==A) continue;
                if (!((int) s.charAt(i) >= 48 && (int) s.charAt(i) <= 57)) {
                    c = 1;
                    break;
                }
            }
            if(c==1) System.out.println("No");
                else
                System.out.println("Yes");
        }
    }
}


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

#define INF ((1<<31)-1)  //int32_t
#define MOD 1000000007
#define MOD2  

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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



int main(){
    bool flag=true;
    ll ans=0,sum=0;
    string s;
    cin >>s;
    
    for (int i = 0; i < s.length(); i++)
    {
        if(i % 2 == 0){
            if(s[i] == 'L')flag = false;
        }else{
            if(s[i] == 'R')flag = false;
        }
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    if(flag)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  static final long n = 10;

  static final boolean DEBUG = false;

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

    StringBuilder left = new StringBuilder("1");
    StringBuilder right = new StringBuilder("10");
    boolean foundLength = false;
    int length = 1;
    while(true){
      System.out.println("? " + left);
      System.out.flush();
      //boolean ans1 = question(Long.decode(left.toString()));
      boolean ans1 = sc.next().equals("Y");
      assert ans1 == question(Long.decode(left.toString()));
      System.out.println("? " + right);
      System.out.flush();
      boolean ans2 = sc.next().equals("Y");
      assert ans2 == question(Long.decode(right.toString()));
      //boolean ans2 = question(Long.decode(right.toString()));
      if(ans1 && !ans2){
        foundLength = true;
        break;
      }
      if(length >= 10){
        break;
      }
      length++;
      left.append("0");
      right.append("0");
    }

    if(DEBUG){
      System.out.println("length = " + length);
    }

    if(foundLength){
      if(DEBUG){
        System.out.println("left = " + left);
        System.out.println("right = " + right);
      }
      long low = 1;
      for(int i = 0; i < length - 1; i++){
        low *= 10;
      }
      long high = 1;
      for(int i = 0; i < length; i++){
        high *= 10;
      }
      high--;
      if(DEBUG){
        System.out.println("low = " + low);
        System.out.println("high = " + high);
      }
      while(high - low > 1){
        long mid = (low + high) / 2;
        System.out.println("? " + (mid * 10L));
        System.out.flush();
        //boolean ans = question(mid * 10);
        boolean ans = sc.next().equals("Y");
        assert ans == question(mid * 10L);
        if(DEBUG){
          System.out.println("mid = " + mid);
          System.out.println(ans);
        }
        if(ans){
          high = mid;
        }
        else{
          low = mid;
        }
      }
      System.out.println("! " + high);
    }
    else{
      // 1, 100, 1000, 10000
      long v = 10;
      while(v <= 1000000000){
        //boolean ans1 = question(v - 1);
        System.out.println("? " + (v - 1));
        System.out.flush();
        boolean ans1 = sc.next().equals("Y");
        assert ans1 == question(v - 1);
        //boolean ans2 = question(v + 1);
        System.out.println("? " + (v + 1));
        System.out.flush();
        boolean ans2 = sc.next().equals("Y");
        assert ans2 == question(v + 1);
        if(!ans1 && ans2){
          System.out.println("! " + v);
          return;
        }
        v *= 10L;
      }
      System.out.println("! " + 1);
    }
  }

  private static boolean question(long x){
    return (x <= n && Long.toString(x).compareTo(Long.toString(n)) <= 0) ||
      (x > n && Long.toString(x).compareTo(Long.toString(n)) > 0);
  }
}


Measured memory_bytes: 24100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

struct edge{
    int to;
    ll s;
    edge(){}
    edge(int to, ll s) : to(to), s(s) {} 
};

int n, m;
vector<edge> G[100010];
bool used[100010];
int si[100010];//0 : +, 1 : -
ll val[100010];
ll l, r;

void dfs(int v){
    used[v] = true;
    if(si[v] == 1){
        chmin(r, val[v] - 1);
    }else{
        chmax(l, 1 - val[v]);
    }

    for(auto u : G[v]){
        ll vl = u.s - val[v];
        int si_ = (si[v] + 1) & 1;

        if(used[u.to]){
            if(si[u.to] != si_ ^ val[u.to] != vl){
                l = inf, r = -inf;
            }else if(si[u.to] != si_ && val[u.to] != vl){
                ll p = abs(vl - val[u.to]);
                if(abs(p) & 1){
                    l = inf, r = -inf;
                }else{
                    p /= 2;
                    chmax(l, p);
                    chmin(r, p);
                }
            }
        }else{
            val[u.to] = vl;
            si[u.to] = si_;
            dfs(u.to);
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    l = 1, r = inf;
    for(int i = 0; i < m; ++i){
        int u, v, s;
        cin >> u >> v >> s;
        G[u].emplace_back(edge{v, s});
        G[v].emplace_back(edge{u, s});
    }
    dfs(1);
    cout << max(0LL, r - l + 1) << endl;
    return 0;
}

Measured memory_bytes: 12288
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#include "bits/stdc++.h"
#define YES "YES"
#define Yes "Yes"
#define NO "NO"
#define No "No"
#define YESNO(x) OUT(three(x,YES,NO))
#define YesNo(x) OUT(three(x,Yes,No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b-1,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB emplace_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int long long
#define zero 0LL
#define all ALL
#define pb PB
using namespace std;
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef LL ll;
typedef double ld;
typedef LL ut;
const LL INF = 1LL << 60;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ppr, Vppr ,greater<ppr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
int dx[] = { 0,1,0,-1,1,1,-1,-1,0 }, dy[] = { 1,0,-1,0,1,-1,1,-1,0 };
const int SIZE1 =5e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 301;
const int SIZE = SIZE1;
const LL p = 7 + 1e9;const long double EPS = 1e-7;
ut N, M, K, X, L, Y,H,W,Q,D;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], nums[SIZE], maps[SIZE2][SIZE2], answer = zero;
LL btimes[SIZE];
LL A[SIZE], B[SIZE],I[SIZE];
LL DP[SIZE];
LL solve() {

	cin >> N;
	DP[0] = 1;
	EFOR(i,1, N) {
		cin >> A[i];
		DP[i] += DP[i - 1];
		if (B[A[i]] != i - 1 and B[A[i]]!=0) {
			DP[i] += DP[B[A[i]]];
		}
		DP[i] %= p;


		B[A[i]] = i;
	}
	return DP[N];
}
signed main() {
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	cout << solve() << endl;
	//cout << solve() << endl;
	//	cin >> N;
	return 0;
}

Measured memory_bytes: 23424
#include<iostream>
#define MAX 50
using namespace std;
int main(){
	int road[MAX][MAX];
	for(int i=0;i<MAX;i++){
		for(int j=0;j<MAX;j++){
			road[i][j]=0;
		}
	}
	int m,n;
	cin>>m>>n;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		road[a-1][b-1]++;
		road[b-1][a-1]++;
	}
	for(int i=0;i<m;i++){
		int count=0;
		for(int j=0;j<m;j++){
			if(road[i][j]>=0)count+=road[i][j];
		}
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = 0;
        int y = 0;
        int z = 0;
        
        while(true){
            x = sc.nextInt();
            y = sc.nextInt();
            if(x == 0 && y == 0)break;
            if(x > y){
                z = x;
                x = y;
                y = z;
            }
            System.out.println(x + " " + y);
        }
        
    }
}



Measured memory_bytes: 36740
#include <bits/stdc++.h>
 
using namespace std;
 
const int maxn = 1000 + 50;
const int inf = 0x3f3f3f3f;
 
template < typename T >
void Read( T & x ){
	x=0;
	char ch;
	for( ch = getchar() ; ch < '0' || ch > '9' ; ch = getchar() );
	for( ; ch <= '9' && ch >= '0' ; ch = getchar() ) x = x * 10 + ch - '0';
}
 
 
int n , f[1001][5005] , x[maxn] , g[5005] , temp[5005] , tr[5005];
vector < int > Edge[maxn];
 
void Dfs( int u ){
	for(auto && v : Edge[u])
		Dfs( v );
	memset( g , 0x3f , sizeof( g ) );
	g[0] = 0;
	for(auto && v : Edge[u]){
		memset( temp , 0x3f , sizeof( temp ) );
		int trlen = 0;
		for(int i = 0 ; i <= 5000 ; ++ i)
			if( f[v][i] != inf )
				tr[trlen ++] = i;
		for(int i = 0 , j = trlen - 1 ; i <= 5000 && j >= 0 ; ++ i)
			if( g[i] != inf ){
				while( j >= 0 && tr[j] + i > 5000 ) -- j;
				for(int k = j ; k >= 0 ; -- k)
					temp[i + tr[k]] = min( temp[i + tr[k]] , g[i] + f[v][tr[k]] );
			}
		memcpy( g , temp , 5001 << 2 );
	}
	memset( temp , 0x3f , sizeof( temp ) );
	for(int i = 0 ; i <= 5000 ; ++ i)
		if( g[i] != inf ){
			if( i <= x[u] ) temp[x[u]] = min( temp[x[u]] , g[i] );
			if( g[i] <= x[u] ) temp[i] = min( temp[i] , x[u] );
		}
	memcpy( f[u] , temp , 5001 << 2 );
}
 
int main( int argc , char * argv[] ){
	Read( n );
	for(int i = 2 ; i <= n ; ++ i){
		int fa;
		Read( fa );
		Edge[fa].emplace_back( i );
	}
	for(int i = 1 ; i <= n ; ++ i) Read( x[i] );
	Dfs( 1 );
	for(int i = 0 ; i <= 5000 ; ++ i)
		if( f[1][i] != inf ){
			puts( "POSSIBLE" );
			return 0;
		}
	puts( "IMPOSSIBLE" );
	return 0;
}

Measured memory_bytes: 19968
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll size = 100007;
ll mod = 1000000007;
vector<ll> dp(size,0),vis(size,0);
vector<ll> edges[size];

void dfs(ll n){
  vis[n] = 1;
  for(auto k: edges[n]){
    if(vis[k]==0){
      dfs(k);
    }
    dp[n] = max(dp[n], 1 + dp[k]);
  }
}

int main()
{
  ll i,j,k,l,m,n,t;
	ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin>>n>>m;

  for(i=0;i<m;i++)
  {
    cin >> j >> k;
    edges[j].push_back(k);
  }

  ll ans = 0;
  for (i = 1; i <= n; i++)
  {
    if (vis[i] == 0){
      dfs(i);
    }
    ans = max(ans, dp[i]);
  }

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

Measured memory_bytes: 9344
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_N = 200000;
int n;
ll a[MAX_N];

int main(){
  cin >> n;
  REP(i, n) cin >> a[i];
  map<ll, int> mp;
  REP(i, n) mp[a[i]]++;

  ll ans = 0;

  for(auto itr = mp.rbegin(); itr != mp.rend(); itr++) {
    for(int j = 31; j >= 1; j--) {
      ll v = itr->first;
      ll s = ll(pow(2, j));
      if (itr->second > 0 && mp.find(s - v) != mp.end() && mp[s - v] > 0) {
        if(2 * v == s) {
          if(itr->second >= 2) {
            ans += itr->second / 2;
            itr->second = itr->second % 2;
          }
        } else {
          int num = min(itr->second, mp[s - v]);
          ans += num;
          itr->second -= num;
          mp[s - v] -= num;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 14336
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f(B, A, A, B).
f(B, A, B, A).
f(B, B, A, A).

main :-
    get_number(A, B, C),
    f(X, A, B, C),
    writeln(X).


Measured memory_bytes: 8184
package main

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

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt64() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt() int {
	return int(nextInt64())
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	return int(max64(int64(x), int64(y)))
}

func min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func min(x, y int) int {
	return int(min64(int64(x), int64(y)))
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func abs(x int) int {
	return int(abs64(int64(x)))
}

func joinInt64s(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func divUp64(x, y int64) int64 {
	return (x + y - 1) / y
}

func divUp(x, y int) int {
	return int(divUp64(int64(x), int64(y)))
}

func gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func gcd(x, y int) int {
	return int(gcd64(int64(x), int64(y)))
}

func lcm64(x, y int64) int64 {
	return x * y / gcd64(x, y)
}

func lcm(x, y int) int {
	return int(lcm64(int64(x), int64(y)))
}

func pow64(x, y int64) int64 {
	return int64(math.Pow(float64(x), float64(y)))
}

func pow(x, y int) int {
	return int(pow64(int64(x), int64(y)))
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	n := nextInt()
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt64()
	}
	out(min64(calc(a, 0), calc(a, 1)))
}

func calc(a []int64, n int) int64 {
	x := int64(0)
	ttl := int64(0)
	for i := 0; i < len(a); i++ {
		ttl += a[i]
		if i&1 == n && ttl <= 0 {
			x += 1 - ttl
			ttl = 1
		} else if i&1 != n && ttl >= 0 {
			x += ttl + 1
			ttl = -1
		}
	}
	return x
}


Measured memory_bytes: 6528
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int h = sc.nextInt();
		int w = sc.nextInt();
		char [][] c = new char[h+2][w+2];
		
		for(int i = 1; i <= h ;i++) {
			String s = sc.next();
			for(int j = 1; j <= w ; j++) {
				c[i][j] = s.charAt(j-1);
 			}	
		}
		int temp = -1;
		
		for(int i = 1; i <= h ;i++) {
			for(int j = 1; j <= w ; j++) {
				boolean x = true;
				x = (c[i][j] == '#'); 
				
				boolean y = true;
				y = (c[i-1][j] != '#'&& c[i][j-1] != '#'&& c[i+1][j] != '#'&& c[i][j+1] != '#');
				

				if(x && y) {
					temp = 0;
					break;
				}
			}
 		}
		
		if(temp == 0)
		System.out.println("No");
		if(temp == -1)
		System.out.println("Yes");
		
		}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

int main () {
  int n, m;
  cin >> n >> m;
  vector<pii> p(n);
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    p[i] = make_pair(a, b);
  }
  sort(p.begin(), p.end());
  ll ans = 0;
  rep(i,n) {
    ans += (ll)p[i].fi*min(m, p[i].se);
    m -= min(m, p[i].se);
    if (m == 0) break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(void){
  	int n;
  cin >> n;
  for(int i = 1; i <= 9; i++){
    	for(int j = 1; j <= 9; j++){
				if(i*j==n){
                  	cout << "Yes" << endl;
                  return 0;
                }
        }
  }
  cout << "No" << endl;
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{   
    int k;
    cin>>k;
    int a=k,b=k,c=k;
    int tong=0;
    for (int i=1;i<=a;i++)
    {
        for (int j=1;j<=b;j++)
        {
            for (int k=1;k<=c;k++)
            {
                tong+=__gcd(__gcd(i,j),k);
            }
        }
    }
    cout<<tong;
}

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

#define endl "\n"

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

    int yen, happy = 0;
    cin >> yen;

    happy += 1000 * (yen / 500);
    yen %= 500;
    happy += 5 * (yen / 5);
    cout << happy << endl;

    return 0;
}

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

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> sequence(n);

    for (int i = 0; i < n; ++i) {
        std::cin >> sequence[i];
    }

    int removed = 0;
    int limit = 100000;
    std::vector<int> count(limit, 0);
    for (int i = 0; i < n; ++i) {
        if (sequence[i] > limit) {
            ++removed;
        } else if (count[sequence[i]] >= sequence[i]) {
            removed++;
        } else {
            ++count[sequence[i]];
        }
    }

    for (int i = 0; i < limit; ++i) {
        if (count[i] < i) {
            removed += count[i];
        }
    }
    

    std::cout << removed;

    return 0;
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  VAR(int, n);

  vector<pair<int, string>> vec;
  rep(i, n) {
    VAR(string, s);
    vec.emplace_back((int)s.length(), s);
  }

  sort(all(vec));

  string norm = vec[0].second;

  string res = "";
  bool exist[100][100] {};
  for (auto e : norm) {
    bool isOk = true;
    for (int i = 1; i < vec.size(); ++i) {
      string t = vec[i].second;
      bool find = false;
      for (int j = 0; j < t.length(); ++j) {
        if (!exist[i][j] && t[j] == e) {
          find = true;
          exist[i][j] = true;
          break;
        }
      }
      if (!find) {
        isOk = false;
        break;
      }
    }
    if (isOk) res += e;
  }

  sort(all(res));

  OUTL(res);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include<string.h>
#include <stack>
#define ll long long
using namespace std;
int a[35][35];
int cnt[35];
int main() {
	int n, m, k[35];
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", k+i);
		for (int j = 0; j < k[i]; j++) {
			scanf("%d", &a[i][j]);
		}
		sort(a[i], a[i] + k[i]);
	}
	for (int i = 0; i < n; i++) {
		cnt[a[i][0]]++;
		for (int j = 1; j < k[i]; j++) {
			if (a[i][j] == a[i][j - 1])
				continue;
			else
				cnt[a[i][j]]++;
		}
	}
	int res = 0;
	for (int i = 0; i <= 30; i++)
		if (cnt[i] == n)
			res++;
	printf("%d\n", res);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

vector<ll> par(1e6);
vector<ll> ran(1e6);
vector<ll> siz(1e6);
void init(ll n){
  rep(i,n){
    par.at(i)=i;
    ran.at(i)=0;
    siz.at(i)=1;
  }
}
ll find(ll x){
  if(par.at(x)==x){
    return x;
  }else{
    return par.at(x)=find(par.at(x));
  }
}
void unite(ll x,ll y){
  x=find(x);
  y=find(y);
  if(x==y) return;
  if(ran.at(x)<ran.at(y)){
    siz.at(y)+=siz.at(x);
    par.at(x)=y;
  }else{
    siz.at(x)+=siz.at(y);
    par.at(y)=x;
    if(ran.at(x)==ran.at(y)) ran.at(x)++;
  }
}

int main(){
  ll N,M,ans=0;
  cin >> N >> M;
  init(N);
  rep(i,M){
    ll a,b;
    cin >> a >> b;
    a--;
    b--;
    unite(a,b);
  }
  rep(i,N){
    ans=max(ans,siz.at(find(i)));
  }
  cout << ans << endl;
}

Measured memory_bytes: 26608
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int tp = 0;
        int hp = 0;

        for(int i=0;i<n;i++){
            String tt = scn.next();
            String ht = scn.next();
            int result = tt.compareTo(ht);
            if (result<0){
                hp +=3;
            }else if(result>0){
                tp +=3;
            }else{
                tp +=1;
                hp +=1;
            }
        }

        System.out.println(tp+" "+hp);

        scn.close();
    }

}


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

int main(){
    int x, y;
    scanf("%d%d", &x, &y);
    if (2 * x > y) printf("No");
    else if (4 * x < y) printf("No");
    else if (y % 2 == 1) printf("No");
    else printf("Yes");
    return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define double long double
typedef long long LL;
using namespace std;

int main(int argc, char **argv) {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 2; i < n; ++i)
		if (s[i] == 'C' && s[i - 1] == 'B' && s[i - 2] == 'A')
			++ans;
	cout << ans << '\n';
	return 0;
}



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

#define pb push_back
#define fs first
#define sc second
#define sz size()
using namespace std;

typedef double D;
typedef complex<D> P;
typedef pair<P, P> L;
typedef pair<P, D> C;
typedef vector<P> Poly;
const D EPS=1e-12;


namespace std{
  bool operator<(const P &a, const P &b){
    return real(a)==real(b)?imag(a)<imag(b):real(a)<real(b);
  }
}

P unit(P p){ return p / abs(p);}

D dot(P x, P y){return real(conj(x)*y);}

D cross(P x, P y){return imag(conj(x)*y);}

P rotate(P v, double s){
  return P(real(v)*cos(s) - imag(v) * sin(s), real(v)*sin(s) + imag(v) * cos(s));
}

D arg(P a, P b, P c){ return acos(dot(b-a, c-a)/(abs(b-a)*abs(c-a)));}
D arg(D a, D b, D c){return acos((b*b+c*c-a*a)/(2*b*c));}

int ccw(P a, P b, P c){
  b -= a; c -= a;
  if(cross(b, c) > EPS) return 1;
  if(cross(b, c) < -EPS) return -1;
  if(dot(b, c) < -EPS) return 2;
  if(abs(b) < abs(c)) return -2;
  return 0;
}

bool para(L a, L b){return abs(cross(a.fs - a.sc, b.fs-b.sc))<EPS;}

int cpr(C a, C b){
  double d = abs(a.fs-b.fs);
  if(a.sc + b.sc + EPS < d) return 0;
  if(b.sc + d + EPS < a.sc) return 2;
  if(a.sc + d + EPS < b.sc) return -2;
  return 1;
}

vector<P> cp_cir_to_cir(C a, C b){
  vector<P> v;
  D s = arg(b.sc, abs(b.fs -a.fs), a.sc);
  P x = a.sc * unit(b.fs - a.fs);
  v.pb(a.fs + rotate(x, s));
  v.pb(a.fs + rotate(x, -s));
  return v;
}


D area(Poly p){
  if(p.sz<3) return 0;
  D res = cross(p[p.sz-1],p[0]);
  for(int i=1;i<p.sz;i++) res += cross(p[i-1], p[i]);
  return res/2;
}

int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    D xa, ya, ra, xb, yb, rb;
    cin >> xa >> ya >> ra >> xb >> yb >> rb;
    printf("%d\n", cpr(C(P(xa, ya), ra), C(P(xb, yb), rb)));
  }
  return 0;
}





Measured memory_bytes: 3268
n = int(input())
line = list(map(int,input().split()))
#print(str(line)+"■")
line.sort()
#print(str(line)+"■")

hil = line[(n//2) - 1]
hir = line[(n//2)]
#print(str(hil)+"■")

print(hir - hil)

Measured memory_bytes: 14428
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
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;}


int main(){
    int n;
    string s;
    cin >> n >> s;

    if(n % 2 == 1){
        cout << "No" << endl;
        return 0;
    }

    for(int i = 0; i < s.size() / 2; i++){
        if(s[i] != s[i + s.size() / 2]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

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


int main() {
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<double> meanOfPs(n+100);
    for (int i = 0; i < n; i++)  
    {
        cin >> meanOfPs[i];
        meanOfPs[i] = (meanOfPs[i] + 1) / 2;
    }
    double ans = 0;
    double ruisekiwa[n+1];ruisekiwa[0] = 0.0;
    for (int i = 0; i < n; i++)
    {
        ruisekiwa[i+1] = ruisekiwa[i] + meanOfPs[i];
    }
    for (int i = k; i <= n; i++) 
    {
        ans = max(ans, ruisekiwa[i] - ruisekiwa[i - k]);
    }
    cout << fixed << setprecision(10);
    cout << ans;
    return 0;
    
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
class Node{
public:
    ll location;
    ll p,l,r;
    Node(){}
};

class Point{
public:
    ll id,x,y;
    Point(){}
    Point(ll id,ll x,ll y): id(id),x(x),y(y){}
    bool operator < (const Point &p) const {
      return id < p.id;
    }

    void print(){
      printf("%d\n",id);
    }
};

static const ll MAX = 1000000;
static const ll NIL = -1;

ll n;
Point P[MAX];
Node T[MAX];
ll np;

bool lessX(const Point &p1, const Point &p2){
  return p1.x < p2.x;
}
bool lessY(const Point &p1,const Point &p2){
  return p1.y < p2.y;
}

ll makeKDTree(ll l,ll r,ll depth){
  if(l >= r)return NIL;
  ll mid = (l+r) / 2;
  ll t = np++; //preorder
  if(depth % 2 == 0){
    sort(P+l,P+r,lessX);
  }else{
    sort(P+l,P+r,lessY);
  }
  T[t].location = mid;
  T[t].l = makeKDTree(l,mid,depth+1);
  T[t].r = makeKDTree(mid+1,r,depth+1);
  return t;
}

void find(ll v,ll sx,ll tx,ll sy,ll ty,ll depth, vector<Point>&ans){
  ll x = P[T[v].location].x;
  ll y = P[T[v].location].y;
  //cout << sx << " " << x << " " << tx << endl;
  //cout << sy << " " << y << " " << ty << endl;
  if(sx <= x && x <= tx && sy <= y && y <= ty){
    ans.push_back(P[T[v].location]);
  }

  if(depth % 2 == 0){
    if(T[v].l != NIL){
      if(sx <= x)find(T[v].l,sx,tx,sy,ty,depth+1,ans);
    }
    if(T[v].r != NIL){
      if(x <= tx)find(T[v].r,sx,tx,sy,ty,depth+1,ans);
    }
  }else{
    if(T[v].l != NIL){
      if(sy <= y)find(T[v].l,sx,tx,sy,ty,depth+1,ans);
    }
    if(T[v].r != NIL){
      if(y <= ty)find(T[v].r,sx,tx,sy,ty,depth+1,ans);
    }
  }
}

int main(){
  ll x,y;
  scanf("%lld",&n);
  rep(i,n){
    scanf("%lld %lld",&x,&y);
    P[i] = Point(i,x,y);
    T[i].l = T[i].r = T[i].p = NIL;
  }
  np = 0;

  ll root = makeKDTree(0,n,0);

  ll q;
  scanf("%lld",&q);
  ll sx,tx,sy,ty;
  vector<Point> ans;
  rep(i,q){
    scanf("%lld %lld %lld %lld",&sx,&tx,&sy,&ty);
    ans.clear();
    find(root,sx,tx,sy,ty,0,ans);
    sort(all(ans));
    ull len = ans.size();
    rep(j,len){
      ans[j].print();
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 29744
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class Main {


    public void solve() throws IOException {
        int x = nextInt(), a = nextInt(), b = nextInt();
        if(a >= b) out.print("delicious");
        else if(Math.abs(b - a) > x) out.print("dangerous");
        else out.print("safe");
    }


    BufferedReader br;
    StringTokenizer sc;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Main().run();
    }

    void run() throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
//            br = new BufferedReader(new FileReader("queue.in"));
//            out = new PrintWriter(new File("queue.out"));
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    String nextToken() throws IOException {
        while (sc == null || !sc.hasMoreTokens()) {
            try {
                sc = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return sc.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
}

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

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

int32_t main() {

    int r, d, x; cin >> r >> d >> x;
    for(int i = 0; i < 10; ++i) {
        x = r*x - d;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256