akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
// #ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


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

  int ar[n];

  long double total = 0;

  for(int i=0;i<n;i++){
    cin >> ar[i];
    total+=ar[i];
  }

  long deno = 4*m;

  long double need = total/deno;

  int count = 0;

  for(int i=0;i<n;i++){
    if(ar[i]>=need) count++;
  }
  
  if(count>=m) cout << "Yes\n";
  else cout << "No\n";

  return 0;
}

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

int main()
{
    long long int n;
    cin >> n;
    //vector<long long int> a;
    float a=0;
    for(long long int i=0;i<n;i++)
    {
        long long int k;
        cin >> k;
        a+=1/(float)k;
    }
    printf("%0.6f",1/a);
}


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

using namespace std;

bool dfs(const vector<int> &as, int n, int m, int i) {
    if(m==0) return true;
    if(i==n) return false;
    if(m>=as[i] && dfs(as, n, m-as[i], i+1)) return true;
    return dfs(as, n, m, i+1);
}

int main() {
    int n;
    cin >> n;
    vector<int> as(n);
    for(int i=0; i<n; i++) cin >> as[i];
    int q;
    cin >> q;
    for(int i=0; i<q; i++) {
        int m;
        cin >> m;
        cout << (dfs(as, n, m, 0) ? "yes" : "no") << endl;
    }
    
}


Measured memory_bytes: 3092
#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;

int find(vector<pair<size_t, int> >& F, int a) {
  while (F[a].first != a) a = F[a].first;
  return a;
}

void merge(vector<pair<size_t, int> >& F, int a, int b) {
  int ar, br;
  ar = find(F, a);
  br = find(F, b);
  if (ar != br) {
    if (F[ar].second > F[br].second) {
      F[br].first = F[ar].first;
      F[ar].second += F[br].second;
    } else {
      F[ar].first = F[br].first;
      F[br].second += F[ar].second;
    }
  }
}

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<pair<size_t, int> > F(N);
  for (size_t i = 0; i < N; i++) F[i] = make_pair(i, 1);
  for (size_t i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    merge(F, A, B);
  }
  int maxsz = 0;
  for (size_t i = 0; i < N; i++) {
    maxsz = max(maxsz, F[i].second);
  }
  cout << maxsz << endl;
  return 0;
}

Measured memory_bytes: 6408
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
using namespace std;
#define INF 999999999

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

	int n, t, a;
	cin >> n >> t >> a;
	vector<int> h(n);
	REP(i, n) cin >> h[i];

	int mini=0, miniv=INF;
	REP(i, n) {
		int average = t*1000 - h[i]*6;
		int ti = average > a*1000 ? average - a*1000 : a*1000 - average;
		if (ti < miniv) {
			mini = i;
			miniv = ti;
		}
	}

	cout << mini+1 << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<deque>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long ll;

using namespace std;

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

	int N, K;
	cin >> N >> K;
	int a[50] = { 0 };
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a, a + N, greater<int>());
	int ans = 0;
	for (int i = 0; i < K; i++) {
		ans += a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 3624
N = int(input())
H = input().split(" ")
H = [int(i) for i in H]

is_true = False
for i in range(0, len(H)):
  if len(H) <= 1:
    print('Yes')
    is_true = True
  elif i == 0:
    if H[0] <= H[1]:
      H[1] -= 1
    elif H[0] > H[1]+1:
      break
  elif i != N-1:
    if H[i] < H[i+1]:
      H[i+1] -= 1
    elif H[i] > H[i+1]:
      break
  elif i == N-1:
    print('Yes')
    is_true = True

if is_true == False:
  print('No')


Measured memory_bytes: 14836
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

int n;
int x[10], y[10];

double dist(int i, int j){
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

void solve(){
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];

    double sum = 0.0;
    vector<int> v(n);
    for(int i = 0; i < n; i++) v[i] = i + 1;

    do{
        for(int i = 0; i < n - 1; i++) sum += dist(v[i], v[i+1]);
    }while(next_permutation(v.begin(), v.end()));

    int factorial = 1;
    for(int i = 2; i <= n; i++) factorial *= i;

    cout << fixed << setprecision(10) << sum / factorial << endl;

    return;
}

int main(){
    solve();

    return 0;
}

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

struct node
{
    std::vector<std::size_t> neighbors;
};

int main()
{
    std::size_t N, X, Y;
    std::cin >> N >> X >> Y;

    std::vector<node> graph(N);
    for(std::size_t i=1; i<N; ++i)
    {
        graph[i-1].neighbors.push_back(i);
        graph[i].neighbors.push_back(i-1);
    }
    graph[X-1].neighbors.push_back(Y-1);
    graph[Y-1].neighbors.push_back(X-1);

    std::vector<std::size_t> ks(N, 0);

    constexpr std::size_t nil = 0xFFFFFFFFFFFFFFFF;
    for(std::size_t i=0; i<N; ++i)
    {
        std::vector<std::size_t> dist(N, nil);
        std::queue<std::size_t> q;
        q.push(i);
        dist.at(i) = 0;
        while(!q.empty())
        {
            const auto current = q.front();
            q.pop();

            for(const auto n : graph.at(current).neighbors)
            {
                if(dist.at(n) != nil) {continue;}

                dist.at(n) = dist.at(current) + 1;
                q.push(n);

                if(i < n)
                {
                    ks[dist.at(n)] += 1;
                }
            }
        }
    }

    for(std::size_t i=1; i < N; ++i)
    {
        std::cout << ks[i] << std::endl;
    }
    return 0;
}


Measured memory_bytes: 384
n = int(input())
a = [int(_) for _ in input().split()]

maximum = max(a)
others = [0] * (n)
for i in range(n):
    if a[i] != maximum:
        others[i] = min(a[i], maximum - a[i])
    else:
        others[i] = -1
choose = others.index(max(others))
ans = [maximum, a[choose]]
print(*ans)

Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define rep(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define For(i, a, n) for (ll (i) = (a); (i) < (n); (i)++)
#define prl(x) cout << (x) << endl
#define pr(x) cout << (x)
#define all(v) (v).begin(), (v).end()

template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) {return '"' + s + '"';}
string to_string(char c){return string(1, c);}
string to_string(const char* s) {return to_string((string) s);}
string to_string(bool b){return (b ? "true" : "false");}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p){return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p){return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";}
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) res += ", ";
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
  return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template<typename T>
string to_string(priority_queue<T>& q){
    priority_queue<T> copy;
    bool first = true;
    string res = "{";
    while(!q.empty()){
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(q.top());
        copy.push(q.top());
        q.pop();
    }

    swap(q, copy);
    res += "}";
    return res;
}

void debug_out() {cerr << endl;}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef _LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main(void){
    string s, t; ll n, m; map<char, vector<ll>> ms;
    cin >> s >> t; n = s.length(), m = t.length();
    rep(i, n) ms[s[i]].push_back(i);
    rep(i, m) if (ms[t[i]].size() == 0) {prl(-1); return 0;}

    ll cur = 0;
    rep(i, m){
        vector<ll>& v = ms[t[i]]; auto it = lower_bound(all(v), cur % n);
        (cur = cur / n * n + 1) += it == v.end() ? *(v.begin()) + n : *it;
    }

    prl(cur);

    return 0;
}


Measured memory_bytes: 4660
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
vector<int> divisor(int n)
{
	vector<int> ret;
	for (int i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n)	ret.push_back(n / i);
		}
	}
	return ret;
}
int main()
{
	// Tenka1 Programmer Contest-C, 1151, 15:40, First-AC
	/*ll n; cin >> n;
	rep(i, 3501) {
		if (i == 0) continue;
		rep(j, 3501) {
			if (j == 0) continue;
			int l = 0, r = 3500;
			while (l + 1 < r) {
				int m = (l + r) / 2;
				ll left = ll(m) * (ll(4) * ll(i) * ll(j) - n * ll(i) - n * ll(j));
				ll right = n * ll(i) * ll(j);
				if (left == right) {
					cout << i << " " << j << " " << m << endl;
					return 0;
				}
				else if (left < right) l = m;
				else r = m;
			}
		}
	}
	assert(false);
	*/

	// ABC106-B
	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i += 2) {
		vector<int> v = divisor(i);
		if (v.size() == 8) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3572
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

	int n, m;
	scanf("%d %d", &n, &m);

	int M[m];
	for (int i = 0; i < m; ++i) {
		scanf("%d", &M[i]);
	}

	int V[n + 1];
	V[0] = 0;
	for (int i = 1; i <= n; ++i) {
		V[i] = 50000;
	}
	for (int i = 0; i < m; ++i) {
		for (int j = M[i]; j <= n; ++j) {
			V[j] = min(V[j], V[j - M[i]] + 1);
		}
	}
	cout << V[n] << endl;

	return 0;
}

Measured memory_bytes: 3424
INF = float("inf")

def bellman_ford(edges, n, s):
    d = [0] + [INF] * (n-1)
    for i in range(n):
        for f, t, c in edges:
            if d[f] == INF: continue
            if d[t] > d[f] + c:
                if i == n-1: d[t] = -INF
                else: d[t] = d[f] + c
    for i in range(n):
        for f, t, c in edges:
            if d[f] == INF: continue
            d[t] = min(d[t], d[f] + c)
    return d

n, m = map(int, input().split())
es = [None] * m
for i in range(m):
    f, t, c = map(int, input().split())
    es[i] = (f-1, t-1, -c)

d = bellman_ford(es, n, 0)
print(-d[n-1])


Measured memory_bytes: 46440
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  int ab[26]={};
  int i;
  while(getline(cin,str)){
    for(i=0;i<str.size();i++){
      if(str[i]>='a'&&str[i]<='z') ab[str[i]-'a']++;
      else if(str[i]>='A'&&str[i]<='Z') ab[str[i]-'A']++;
    }
  //cout << str << endl;
  }
  for(i=0;i<26;i++){
    cout << (char)('a'+i) << " : " << ab[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3208
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
char m[500][500];
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)scanf("%s", m[i]);
	int cnt = 0;
	bool flag = false;
	for (int i = 0; i < num; i++)
	{
		int t = 0;
		for (int j = 0; j < num; j++)t += (m[j][i] == '#');
		if (t == num)cnt++;
		if (t > 0)flag = true;
	}
	if (!flag)printf("-1\n");
	else
	{
		int mini = 1000000000;
		for (int i = 0; i < num; i++)
		{
			int ca = 0, cb = 0;
			for (int j = 0; j < num; j++)ca += (m[i][j] == '#'), cb += (m[j][i] == '#');
			if (cb == 0)mini = min(mini, num - cnt + 1 + num - ca);
			else mini = min(mini, num - cnt + num - ca);
		}
		printf("%d\n", mini);
	}
}

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

int main()
{
    long long N, W;
    cin >> N >> W;
    vector<long long> w(N);
    vector<long long> v(N);
    vector<vector<long long>> dp(N + 1, vector<long long>(W + 1, 0));

    for (int i = 0; i < N; i++)
    {
        cin >> w.at(i) >> v.at(i);
    }

    for (int i = 0; i <= W; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (i - w.at(j) >= 0)
                dp.at(j + 1).at(i) = max(dp.at(j + 1).at(i), dp.at(j).at(i - w.at(j)) + v.at(j));

            dp.at(j + 1).at(i) = max(dp.at(j + 1).at(i), dp.at(j).at(i));
        }
    }

    cout << dp.at(N).at(W) << endl;
}


Measured memory_bytes: 80256
import sys

H,W = raw_input().split()
a =[]
for line in range(int(H)):
    a.append(raw_input())

for i in range(0,int(W)+2):
    sys.stdout.write("#")
print

for i in range(0,int(H)):
    sys.stdout.write("#")
    for j in range(0,int(W)):
        sys.stdout.write(a[i][j])
    sys.stdout.write("#")
    print

for i in range(0,int(W)+2):
    sys.stdout.write("#")
print


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;

const ll mod = 1e9+7;
int main(){
  ll N; cin >>N;
  vll A(N);
  rep(i,N) cin >> A[i] ;
  ll ans = 0;
  ll temp = 0;
  rep2(i,1,N) temp += A[i];
  temp %= mod;
  ans += temp*A[0];
  ans %= mod;
  rep2(i,1,N-1){
    temp -= A[i];
    if(temp<0) temp += mod;
    ans += (A[i]*temp)%mod;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4788
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
    char S[10];
    cin>>S;
    int n=strlen(S);
    int judge[10];
    int l=0;
    int i=0;
    for(int a=0;a<n;a++){

          if(S[a]=='A' || S[a]=='T' || S[a]=='C' || S[a]=='G') { 
       
          l++;
          
          judge[a]=l;
          }
    
    else{
               judge[a]=0;
               l=0;
    }
    
    }
    int ans=-2;
    for(int j=0;j<n;j++){
        ans=max(ans,judge[j]);
    }
    cout<<ans;
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> V(N);
  int ac = 0, pn = 0;
  for (int i = 0; i < M; i++) {
    int p;
    string S;
    cin >> p >> S;
    p--;
    if (V.at(p) == -1) continue;
    else {
      if (S == "AC") ac++, pn += V.at(p), V.at(p) = -1;
      else V.at(p)++;
    }
  }
  cout << ac << "\n";
  cout << pn << "\n";
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
#include <numeric>
#include <iomanip>
using namespace std;

int main(){
    int n;
    cin >> n;
    int m=n;
    for(int i=0;;i++){
        if(m%4==0){
            cout << "Yes";
            return 0;
        }
        m-=7;
        if(m<=0){
            break;
        }
    }
    for(int j=0;;j++){
        if(n%7==0){
            cout << "Yes";
            return 0;
        }
        n-=4;
        if(n<=0){
            break;
        }
    }
    cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
	
	int i;
	string s;
	cin >> s;
	for (i = 0; i < (int)s.size(); i++) {
		if (s[i] == '?')
			s[i] = 'D';
	}
	cout << s << "\n";
	return 0;
}


Measured memory_bytes: 3768
#include<stdio.h>
int main(void)
{
	int N,a,max=0,min=1000,i;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&a);
		if(max<a) max=a;
		if(min>a) min=a;
	}
	printf("%d\n",max-min);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main() {
	int ans1 = 0, ans2 = 0;
	string S;
	cin >> S;
	if (S.size() % 2 == 1 && S[0] == '0'){
		S.push_back(0);
		ans1--;
	}
	if (S.size() % 2 == 1 && S[0] == '1'){
		S.push_back(1);
		ans2--;
	}
	for (int i = 1; i < S.size(); i += 2) {
		if (S[i] != '1') {
			ans1++;
		}
		if (S[i - 1] != '0') {
			ans1++;
		}
	}




	for (int i = 1; i < S.size(); i += 2) {
		if (S[i] != '0') {
			ans2++;
		}
		if (S[i - 1] != '1') {
			ans2++;
		}
	}


	cout << min(ans1, ans2) << endl;
	return 0;
}


Measured memory_bytes: 512
N = int(input())
XY = [list(map(int,input().split())) for _ in range(N)]
w,z = [],[]
for x,y in XY:
    w.append(x-y)
    z.append(x+y)

a,b = max(w)-min(w),max(z)-min(z)
print(max(a,b))

Measured memory_bytes: 61420
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int dp[3010][3010];
string s,t;
int main(void){
    cin >> s >> t;
    for(int i = 0;i < s.size();i++){
        for(int j = 0;j < t.size();j++){
            if(s[i] == t[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
            chmax(dp[i+1][j+1],dp[i+1][j]);
            chmax(dp[i+1][j+1],dp[i][j+1]);
        }
    }
    
    string ans = "";
    int i = s.size(),j = t.size();
    while(i > 0 && j > 0){
        if(dp[i][j] == dp[i-1][j]) i--;
        else if(dp[i][j] == dp[i][j-1]) j--;
        else{
            ans = s[i-1] + ans;
            i--;
            j--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35584
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

bool check(string str) {
    int l = 0;
    int r = str.length()-1;

    while (l < r) {
        if (str[l] != str[r]) return false;
        l++;
        r--;
    }

    return true;
}

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

    string s;
    cin >> s;

    if (check(s) and check(s.substr(0, (s.length()-1)/2)) and check(s.substr((s.length()+3)/2-1))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    // cout << s.substr(0, (s.length()-1)/2) << endl;
    // cout << s.substr((s.length()+3)/2-1) << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int f(int x){
  return 0.5*x*(x+1);
}

int main() {
  int n,k;
  cin >> n >>k;
  vi p(n);
  rep(i,n)cin >> p[i];

  vector<double> q(n);

  rep(i,n){
    q[i] = (double)f(p[i])/(double)p[i];
  }
  
  vector<double> s(n+1,0);

  rep(i,n) s[i+1] = s[i]+q[i];

  double e = 0.0;

  rep(i,n){
    if(i+k > n) continue;
    maxs(e,s[i+k]-s[i]);
  }
  cout << fixed << setprecision(10)<<e<<endl;
  return 0;
}

Measured memory_bytes: 4096
#!/usr/bin/env python3
import sys
from collections import Counter


def solve(N: int, S: "List[str]"):
    cnt = Counter()
    for s in S:
        cnt[s] += 1
    
    lst = []
    mx = max(cnt.values())
    for key, val in cnt.items():
        if val == mx:
            lst += [key]

    for word in sorted(lst):
        print(word)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 35552
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {

    const lines = input.split('\n')
    const N = lines[0] - 0
    const a = lines[1].split(' ').map(Number)

    let ans1 = 0
    let sum = 0
    for (let i = 0; i < N; i++) {
        const odd = i % 2
        if (!odd & sum + a[i] > 0) {
            sum += a[i]
        } else if (odd & sum + a[i] < 0) {
            sum += a[i]
        } else {
            ans1 += Math.abs(sum + a[i] - (odd ? -1 : 1))
            sum = odd ? -1 : 1
        }
    }

    let ans2 = 0
    sum = 0
    for (let i = 0; i < N; i++) {
        const odd = (i + 1) % 2
        if (!odd & sum + a[i] > 0) {
            sum += a[i]
        } else if (odd & sum + a[i] < 0) {
            sum += a[i]
        } else {
            ans2 += Math.abs(sum + a[i] - (odd ? -1 : 1))
            sum = odd ? -1 : 1
        }
    }

    console.log(Math.min(ans1, ans2))

})(input)


Measured memory_bytes: 41360
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        String ans = "Yes";

        int n = sc.nextInt();

        int[] list = new int[n];

        for (int i = 0; i < n; i++) {
            list[i] = sc.nextInt();
        }

        int lastValue = list[n - 1];
        for (int i = n - 2; i >= 0; i--) {
            int value = list[i];
            if (value > lastValue) {
                if (value - lastValue == 1) {
                    value--;
                } else {
                    ans = "No";
                    break;
                }
            }
            lastValue = value;
        }

        System.out.println(ans);
    }
}

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

int main() {
	int n,k,q;
	cin >> n >> k >> q;
	vector<int> a(q);
	for(int i=0; i<q; i++){
		cin >> a.at(i);
	}
	vector<int> score(n);
	for(int i=0; i<n; i++){
		score.at(i) = k-q;
	}
	for(int i=0; i<q; i++){
		score.at(a.at(i)-1) += 1;
	}
	for(int i=0; i<n; i++){
		if(score.at(i)>0){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 1408
N , M , X = list(map(int, input().split()))
C = []
for _ in range(N):
    C.append(list(map(int, input().split())))
ans = 10**9
for i in range(2**N):
    i_bin = (bin(i)[2:]).zfill(N)
    flag = True
    for j in range(1,M+1):
        tot = sum([ int(i_bin[k])* C[k][j] for k in range(N)])
        if tot < X:
            flag = False
    am = sum([ int(i_bin[k]) * C[k][0] for k in range(N)])
    if flag and am<ans:
        ans = am

if ans == 10**9:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 74920
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

template<int MOD> struct modint {
    long long val;
    constexpr modint(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr modint operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr modint operator + (const modint& r) const noexcept { return modint(*this) += r; }
    constexpr modint operator - (const modint& r) const noexcept { return modint(*this) -= r; }
    constexpr modint operator * (const modint& r) const noexcept { return modint(*this) *= r; }
    constexpr modint operator / (const modint& r) const noexcept { return modint(*this) /= r; }
    constexpr modint& operator += (const modint& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr modint& operator -= (const modint& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr modint& operator *= (const modint& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr modint& operator /= (const modint& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const modint& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const modint& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const modint<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr modint<MOD> modpow(const modint<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = modint<MOD>;

int n, a[2010];
ll k;

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

    vector<ll> l(n), r(n);
    rep(i, n) rep(j, n) {
        if (a[j] >= a[i]) continue;
        if (j < i) l[i]++;
        if (j > i) r[i]++;
    }

    mint ans = 0;
    rep(i, n) {
        ans += mint(k) * mint(r[i]);
        ans += mint(k*(k-1)/2) * mint(l[i] + r[i]);
    }
    cout << ans << endl;
}


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

int main(){
    int N;
    cin>>N;
    vector<int> d;
    int ans=0;
    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        d.push_back(x);
        if(i>1){
            if(d.at(i)>d.at(i-1) && d.at(i-1)>d.at(i-2)) ans++;
            if(d.at(i)<d.at(i-1) && d.at(i-1)<d.at(i-2)) ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <boost/dynamic_bitset.hpp>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;
 
int main() {
	uint H, W;
	cin >> H >> W;
	
	vector<vector<uint>> AB(H, vector<uint>(W));

	for(uint i=0; i<H; i++) {
		for(uint j=0; j<W; j++) {
			cin >> AB[i][j];
		}
	}
	
	for(uint i=0; i<H; i++) {
		for(uint j=0; j<W; j++) {
			int B;
			cin >> B;
			AB[i][j] = abs((int)AB[i][j] - B);
		}
	}
	
	uint nbit = 80 * (H + W) * 2 + 1;
	uint p0 = 80 * (H + W);
	vector<vector<boost::dynamic_bitset<>>> dp(2, vector<boost::dynamic_bitset<>>(W, boost::dynamic_bitset<>(nbit)));
	
	dp[1][0].set(p0);
	
	for(uint i=0; i<H; i++) {
		uint i0 = i % 2;
		uint i1 = (i + 1) % 2;
			
		for(uint j=0; j<W; j++) {
			dp[i0][j] = (dp[i1][j] << AB[i][j]) | (dp[i1][j] >> AB[i][j]);
			//cout << i << " " << j << " " << dp[i0][j] << endl;
		}
		
		for(uint j=1; j<W; j++) {
			dp[i0][j] = dp[i0][j] | (dp[i0][j-1] << AB[i][j]) | (dp[i0][j-1] >> AB[i][j]);
			//cout << i << " " << j << " " << dp[i0][j] << endl;
		}
	}
	
	for(uint i=0; i<=nbit/2; i++) {
		if(dp[(H-1)%2][W-1][p0+i]) {
			cout << i;
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;

long long n, k;

string Tostring(long long num){
	stringstream ss;
	ss << num;
	return ss.str();
}

void func(int t){
	long long po = 1;
	rep(i,t-1) po *= 10;
	if(n > po*9*t){
		n -= po*9*t;
		return;
	}
	long long m = n;
	m /= t;
	n -= m*t;
	long long num = po+m;
	if(n == 0){
		n += t;
		num--;
	}
	
	while(k > 0){
		string str = Tostring(num);
		rep(i,str.size()){
			if(n > 1){
				n--;
				continue;
			}
			if(k <= 0) break;
			cout << str[i];
			k--;
		}
		num++;
		if(num >= po*10) break;
	}
}

void solve(){
	for(int i = 1; i <= 10; i++){
		func(i);
		if(k == 0) break;
	}
	cout << endl;
}

int main(){
	while(cin >> n >> k){
		if(n == 0 && k == 0) break;
		solve();
	}
}

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

int main() {
  vector<int> cnt(4, 0);
  for (int i = 0; i < 3; ++i) {
    int v, u;
    cin >> v >> u;
    v--; u--;
    cnt[v]++; cnt[u]++;
  }

  bool is_valid = true;
  for (int i = 0; i < 4; ++i) {
    if (cnt[i] > 2) is_valid = false;
  }

  if (is_valid) puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<numeric>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int N, A, B;

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

	int dist = B - A - 1;
	if (dist % 2 == 0) {
		cout << "Borys" << endl;
	}
	else if (dist % 2 == 1) {
		cout << "Alice" << endl;
	}

	return 0;
}

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

void result(int ok) {
 if(ok)
  	cout <<"YES" << endl;
  else
    cout << "NO" << endl;
}

int main(void) {
  string str;
  cin >> str;
  
  int i = 0;
  int size = str.size();
  string keyence = "keyence";
  int size_out = keyence.size();
  
  if(size < size_out)  
  {
    cout << "aa" << endl;
    result(0);
    return 0;
  }
  else {
    for(i=0;i<size_out;i++) {
    	string first = str.substr(0,i);
        string last = str.substr(size - (size_out-i),size_out-i);
        if(i == 0){
          if(str.compare(keyence) == 0) {
            result(1);return 0;
          }
        }
        else if(first.compare(0, i, keyence, 0, i) == 0) {
          if(last.compare(0, size_out - i, keyence, i, size_out - i) == 0) {
          	result(1);
            return 0;
          }
        }
    }
  }
  result(0);
  return 0;
  
  
 return 0; 
}

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

int main() {
	int x, a, b;
	cin >> x >> a >> b;

	if (b - a <= 0) cout << "delicious" << endl;
	else if (b - a > 0 && b - a <= x) cout << "safe" << endl;
	else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.TreeMap;
import java.util.Map;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ESequenceDecomposing solver = new ESequenceDecomposing();
        solver.solve(1, in, out);
        out.close();
    }

    static class ESequenceDecomposing {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int cnt = 0;
            TreeMap<Integer, Integer> tm = new TreeMap<>();
            for (int i = 0; i < n; i++) {
                int k = in.nextInt();
                if (tm.lowerKey(k) == null) {
                    cnt++;
                } else {
                    int lk = tm.lowerKey(k);
                    tm.merge(lk, -1, Integer::sum);
                    if (tm.get(lk) == 0) {
                        tm.remove(lk);
                    }
                }
                tm.merge(k, 1, Integer::sum);
            }

            out.println(cnt);

        }

    }
}



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

using namespace std;

template <class T, class UnaryPredicate>
vector<int> FindPositions(const vector<T> &vec, UnaryPredicate pred)
{
    vector<int> pos;
    auto it = find_if(vec.begin(), vec.end(), pred);

    while (it != vec.end()) {
        pos.push_back(it - vec.begin());
        it = find_if(next(it, 1), vec.end(), pred);
    }
    return pos;
}

vector<int> GetSums(const vector<int> &nums, int max_sum)
{
    vector<bool> possible(max_sum + 1, false);
    possible[0] = true;

    for (const auto &num : nums) {
        for (int i = 0; i + num <= max_sum; i += 1) {
            if (possible[i]) {
                possible[i + num] = true;
            }
        }
    }
    return FindPositions(possible, [](bool b) { return b; });
}

double GetDensity(int water, int sugar)
{
    if (water + sugar <= 0) {
        return 0;
    }
    return 100.0 * sugar / (water + sugar);
}

bool ValidSubstance(int water, int sugar, int dissolution_rate, int max_substance)
{
    if (water + sugar > max_substance) {
        return false;
    }
    if (water == 0) {
        return false;
    }
    if (dissolution_rate * water < 100 * sugar) {
        return false;
    }
    return true;
}

int main()
{
    int water_a, water_b;
    cin >> water_a >> water_b;

    int sugar_a, sugar_b;
    cin >> sugar_a >> sugar_b;

    int dissolution_rate, max_substance;
    cin >> dissolution_rate >> max_substance;

    auto water = GetSums({100 * water_a, 100 * water_b}, max_substance);
    auto sugar = GetSums({sugar_a, sugar_b}, max_substance);

    double best_density = 0;
    int best_water = 0;
    int best_sugar = 0;

    for (const auto &w : water) {
        for (const auto &s : sugar) {
            if (!ValidSubstance(w, s, dissolution_rate, max_substance)) {
                continue;
            }

            double density = GetDensity(w, s);
            if (density >= best_density) {
                best_density = density;
                best_water = w;
                best_sugar = s;
            }
        }
    }

    cout << best_water + best_sugar << " " << best_sugar << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>
using namespace std;
int main(){
	int n,q,t,sum=0;
	string name;
	queue< pair<string, int> >que;

	cin >> n >> q;

	for (int i = 0; i < n; i++){
		cin >> name >> t;
		que.push(make_pair(name,t));
		}	

	while (!que.empty()){
		pair<string, int>p = que.front(); que.pop();

		if (p.second <= q){
			sum += p.second;
			cout << p.first << " " << sum << endl;
		}
		else if (p.second > q){
			sum += q;
			que.push(make_pair(p.first, p.second - q));
		}
	}

	return 0;
}

Measured memory_bytes: 4408
#include<stdio.h>
int main()
{
while(1){
   int x, y;
   scanf("%d %d", &x, &y);
   if(x == 0 && y == 0){
      break;
   }
   if(x > y){
      int z = x;
      x = y;
      y = z;
   }
   printf("%d %d\n", x, y);
 }
}


Measured memory_bytes: 2008
import sys

dict = {}
for i in range(97, 123):
    dict[chr(i)] = 0

lines = sys.stdin.readlines()

for line in lines:
    for i in range(len(line)):
        c = line[i].lower()
        if ord(c) >= 97 and ord(c) <= 123:
            dict[c] += 1

l = list(dict.items())
for i in l:
    print(f'{i[0]} : {i[1]}')


Measured memory_bytes: 5576
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,q;cin>>n>>q;
    int S,T,X;
    vector<tuple<int,int,int>> time;
    rep(i,n){
        cin>>S>>T>>X;
        time.push_back(make_tuple(S-X,1,X));
        time.push_back(make_tuple(T-X,-1,X));
    }
    int d;
    rep(i,q){
        cin>>d;
        time.push_back(make_tuple(d,2,0));
    }
    sort(all(time));
    vin ans;
    set<int> st;
    int t,tmp,x;
    rep(i,2*n+q){
        t=get<0>(time[i]);
        tmp=get<1>(time[i]);
        x=get<2>(time[i]);
        if(tmp==1)st.insert(x);
        else if(tmp==-1)st.erase(x);
        else{
            if(st.size()==0)ans.push_back(-1);
            else ans.push_back(*(st.lower_bound(-inf)));
        }
    }
    rep(i,q)cout<<ans[i]<<endl;
}

Measured memory_bytes: 21504
#include<cstdio>
using namespace std;
#include<vector>
template<typename T>
struct lazysegtree{
	int n;
	vector<T>dat,lazy;
	vector<bool>lazyflag;
	lazysegtree(int n_=0)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,0);
		lazy.assign(2*n-1,0);
		lazyflag.assign(2*n-1,false);
	}
	void eval(int i,int l,int r)
	{
		if(lazyflag[i])
		{
			dat[i]=lazy[i]*(r-l);
			if(r-l>1)
			{
				lazy[2*i+1]=lazy[i];
				lazy[2*i+2]=lazy[i];
				lazyflag[2*i+1]=lazyflag[2*i+2]=true;
			}
			lazy[i]=0;
			lazyflag[i]=false;
		}
	}
	void update(int a,int b,T x,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return;
		else if(a<=l&&r<=b)
		{
			lazy[k]=x;
			lazyflag[k]=true;
			eval(k,l,r);
		}
		else
		{
			update(a,b,x,2*k+1,l,(l+r)/2);
			update(a,b,x,2*k+2,(l+r)/2,r);
			dat[k]=dat[2*k+1]+dat[2*k+2];
		}
	}
	T query(int a,int b,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return 0;
		else if(a<=l&&r<=b)return dat[k];
		else return query(a,b,2*k+1,l,(l+r)/2)+query(a,b,2*k+2,(l+r)/2,r);
	}
};
int N,Q;
main()
{
	scanf("%d%d",&N,&Q);
	lazysegtree<long>P(N);
	for(;Q--;)
	{
		int a;long b;
		scanf("%d%ld",&a,&b);
		long V;
		int l=-1,r=a;
		while(r-l>1)
		{
			int m=l+r>>1;
			long L=P.query(m,m+1)-1;
			long pL=L;
			long R=m==0?2e13:P.query(m-1,m)+1;
			long S=P.query(m,a);
			while(R-L>1)
			{
				long M=L+R>>1;
				if(M*(a-m)-S>b)R=M;
				else L=M;
			}
			if(pL==L)l=m;
			else
			{
				r=m;
				V=L;
			}
		}
		b-=V*(a-r)-P.query(r,a);
		P.update(r,a,V);
		P.update(r,r+b,V+1);
	}
	for(int i=0;i<N;i++)printf("%ld\n",P.query(i,i+1));
}


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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}
int digits(ll a){
  int res=0;
  while(a>0){
    res++;
    a/=10;
  }
  return res;
}
int sum_digits(ll a){
  int res=0;
  while(a>0){
    res+=a%10;
    a/=10;
  }
  return res;
}
unsigned long long bigger_calc(ll a,ll b){
  return sum_digits(b)*a>=sum_digits(a)*b;
}

int K;

int main(){
  cin>>K;
  ll add=1,current=0;
  while(K>0){
    if(bigger_calc(current+add*2,current+add)){
    }else{
      add*=10;
    }
    current+=add;
    cout<<current<<endl;
    K--;
  }
  return 0;
}


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

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

    int cnt = 0;
    if (s[0] == '1') cnt++;
    if (s[1] == '1') cnt++;
    if (s[2] == '1') cnt++;
    cout << cnt << endl;
}


Measured memory_bytes: 256
a,b=map(int,input().split())

if(a%2==0):
  y1=[a*12.5,(a+1)*12.5]
else:
  y1=[a*12.5+0.5,(a+1)*12.5]  

y2=[b*10,(b+1)*10]

if(y1[0]<=y2[0] and y2[0]<y1[1]):
  print(int(y2[0]))
elif(y2[0]<=y1[0] and y1[0]<y2[1]):
  print(int(y1[0]))
else:
  print("-1")

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

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int A, B,X;
	cin >> X >> A >> B;
	cout << (X - A) % B << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define N 100

int main(){
  char str_base[N];
  char str[N+100];
  char str_in[N];

  scanf("%s",str_base);

  strcpy(str,str_base);
  strcat(str,str_base);

  scanf("%s",str_in);
 
  if(strstr(str,str_in)==NULL){
    printf("No\n");
  }else{
    printf("Yes\n");
  }

  return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  cout << (s.at(0)==s.at(1) && s.at(1)!=s.at(2) && s.at(2)==s.at(3) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import bisect
from collections import Counter
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n, m = LI()
a = LI()
a = sorted(a)[::-1]
bc = LIR(m)
bc = sorted(bc, key=lambda x: x[1])[::-1]
all_c = []
for bi, ci in bc:
    all_c += [ci] * bi
    if len(all_c) >= n:
        break
if len(all_c) < n:
    all_c += [0] * (n - len(all_c))

ans = 0
a_i = 0
c_i = 0
for _ in range(n):
    if a[a_i] > all_c[c_i]:
        ans += a[a_i]
        a_i += 1
    else:
        ans += all_c[c_i]
        c_i += 1
print(ans)


Measured memory_bytes: 35064
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 char s,t;
 sc(s);sc(t);
 if(s==t)puts("H");
 else puts("D");
return 0;}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdlib>
#include <stack>
#include <cstdio>
using namespace std;

int main() {
    stack<int> S;
    string s;
    while (cin >> s) {
        int a, b;
        switch (s[0]) {
            case '+':
                a=S.top(); S.pop();
                b=S.top(); S.pop();
                S.push(a+b);
                break;
            case '-':
                b=S.top(); S.pop();
                a=S.top(); S.pop();
                S.push(a-b);
                break;
            case '*':
                a=S.top(); S.pop();
                b=S.top(); S.pop();
                S.push(a*b);
                break;
            default:
                S.push(atoi(s.c_str()));
                break;
        }
    }
    printf("%d\n",S.top());
    return 0;
}

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

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

    x/=200;

    cout << 10-x << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
inline int read(){
	int f=1,ans=0;char c;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}
const int MAXN=3001;
int n,a[MAXN];
struct node{
	int u,v,nex;
}x[MAXN<<1];
int head[MAXN],cnt;
void add(int u,int v){
	x[cnt].u=u,x[cnt].v=v,x[cnt].nex=head[u],head[u]=cnt++;
}
int f[MAXN];
void dfs(int u,int fath){
	for(int i=head[u];i!=-1;i=x[i].nex){
		if(x[i].v==fath) continue;
		if(a[u]<=a[x[i].v]) continue;
		dfs(x[i].v,u);
		if(!f[x[i].v]) f[u]=1;
	}return;
}
int main(){
	memset(head,-1,sizeof(head));
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<n;i++){int u=read(),v=read();add(u,v),add(v,u);}
	for(int i=1;i<=n;i++){
		memset(f,0,sizeof(f));
		dfs(i,0);
		if(f[i]) printf("%d ",i);
	}printf("\n");return 0; 
}


Measured memory_bytes: 384