akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int ar[100000];

int main(int argc, char *argv[]) {
  // INFILE();
  int n;
  cin >> n;

  vector<int> v(n);
  scan(v);

  for (const auto &val : v) {
    ar[val]++;
  }

  int oddCnt = 0, evenCnt = 0;
  for (const auto &val : ar) {
    if (val == 0) {
      continue;
    }

    if (val % 2 == 0) {
      evenCnt++;
    } else {
      oddCnt++;
    }
  }

  cout << oddCnt + evenCnt - ((evenCnt % 2 == 0) ? 0 : 1) << endl;
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


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

int main() {
  int A, B , C, D;
  cin >> A >> B >> C >> D;
  int L =A+B, R =C+D;

  if (L > R) puts("Left");
  else if (L == R) puts("Balanced");
  else puts("Right");
}

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

int main() {
    int x, y, z, k; cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    for (int i = 0; i < x; i++) cin >> a[i];
    for (int i = 0; i < y; i++) cin >> b[i];
    for (int i = 0; i < z; i++) cin >> c[i];
    
    vector<ll> v(x*y);
    for (int i = 0; i < x; i++)
    {
        for (int j = 0; j < y; j++)
        {
            v[y*i+j] = a[i] + b[j];
        }
    }

    sort(v.begin(), v.end(), greater<ll>());
    vector<ll> w(k*z);
    for (int i = 0; i < z; i++)
    {
        for (int j = 0, nnn=min(k, x*y); j < nnn; j++)
        {
            w[i*k+j] = c[i] + v[j];  
        }
    }
    sort(w.begin(), w.end(), greater<ll>());
    for (int i = 0; i < k; i++)
    {
        cout << w[i] << '\n';
    }
}

Measured memory_bytes: 31616
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;
   
  
   
int main(){
   
    int n; 
    int r[1000],w[1000];
    int sum_r=0,sum_w=0,idx=0;
	
    while(scanf("%d",&n),n){
         
        sum_r=sum_w=idx=0;
        for(int i=0;i<n;i++){
            scanf("%d %d",&r[i],&w[i]);
            sum_r+=r[i];
            sum_w+=w[i];
            if(r[idx]<r[i]) idx=i;
        }
  
        int r0=r[idx],r=sum_r-r0;
        w[idx]=0;
 
        if(r0 <= r){
            cout<<sum_r+sum_w<<endl;
        }else{
  
            int res=2*r0;
            //vector<vector<bool> > dp(1001,vector<bool>(1000,false));
  
//			bool cur[1001]={};
			bool *cur = (bool*)malloc( r0-r+2 );
            cur[0]=true;
            for(int i=0;i<n;i++){
				bool *next = (bool*)malloc( r0-r+2 );
                for(int j=0;j<=r0-r;j++){
                    if(cur[j]){
                        next[j]=true; 
                        if(j+w[i]<=r0-r)
                            next[j+w[i]]=true; 
                    }
                }
				swap(cur,next);
            }
  
            int opt=r0-r;
            while(!cur[opt]) opt--;
  
            res+=sum_w-opt;
            printf("%d\n",res);
  
  
  
        }
          
          
    }
}

Measured memory_bytes: 4920
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll N;
  cin>>N;
  ll ans=10000000000000;
  for(ll i=1;i<=sqrt(N);i++) {
    if(N%i==0) {
ans=min(ans,i+N/i);
    }
  }
    
cout<<ans-2<<endl;
}
 
    
    
    
    
    
    
    
    
  
  

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

int main() {
  int n;
  cin >> n;
  int remainder;
  if ((n - (n % 10)) % 1110 == 0 || (n % 1000) % 111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main(){
    
    int h, w;
    string odd, even;
    
    while( cin >> h >> w && !(h==0 && w==0)){
        odd  = "";
        even = "";
        for(int j=0; j<(w/2); ++j){
            even  += "#.";
            odd   += ".#";
        }
        if(w%2==1){
            even += '#';
            odd  += '.';
        }
        
        for (int i=0; i<h; ++i){
            if  (i%2==0) cout << even << endl;
            else         cout << odd  << endl;
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3172
ABCD = input()
for p in range(1 << 3):
    v = int(ABCD[0])
    ans = ABCD[0]
    for i in range(3):
        if p & (1 << i):
            v -= int(ABCD[i + 1])
            ans += '-' + ABCD[i + 1]
        else:
            v += int(ABCD[i + 1])
            ans += '+' + ABCD[i + 1]
    if v == 7:
        print(ans + '=7')
        exit()


Measured memory_bytes: 61820
#include<iostream>
#include<cmath>
#include<vector>
#define N 10000

using namespace std;

int main(){
  int i, j, n, isFound, large, small;
  vector<int> data;

  data.push_back(2);
  data.push_back(3);
  for(i=5; i<=N; i+=2){
    for(j=1, isFound=0; data[j]<=sqrt(i); ++j){
      if(i%data[j] == 0){
	isFound = 1;
	break;
      }
    }
    if(isFound == 0) data.push_back(i);
  }

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<data.size(); ++i){
      if(n < data[i]) break;
    }
    for(j=i-1; j>0; --j){
      if(data[j] == data[j-1]+2) break;
    }

    cout << data[j-1] << " " << data[j] << endl;
  }

  return 0;
}

Measured memory_bytes: 920
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        for(int i=0; i<n; i++){
            b[i] = sc.nextInt();
        }
        for(int i=0; i<n; i++){
            c[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);

        long ans = 0;
        long[] cnum = new long[n+1];
        int pos = 0;
        for(int i=0; i<n; i++){
            while(c[pos] <= b[i]){
                pos++;
                if(pos >= n){
                    pos = n;
                    break;
                }
            }
            if(pos >= n) break;
            cnum[i] = n - pos;
        }
        for(int i=1; i<n; i++){
            cnum[n-i-1] = cnum[n-i] + cnum[n-i-1];
        }
        pos = 0;
        for(int i=0; i<n; i++){
            while(b[pos] <= a[i]){
                pos++;
                if(pos >= n){
                    pos = n;
                    break;
                }
            }
            if(pos >= n) break;
            ans += cnum[pos];
        }

        System.out.println(ans);
    }
}

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

int main() {
  int h,l;
  cin >> h >> l;
  if( l%2==0){
    if( h*2<=l and h*4>=l){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
using ld = long double;
constexpr ld EPS = 1e-10;

int main() {
    int n;
    cin >> n;
    vector<ld> r(n);
    vector<ld> x(n, 0);
    for(int i=0; i<n; ++i) {
        cin >> r[i];
    }

    for(int i=0; i<n; ++i) {
        if(i == 0) {
            x[i] = r[i];
        } else {
            ld min_x = -1;
            for(int j=0; j<i; ++j) {
                min_x = max(min_x, x[j] + sqrt((r[i] + r[j])*(r[i]+r[j]) - (r[j]-r[i])*(r[j]-r[i])));
            }
            x[i] = min_x;
        }
    }

    cout << fixed << setprecision(8);
    ld left = 0, right = 0;
    for(int i=0; i<n; ++i) {
        left = min(x[i]-r[i], left);
        right = max(x[i]+r[i], right);
    }
    cout << right - left << endl;
}


Measured memory_bytes: 3252
#include<iostream>
using namespace std;
int main(){
	int N,X,L,D=0,ans=1;
	cin>>N>>X;
	for(int i=0;i<N;i++){
		cin>>L;
		D=D+L;
		if(D>X)break;
		else ans++;
	}
	cout<<ans;
	return 0;
}

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

int main(){
  double a,b,c,d,e,f;
  double x,y;
  while(cin>>a>>b>>c>>d>>e>>f){
    x= (c*e-b*f)/(a*e-b*d)+0;
    y= (c*d-a*f)/(b*d-a*e)+0;
    printf("%.3f %.3f\n",x,y);
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N,M;
  cin >> N >> M;
  vector<int> a (2 * M);
  for (int i = 0;i < 2*M;i++)
    cin >> a.at(i);
  for (int i = 0;i < N;i++){
    int count = 0;
    for (int l = 0; l < a.size();l++){
      if (a.at(l) == i + 1)count++;
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> as(n), bs(n);
    vector<pair<ll, int>> nums(2 * n);
    for(int i = 0; i < n; i++){
        cin >> as[i] >> bs[i];
        nums[i * 2] = {as[i], i * 2};
        nums[i * 2 + 1] = {bs[i], i * 2 + 1};
    }
    sort(nums.begin(), nums.end());
    // printde(accumulate(nums.begin(), nums.begin() + n, 0ll));
    int e = 0, o = 0;
    bool ok = false;
    vector<int> used(n);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += nums[i].first;
        e += !(nums[i].second & 1);
        o += nums[i].second & 1;
        int idx = nums[i].second / 2;
        if(used[idx]){
            ok = true;
        }
        used[idx] = 1;
    }
    if(!ok && e && o){
        ans = ans - nums[n - 1].first + nums[n].first;
        printde(nums[n - 1].second / 2, nums[n].second / 2, ((nums[n - 1].second & 1) && e != 1), (!(nums[n - 1].second & 1) && o != 1), e, o);
        if(nums[n - 1].second / 2 == nums[n].second / 2 && ((!(nums[n - 1].second & 1) && e != 1) || ((nums[n - 1].second & 1) && o != 1))){
        // if(nums[n - 1].second / 2 == nums[n].second / 2 && (e > 1 && o > 1)){
            ans = min(ans - nums[n].first + nums[n + 1].first,
                      ans - nums[n - 2].first + nums[n - 1].first);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 5376
import java.util.*;

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int Len = S.length();
		int count = 0;

			for(int i=0; i<Len/2; i++){
				char ch1 = S.charAt(i);
				char ch2 = S.charAt(Len -1 -i);
			
				if(ch1 != ch2){
					count++;
				}
			}
			System.out.println(count);

	}
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	auto V=vecin<ll>(N);
	map<ll,ll> M;
	REP(i,N){
		M[V[i]]++;
	}
	ll S=0;
	for(auto& x:M){
		S += x.second*(x.second-1LL)/2LL;
	}
	REP(i,N){
		ll T = M[V[i]]-1LL;
		out(S-T);
	}
	return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define lli long long int
#define f(i,a,b) for (lli i = a; i <= b; i++)
#define fr(i,a,b) for (lli i = a; i >= b; i--)
#define sl(x)	scanf("%lld",&x)
#define pl(x)	printf("%lld",x)
#define ss(s)	scanf("%s",s)
#define mod 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve()
{
	lli n;
	cin >> n;
	vector<lli> a(n);
	for (lli& x : a)
		cin >> x;
	vector<lli> dp(n, INT_MAX);
	dp[0] = 0;
	f(i, 0, n - 1)
	{
		for (lli j : {i + 1, i + 2})
		{
			if (j < n)
			{
				dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
			}
		}
	}
	cout << dp[n - 1];
}
int main()
{
	IOS;
	// lli t;
	// cin >> t;
	// while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 4700
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		StringBuilder sb = new StringBuilder();
		sb.append(s);
		sb.replace(0, 4, "2018");
		System.out.println(sb);
	}

}


Measured memory_bytes: 21716
#include <stdio.h>

int main(void)
{
	int i;
	int N;
	scanf("%d",&N);
	int T[N];
	for(i=0;i<N;i++){
		scanf("%d",&T[i]);
	}
	int M;
	scanf("%d",&M);
	int P[M];
	int X[M];
	for(i=0;i<M;i++){
		scanf("%d %d",&P[i],&X[i]);
	}
	
	long sum=0;
	for(i=0;i<N;i++){
		sum+=T[i];
	}
	for(i=0;i<M;i++){
		printf("%ld\n",sum-T[P[i]-1]+X[i]);
	}
	
	return 0;
}

Measured memory_bytes: 128
// 24/01/20 // 9:53 PM //

#include <bits/stdc++.h>

using namespace std;

const int MAXN = (int)(3e2) + 10;

int n;
double memo[MAXN][MAXN][MAXN];

double solve(int a, int b, int c){
    if(memo[a][b][c]!=-1) return memo[a][b][c];

    if(a==0 && b==0 && c==0) return 0.0;

    double dn=n, da = a, db = b, dc = c;

    memo[a][b][c] = dn/(da+db+dc);
    if(a>0) memo[a][b][c] += da/(da+db+dc) * solve(a-1, b, c);
    if(b>0) memo[a][b][c] += db/(da+db+dc) * solve(a+1, b-1, c);
    if(c>0) memo[a][b][c] += dc/(da+db+dc) * solve(a, b+1, c-1);

    return memo[a][b][c];
}

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

    cin >> n;

    int a=0, b=0, c=0;
    for(int i=0; i<n; i++){
        int temp;
        cin >> temp;

        a += (temp==1);
        b += (temp==2);
        c += (temp==3);
    }

    for(int x=0; x<MAXN; x++)
        for(int y=0; y<MAXN; y++)
            for(int z=0; z<MAXN; z++)
                memo[x][y][z] = -1;

    cout.precision(10);
    cout.setf(ios::fixed);
    cout << solve(a, b, c) << endl;
}


Measured memory_bytes: 233088
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
    int N, M; cin >> N >> M;
    vector<int> human(101, 0);

    REP(i, N){
        int K; cin >> K;
        FOR(j, 0, K){
            int A; cin >> A;
            human.at(A)++;
        }
    }

//    DEBUG_VEC(human);

    int ans = 0;
    REP(i, M+1){
        if(human.at(i) == N) ans++;
    }
    cout << ans;

//    REP(i, M) if(M == human.at(i)) cout << i;
//    DEBUG(human.at(0));

    return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<double> money(N);
	vector<string> vec(N);
	double sum = 0.0;

	for (int i = 0; i < N; i++) {
		cin >> money.at(i) >> vec.at(i);
		if (vec.at(i) == "JPY")
			sum += money.at(i);
		else if (vec.at(i) == "BTC")
			sum = sum + money.at(i) * 380000;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

// long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a;
// }

// int binary_search(int key) {
//     int ng = -1;
//     int ok = (int)a.size();
//     while(abs(ok - ng) > 1) {
//         int mid = (ok + ng) / 2;
//         if(isOK(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }

// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W
// int MOD = 1000000007;

int main() {
    int N, M;
    cin >> N >> M;
    int ans = 0;
    ans += N * (N - 1) / 2 + M * (M - 1) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 888
#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()
typedef long long ll;
const int INF = 100000000;
const int MOD = 1000000007;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 11;
}
int main(){
  int a,b;
  bool han=true;
  std::cin >> a>>b;
  string s;
  std::cin >> s;
  rep(i,a)if(ctoi(s[i])==11)han=false;
  if(s[a]!='-')han=false;
  for (int i = a+1; i < a+b+1; i++) {
    /* code */
    if(ctoi(s[i])==11)han=false;
  }
  if(han)std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define all(x) x.begin(), x.end()
using pii = pair<int, int>;
using ll = long long;
const int INF = 1e9;

bool solve() {
    int a, b, d;
    cin >> a >> b >> d;
    if (a == 0 && b == 0 && d == 0) return false;
    int mx = 1e15;
    pii ans = {1e9, 1e9};
    REP(x, 50050) {
        if (x * a < d) continue;
        int rem = x * a - d;
        if (rem % b == 0) {
            int y = rem / b;
            if (x + y < ans.first + ans.second) {
                mx = a * x + b * y;
                ans = {x, y};
            } else if (x + y == ans.first + ans.second) {
                if (a * x + b * y < mx) {
                    mx = a * x + b * y;
                    ans = {x, y};
                }
            }
        }
    }
    REP(y, 50050) {
        if (y * b < d) continue;
        int rem = y * b - d;
        if (rem % a == 0) {
            int x = rem / a;
            if (x + y < ans.first + ans.second) {
                mx = a * x + b * y;
                ans = {x, y};
            } else if (x + y == ans.first + ans.second) {
                if (a * x + b * y < mx) {
                    mx = a * x + b * y;
                    ans = {x, y};
                }
            }
        }
    }
    REP(x, 50050) {
        int rem = d - x * a;
        if (rem < 0) break;
        if (rem % b == 0) {
            int y = rem / b;
            if (x + y < ans.first + ans.second) {
                mx = a * x + b * y;
                ans = {x, y};
            } else if (x + y == ans.first + ans.second) {
                if (a * x + b * y < mx) {
                    mx = a * x + b * y;
                    ans = {x, y};
                }
            }
        }
    }
    cout << ans.first << " " << ans.second << endl;
    return true;
}

signed main() {
    while (solve())
        ;
}



Measured memory_bytes: 3064
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int mod = 86400;
        int[] rec = new int[mod+1];
        int cur = 0;
        for(int i=0;i<n;i++){
            int a = sc.nextInt(), b = sc.nextInt();
            cur = (cur+a)%mod;
            rec[cur%mod+1]++;
            cur = (cur+b)%mod;
        }
        int[] sum = new int[mod+1];
        for(int i=1;i<=mod;i++){
            sum[i] = sum[i-1]+rec[i];
        }
        int len = 10800+1;
        int ans = 0;
        for(int start=1;start+len-1<=mod;start++){
            int now = sum[start+len-1]-sum[start-1];
            ans = Math.max(ans,now);
        }
        for(int start = mod+2-len;start<=mod;start++){
            int tail = mod-start+1;
            int now = sum[mod]-sum[start-1]+sum[len-tail];
            ans =Math.max(ans,now);
        }
        System.out.println(ans);
    }
}


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

int main() {
    int a[5],k;
    for(int i=0;i<5;i++){
        cin>>a[i];
    }
    cin>>k;
    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            if(abs(a[j]-a[i])>k){
            cout<<":("<<endl;
            return 0;
            }
        }
        
    }
    cout<<"Yay!"<<endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

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

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

    string t = "keyence";

    int l, r;
    l = r = 0;
    rep(i, 7){
        if(s[i] != t[i]){
            break;
        }
        l = i + 1;
    }
    for(int i = 1; i <= 7; i++){
        if(s[n-i] != t[7-i]){
            break;
        }
        r = i;
    }

    if(l + r >= 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void){
	int n; cin >> n;
	int l = 0, r = 10000;
	while(r - l > 1){
		int mid = (r + l) / 2.0;
		// printf("%lld\n", mid);
		ll tmp = mid * (mid + 1) / 2.0;
		// printf("tmp %d\n", tmp);
		if(tmp >= n){
			r = mid;
		}else{
			l = mid;
		}
	}

	ll sum = l * (l + 1) / 2.0;
	int lim = l;
	if(sum < n){
		sum = r * (r + 1) / 2.0;
		lim = r;
	}

	for (int i = 0; i <= lim; ++i){
		if(sum - i == n){
			for (int j = 1; j <= lim; ++j){
				if(i == j) continue;
				printf("%d\n", j);
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
)

func main() {
	sc := NewScanner(os.Stdin)
	sc.Scan()
	s := sc.Text()
	fmt.Println(string([]rune(s)[:3]))
}

// Scanner is a wrapper of bufio.Scanner which is customized for competitive programing.
type Scanner struct {
	bufio.Scanner
}

// NewScanner is a constructor for Scanner.
func NewScanner(r io.Reader) *Scanner {
	sc := Scanner{*bufio.NewScanner(r)}
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
	return &sc
}


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

typedef long long ll;

using namespace std;

int main() {
	int n, m, total = 0, nums[105];
	cin >> n >> m;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		sum += a;
		nums[i] = a;
	}
	for (int i = 0; i < n; i++) {
		if(nums[i] >= sum/(4.00*m)) total++;
		if (total == m) { cout << "Yes"; return 0;} 
	}
	cout << "No";
}





Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from itertools import accumulate

MOD = 10**9+7
S = input()
n = len(S)
acc_A = [0]*n
acc_C = [0]*n
acc_Q_left = [0]*n
acc_Q_right = [0]*n
cnt = 0
for i, s in enumerate(S):
  if s == "A":
    acc_A[i] = 1
  elif s == "C":
    acc_C[i] = 1
  elif s == "?":
    acc_Q_left[i] = 1
    acc_Q_right[i] = 1
    cnt += 1
acc_A = list(accumulate(acc_A))
acc_C = list(accumulate(acc_C[::-1]))[::-1]
acc_Q_left = list(accumulate(acc_Q_left))
acc_Q_right = list(accumulate(acc_Q_right[::-1]))[::-1]
ans = 0
for i, s in enumerate(S):
  if i == 0 or i == n-1:
    continue
  if s == "B":
    ans += acc_A[i-1] * acc_C[i+1] * pow(3, cnt, MOD)
    if cnt >= 1:
      ans += acc_A[i-1] * acc_Q_right[i+1] * pow(3, cnt-1, MOD)
      ans += acc_Q_left[i-1] * acc_C[i+1] * pow(3, cnt-1, MOD)
    if cnt >= 2:
      ans += acc_Q_left[i-1] * acc_Q_right[i+1] * pow(3, cnt-2, MOD)
  elif s == "?":
    ans += acc_A[i-1] * acc_C[i+1] * pow(3, cnt-1, MOD)
    if cnt >= 2:
      ans += acc_A[i-1] * acc_Q_right[i+1] * pow(3, cnt-2, MOD)
      ans += acc_Q_left[i-1] * acc_C[i+1] * pow(3, cnt-2, MOD)
    if cnt >= 3:
      ans += acc_Q_left[i-1] * acc_Q_right[i+1] * pow(3, cnt-3, MOD)
  ans %= MOD
print(ans)

Measured memory_bytes: 20548
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    long long a, b; std::cin >> a >> b;
    long long c = b - a;
    if (c & 1) std::cout << "IMPOSSIBLE" << std::endl;
    else std::cout << a + c / 2 << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <string>
using namespace std;
long int A[2000000];

int n;

int parent(int i){
    return i/2;
}
int left(int i){
    return 2*i;
}
int right(int i){
    return 2*i+1;
}

void heapIncreaseKey(int i,int key){
    if(key < A[i])
	    return;
    A[i] = key;
    while(i>1 && A[parent(i)] < A[i]){
        swap(A[i], A[parent(i)]);
        i = parent(i);
    }
}

void maxHeapInsert(int key){
    n++;
    A[n]=INT_MIN;
    heapIncreaseKey(n, key);
}

void maxHeapify(int);
int heapExtractMax(){
    int maxi;
    if(n<1)
        return -1;
    maxi = A[1];
    A[1] = A[n];
    n--;
    maxHeapify(1);
    return maxi;
}
void maxHeapify(int i){
    int l = left(i);
    int r = right(i);
    int large;
    if(l<=n&&A[l]>A[i]){
        large = l;
    }else{ 
        large = i;
    }    
    if(r<=n&&A[r]>A[large]){
        large = r;
    }
    if(large!=i){
        swap(A[i],A[large]);
        maxHeapify(large);
    }
}

void buildMaxHeap(){
    for(int i=n/2;i>0;i--)
        maxHeapify(i);
}

int main(){
    int id;
    string cmd;
    A[0]=0;
    do{
	    cin>>cmd;
	    if(cmd=="insert"){
	        cin>>id;   
	        maxHeapInsert(id);
	    }
	    if(cmd=="extract"){
	        cout<<heapExtractMax()<<endl;;
    	} 
    }while(cmd!="end");

    return 0;
}

Measured memory_bytes: 9392
#include<iostream>
#include<iterator>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;
struct Card {
  int rank;
  char suit;
  int orig_idx;
};

vector<Card> ns;
map<int,vector<int>> idxs;

int partition(int p, int r)
{
  auto x = ns[r];
  int i = p-1;
  for (int j=p; j<r; ++j) {
    if (ns[j].rank <= x.rank) {
      ++i;
      swap(ns[i], ns[j]);
    }
  }
  swap(ns[i+1], ns[r]);
  return i+1;
}

void sort(int p, int r) {
  if(p<r) {
    int q = partition(p, r);
    sort(p, q-1);
    sort(q+1, r);
  }
}

int main()
{
  int n; cin >> n;
  for(int i=0; i<n;++i) {
    Card c;
    cin >> c.suit;
    cin >> c.rank;
    c.orig_idx = i;
    ns.push_back(c);
  }
  sort(0, n-1);
  bool stable=true;
  for(int i=0; i<n; ++i) {
//    cout << "Test: " << ns[i].suit << ' ' << ns[i].rank << ", orig idx: " << ns[i].orig_idx << endl;
    if (!idxs.count(ns[i].rank)) {
      idxs[ns[i].rank]=vector<int>{ns[i].orig_idx};
    } else {
      if(ns[i].orig_idx < idxs[ns[i].rank].back()) {
        stable=false; 
        break;
      }
    }
  }
  if(stable) cout << "Stable" << endl;
  else cout << "Not stable" << endl;
  for(int i=0; i<n; ++i) {
    cout << ns[i].suit << ' ' << ns[i].rank << endl;
  }
}


Measured memory_bytes: 4476
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    int ret = 0;
    for(int i=0; i<n; ++i){
        int j = i;
        while(j < n && s[j] == 'O')
            ++ j;
        int m = j - i;

        if(i - m >= 0 && s.substr(i - m, m) == string(m, 'J')){
            if(s.substr(j, m) == string(m, 'I')){
                ret = max(ret, m);
            }
        }

        i = j;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 2232
/*
  AOJ 1044
  Title:CamelCase
  @kankichi573
*/
#include <stdio.h>
#include <string.h>

char identifier[101];
char naming_rule;
char outbuffer[201];

solve(char * id,char rule,char * out)
{
  int flag;
  char *outp;

  if(isupper(id[0]))   //upperCamelCase
    {
      if(rule=='U')
	strcpy(out,id);
      else if(rule=='L')
	{
	  strcpy(out,id);
	  out[0]=tolower(out[0]);
	}
      else
	{
	  while(1)
	    {
	      *out++ =tolower(*id++);
	      while(islower(*id))
		{
		  *out++ = *id++;
		}
	      if(*id=='\0')
		break;
	      *out++ = '_';
	    }
	}
    }
  
  else if(strchr(identifier,'_'))
    {
      outp=out;
      flag=0;

      if(rule=='D')
	strcpy(out,id);
      else
	{
	  do
	    {
	      if(*id!='_')
		{
		  *outp = *id;
		  if(flag && *out)
		    {
		      *outp = toupper(*outp);
		      flag=0;
		    }
		  outp++;id++;
		}
	      else
		{
		  flag=1;
		  id++;
		}
	    }
	  while(*id);
	  if(rule=='U')
	    out[0]=toupper(out[0]);
	}
    }
  else
   {
      if(rule=='L')
	strcpy(out,id);
      else if(rule=='U')
	{
	  strcpy(out,id);
	  out[0]=toupper(out[0]);
	}
      else
	{
	  while(1)
	    {
	      *out++ =tolower(*id++);
	      while(islower(*id))
		{
		  *out++ = *id++;
		}
	      if(*id=='\0')
		break;
	      *out++ = '_';
	    }
	}
    } 
}
clear()
{
  memset(outbuffer,0,sizeof(outbuffer));
}
main()
{
  while(scanf("%s %c",identifier,&naming_rule),naming_rule!='X')
    {
      clear();
	// printf("%s\n",identifier);
      solve(identifier,naming_rule,outbuffer);
      printf("%s\n",outbuffer);
    }
  return(0);
}

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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	int H, W, sx, sy, gx, gy;
	cin >> H >> W >> sx >> sy >> gx >> gy;
	sx--; sy--; gx--; gy--;
	vector<string> S(H);
	REP(i, H) cin >> S[i];

	vector<vint> dist(H, vint(W, 2e9));
	dist[sx][sy] = 0;
	deque<pint> que;
	que.push_back({sx, sy});
	while(!que.empty()){
		auto q = que.front(); que.pop_front();
		int x = q.first, y = q.second;
		REP(i, 4){
			int nx = x+dx[i], ny = y+dy[i];
			if(nx < 0 or nx >= H or ny < 0 or ny >= W) continue;
			if(S[nx][ny] == '#') continue;
			if(chmin(dist[nx][ny], dist[x][y])){
				que.push_front({nx, ny});
			}
		}
		for(int i = -2; i <= 2; i++){
			for(int j = -2; j <= 2; j++){
				if(i == 0 and j == 0) continue;
				int nx = x + i, ny = y+j;
				if(nx < 0 or nx >= H or ny < 0 or ny >= W) continue;
				if(S[nx][ny] == '#') continue;
				if(chmin(dist[nx][ny], dist[x][y]+1)){
					que.push_back({nx, ny});
				}
			}
		}
	}
	if(dist[gx][gy] == 2e9) cout << -1 << ln;
	else cout << dist[gx][gy] << ln;
}

Measured memory_bytes: 8648
from collections import Counter
N = int(input())
xy = [tuple(map(int,input().split())) for i in range(N)]
ct = Counter()
for i in range(N):
  for j in range(i+1,N):
    dx = xy[i][0]-xy[j][0]
    dy = xy[i][1]-xy[j][1]
    ct[(dx,dy)] += 1
    ct[(-dx,-dy)] += 1
print(N-max(ct.values() if len(ct)>0 else [0]))

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

int main() {
  int n;
  cin >> n;
  int a[n];
  
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  for(int j=n; j>0; j--){
    cout << a[j-1];
    if(j!=1)
      cout << ' ';
  }
 cout << endl;   
}


Measured memory_bytes: 3032
#include<iostream>
#include<vector>
#include<string>
#include<queue>
//#include<set>
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef double db;
const int MOD = 1e9 + 7;
vector<int> f, inv;
int pow_bin(int a, int b)
{
	int t = 1;
	while (b > 0)
	{
		if (b & 1)
			t = 1ll * t * a % MOD;
		a = 1ll * a * a % MOD;
		b >>= 1;
	}
	return t;
}
int nCk(int n, int k)
{
	return 1ll * f[n] * inv[k] % MOD * inv[n - k] % MOD;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int k;
	cin >> k;
	string s;
	cin >> s;
	int n = s.size();
	f.resize(k + n);
	inv.resize(k + n);
	f[0] = 1;
	for (int i = 1; i < k + n; ++i)
		f[i] = 1ll * f[i - 1] * i % MOD;
	inv[k + n - 1] = pow_bin(f[k + n - 1], MOD - 2);
	for (int i = k + n - 2; i >= 0; --i)
		inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;
	int ans = 0, add, f1 = 1, f2 = pow_bin(26, k), inv26 = pow_bin(26, MOD - 2);
	for (int i = 0; i <= k; ++i)
	{
		add = 1ll * f1 * f2 % MOD * nCk(n - 1 + i, n - 1) % MOD;
		ans = (1ll * ans + add) % MOD;
		f1 = 1ll * f1 * 25 % MOD;
		f2 = 1ll * f2 * inv26 % MOD;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 20080
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

int main(void)
{
	int a, b;
	while(scanf("%d%d", &a, &b)==2)
	{
		printf("%d\n", a*b);
	}
	return 0;
}


Measured memory_bytes: 1732
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main(){

    ll R, G, B, N;
    cin >> R >> G >> B >> N;
    ll ans = 0;
    for(ll r = 0; r <= N; r++){
        for(int g = 0; g <= N; g++){
            ll tmp = R * r + g * G;
            if(tmp > N)continue;
            if((N - tmp) % B == 0)ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>

template<typename Monoid>
struct SegTree {
  using value_type = typename Monoid::value_type;
  using Index0 = int;

  const int N;
  std::vector<value_type> nodes;

  SegTree(int size) : SegTree(size, 1 << (32 - __builtin_clz(size - 1))) {}
  SegTree(int size, int aligned) : N(aligned), nodes(aligned * 2, Monoid::empty()) {}

  void update(Index0 x, value_type v) {
    x += N;
    nodes[x] = v;
    while (x > 1) {
      x >>= 1;
      nodes[x] = Monoid::append(nodes[x << 1], nodes[x << 1 | 1]);
    }
  }

  template<typename F>
  void modify(Index0 x, F f) {
    update(x, f(nodes[x + N]));
  }

  value_type query(Index0 a, Index0 b) const {
    auto x = Monoid::empty();
    for (int l = a + N, r = b + N; l < r; l >>= 1, r >>= 1) {
      if (l & 1) x = Monoid::append(x, nodes[l++]);
      if (r & 1) x = Monoid::append(x, nodes[--r]);
    }
    return x;
  }
};

#include <cstdio>
#include <limits>
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
template<typename T=int>inline T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
template<typename T=int>inline void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}

struct Min {
  using value_type = int;
  static const int empty() { return std::numeric_limits<int>::max(); }
  static const int append(int x, int y) { return std::min(x, y); }
};

int main() {
  int N = rd(), Q = rd();
  SegTree<Min> st(N);
  for (int i = 0; i < Q; i++) {
    int c = rd(), x = rd(), y = rd();
    if (c == 0) {
      st.modify(x, [y](int a){ return y; });
    } else {
      wr(st.query(x, y + 1));
    }
  }
  return 0;
}

Measured memory_bytes: 3340
N,T = map(int, input().split())
x = [list(map(int, input().split())) for i in range(N)]
c = []
for i in range(N):
  if x[i][1] <= T:
    c.append(x[i][0])
if c == []:
  print("TLE")
else:
  print(min(c))

Measured memory_bytes: 3060
N = int(input())
B = list(map(int, input().split()))

# B.reverse()
result = [B[0]]
for i, e in enumerate(B):
    if i < len(B) - 1:
        result.append(min(B[i], B[i+1]))
    else:
        result.append(B[i])
print(sum(result))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define F first
#define S second
#define pb push_back
const ll N = 1e5 + 5, MOD =  1e9 + 7, INF = 1e9 + 10;
const long double PI = acos(-1);
pair <ll, ll> d[N];
map <ll, ll> mp;
vector <ll> adj[N];
ll sz[N];
ll h[N];
bool mrk[N];
ll n;
void dfs(int v){
	mrk[v] = true;
	for(int u : adj[v]){
		if(!mrk[u]){
			h[u] = h[v] + 1;
			dfs(u);
		}
	}
}
bool ok(){
	dfs(d[n].S);
	ll all = 0;
	for (int i = 1; i <= n; i++){
		all += h[i];
	}
	return (all == d[n].F);
}
int main(){
	cin >> n;
	for (ll i = 1; i <= n; i++){
		cin >> d[i].F;
		d[i].S = i;
		mp[d[i].F] = i; 
	}
	sort(d + 1, d + n + 1);
	reverse(d + 1, d + n + 1);
	bool flag = true;
	
	for (ll i = 1; i <= n - 1; i ++){
		int u = d[i].S;
		sz[u] = 1;
		for(ll v : adj[d[i].second]){
			sz[u] += sz[v];
		}
		ll x = d[i].F + 2 * sz[u] - n;
		auto f = mp.find(x);
		if(f == mp.end()) break;
		adj[mp[x]].pb(d[i].second);
	}
	if(ok()){
		for(ll i = 1; i <= n; i ++){
			for(ll u : adj[i]){
				cout << i  << ' ' << u << '\n';
			}
		}
	}
	else{
		cout << "-1\n";;
	}
	
	return 0;
}


Measured memory_bytes: 20892
prime=[0]*100001
prime[0]=1
prime[1]=1
prime_ans=[0]*100001
for i in range(0,100001):
  if prime[i]==0:
    cnt=2
    while cnt*i<100001:
      prime[cnt*i]=1
      cnt+=1
ans=0
for i in range(3,100001):
  if prime[i]==0 and prime[int((i+1)/2)]==0:
    ans+=1
  prime_ans[i]=ans

Q=int(input())
for i in range(Q):
  l,r=map(int,input().split())
  res=prime_ans[r]-prime_ans[l-1]
  print(res)

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

long count(int b,int e,long k,long* A);

int main(void){
  int n,q;
  int b,e;
  long k;
  cin>>n;
  long A[n];
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>b>>e>>k;
    cout<<count(b,e,k,A)<<endl;
  }
  return 0;
}


long count(int b,int e,long k,long* A){
  long retval=0;
  for(int i=b;i<e;i++){
    if(A[i]==k){
      retval++;
    }
  }
  return retval;
}



Measured memory_bytes: 3108
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
//const int MOD = 1000000007;
const int MOD = 998244353;
//const long long int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	cin >> N;
	string s;
	cin >> s;
	cin >> K;
	K--;
	for (int i = 0; i < N; i++)cout << (s[i] == s[K] ? s[i] : '*');
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int t,n,d,ans;

int main()
{
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d",&n,&d);
        n-=1;
        ans = n*127+(n%2==0?d:127^d);
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
n,q = $stdin.gets.split.map(&:to_i)
s = $stdin.gets.chomp
result = []
count = 0

result[0] = 0
(1..n).each do |i|
  if s[i-1]=='A' && s[i]=='C'
    count += 1
  end
  result[i] = count
end
q.times do
  l,r = $stdin.gets.split.map(&:to_i)
  puts result[r-1]-result[l-1]
end


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

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

using namespace std;

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

int const MAXN = 1e5 + 5;
string s[MAXN], t;
int tt[MAXN];

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n; cin >> n;
  for (RI i = 1; i <= n; ++i)
    cin >> s[i] >> tt[i];
  cin >> t;
  int pos = 1;
  for (RI i = 1; i <= n; ++i)
    if (s[i] == t) { pos = i + 1; break; }
  int ans = 0;
  for (RI i = pos; i <= n; ++i)
    ans += tt[i];
  cout << ans << endl;

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 1024
n = int(input())
a = [int(input()) for _ in range(n)]
d = {}
for i in a:
    if not i in d:
        d[i] = 1
    else:
        d[i] += 1
res = 0
for i in d.values():
    if i % 2 == 1:
        res += 1
print(res)


Measured memory_bytes: 16268
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int n , x;
int a[1010];
int main(){
    cin >> n >> x;
    for(int i = 1 ; i <= n ; ++ i){
        cin >> a[i];
        x -= a[i];
    }
    int ans = n;
    sort(a + 1 , a + n + 1);
    ans += x / a[1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int N, M, C;
    cin >> N >> M >> C;

    vector<int> B;
    for (int i=0; i<M; i++) {
        int t;
        cin >> t;
        B.push_back(t); 
    }

    int n=0;
    for (int i=0; i<N; i++) {
        int sum=0;
        for (int j=0; j<M; j++) {
            int t;
            cin >> t;
            sum += t*B[j];
        }
        if (sum > -C) n++;
    }

    cout << n << endl;

    return 0;
}

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

main()
{
  int N,x,*a;
  int i,j,count=0,m;
  
  scanf("%d%d",&N,&x);
  a = malloc(sizeof (int)*N);
  for(i=0; i<N; i++)
    scanf("%d",&a[i]);
  for(i=N-1;i>0;i--)
    for(j=0;j<i;j++)
      if(a[j]>a[j+1])
      {
        m=a[j];a[j]=a[j+1];a[j+1]=m;
      }
  for(i=0;i<N;i++)
  {
    x-=a[i];
    if(i==N-1&&x>0)
      break;
    else if(x>=0)
      count++;
    else
      break;
  }
  printf("%d\n",count);
}

Measured memory_bytes: 128