akhauriyash/Code-Regression huggingface dataset:
import math

def binary_search():

    s = input().split()
    i = int(s[0] + s[1])

    low = 0
    high = i

    while low <= high:

        mid = (low + high) // 2
        guess = mid**2

        if guess == i:
            print('Yes')
            return

        elif guess > i:
            high = mid - 1

        else:
            low = mid + 1

    print('No')
    return

def square_root():
    s = input().split()
    i = int(s[0] + s[1])

    root = int(math.sqrt(i))

    if root**2 == i:
        print('Yes')

    else:
        print('No')

if __name__=='__main__':

    # square_root() #正攻法
    binary_search() #[0,i]で mid**2 = i　になる mid　を二分探索で見つける


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i += 2) {
        cout << s[i];
    }
    cout << endl;
}


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

// queueを用いた幅優先探索

int main() {
  string s;
  cin >> s;
  vector<string> options = {"dream", "dreamer", "erase", "eraser"};
  
  queue<int> BFS;  // index管理用queue
  BFS.push(0);
  
  bool divisible = false;
  while (!BFS.empty()) {
    int t = BFS.front();
    BFS.pop();
    
    if (t == s.size()) {  // 綺麗に分割できたとき
      divisible = true;
      break;
    }
    
    for (string c : options) {
      // sのi番目からc.size要素までがoptionsのどれかと一致したら、
      // 現在地からc.size文字分進めてqueueにpushする
      if (s.substr(t, c.size()) == c) {
        BFS.push(t + c.size());
      }
    }
  }
 
  cout << (divisible ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3720
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

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

        sc.nextInt();
        int K = sc.nextInt();
        String S = sc.next();

        System.out.println(solve(S, K));

        sc.close();
    }

    static int solve(String S, int K) {
        int result = -1;
        Deque<Element> deque = new ArrayDeque<>();
        int totalLength = 0;
        int directionNum = 0;
        for (char value : S.toCharArray()) {
            if (!deque.isEmpty() && deque.peekLast().value == value) {
                ++deque.peekLast().length;
                ++totalLength;
            } else {
                if (value == '0') {
                    ++directionNum;
                }
                deque.offerLast(new Element(value, 1));
                ++totalLength;

                while (directionNum == K + 1) {
                    Element head = deque.pollFirst();
                    totalLength -= head.length;
                    if (head.value == '0') {
                        --directionNum;
                    }
                }
            }

            result = Math.max(result, totalLength);
        }

        return result;
    }
}

class Element {
    char value;
    int length;

    Element(char value, int length) {
        this.value = value;
        this.length = length;
    }
}

Measured memory_bytes: 42812
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int[] d = new int[6];
    int i, q, a, b;
    for(i = 0;i < 6;i++)d[i] = sc.nextInt();
    for(q = sc.nextInt();q-- > 0;out.println(solve(d, a, b))){
      a = sc.nextInt(); b = sc.nextInt();
    }

    sc.close();
  }
  private static int solve(int[] d, int a, int b){
    int i, j;
    for(i = 0;i < 4;i++){
      for(j = 0;j < 3;j++){
        if(d[0] == a && d[1] == b)return d[2];
        if(d[0] == b && d[1] == a)return d[3];
        nroll(d);
        if(d[0] == a && d[1] == b)return d[2];
        if(d[0] == b && d[1] == a)return d[3];
        eroll(d);
      }
      if(d[0] == a && d[1] == b)return d[2];
      if(d[0] == b && d[1] == a)return d[3];
      rroll(d);
    }
    return -1;
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static void nroll(int[] dice){ //(1265)
    int tmp;
    tmp = dice[0]; dice[0] = dice[1]; dice[1] = dice[5];
    dice[5] = dice[4]; dice[4] = tmp;
    return;
  }
  private static void eroll(int[] dice){ //(1463)
    int tmp;
    tmp = dice[0]; dice[0] = dice[3]; dice[3] = dice[5];
    dice[5] = dice[2]; dice[2] = tmp;
    return;
  }
  private static void rroll(int[] dice){ //(2354)
    int tmp;
    tmp = dice[1]; dice[1] = dice[2]; dice[2] = dice[4];
    dice[4] = dice[3]; dice[3] = tmp;
    return;
  }
}

Measured memory_bytes: 26312
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <stdio.h>
using namespace std;

string s;
char s1[100003];
int n, c1, c2;

int main() {
	
	cin >> s;
	n = s.size();

	for (int i = 0; i < n; i++) {
		if (i == 0) {
			s1[i] = '0';
		}
		else if (i % 2 == 1) {
			s1[i] = '1';
		}
		else {
			s1[i] = '0';
		}
	}

	for (int i = 0; i < n; i++) {
		if (s1[i] == s[i]) {
			c1++;
		}
		else {
			c2++;
		}
	}

	cout << min(c1, c2) << endl;

	return 0;
}



Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

int read() {
	char ch;
	for(ch=getchar();ch<'0'||ch>'9';ch=getchar());
	int x=ch-'0';
	for(ch=getchar();ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

const int N=2e5+5;

int n,a[N],b[N],c[N];
ll ans,suma,sumb,sum[N];

int main() {
	n=read();
	fo(i,1,n) {
		a[i]=read();b[i]=read();
		c[i*2-1]=a[i];c[i*2]=b[i];
		suma+=a[i];sumb+=b[i];
	}
	sort(c+1,c+n*2+1);
	ans=min(suma,sumb);
	fo(i,1,2*n) sum[i]=sum[i-1]+c[i];
	fo(i,1,n) {
		int boder=n,tmp=0;
		if (a[i]>=c[boder]) tmp+=a[i],boder--;
		if (b[i]>=c[boder]) tmp+=b[i],boder--;
		ans=min(ans,sum[boder]+tmp);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
import bisect

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    A.sort()
    C.sort()
    ans = 0
    for b in B:
        a_num = bisect.bisect_left(A, b)
        c_num = N - bisect.bisect_right(C, b)
        ans += a_num * c_num

    print(ans)


Measured memory_bytes: 23360
n = int(input())
a = list(map(int, input().split()))
aa = a+a
g = sum(a)//2
ans = []
for i in range(1):
    temp = sum([aa[i+1+j*2] for j in range(n//2)])
    ans.append(g-temp)
temp = ans[0]
for i in range(1,n):
    temp = a[i-1] - temp
    ans.append(temp)
for k in ans:
    print(2*k,end=" ")

Measured memory_bytes: 67812
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

ll func(ll s, ll f, ll now) {

	if (s < now) {

		if (now%f == 0)return now;
		else return now - now%f + f;

	}
	else return s;

}

int main() {

	ll N, C[505], S[505], F[505];

	cin >> N;
	for (int i = 1; i <= N - 1; i++) {

		cin >> C[i] >> S[i] >> F[i];

	}

	for (int i = 1; i <= N - 1; i++) {

		int time = 0;
		for (int j = i; j <= N - 1; j++) {
			
			time = func(S[j], F[j], time) + C[j];

		}

		cout << time << endl;

	}
	cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
  int n;
  cin>>n;
  vvi g(n,vi(n));
  rep(i,n)rep(j,n)cin>>g[i][j];
  int ans=0;
  rep(i,n){
    rep(j,i){
      ans+=min(g[i][j],g[j][i]);
    }
  }
  cout<<ans<<endl;
}



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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    string s; cin >> s;
    int n = s.size();
    int res = 105;
    rep(i, n){
        int cnt = 0;
        int tmp = 0;
        rep(j, n){
            if(s[i] == s[j]){
                tmp = max(tmp, cnt);
                cnt = 0;
            }else{
                cnt++;
            }
            if(j == n-1) tmp = max(tmp, cnt);
        }
        res = min(res, tmp);
    }
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define Bye return 0
#define ll long long

using namespace std;

void solve(){
    int x, y, a, b; cin>>x>>y;

    a = (4*x-y)/2;
    b = (y-2*x)/2;

    if(a>=0 && b>=0 && y%2 == 0 && y>=2*x && y<=4*x)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long nck(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    cominit();
    vector<ll> ans;
    for(int i=1; i<=k; i++){
        ans.push_back(nck(k-1, i-1) * nck(n-k+1, i) % MOD);
    }
    for(auto t : ans){
        cout<<t<<endl;
    }
    return 0;
}

Measured memory_bytes: 12288
#include <iostream>

using namespace std;

int main() {
	
	int C1, C2, C3, c;

	while(cin >> C1 >> C2 >> C3) {
		c=0;
		for(int i=1; i<=10; i++) {
			if(i!=C1&&i!=C2&&i!=C3&&i+C1+C2<=20)
				c++;
		}
		if(c>3)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}

	return 0;

}

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

using namespace std;

const int MAX = 1e5+10;

long long dp[110][MAX];

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

    int N, W;
    cin >> N >> W;

    for(int i=1; i<=N; i++){
        int w, v;
        cin >> w >> v;

        dp[i][w] = v;
        for(int j=1; j<=W; j++){
            if(dp[i-1][j]){
                dp[i][j] = max(dp[i-1][j], dp[i][j]);
                if(j+w<=W) dp[i][j+w] = max(dp[i][j+w], dp[i-1][j] + v);
            } 
        }
    }

    long long sol = 0;
    for(int i=1; i<=W; i++) sol = max(sol, dp[N][i]);
    cout << sol << "\n";

    return 0;
}

Measured memory_bytes: 78080
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{	
	string s,t;
	cin>>s>>t;
	vi pos[26];
	int ans=0,cnt=0,pre=-1;
	for(int i=0;i<s.length();i++){
		pos[s[i]-'a'].pb(i);
	}
	for(int i=0;i<t.length();i++){
		int curr=t[i]-'a';
		if(pos[curr].size()==0){
			cout<<"-1";
			return 0;
		}
		if(pos[curr].back() <=pre){
			cnt++;
			pre=-1;
		}
		auto it=lower_bound(pos[curr].begin(),pos[curr].end(),pre+1)-pos[curr].begin();
		pre=pos[curr][it];
		ans=cnt*s.size()+pre+1;
	}
	cout<<ans<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}







Measured memory_bytes: 4620
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

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

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 200 * 1000 + 47;
const int MOD = 1000 * 1000 * 1000 + 7;

struct Item
{
	int x, v, ind;
	bool operator <(const Item& a) const
	{
		return x < a.x;
	}
};

bool cmp(const Item& a, const Item& b)
{
	return a.v < b.v;
}

struct FenvicMin
{
	int T[MAX];
	int n;

	void init(int n1)
	{
		n = n1;
		FOR(i, 0, n)
		{
			T[i] = INF;
		}
	}

	int get(int i)
	{
		int res = INF;
		for (; i >= 0; i = (i & (i + 1)) - 1)
		{
			res = min(res, T[i]);
		}

		return res;
	}

	void upd(int i, int val)
	{
		for (; i < n; i = i | (i + 1))
		{
			T[i] = min(T[i], val);
		}
	}

	int getSuf(int i)
	{
		return get(n - i - 1);
	}

	void updSuf(int i, int val)
	{
		upd(n - i - 1, val);
	}
} RM;

void ADD(int& key, int val)
{
	key += val;
	if (key >= MOD) key -= MOD;
}

struct FenvicSum
{
	int T[MAX];
	int n;

	void intit(int n1)
	{
		n = n1;
	}

	int get(int i)
	{
		int res = 0;
		for (; i >= 0; i = (i & (i + 1)) - 1)
		{
			ADD(res, T[i]);
		}

		return res;
	}

	int get(int l, int r)
	{
		int res = get(r) - get(l - 1);
		if (res < 0) res += MOD;
		return res;
	}

	void add(int i, int d)
	{
		for (; i < n; i = i | (i + 1))
		{
			ADD(T[i], d);
		}
	}
} RS;

Item A[MAX];
int P[MAX];
PII B[MAX];

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	FOR(i, 0, n)
	{
		cin >> A[i].x >> A[i].v;
	}

	sort(A, A + n);
	FOR(i, 0, n) A[i].ind = i;
	sort(A, A + n, cmp);
	FOR(i, 0, n) P[i] = A[i].ind;
	RM.init(n);
	FOR(i, 0, n)
	{
		int ind = RM.getSuf(P[i]);
		B[i].first = ind == INF ? i : ind;
		RM.updSuf(P[i], i);
	}

	RM.init(n);
	RFOR(i, n, 0)
	{
		int ind = RM.get(P[i]) * -1;
		B[i].second = ind == -INF ? i : ind;

		RM.upd(P[i], -i);
	}

	sort(B, B + n);

	RS.intit(n);
	FOR(i, 0, n)
	{
		int l = B[i].first;
		int r = B[i].second;

		int s = RS.get(max(l - 1, 0), r);
		if (l == 0) ADD(s, 1);

		//cout << i << " " << s << endl;
		RS.add(r, s);
	}

	int res = RS.get(n - 1, n - 1);
	cout << res << endl;
}

Measured memory_bytes: 6528
#include<iostream>

int main(void){
  int n, m, max=0;
  int price[1000];

  for(int t=0; t<10000; t++){

    max = 0;
    std::cin >> n;
    std::cin >> m;
    if(n == 0 && m == 0){
      break;
    }

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

    for(int j=0; j<n; j++){
      for(int s=0; s<n; s++){
	if(j == s){
	  break;
	}
	if(price[j] + price[s] > max && price[j] + price[s] <= m){
	  max = price[j] + price[s];
	}
      }
    }
    if(max > 0){
      std::cout << max << "\n";
    }else{
      std::cout << "NONE\n";
    }
  }
  return 0;
}



Measured memory_bytes: 3036
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
int main()
{
    int a,b;
    cin>>a>>b;
    int t=1;
    while(a--)
    {
        if(t>b)
            t+=b;
        else
            t*=2;
    }
    cout<<t<<endl;
    return 0;
}


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

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}

#define pb push_back

const int N=1e5+7;

ll n,mod;
vector <int> G[N];
ll dp[N],Ans[N];

void dfs1(int u,int fa){
	dp[u]=1;
	for(auto v:G[u]){
		if(v==fa) continue;
		dfs1(v,u);
		dp[u]=dp[u]*(dp[v]+1)%mod;
	}
}

void dfs2(int u,int fa){
	vector<ll> suf;
	ll tmp=1;
	suf.pb(1);
	for(int i=G[u].size()-1;i>=0;i--){
		tmp=tmp*(dp[G[u][i]]+1)%mod;
		suf.pb(tmp);
	}

	tmp=1;
	int it=suf.size()-2;

	for(auto v:G[u]){
		Ans[v]=dp[v]*(tmp*suf[it]%mod+1)%mod;
		if(v!=fa){
			ll tt=dp[u];
			dp[u]=tmp*suf[it]%mod;
			dfs2(v,u);
			dp[u]=tt;
		}
		tmp=tmp*(dp[v]+1)%mod;
		it--;
	}
}

int main(){
	n=input(),mod=input();
	for(int i=1;i<n;i++){
		int u=input(),v=input();
		G[v].pb(u);
		G[u].pb(v);
	}

	dfs1(1,0);
	dfs2(1,0);
	Ans[1]=dp[1];
	
	for(int i=1;i<=n;i++){
		printf("%lld\n",Ans[i]);
	}
}

Measured memory_bytes: 20608
# Studying https://atcoder.jp/contests/agc038/submissions/7680063
N, K, *P = $<.read.split.map(&:to_i)

pm, n = 0, 0
i, QMin, QMax = 0, [0], [0]
until (i+=1) == N
	p = P[i]

	min_gone = QMin[0] == i-K
	if p < P[QMin[0]]
		QMin.clear
	else
		QMin.pop while p < P[QMin[-1]]
	end
	QMin << i
	QMin.shift if QMin[0] == i-K

	if P[QMax[0]] < p
		QMax.clear
	else
		QMax.pop while P[QMax[-1]] < p
	end
	QMax << i
	QMax.shift if QMax[0] == i-K
	max_entered = QMax[0] == i

	next if i < K-1

	if QMin.size == K
		pm += 1
	elsif ! min_gone or ! max_entered
		n += 1
	end
end

p n+[pm,1].min


Measured memory_bytes: 19124
#include<stdio.h>

int main()
{
    int N, x, i, j, mem, ans=0;
    scanf(" %d %d", &N, &x);
    int a[N];
    for(i=0; i<N; i++)
    {
        scanf("%d", &a[i]);
    }

    for(i=0; i<N; i++)
    {
        for(j=i+1; j<N; j++)
        {
            if(a[i]>a[j])
            {
                mem=a[i];
                a[i]=a[j];
                a[j]=mem;
            }
        }
    }

    for(i=0; i<N; i++)
    {
        if(x-a[i]>=0){
            x-=a[i];
            ans++;
        }
        else break;
        if(i==N-1&&x>0) ans--;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
import copy
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
p = list(map(int, input().split()))
sorted_p = copy.copy(p)
sorted_p.sort()
counter = 0

for i in range(N):
	if p[i] != sorted_p[i]:
		counter += 1
		
if counter <= 2:
	print('YES')
else:
	print('NO')
	

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

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

    if(N[0] == '9'){
        cout << "Yes" << endl;
    }
    else if(N[1] == '9'){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3620
while(1):
    try:
        eq=raw_input()
    except:
        break
    N=[0,0,0] #C,B,A
    D=[0,0,0]
    n=0
    d=0
    Xtop=0
    na=1
    for c in eq[::-1]:
        if c=='+'or c=='=':
            d=0
            n=n+1
        elif c=='X':
            D[n]=D[n]+10**d
            d=d+1
        else:
            N[n]=N[n]+int(c)*10**d
            d=d+1
    for i in range(3):
        if D[i]>N[i] and D[i]>1:
            Xtop=1
    for i in range(10):
        if N[0]+D[0]*i==N[1]+D[1]*i+N[2]+D[2]*i:
            if not (Xtop and i==0):
                print i
                na=0
                break
    if na:
        print 'NA'

Measured memory_bytes: 4260
n = int(input())

red_array = []
for i in range(n):
    red_array.append([int(x) for x in input().split()])
red_array = sorted(red_array, key=lambda x: x[1], reverse=True)

blue_array = []
for i in range(n):
    blue_array.append([int(x) for x in input().split()])
blue_array.sort()

for blue in blue_array:
    for red in red_array:
        if blue[0] > red[0] and blue[1] > red[1]:
            red_array.remove(red)
            break

print(n - len(red_array))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

double maxv[50000];

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

    int n, m;
    cin >> n >> m;
    vector<vector<int>> G(n, vector<int>(n, 0));
    vector<P> es;
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a][b] = G[b][a] = 1;
        es.emplace_back(a, b);
    }
    int ans = 0;
    for(auto p : es){
        int a = p.first, b = p.second;
        G[a][b] = G[b][a] = 0;
        vector<bool> visited(n, false);
        queue<int> que;
        que.push(0);
        visited[0] = true;
        while(!que.empty()){
            int from = que.front();
            que.pop();
            for(int to = 0; to < n; ++to){
                if(visited[to]) continue;
                if(!G[from][to])    continue;
                visited[to] = true;
                que.push(to);
            }
        }
        bool allvisited = true;
        for(int i = 0; i < n; ++i){
            if(!visited[i]){
                allvisited = false;
                break;
            }
        }
        if(!allvisited) ++ans;
        G[a][b] = G[b][a] = 1;
    }
    cout << ans << endl;
}

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

int n, m;
string s, t;
string ans;

void in();
void solve();
void out();

int main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    in();
    solve();
    out();
}

void in(){
    cin >> s;
    n = s.size();
}

void solve(){
    string revs = s;
    ans = "Yes";
    reverse(s.begin(), s.end());
    if(s != revs)
        ans = "No";
    string a = s.substr(0, (n - 1) / 2);
    string w = a;
    reverse(w.begin(), w.end());
    if(a != w)
        ans = "No";
    a = s.substr((n - 1) / 2 + 1, (n - 1) / 2);
    w = a;
    reverse(w.begin(), w.end());
    if(a != w)
        ans = "No";
}
void out(){
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define ll long long
using namespace std;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(){
    ll n,m; cin>>n>>m;
    struct UnionFind tree(n);
    for(ll i=0; i<m; i++){
        ll a,b; cin>>a>>b;
        tree.unite(a,b);
    }
    
    ll count=0;
    map<ll,ll> mp;
    for(ll i=0; i<n; i++){
        ll p=tree.root(i);
        if(mp[p]==0){
            count++;
            mp[p]++;
        }
    }
    
    cout<<count-1<<endl;
}

Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int a; scanf("%d", &a);
	printf("%d\n", a+a*a+a*a*a);
}


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

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

    int h, a;
    cin >> h >> a;
    int res = 0;
    while (h > 0) {
        h -= a;
        res++;
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
using namespace std;
typedef long long int ll;

int n;
int used[110100];
int used2[110100];
int de[110100];
int de2[110100];
vector<int> G[100100];

void dfs(int s,int t,int depth){
	if(s==t){
		return;
	}
	used[s]=1;
	de[s]=depth;
	for(int v:G[s]){
		if(!used[v]){
			dfs(v,t,depth+1);
		}
	}
	return;
}

void dfs2(int s,int t,int depth){
	if(s==t){
		return;
	}
	used2[s]=1;
	de2[s]=depth;
	for(int v:G[s]){
		if(!used2[v]){
			dfs2(v,t,depth+1);
		}
	}
	return;
}

int main(){
	int n; cin >> n;
	for(int i=0;i<n-1;i++){
		int x,y; cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	dfs(0,n-1,1);
	dfs2(n-1,0,1);
	int black=0;
	for(int i=0;i<n;i++){
		if(used2[i]==0)black++;
		else{
			if(de[i]>0&&de[i]<=de2[i])black++;
		}
	}
	if(black>n-black){
		cout << "Fennec" << endl;
	}
	else{
		cout << "Snuke" << endl;
	}
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int dp[550000];

int main(){
    int n;
    string str;
    cin >> n >> str;
    for(int i = 0; i <= n; i++) dp[i] = -1000000;
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        dp[i+1] = max(dp[i], dp[i+1]);
        if(str[i] == '1') continue;
        int s1 = i;
        int s2 = i;
        while(s1-1 >= 0 && str[s1-1] == '1') s1--;
        while(s2+1 < n  && str[s2+1] == '1') s2++;
        if(s1 == i || s2 == i) continue;
        //cout << s1 << " " << i << " " << s2 << endl;
        for(int t = i-1; t >= s1; t--){
            dp[i+2] = max(dp[i+2], dp[t] + i-t);
        }
        for(int t = i+1; t <= s2; t++){
            dp[t+1] = max(dp[t+1], dp[i-1] + t-i);
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 2820
fun main() {
    val (n, _) = readLine()!!.split(" ").map { it.toInt() }
    val list = mutableListOf<String>()
    for (i in 1..n) list.add(readLine()!!)
    println(bubbleSort(n, list).joinToString(""))
}

fun <T> MutableList<T>.swap(index1: Int, index2: Int) {
    val tmp = this[index1]
    this[index1] = this[index2]
    this[index2] = tmp
}

fun bubbleSort(listSize: Int, list: MutableList<String>): List<String> {
    var head = 0
    while (head < listSize - 1) {
        for (j in listSize - 1 downTo head + 1) {
            if (list[j] < list[j - 1]) {
                list.swap(j, j - 1) // list[j]とlist[j - 1]の入れ替え
            }
        }
        head ++
    }
    return list
}

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

using namespace std;

const int N = 100000 + 7;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int k;
  cin >>k; --k;
  for(int i = 0; i < n; ++i) {
    if(s[i] != s[k]) s[i] = '*';
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  string a, b;
  cin >> a >> b;
  if (a.size() > b.size()) {
      puts("GREATER");
      return 0;
    } else if (a.size() < b.size()) {
      puts("LESS");
      return 0;
    }
	
  for (int i = 0; i < min(a.size(), b.size()); i++) {
    if (a[i] > b[i]) {
      puts("GREATER");
      return 0;
    } else if (a[i] < b[i]) {
      puts("LESS");
      return 0;
    }
  }
  
  puts("EQUAL");
  return 0;
}

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

int n,m;
vector<int> V[100010]; 
typedef pair<int,int> pi;
vector<pi> ve;
set<int> s;
deque<int> path;
bool used[100010];

int main()
{
	int f,sec;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		a--,b--;
		V[a].push_back(b);
		V[b].push_back(a);
		f=a,sec=b;
		}
	s.insert(f);
	s.insert(sec);
	path.push_back(f);
	path.push_back(sec);
	while(1)
	{
		bool good=true;
		 for(int i=0;i<V[f].size();i++)
	 		if(!s.count(V[f][i]))
	 		{
			 	path.push_front(V[f][i]);
			 	s.insert(V[f][i]);
			 	f=V[f][i];
				good=false;
				}
		for(int j=0;j<V[sec].size();j++)
			if(!s.count(V[sec][j]))
			{
				path.push_back(V[sec][j]);
				s.insert(V[sec][j]);
				sec=V[sec][j];
				good=false;
				}
		if(good) break;
		}
	cout<<path.size()<<endl;
	for(__typeof(path.begin()) it=path.begin();it!=path.end();it++)
		cout<<*it+1<<" ";
		cout<<endl;		
	return 0;
	}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
long long n, a[700001], b[700001], c[700001], ts=0, ans=-1e18;
multiset <long long> t;
int main() {
	cin >> n;
	for(int i=0;i<n*3;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		t.insert(a[i]);
		ts+=a[i];
		if(i!=0)b[i]=b[i-1];
		b[i]+=a[i];
	}
	for(int i=n;i<2*n;i++){
		if(a[i]>*t.begin()){
			ts+=(a[i]-*t.begin());
			t.erase(t.begin());
			t.insert(a[i]);
		}
		b[i]=ts;
	}
	t.clear();
	ts=0;
	for(int i=3*n-1;i>=2*n;i--){
		t.insert(-a[i]);
		ts+=a[i];
		if(i!=3*n-1)c[i]=c[i+1];
		c[i]+=a[i];
	}
	for(int i=2*n-1;i>=0;i--){
		if(-a[i]>*t.begin()){
			ts+=(a[i]+*t.begin());
			t.erase(t.begin());
			t.insert(-a[i]);
		}
		c[i]=ts;
	}
	for(int i=n-1;i<2*n;i++){
		//cout << b[i] << " " << c[i] << endl;
		ans=max(ans,b[i]-c[i+1]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 17152
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)


#define INF (1e9)
typedef long long unsigned int ll;


int main()
{

    string s;
    cin >> s;
    int n;
    n = s.size();

    int count = 0;
    int r = 0;
    int b = 0;
    REP(i, n)
    {
        if(s[i]=='0'){
            r++;
        }else{
            b++;
        }
    }
    if(r<b){
        cout << r * 2;
    }else{
        cout << b * 2;
    }

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 2e5+5;
ll n, m;
vector<ll>arr[nax];
	
int main(){
	IOS
	cin >> n >> m;
	while(m--){
		ll a, b;
		cin >> a >> b;
		arr[a].pb(b);
		arr[b].pb(a);
	}
	bool cek=0;
	for(auto x:arr[1]){
		for(auto y:arr[x]){
			if(y==n){
				cek=1;
				break;
			}
		}
	}
	if(cek) cout << "POSSIBLE" << '\n';
	else cout << "IMPOSSIBLE" << '\n';
}


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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ; 
ll _abs (ll x ) { return (x>0?x:-x); }

const int N =3e3+5; 
string s , t ; 
int dp[N][N];  
string lcs[2][N]; 
int main(){
	cin>>s>>t;
	int n=s.length(),m=t.length();  
	 
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){ 
			int& r=dp[i][j]; 
			if( r < dp[i-1][j] ) {
				r=dp[i-1][j]; 
				lcs[1][j] = lcs[0][j]; 
			}	if( r < dp[i][j-1] ) {
				r=dp[i][j-1]; 
				lcs[1][j] = lcs[1][j-1];  
			}
//			cout<<"// "<<r<<" "<<dp[i-1][j-1]<<endl; 
			if(r <= dp[i-1][j-1] && s[i-1]==t[j-1])
				r = dp[i-1][j-1]+1 , lcs[1][j]=lcs[0][j-1]+s[i-1];
//			cout<<i<<" "<<j<<" "<<lcs[i][j]<<endl; 	
		}
		for(int j=0;j<=m;j++){
			lcs[0][j]=lcs[1][j]; 
			lcs[1][j]=""; 
		}
	}
	cout<<lcs[0][m]<<endl; 
}


Measured memory_bytes: 43136
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
using namespace std;
string s;

void solve(){
    if(s.size()==1){
        printf("-1 -1\n");
        return;
    }
    if(s.size()==2){
        if(s[0]==s[1])printf("1 2\n");
        else printf("-1 -1\n");
        return;
    }
    for(int i=0;i<s.size()-2;i++){
        if(s[i]==s[i+1]||s[i]==s[i+2]){
            printf("%d %d\n",i+1,i+3);
            return;
        }
    }
    printf("-1 -1\n");
}

int main() {
    cin >> s;
    solve();
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

//#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;

const ll INF = 1LL << 58;

// vector v において、x の前方と後方のインデックスを求める
// 番兵を設置を設置しなければ境界外がアクセス発生する
template<class T>
int former(const vector<T>& v, T x) {
    return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
template<class T>
int latter(const vector<T>& v, T x) {
    return lower_bound(v.begin(), v.end(), x) - v.begin();
}

template<class T>
void chmin(T& x, T y) {
    if (x > y) x = y;
}

int main()
{
    int a, b, q; cin >> a >> b >> q;
    vector<ll> ss(a), ts(b);
    for (int i = 0; i < a; i++) {
        cin >> ss[i];
    }
    for (int i = 0; i < b; i++) {
        cin >> ts[i];
    }
    // 番兵を設置してソート
    ss.push_back(INF); ss.push_back(-INF); sort(ss.begin(), ss.end());
    ts.push_back(INF); ts.push_back(-INF); sort(ts.begin(), ts.end());

    for (int i = 0; i < q; i++) {
        ll x; cin >> x;
        ll res = INF;

        // 最初にss(神社)に行く場合
        for (int j = 0; j < 2; j++) {
            // 前方か後方の神社にいく
            ll first = (j ? ss[former(ss, x)] : ss[latter(ss, x)]);
            for (int k = 0; k < 2; k++) {
                ll second = (k ? ts[former(ts, first)] : ts[latter(ts, first)]);
                chmin(res, abs(x - first) + abs(first - second));
            }
        }

        // 最初にts(寺)に行く場合
        for (int j = 0; j < 2; j++) {
            // 前方か後方の寺にいく
            ll first = (j ? ts[former(ts, x)] : ts[latter(ts, x)]);
            for (int k = 0; k < 2; k++) {
                ll second = (k ? ss[former(ss, first)] : ss[latter(ss, first)]);
                chmin(res, abs(x - first) + abs(first - second));
            }
        }

        cout << res << endl;
    }
}

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

typedef long long ll;

struct store { ll p,t; };

inline bool operator < (const store &a, const store &b) {
    return (a.p != b.p)? a.p < b.p : a.t > b.t;
}

typedef vector<store> vs;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll n,m;
    while(cin >> n >> m) {
        vs v(n);
        for(int i = 0; i < n; i++) {
            cin >> v[i].p >> v[i].t;
        }
        sort(v.begin(), v.end());
        ll ans = 0;
        for(int i = 0; i < n && m > 0; i++) {
            ll buy = min(m, v[i].t);
            ans += buy * v[i].p;
            m -= buy;
        }
        cout << ans << '\n';
    }
    return 0;
}

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

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

    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> x_sort(n);
    rep(i, n) {
        cin >> x[i];
        x_sort[i] = x[i];
    }
    sort(x_sort.begin(), x_sort.end());

    int c_r = x_sort[(int)x_sort.size()/2];
    int c_l = x_sort[(int)x_sort.size()/2 - 1];

    rep(i, n) {
        if(c_r == c_l) printf("%d\n", c_l);
        else {
            if(x[i] >= c_r) printf("%d\n", c_l);
            if(x[i] <= c_l) printf("%d\n", c_r);
        }
    }

    return 0;
}

Measured memory_bytes: 4756
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <algorithm>

typedef long long ll;
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

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



#define MOD 998244353


int main()
{
	int k;
	string s;
	cin >> k >> s;
	
	if (s.size() <= k)
		cout << s << endl;
	else {
		rep(i, k) {
			cout << s[i];
		}

		cout << "..." << endl;
	}
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
using namespace std;

int N,M,x,y,gx,gy,dir;
bool d[4][55][55];
char field[55][55];
bool visit[55][55];
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};

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

	int dir;
	REP(i,1,N+1){
		REP(j,1,M+1){
			cin>>field[i][j];
			if(field[i][j] == 'G'){
				gy = i;	gx = j;
			}
			if(field[i][j] == '^' || field[i][j] == '>'|| field[i][j] == 'v' || field[i][j] == '<'){
				y = i;
				x = j;
				if(field[i][j] == '^') dir = 0;
				if(field[i][j] == '>') dir = 1;
				if(field[i][j] == 'v') dir = 2;
				if(field[i][j] == '<') dir = 3;
			}
		}
	}
	REP(i,0,M+2) field[0][i]=field[N+1][i]='#';
	REP(i,0,N+2) field[i][0]=field[i][M+1]='#';
	int ans=-1;
	while(1){
		if(d[dir][y][x])break;
		visit[y][x]=true;
		d[dir][y][x]=true;
		if(y==gy&&x==gx){//goal
			ans=0;
			REP(i,1,N+1) REP(j,1,M+1)	ans+=visit[i][j];
			break;
		}

		int rdir=(dir+1)%4;//turn right
		int ry=y+dy[rdir];
		int rx=x+dx[rdir];

		if(field[ry][rx]=='#'){//right wall
			if(field[y+dy[dir]][x+dx[dir]]=='#'){//front wall
				dir=(dir+3)%4;//turn left
			}else{
				x+=dx[dir];y+=dy[dir];//straight
			}
		}else{// no right wall
			dir = rdir;//turn right
			x=rx;y=ry;//and go
		}
	}
	p(ans);

	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl
#define COUT(x) cerr<<#x<<" = "; cout<<(x)<<endl

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

int H, W;
V<V<bool>> used;
V<string> S;

const V<V<int>> d{{1,0},{-1,0},{0,1},{0,-1}};

void dfs(int i, int j, int& white, int& black) {
   if (used[i][j]) return;
   used[i][j] = true;
   if (S[i][j] == '.') {
      white++;
   } else {
      black++;
   }
   for (int k = 0; k < 4; k++) {
      int x = i + d[k][0], y = j + d[k][1];
      if (0 <= x && x < H && 0 <= y && y < W) {
         if (S[x][y] != S[i][j]) dfs(x, y, white, black);
      }
   }
}

signed main()
{
   cin >> H >> W;
   S.resize(H);
   for (int i = 0; i < H; i++) {
      cin >> S[i];
   }

   used.resize(H, V<bool>(W, false));
   int ans = 0;
   for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
         int white = 0, black = 0;
         dfs(i, j, white, black);
         ans += white * black;
      }
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 15488
#include<iostream>

int main() {
  int A, B;
  int ans;
  std::cin >> A >> B;

  if(A > B) {
    ans = A + A - 1;
  }
  else if(B > A) {
    ans = B + B - 1;
  }
  else {
    ans = A + B;
  }

  std::cout << ans;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/*	#include <boost/math/common_factor.hpp>  boost::math::lcm(10,20) ---> use it to find lcm. fill_n(&an[0][0],n*m,0); typedef long long ll;*/
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define PI pair<int , int >
#define mpr make_pair
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define FO(i,a,b) for(int i = (int)a;i < (int)b;++i)
#define FE(i,a,b) for(int i = (int)a;i <= (int)b;++i)
const int MOD = 1e9+7;
const int MAXN = 1e5+3;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
#define print(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
bool cmp(PI p1,PI p2){
	if(p1.ff < p2.ff)return true;	// You should not be writing p1.ss <= p2.ss !!!
	else if(p1.ff == p2.ff){ if(p1.ss < p2.ss)return true; return false; }
	return false;
}

void solve(){
	int n,r;
	cin >> n >> r;
	int ans = r;
	if(n<10)ans = r + 100*(10-n);
	cout << ans << endl;
}
/* When you have to multiply many things , do it in different (multiple) lines, not in a single line .*/
int32_t main(){
	IO;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif // ONLINE_JUDGE
	// std::cout << std::setprecision(15); std::cout << std::fixed;
	int nT = 1;
	//cin >> nT;
	FE(i,1,nT)
		solve();
	return 0;
}


Measured memory_bytes: 256