akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define    int                      long long int
#define    ld                       long double
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int ttt; cin >> ttt; while(ttt--)
#define    ff                       first
#define    ss                       second
#define    all(container)            container.begin() , container.end()
#define    sz(container)             (int)container.size()
#define    pii                      pair <int , int>
#define    sp(x)                    setprecision(x)

int power(int x, int y, int p)  
{  
    int res = 1;     
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {  
        
        if (y & 1)  
            res = (res*x) % p;  
  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}  
  

int32_t main()
{
    speed upp
    int n,m,sum=0;
    cin>>n>>m;
    int a[n+1];
    f(i,1,n)
    {
        cin>>a[i];
        sum+=a[i];
    } 
    int z=4*m,ans=0;
    sum=(sum+ z-1)/z;
    f(i,1,n)
        if(a[i]>=sum)
            ans++;
    if(ans>=m)
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    string s;
    cin>>s;
    int w;
    cin>>w;
    
    int n=s.size();
    rep(i,0,n){
        if(i%w==0) cout<<s[i];
    }
    cout<<endl;
}


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


template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};


using pint = pair<int,int>;
int N, M;
vector<pint> inter;

int main() {
    cin >> N >> M;
    inter.resize(N);
    for (int i = 0; i < N; ++i)
        cin >> inter[i].first >> inter[i].second, ++inter[i].second;
    sort(inter.begin(), inter.end(), [&](pint i, pint j) {
            return i.second - i.first < j.second - j.first;});

    BIT<int> bit(M + 10);
    int pos = 0;
    for (int d = 1; d <= M; ++d) {
        while (pos < N && inter[pos].second - inter[pos].first <= d-1) {
            bit.add(inter[pos].first, inter[pos].second, 1);
            ++pos;
        }
        int res = 0;
        for (int i = d; i <= M; i += d) res += bit.sum(i, i+1);
        res += (N - pos);
        cout << res << endl;
    }
}


Measured memory_bytes: 4096
defmodule Main do
	def main do
    	[one, zero, _minus, num] = IO.gets("") |> String.trim() |> String.split() |> Enum.map(&String.to_integer/1)
        cond do
            one >= num ->
            	IO.puts(num)
            one + zero >= num ->
            	IO.puts(one)
            true ->
            	num = num - one - zero
                IO.puts(one - num)
        end
    end
end

Measured memory_bytes: 30732
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<iostream>
#include<cctype>
#include<set>
#include<vector>
#include<queue>
#include<map>
#define fi(s) freopen(s,"r",stdin);
#define fo(s) freopen(s,"w",stdout);
using namespace std;
typedef long long LL;

inline LL read() {
    LL x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
    for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}

LL a[200005];

int main() {
	int n = read();LL x = read();
	for (int i=1; i<=n; ++i) a[i] = read() + a[i - 1];
	LL ans = 1e18;
	for (int k=1; k<=n; ++k) {
		LL sum = 0, now = 3;
		for (int i=n; i>=1; i-=k) {
			sum += (a[i] - a[max(0, i - k)]) * max(now, 5ll), now += 2;
			if (sum >= ans) break;
		}
		ans = min(ans, sum + 1ll * (k + n) * x);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
	
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(),p=sc.nextInt();
		int ans;
		p+=a*3;
		ans = p/2;
		
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 21844
N, K = map(int, input().split())
S = list(str(input()))

moji = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

a = moji.index(S[K-1])
S[K-1] = moji[(a+26)%52]
print(''.join(S))

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

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		String s = scan.next();
		boolean flg = true;

		for(int i=0;i<n;i++) {
			if(s.substring(0,n/2).equals(s.substring(n/2,n))) {
				flg = true;
			}else {
				flg = false;
			}
		}

		System.out.println(flg?"Yes":"No");
		scan.close();

	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<P> a(n),b(n);
  rep(i,n) cin >> a[i].first >> a[i].second;
  rep(i,n) cin >> b[i].first >> b[i].second;
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  int ans = 0;
  vector<bool> used(n);
  rep(i,n){
    int idx = -1, y = -1;
    rep(j,n){
      if(a[j].first>=b[i].first) break;
      if(used[j]) continue;
      if(a[j].second>=b[i].second) continue;
      if(y<a[j].second){
        idx = j;
        y = a[j].second;
      }
    }
    if(idx!=-1){
      ++ans;
      used[idx] = true;
    }
  }
  cout << ans << endl;
}


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

int top, S[100];

void push(int x){
    S[++top] = x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){
    int a, b;
    top = 0;
    char s[100];
    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }else if(s[0] == '-'){
            a = pop();
            b = pop();
            push(b-a);
        }else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        }else push(atoi(s));
    }
printf("%d\n", pop());
        return 0;
}


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

int main(void){
	unsigned long long H;
	cin >> H;
	int num = 0;
	while(H){
		H /= 2;
		++num;
	}
	cout << (unsigned long long)(pow(2, num) - 1);
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
int a, b, c;
int ct;
scanf("%d %d %d", &a, &b, &c);
int max;
max=(b>c)?(a>b)?a:b:(a>c)?a:c;
a = max - a;
b = max - b;
c = max - c;
int d, e;
if(a==0){
	d = b;
	e = c;
}else if(b==0){
	d = a;
	e = c;
}else{
	d = a;
	e = b;
}
int min;
if((d%2==0 && e%2==0) || (d%2 && e%2)){
	min = (d>e)?e:d;
	max = (d>e)?d:e;
	ct = min + ((max-min)/2);
}else{
	min = (d>e)?e:d;
	max = (d>e)?d:e;
	ct = min + ((max-min)/2) + 2;
}
printf("%d\n", ct);
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
using namespace std;
int main() {
	constexpr int INF = numeric_limits<int>::max()/2;
	int n;
	cin>>n;
	vector<int> a(n);
	for (auto& i : a) cin>>i;
	vector<int> dp(n, INF);	//dp[i] = minimum last element of LIS which has length i
	for (auto& i : a)
		*lower_bound(begin(dp),end(dp),i) = i;
	cout << lower_bound(begin(dp),end(dp),INF)-dp.begin() << endl;
	return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const unsigned int M = 1000000007;
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    while(cin>>n){
        n<1200?cout<<"ABC"<<endl:cout<<"ARC"<<endl;
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			char[][] b = new char[14][14];
			for (int i = 0; i < 14; i++)
				Arrays.fill(b[i], '0');
			String s = null;
			for (int i = 0; i < 12; i++) {
				s = bf.readLine();
				if(s==null)break;
				if(s.length()==0){i--;continue;}
				char[] t = s.toCharArray();
				for (int j = 0; j < 12; j++)
					b[i + 1][j + 1] = t[j];
			}
			if (s == null)
				break;
			int c = 0;
			ArrayDeque<Integer> xq = new ArrayDeque<Integer>();
			ArrayDeque<Integer> yq = new ArrayDeque<Integer>();
			for (int i = 1; i < 13; i++) {
				for (int j = 1; j < 13; j++) {
					if(b[i][j]!='1')continue;
					xq.addLast(i);yq.addLast(j);
					c++;
					while(!xq.isEmpty()){
						int x = xq.pollFirst();
						int y = yq.pollFirst();
						if(b[x][y] != '1')continue;
						b[x][y] = (char)(c+'a'); //'0'
						xq.addLast(x);xq.addLast(x);xq.addLast(x-1);xq.addLast(x+1);
						yq.addLast(y+1);yq.addLast(y-1);yq.addLast(y);yq.addLast(y);
					}
				}
			}
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 10000
#include<stdio.h>
#include<math.h>

typedef struct{
    double x;
    double y;
} P;
void Koch(int,P,P);

int main(){
    int n;
    P f,l;

    scanf("%d",&n);

    f.x = f.y = l.y = 0.0;
    l.x = 100.0;

    printf("%.8f %.8f\n",f.x,f.y);

    Koch(n,f,l);

    printf("%.8f %.8f\n",l.x,l.y);

    return 0;
}

void Koch(int n,P p1,P p2){
    P s,t,u;
    double angle;

    if(n==0){
        return;
    }

    s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
    s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
    t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
    t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
    
    angle = 60 * M_PI / 180.0;

    u.x = (t.x - s.x) * cos(angle) - (t.y - s.y) * sin(angle) + s.x;
    u.y = (t.x - s.x) * sin(angle) + (t.y - s.y) * cos(angle) + s.y;

    Koch(n-1,p1,s);
    printf("%.8f %.8f\n",s.x,s.y);
    Koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    Koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    Koch(n-1,t,p2);
}


Measured memory_bytes: 2036
# C - Traveling Salesman around Lake

K, N = map(int, input().split())
A = [a for a in map(int, input().split())]

total = 0
mx = 0

for i in range(N):
    if i == N - 1:
        dist = K - A[i] + A[0]
    else:
        dist = A[i + 1] - A[i]
    if mx < dist:
        mx = dist
    total += dist

print(total - mx)


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

typedef long long ll;

ll N, M;
vector<tuple<ll, ll, ll>> ABC, DEF;
const ll INF = 1e9 + 1;
vector<ll> X, Y;
ll NX, NY;
unordered_map<ll, ll> IX, IY;
vector<vector<bool>> H, V;
queue<pair<ll, ll>> Q;
vector<vector<bool>> A;
ll Res;

int main() {
  cin >> N >> M;
  ABC.resize(N);
  for (ll i = 0; i < N; ++i) {
    ll a, b, c;
    cin >> a >> b >> c;
    ABC.push_back({a, b, c});
    X.push_back(a);
    X.push_back(b);
    Y.push_back(c);
  }
  DEF.resize(M);
  for (ll i = 0; i < M; ++i) {
    ll d, e, f;
    cin >> d >> e >> f;
    DEF.push_back({d, e, f});
    X.push_back(d);
    Y.push_back(e);
    Y.push_back(f);
  }
  X.push_back(0);
  X.push_back(INF);
  X.push_back(-INF);
  Y.push_back(0);
  Y.push_back(INF);
  Y.push_back(-INF);
  sort(X.begin(), X.end());
  X.erase(unique(X.begin(), X.end()), X.end());
  sort(Y.begin(), Y.end());
  Y.erase(unique(Y.begin(), Y.end()), Y.end());
  ll NX = X.size(), NY = Y.size();
  H.resize(NX);
  for (auto &Hx : H) Hx.resize(NY);
  V.resize(NX);
  for (auto &Vx : V) Vx.resize(NY);
  A.resize(NX);
  for (auto &Ax : A) Ax.resize(NY);
  for (ll i = 0; i < NX; ++i) IX[X[i]] = i;
  for (ll i = 0; i < NY; ++i) IY[Y[i]] = i;
  for (auto abc : ABC) {
    ll a, b, c;
    tie(a, b, c) = abc;
    a = IX[a];
    b = IX[b];
    c = IY[c];
    for (ll x = a; x < b; ++x) H[x][c] = true;
  }
  for (auto def : DEF) {
    ll d, e, f;
    tie(d, e, f) = def;
    d = IX[d];
    e = IY[e];
    f = IY[f];
    for (ll y = e; y < f; ++y) V[d][y] = true;
  }
  for (ll x = 0; x < NX - 1; ++x) H[x][0] = H[x][NY - 1] = true;
  for (ll y = 0; y < NY - 1; ++y) V[0][y] = V[NX - 1][y] = true;
  Q.push({IX[0], IY[0]});
  while (!Q.empty()) {
    ll x, y;
    tie(x, y) = Q.front();
    Q.pop();
    if (A[x][y]) continue;
    A[x][y] = true;
    Res += (X[x + 1] - X[x]) * (Y[y + 1] - Y[y]);
    if (!H[x][y + 1]) Q.push({x, y + 1});
    if (!H[x][y]) Q.push({x, y - 1});
    if (!V[x + 1][y]) Q.push({x + 1, y});
    if (!V[x][y]) Q.push({x - 1, y});
  }
  if (A[0][0])
    cout << "INF" << endl;
  else
    cout << Res << endl;
  return 0;
}


Measured memory_bytes: 7796
/*
 * @Author: Kaizyn
 * @Date: 2020-03-07 21:03:11
 * @LastEditors: Kaizyn
 * @LastEditTime: 2020-03-07 21:06:29
 * @FilePath: \Code\atcoder\abc158C.cpp
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const int N = 1e2+7;
const int MOD = 1e9+7;
const double eps = 1e-7;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> pii;

inline void solve()
{
    int a, b;
    cin >> a >> b;
    for (int i = 13; i <= 1000; ++i) {
        if ((int)(i*.08) == a && (int)(i*.1) == b) {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int testcase = 1;
    // cin >> testcase;
    for (int i = 1; i <= testcase; ++i) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
int n,m,h;
int main()
{
	cin>>n>>m;
	n-=1,m-=1;
	h+=(n-2+m-2)*2;
	h+=4;
	h+=(n-2)*(m-2);
	if(n==-1&&m==-1)cout<<0;
	else cout<<h;
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        
        if(n%2 != 0){
            System.out.println("No");
        }else if(s.subSequence(0, n/2).equals(s.substring(n/2))){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    ll n;
    cin >> n;
    map<ll, ll> mp;
    ll sum = 0;
    rep(i, n){
        ll num;
        cin >> num;
        sum += num;
        mp[num]++;
    }
    ll q;
    cin >> q;
    rep(i, q){
        ll a, b;
        cin >> a >> b;
        sum -= a*mp[a];
        sum += b*mp[a];
        mp[b] += mp[a];
        mp[a] = 0;
        cout << sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 9436
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>

using namespace std;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...)
#endif
#define sz(x) ((int)(x).size())
#define forn(i, n) for (int i = 0; i < (n); i++)

#ifdef DEBUG
struct Timestamper {
  string msg;
  clock_t start;

  Timestamper(const string &_msg) : msg(_msg), start(clock()) {}
  ~Timestamper() {
    eprintf("[ %s ] Time=%.3lfs\n", msg.c_str(), (clock() - start) * 1.0 / CLOCKS_PER_SEC);
  }
} __timestamper("end");
#else
struct Timestamper {};
#endif

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int inf = 1e9;

int main() {
  #ifdef DEBUG
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
  #endif

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


Measured memory_bytes: 128
#include <sstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <queue>
#include <bitset>
using namespace std;

#define int long long
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define REP(i, a) for (int i = 0, _a = (a); i < _a; ++i)
#define REPD(i,n) for(int i = (n)-1; i >= 0; --i)

#define DEBUG(X) { cerr << #X << " = " << (X) << endl; }
#define PR(A, n) { cerr << #A << " = "; FOR(_, 1, n) cerr << A[_] << ' '; cerr << endl; }
#define PR0(A, n) { cerr << #A << " = "; REP(_, n) cerr << A[_] << ' '; cerr << endl; }

#define sqr(x) ((x) * (x))
#define ll long long
#define double long double
typedef pair<int, int> II;
#define PI (2 * acos((double)0))
#define __builtin_popcount __builtin_popcountll
#define SZ(x) ((int)(x).size())
#define ALL(a) (a).begin(), (a).end()
#define MS(a,x) memset(a, x, sizeof(a))
#define next ackjalscjaowjico
#define prev ajcsoua0wucckjsl
#define y1 alkscj9u20cjeijc
#define y0 u9cqu3jioajc

double safe_sqrt(double x) { return sqrt(max((double)0.0, x)); }
int GI(int& x) { return scanf("%lld", &x); }

const int MN = 500111;
string s;
int a[MN];
int f[MN][33], g[22][MN];

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << (fixed) << setprecision(9);
    while (cin >> s) {
        int Z = 'z' - 'a';

        int n = SZ(s);
        FOR(i,1,n) a[i] = s[i-1] - 'a';

        MS(f, 0x3f);
        MS(g, 0x3f);

        FORD(i,n,1) {
            FOR(c,a[i],Z+1) {
                if (c == a[i]) f[i][c] = i;
                else {
                    int j = f[i][c-1];
                    if (j > n) f[i][c] = n+1;
                    else f[i][c] = f[j+1][c-1];
                }
            }

            g[0][i] = f[i][Z + 1];

            FOR(c,0,a[i]-1) {
                int j = g[0][i];

                if (j > n) f[i][c] = n+1;
                else f[i][c] = f[j+1][c];
            }
        }

        FOR(t,1,20) {
            FOR(i,1,n) {
                int j = g[t-1][i];
                if (j > n) g[t][i] = n+1;
                else g[t][i] = g[t-1][j+1];
            }
        }

        int q; cin >> q;
        REP(qq,q) {
            int l, r; cin >> l >> r;
            ++r;
            FORD(t,20,0) {
                if (g[t][l] < r) {
                    l = g[t][l] + 1;
                    if (l == r) break;
                }
            }
            cout << (l == r ? "Yes" : "No") << '\n';
        }
    }
}


Measured memory_bytes: 220060
n = int(input())
a = list(map(int,input().split()))

count = 0
for i in range(n):
    minj = i
    for j in range(i, n):
        if (a[j]<a[minj]):
            minj = j
    if (minj != i):
        (a[i], a[minj]) = (a[minj], a[i])
        count += 1

print(' '.join(map(str,a)))
print(count)



Measured memory_bytes: 5596
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++)  cin >> a[i];
    for(int i = 0; i < n; i++)  cin >> b[i];

    priority_queue<pair<int,int>> pq;
    for(int i = 0; i < n; i++){
        if(a[i] > b[i]){
            cout << -1 << endl;
            return 0;
        }else if(a[i] < b[i]){
            pq.push({b[i], i});
        }
    }

    ll ans = 0;
    while(!pq.empty()){
        pair<int,int> p = pq.top(); pq.pop();
        int i = p.second;
        int unit = b[(i-1+n)%n] + b[(i+1)%n];
        if((b[i]-a[i])/unit == 0){
            cout << -1 << endl;
            return 0;
        }
        ans += (b[i]-a[i])/unit;
        b[i] -= (b[i]-a[i])/unit*unit;
        if(b[i] > a[i]) pq.push({b[i], i});
    }

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

Measured memory_bytes: 3956
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#include <numeric>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const double pi = 3.14159265358979323846;
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, M; cin >> N >> M;    graph r(N + 1);
    rep(i, M) {
        int A, B; cin >> A >> B;
        
            r[A].push_back(B);
        
       
            r[B].push_back(A);
        
    }
    vector<bool>rooted(N + 1, false);
    int ans = 0;
    REP(i, N) {
        if (rooted[i] == false) {
            rooted[i] = true;
            queue<int> q;
            for (int& e : r[i]) {
                q.push(e);
            }
            while (!q.empty()) {
                int a = q.front();
                rooted[a] = true;
                q.pop();
                for (int& e : r[a]) {
                    if(rooted[e]==false)
                    q.push(e);
                }
            }
            ans++;
        }

    }

    cout << ans - 1 << endl;
}





Measured memory_bytes: 8520
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
def debug(k,v) puts "#{k}: #{v}" end
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end


x = gi

ans = (x-400)/200
puts 8-ans


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

struct BIT{
    vector<int> array;
    int n;

    BIT(int _n): array(_n+1, 0), n(_n){
    }

    // [1, i] の和、1-ind
    int sum(int i){
        int ans = 0;
        while(i != 0){
            ans += array[i];
            i -= i & (-i);
        }
        return ans;
    }

    // [i, j] の和、1-ind
    int sum(int i, int j){
        return sum(j) - sum(i-1);
    }

    // i に x を足す
    void add(int i, int x){
        while(i <= n){
            array[i] += x;
            i += i & (-i);
        }
    }
};

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, q;
    cin >> n >> q;
    BIT fw(n);
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        fw.add(i+1, a);
    }
    for(int qq=0; qq<q; qq++){
        int t, a, b;
        cin >> t >> a >> b;
        if(t) cout << fw.sum(a+1, b) << endl;
        else fw.add(a+1, b);
    }

    return 0;
}

Measured memory_bytes: 8224
#include<bits/stdc++.h>
		#include <bitset>
		using namespace std;
		#define ll long long 
		#define ld long double
		#define MOD 1000000007
		#define mod9 1000000009
		#define mod 1000003
		#define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
		#define mp make_pair
		#define pb push_back
		#define ct ll t;cin>>t;while(t--)
		#define bi begin()
		#define ei end()
		#define fi first 
		#define se second   	
		bool isPrime(ll n) 
		{ 
			// Corner case 
			if (n <= 1) 
				return false; 
			
			// Check from 2 to n-1 
			for (ll i = 2; i*i <= n; i++) 
				if (n % i == 0) 
					return false; 
			
			return true; 
		}
		long long binpow(long long a, long long b) {
			long long res = 1;
			while (b > 0) {
				if (b & 1)
					res = (res%mod) * (a%mod);
				a = (a%mod) * (a%mod);
				b >>= 1;
			}
			return res%mod;
		}

		bool compare(const pair<ll,ll>&a,const pair<ll,ll>&b)
		{
			return (a.se<b.se);
		}
		ll lcm(ll a,ll b)
		{
			return(a*b)/__gcd(a,b);
		}
		vector<ll>s[2005];
		void SieveOfEratosthenes() 
		{  
			ll n=2005;
			bool prime[1000005]; 
			memset(prime, true, sizeof(prime)); 
			// s[0]=1;
			// s[1]=1;
			for (int p=2; p*p<=n; p++) 
			{ 
				s[p].pb(1);
				if (prime[p] == true) 
				{   
					for (int i=p+p; i<=n; i += p) {
						prime[i] = false; 
						s[i].pb(p);
						}
				} 
			} 
			// for(ll i=2;i<10005;i++)
			// {
			// 	if(prime[i])
			// 	{
			// 		// s.pb(i);
			// 	}
			// }
		} 
		void eea(ll a, ll b, ll & x, ll & y) {
		if (a == 0) {
			x = 0;
			y = 1;
			return ;
		}
		ll x1, y1;
		eea(b % a, a, x1, y1);
		x = y1 - (b / a) * x1;
		y = x1;
		return ;
	}
	ll modinverse(ll a,ll m)
	{
		ll x, y;
		eea(a, m, x, y);
		if (__gcd(a,m) != 1) {
		return -1;
		}
	else {
		x = (x % m + m) % m;
		cout << x << endl;
		return x;
	}
	}
		ll fact[1000007]={0};
		ll expo(ll x, ll y) {ll res=1;x=x%MOD;while(y>0){if(y&1)res=(1ll*res*x)%MOD;
		y=y>>1;x=(1ll*x*x)%MOD;} return res;}
		void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%MOD;}
		ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res; }
		ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
			ll C(ll n, ll k) {
    ll res = 1;
    for (ll i = 1; i <= k; ++i)
        res = ((res) * (n - k + i) / i)%MOD;
    return (ll)(res + 0.01)%MOD;
}
				
		int main()
		{
			fast
			ll x;
			cin>>x;
			ll sum=x/500;
			sum*=1000;
			ll t=x%500;
			sum+=(t/5)*5;
			cout<<sum<<" ";

			}

 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  using P = pair<int, int>;
  vector<int> X(N), Y(N);
  rep(i, 0, N) cin >> X[i] >> Y[i];
  map<P, int> ma;
  rep(i, 0, N) ma[P(X[i], Y[i])]++;
  int ans = 1e9;
  rep(i, 0, N-1) rep(j, i+1, N) {
    int dx = X[i] - X[j];
    int dy = Y[i] - Y[j];
    int cnt = 0;
    rep(k, 0, N) {
      bool f = false;
      if(ma[{X[k]+dx, Y[k]+dy}]) f = true;
      if(f) cnt++;
    }
    ans = min(ans, N - cnt);
  }
  if(N == 1) ans = 1;
  cout << ans << endl;
  return 0;
}


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

int sumdigit(int d);

int main() {
  int a,b,c;
  cin >> a;
  cin >> b;
  cin >> c;
  int t = 0;
  int sum = 0;
  for(int i=1;i<=a;i++){
    t = sumdigit(i);
    if(b <= t && c >= t){
      sum = sum + i;
    }
  }
  std::cout << sum << std::endl;
}

int sumdigit(int d){
  int sum = 0;
  int n = 0;
  int dd = d;
  while(int(d/10) > 0){
    n++;
    d=int(d/10);
  }  
  for(int i=0; i<=n; i++){
    int tmp = pow(10,n-i);
    int s = int(dd/tmp);
    // cout << s << "\n";
    sum = sum + s;
    dd=dd - s*tmp;
  }
  return sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

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

  string s;
  cin >> s;

  int tmp = 0;
  REP(i, n){
    if(i > 0){
      if(s[i] == 'E') tmp++;
    }
  }

  int ans = tmp;

  REP(i, n - 1){
    if(s[i] == 'W' && s[i + 1] == 'W') tmp++;
    if(s[i] == 'E' && s[i + 1] == 'E') tmp--;
    if(tmp < ans) ans = tmp;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 900
#include <iostream>
#include <algorithm>
#include <cmath>


int main() {
    int n, x, count, p;
    count = 0;
    std::cin >> n;
    int nums[n];
    for (int i = 0; i < n; i++) {
        std::cin >> x;
        if (x == 2) {
            count++;
            continue;
        }
        else if (x >= 2 && x % 2 != 0) {
            p = 3;
            bool u = true;
            while (p <= std::sqrt(x)) {
                if (x % p == 0) {
                    u = false;
                    break;
                }
                p += 2;
            }
            if (u) count++;
        }
    }
    std::cout << count << std::endl;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; long long ans = 0;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
        if(i>0){
            if(a[i-1]>a[i]){
                ans += a[i-1]-a[i];
                a[i] = a[i-1];
            }

        }
    }

    cout << ans;
    return 0;
}

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

int N, M;
bool flag[100005] = {};
vector < int > G[100005];

void coloring(int v)
{
        if ( flag[v] ) return;
        flag[v] = true;
        
        for ( auto &x : G[v] ) {
                coloring(x);
        }
}

int main()
{
        cin >> N >> M;
        while ( M-- ) {
                int a, b, c;
                cin >> a >> b >> c; --a, --b;
                G[a].push_back(b);
                G[b].push_back(a);
        }
        
        int cnt = 0;
        for ( int i = 0; i < N; i++ ) {
                if ( !flag[i] ) {
                        cnt++;
                        coloring(i);
                }
        }

        cout << cnt << endl;

        return ( 0 );
}


Measured memory_bytes: 8960
H, W, K = map(int, input().split())
Sss = [input() for _ in range(H)]

ansss = []
no = 1
isFound = False
for i in range(H):
    num = 0
    anss = []
    for j in range(W):
#        print((i, j), ':', num)
        if Sss[i][j] == '#':
            if num > 0:
                no += 1
            num += 1
        anss.append(no)
    isFound = isFound or (num > 0)
    if num > 0:
        ansss.append(anss)
        no += 1
    elif isFound:
        ansss.append(ansss[-1])

#print(len(ansss))
for _ in range(H-len(ansss)):
    print(' '.join(map(str, ansss[0])))
print('\n'.join([' '.join(map(str, anss)) for anss in ansss]))


Measured memory_bytes: 8416
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int w, h;

bool isNum(char c){return '0' <= c && c <= '9';}

void solve() {
  vector<string> mat(h);
  for(int i=0;i<h;i++) cin>>mat[i];
  
  vector<vector<string> > dp(h, vector<string>(w));
  if (isNum(mat[0][0])) dp[0][0] = mat[0][0];
  
  for (int i = 1; i < w; i += 1) {
    if (isNum(mat[0][i])) {
      dp[0][i] = dp[0][i-1] + mat[0][i];
      if (dp[0][i][0] == '0') dp[0][i].erase(0, 1);
    }
  }
  for (int i = 1; i < h; i += 1) {
    if (isNum(mat[i][0])) {
      dp[i][0] = dp[i-1][0] + mat[i][0];
      if (dp[i][0][0] == '0') dp[i][0].erase(0, 1);
    }
  }
  
  for (int i = 1; i < h; i += 1) {
    for (int j = 1; j < w; j += 1) {
      if (isNum(mat[i][j])) {
        if (dp[i-1][j].size() != dp[i][j-1].size()) {
          if (dp[i-1][j].size() > dp[i][j-1].size()) {
            dp[i][j] = dp[i-1][j];
          } else {
            dp[i][j] = dp[i][j-1];
          }
        } else {
          dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
        if (dp[i][j].size() == 0 && mat[i][j] == '0') continue;
        dp[i][j] += mat[i][j];
        if (dp[i][j][0] == '0') dp[i][j].erase(0, 1);
      }
    }
  }
  
  string max_s = "";
  for(int i=0;i<h;i++)
  for(int j=0;j<w;j++)
  if (max_s.size() < dp[i][j].size()) {
    max_s = dp[i][j];
  } else if (max_s.size() == dp[i][j].size()) {
    max_s = max(max_s, dp[i][j]);
  }
  
  /*
  for(;;) {
    if (max_s[0]!='0') break;
    max_s.erase(0, 1);
  }*/
  
  cout<<max_s<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>w>>h, w||h) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MAX_N = 100010;

struct edge { int to; int cost; };
vector<edge> G[MAX_N];
ll color[MAX_N];

bool dfs(ll node, ll col) {

  color[node] = col;
  
  for(ll i = 0; i < G[node].size(); i++) {
    ll n_node = G[node][i].to;
    ll dist   = G[node][i].cost;
    ll n_col;
    
    if (color[n_node] == -1) {
      if(dist % 2 == 0) n_col = col;
      else n_col = col ^ 1;
      dfs(n_node, n_col);
    }
  }
  return true;
}


int main() {

  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll N; 
  cin >> N;

  for (int i = 0; i < N - 1; i++){
    ll s, t, c;
    cin >> s >> t >> c;

    edge e1;
    e1.to = t; e1.cost = c;
    G[s].push_back(e1);
    edge e2;
    e2.to = s; e2.cost = c;
    G[t].push_back(e2);
  }

  fill(color, color + MAX_N, -1);
  dfs(1, 0);

  for (int i = 1; i <= N; i++) cout << color[i] << endl;
  return 0;
}


Measured memory_bytes: 10660
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int n,x,y;cin>>n>>x>>y;
    //vector<vector<int>> t(n);
    int cost[n][n];
    x--;y--;
    //int buf=(x+y)/2;
    rep(i,n)rep(j,n){
        cost[i][j]=(i>j)? i-j:j-i;
    }
    rep(i,n){
        for(int j=i;j<n;j++){
        int nw1=i-x,nw2=j-y;
        if(nw1<0)nw1*=-1;
        if(nw2<0)nw2*=-1;
        int nw=nw1+nw2+1;
        cost[i][j]=min(nw,cost[i][j]);
        cost[j][i]=min(nw,cost[j][i]);
        }
    }
    map<int,int> mp;
    rep(i,n){
        for(int j=i;j<n;j++){
            mp[cost[i][j]]++;
        }
    }
    rep(i,n){
        if(i==0)continue;
        cout<<mp[i]<<endl;
    }
}


Measured memory_bytes: 16000
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>
#include <functional>

using namespace std;
using ll = long long;
using ld = double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>; //(x, y, dx, dy)
const ll INF = 1e17;
const ld eps = 1e-10;
const ll MOD = 1e9 + 7;

const double pi = acos(-1.0);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	cin >> N;
	vector<ll> a(N);
	ll mini = INF;
	ll sum = 0;
	for (int i = 0;i < N;i++) {
		cin >> a[i];
		mini = min(mini, abs(a[i]));
		sum += abs(a[i]);
	}
	ll ans = sum - mini * 2;
	bool now = false;
	for (int i = 0;i < N;i++) {
		int f = (now + (a[i] < 0)) % 2;
		now = f;
	}
	if (!now)
		ans = sum;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int num = N/500;
    int ans = 1000*(num) +(N-500*(num))/5*5;
    System.out.println(ans);
  }
}

Measured memory_bytes: 35636
S = input()

s = ['dream', 'dreamer', 'erase', 'eraser']
R = len(S)
while(R > 0):
    for i in range(4):
        if R >= len(s[i]):
            if S[R-len(s[i]):R] == s[i]:
                R -= len(s[i])
                break
        if i == 3:
            print("NO")
            exit(0)
print("YES")


Measured memory_bytes: 3188
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int a[10][10];
int w, h;
int sx, sy;
int N;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int tmp1[10], tmp2[10];
int dfs(int x, int y, int n){
  if(n == N){
    //REP(i, n) printf("(%d %d) ", tmp1[i], tmp2[i]);
    //cout<<endl;
    if(x == sx || y == sy) return 1;
    else return 0;
  }
  int res = 0;
  REP(r, 4){
    int nx = x + dx[r];
    int ny = y + dy[r];
    while(nx >= 0 && nx < w && ny >= 0 && ny < h){
      if(a[ny][nx] == 1){
        break;
      }
      ny += dy[r];
      nx += dx[r];
    }
    if(nx >= 0 && nx < w && ny >= 0 && ny < h){
      assert(a[ny][nx] == 1);
      a[ny][nx] = 0;
      //tmp1[n] = nx, tmp2[n] = ny;
      res += dfs(nx, ny, n + 1);
      a[ny][nx] = 1;
    }
  }
  return res;
}


int main(){
  while(cin>>w>>h && w){
    N = 0;
    REP(y, h) REP(x, w){
      cin>>a[y][x];
      if(a[y][x] == 2){
        a[y][x] = 0;
        sx = x, sy = y;
      }
      if(a[y][x] == 1) N ++;
    }
    cout<<dfs(sx, sy, 0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import numpy as np
import sys
sys.setrecursionlimit(100000)



def acinput():
    return list(map(int, input().split(" ")))



directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

def f(x):
    for i in range(K):
        x = x-x % A[i]
    return x

def bisect_search(f,val=0,l=0,r=10**6):

    #is_increase=(f(r)-f(l))>=0

    eps=10**(-5)
    while True:

        c=(l+r)//2
        print(l,c,r)
        input()
        if f(c)==val and f(c-1)!=val:
            return c
        #if f(c)-val < eps:
        #    return c

        if f(c)>val:
            r=c

        else:
            l=c
        
        if l==r:
            return False

def bisect_search_int(f,val=0,l=0,r=10**6,equal=False):
    #is_increase=(f(r)-f(l))>=0
    
    eps=10**(-5)
    if not equal:
        siki = "f(c) > val"
    else:
        siki = "f(c) >= val"

    while r-l>1:

        c=(l+r)//2
        
        if eval(siki,{"c":c,"f":f,"val":val}):
            r=c            
        else:
            l=c
        
        #if l==r:
        #    return False
    if f(l)!= f(c) and f(r)!=f(c):
        return False
    return l,r



K=int(input())
A=acinput()

R = 2+K*max(A)
#R=10**6

l,r=bisect_search_int(f, 2,0,R,equal=True)
if f(l)==2:
    resL=l
elif f(r)==2:
    resL=r
else:
    resL=-1

l, r = bisect_search_int(f, 2,0,R,equal=False)
#print(l,r,f(l),f(r))
if f(l) == 2:
    resR = l
elif f(r) == 2:
    resR = r
else:
    resR = -1

if resL>=0:
    print(resL,resR)
else:
    print(-1)


#for x in range(0,20):
#    print(x,f(x))


Measured memory_bytes: 23992
import sys, itertools
N,D = map(int, input().strip().split(' '))

def dis(x,y):
  return (sum((a-b)**2 for a,b in zip(x,y)))**0.5

X = [list(map(int, line.strip().split(' '))) for line in sys.stdin]

c = 0
for i,j in itertools.combinations(range(N),2):
  if dis(X[i], X[j]).is_integer():
    c += 1
print(c)


Measured memory_bytes: 3188
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int n = sc.nextInt(), k = sc.nextInt(), c = sc.nextInt();
        String s = sc.next();

        int[] dpl = new int[n + 2], dpr = new int[n + 2];

        for (int i = 1; i <= n; i++) {
            if (s.charAt(i - 1) == 'x') {
                dpl[i] = dpl[i - 1];
            } else {
                dpl[i] = dpl[Math.max(0, i - c - 1)] + 1;
            }
        }
        dpr[n + 1] = k + 1;
        for (int i = n; i >= 1; i--) {
            if (s.charAt(i - 1) == 'x') {
                dpr[i] = dpr[i + 1];
            } else {
                dpr[i] = dpr[Math.min(n + 1, i + c + 1)] - 1;
            }
        }

//        debug(dpl);
//        debug(dpr);

        int cnt = 0;
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 1; i <= n; i++) {
            if (dpl[i] == dpr[i]) {
                map.put(dpl[i], map.getOrDefault(dpl[i], 0) + 1);
            }
        }
//        debug(map);

        for (int i = 1; i <= n; i++) {
            if (dpl[i] == dpr[i] && dpl[i] <= k && s.charAt(i - 1) == 'o' && map.getOrDefault(dpl[i], -1) == 1) {
                out.println(i);
            }
        }
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

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

typedef long long ll;
const int N = 2000006;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	set<int> s;
	int x;
	cin>>x;
	s.insert(x);
	int ans = 1;
	for(int i=1;i<n;i++){
		cin>>x;
		if( x < *s.begin())ans++;
		s.insert(x);
	}
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 12976
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n,c,a,b,ta,tb,tc;
	cin>>n;
	n--;
	int dp[3];
	cin>>dp[0]>>dp[1]>>dp[2];
	while(n--){
		cin>>a>>b>>c;
		a+=max(dp[2],dp[1]);
		b+=max(dp[0],dp[2]);
		c+=max(dp[0],dp[1]);
		dp[0]=a,dp[1]=b,dp[2]=c;
	}
	cout<<max({dp[0],dp[1],dp[2]})<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << max(max(a*c,a*d),max(b*c,b*d)) << endl;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n, m; cin >> n >> m;
  int cnt[n] = {0};
  int a[m], b[m];
  for(int j = 0; j < m; j++) {
    cin >> a[j] >> b[j];
    cnt[a[j]-1] += 1;
    cnt[b[j]-1] += 1;
  }
  for(int i = 0; i < n; i++) {
    cout << cnt[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_set>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
#include<climits>
using namespace std;

int main() {
    int h,w;
    cin>>h>>w;
    vector<vector<int>> dp(h+1, vector<int> (w+1,0));
    dp[1][0]=1;
    dp[1][1]=1;
    int mod = 1e9 + 7;
    for(int i=1;i<=h;i++) {
        for(int j=1;j<=w;j++) {
            char ch;
            cin>>ch;
            if(ch=='#')     dp[i][j]=0;
            else {
                if(i==1)    dp[i][j]=dp[i][j-1];
                else if(j==1)   dp[i][j] = dp[i-1][j];
                else
                    dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
            }
        }
    }
    cout<<dp[h][w];
}


Measured memory_bytes: 7568
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    cout << s1[0] << s2[1] << s3[2] << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef struct{
	double x,y;
}Point_obj;

class Vector_obj{
private:
	double x,y;
public:
	void set(Point_obj *p0,Point_obj *p1){
		x = p1->x - p0->x;
		y = p1->y - p0->y;
	}
	void print(){
		cout<<x<<" "<<y<<endl;
	}
	double GetX(){return x;}
	double GetY(){return y;}
};

double exteriorProduct(Vector_obj *v0,Vector_obj *v1){
	return v0->GetX() * v1->GetY() - v0->GetY() * v1->GetX();
}


int main(){

	Point_obj point[4];
	Vector_obj Vector[8];
	char tmp;

	while(cin>>point[0].x){
		cin>>tmp;
		cin>>point[0].y;
		cin>>tmp;

		for(int i=1;i<4;i++){
			cin>>point[i].x;
			cin>>tmp;
			cin>>point[i].y;
			if(i!=3){
				cin>>tmp;
			}
		}

		for(int i=0;i<8;i+=2){
			Vector[i].set(&point[i/2],&point[(i/2+1)%4]);
			//Vector[i].print();
			Vector[i+1].set(&point[i/2],&point[(i/2+2)%4]);
			//Vector[i+1].print();
		}

		double tmp;
		
		tmp = exteriorProduct(&Vector[0],&Vector[1]);

		if(tmp >= 0){
			if( exteriorProduct(&Vector[2],&Vector[3]) >= 0 && exteriorProduct(&Vector[4],&Vector[5]) >= 0
				&& exteriorProduct(&Vector[6],&Vector[7]) >= 0){
					cout<<"YES"<<endl;
			}
			else{
				cout<<"NO"<<endl;
			}
		}
		else{
			if( exteriorProduct(&Vector[2],&Vector[3]) < 0 && exteriorProduct(&Vector[4],&Vector[5]) < 0
				&& exteriorProduct(&Vector[6],&Vector[7]) < 0){
					cout<<"YES"<<endl;
			}
			else{
				cout<<"NO"<<endl;
			}

		}

	}

	return 0;
}

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

int main(void){
  int k, a, b;
  cin >> k >> a >> b;
  
  for(int i=a; i<=b; i++){
    if(i%k == 0){
      cout << "OK";
      return 0;
    }
  }
  cout << "NG";
  return 0;
}

Measured memory_bytes: 3580