akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

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

        int n = sc.nextInt();
        List<String> list = new ArrayList<>();
        int count = 1;

        for(int i = 0 ; i < n ; i++){
            list.add(sc.next());
        }

        Collections.sort(list);

        for(int i = 0 ; i < n - 1 ; i++){
            if(list.get(i).equals(list.get(i+1))){
            }else{
                count++;
            }
        }

        System.out.println(count);
        
        
        

        






    }
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    if (a+b == c+d)
        cout << "Balanced" << endl;
    else if (a+b < c+d)
        cout << "Right" << endl;
    else if (a+b > c+d)
        cout << "Left" << endl;
}

Measured memory_bytes: 256
def DE(n):
    return float((float(n)+1)/2)

def main():
    N,K = map(int,input().split())
    p = list(map(DE,input().split()))
    ans = 0
    tmp = [sum(p[:K])]
    for i in range(K,N):
        tmp.append(tmp[i-K]+p[i]-p[i-K])
    print(max(tmp))

if __name__ == '__main__':
    main()

Measured memory_bytes: 22884
# https://atcoder.jp/contests/abc137/tasks/abc137_c

from collections import defaultdict

def nC2(n):
    return n * (n - 1) // 2

n = int(input())
d = defaultdict(int)
for _ in range(n):
    s = list(input())
    s.sort()
    s = ''.join(s)
    d[s] += 1

ans = 0
for k, v in d.items():
    ans += nC2(v)
print(ans)


Measured memory_bytes: 62424
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){

	int N,A;
	cin>>N>>A;
	
	cout<<N*N-A<<endl;
	
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
const Int MOD = 1000000007;
const Int MAX = 500000;
Int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
Int COM(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
Int POW(Int x, Int y) {
    if (y == 0) return 1;
    if (y % 2 == 0) return POW(x*x%MOD, y/2);
    return x * POW(x, y-1) % MOD;
}
int main() {
    COMinit();
    int N; cin >> N;
    vector<vector<int>> G(N);
    vector<int> A(N), B(N), sz(N), ans(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    auto recur = [&](auto&& recur, int node, int par) -> void {
        Int k = 1;
        for (auto child : G[node]) if (child != par) {
            recur(recur, child, node);
            sz[node] += sz[child];
            k = k * finv[sz[child]] % MOD * A[child] % MOD;
        }
        k = k * fac[sz[node]] % MOD;
        sz[node]++;
        A[node] = k;
    };
    recur(recur, 0, -1);
    auto recur2 = [&](auto&& recur2, int node, int par) -> void {
        vector<int> children;
        for (auto child : G[node]) if (child != par) children.push_back(child);
        Int k = 1;
        for (auto child : children) {
            k = k * finv[sz[child]] % MOD * A[child] % MOD;
        }
        k = k * finv[N - sz[node]] % MOD * B[node] % MOD;
        ans[node] = k * fac[N - 1] % MOD;
        for (auto child : children) {
            B[child] = k * fac[N - 1 - sz[child]] % MOD
                * fac[sz[child]] % MOD * POW(A[child], MOD-2) % MOD;
            recur2(recur2, child, node);
        }
    };
    B[0] = 1;
    ans[0] = A[0];
    recur2(recur2, 0, -1);
    for (auto a : ans) cout << a << '\n';
    return 0;
}


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

int main() {
    string str; cin >> str;
    int q; cin >> q;
    while (q--) {
        string com; cin >> com;
        if (com == "print") {
            int a, b; cin >> a >> b; b++;
            cout << str.substr(a, b - a) << endl;
        } else if (com == "reverse") {
            int a, b; cin >> a >> b; b++;
            reverse(str.begin() + a, str.begin() + b);
        } else if (com == "replace") {
            int a, b; cin >> a >> b; b++;
            string p; cin >> p;
            str.replace(a, b - a, p);
        }
    }
    return 0;
}


Measured memory_bytes: 3232
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using ll = unsigned long long;
using namespace std;

int main(void) {
    int n,d;
    cin >> n >> d;
    int check = 1+d*2;

    cout << ceil(double(n)/check) << endl;

    return 0;
}

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

/*
階乗の問題。Nはたかだが8なので40320通りで十分間に合う。
next_permutationでやるか
*/

double calc_dist(int x1, int y1, int x2, int y2) {
    return sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
}

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

    vector<int> X(N), Y(N);
    for (int i = 0; i < N; i++)
    {
        cin >> X[i];
        cin >> Y[i];
    }

    vector<int> P(N);
    for (int i = 0; i < N; i++)
    {
        P[i] = i;
    }

    double dist_sum = 0.0;
    int cnt = 0;
    do
    {
        cnt++;
        /* code */
        for (int i = 0; i < N-1; i++)
        {
            int i1 = P[i];
            int i2 = P[i + 1];
            dist_sum += calc_dist(X[i1], Y[i1], X[i2], Y[i2]);
        }

    } while (next_permutation(P.begin(), P.end()));

    cout << fixed << setprecision(10) << dist_sum / cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long n,m,c,k,h;
long long a[1010],b[1010];
long long dp[5010];
int main()
{
	cin>>n>>m;
	for(int i=0;i<=(1<<n);i++)
		dp[i]=9999999999;
	for(int i=0;i<m;i++)
	{
		cin>>a[i]>>c;
		h=0;
		for(int o=0;o<c;o++)
		{
			cin>>k;
			h+=(1<<k-1);
		}
		b[i]=h;
	}
	dp[0]=0;
	for(int i=0;i<(1<<n);i++)
	{
		for(int o=0;o<m;o++)
		{
			dp[i | b[o]]=min(dp[i | b[o]],dp[i]+a[o]);
		}
	}
	if(dp[(1<<n)-1]==9999999999)
		cout<<"-1"<<endl;
	else
		cout<<dp[(1<<n)-1]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX_V 4005
typedef pair<ll,ll> P;
ll INF=(1LL<<40);

struct edge { ll to,cap,cost,rev; };

int V;
vector<edge> G[MAX_V];
ll h[MAX_V];
ll dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void init_edge(){
  for(int i=0;i<V;i++)G[i].clear();
}

void add_edge(int from,int to,int cap,ll cost){
  G[from].push_back((edge){to,cap,cost,(int)G[to].size()});
  G[to].push_back((edge){from,0,-cost,(int)G[from].size()-1});
}

ll min_cost_flow(int s,int t,int f){
  ll res = 0;
  fill(h,h+V,0);
  while(f>0){
    
    priority_queue< P, vector<P>, greater<P> >  que;
    fill( dist, dist+V , INF );
    dist[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      int v = p.second;
      if(dist[v]<p.first)continue;
      for(int i=0;i<(int)G[v].size();i++){
        edge &e = G[v][i];
        if(e.cap>0&&dist[e.to] > dist[v]+e.cost+h[v]-h[e.to]){
          dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
          prevv[e.to]=v;
          preve[e.to]=i;
          que.push(P(dist[e.to],e.to));
        }
      }
    }

    if(dist[t]==INF){
      return -1;
    }

    for(int v=0;v<V;v++)h[v]+=dist[v];
    ll d=f;
    for(int v=t;v!=s;v=prevv[v]){
      d=min(d,G[prevv[v]][preve[v]].cap);
    }
    f-=d;
    res+=(ll)d*h[t];
    for(int v=t;v!=s;v=prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }


  }
  return res;
}


void init(){
  for(int i=0;i<MAX_V;i++)
    G[i].clear();
}


typedef pair< P , ll > PP;

int main(){
  int N;
  while(1){
    cin>>N;
    if(N==0)break;
    init();
    vector<PP> t(N);
    for(int i=0;i<N;i++){
      int a,b,c;
      cin>>a>>b>>c;
      if(a<b)swap(a,b);
      if(b<c)swap(b,c);
      if(a<b)swap(a,b);
      t[i]=PP( P(a,b) , c);
    }
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    ll MAX=1e7;
    
    for(int i=0;i<N;i++){
      for(int j=i+1;j<N;j++){
        if(t[i].first.first>t[j].first.first)
          if(t[i].first.second>t[j].first.second)
            if(t[i].second>t[j].second){
              ll value=t[j].first.first*t[j].first.second*t[j].second;
              //              cout<<MAX-value<<endl;
              add_edge(i,N+j,1,MAX-value);
            }
      }
    }

    V=N+N+2;
    int si=V-2;
    int ti=V-1;

    ll sum=0;
    for(int i=0;i<N;i++){
      sum+= t[i].first.first*t[i].first.second*t[i].second;
      add_edge(si,i,1,0);
      add_edge(N+i,ti,1,0);
    }
    
    add_edge(si,ti,N,MAX);
    
    ll ans=min_cost_flow(si,ti,N);
    ans-=MAX*N;
    ans=-ans;
    cout<<sum-ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 3572
import sys
input = sys.stdin.readline

import heapq
N,M = (int(x) for x in input().split())
pref = [[] for _ in range(N)]
ans = [0] * M
prefnumber = 0
for i in range(M):
    P,Y = (int(x) for x in input().split())
    pref[P-1].append((Y,i))
for p in pref:
    prefnumber += 1
    count = 1
    if p:
        heapq.heapify(p)
        while p:
            temp = heapq.heappop(p)
            ans[temp[1]] = ''.join([str(prefnumber).zfill(6),str(count).zfill(6)])
            count += 1
print('\n'.join(ans))

Measured memory_bytes: 29660
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	std::string s, t; cin >> s >> t;
	int a, b; scanf("%d%d", &a, &b);
	std::string u; cin >> u;

	if(s == u) a--;
	if(t == u) b--;
	printf("%d %d\n", a, b);
	return 0;
}


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

int main() {
  int YABAI, WAYO, MRKT = 0;
  string TKSS, EKSA, LAPLAND;
  cin >> YABAI >> WAYO;
  
  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
  
  vector<string> OOTJNY(50);
  
  for(int YUNI = 0; YUNI < YABAI; YUNI++){
    cin >> OOTJNY.at(YUNI);
  }
  
  for(int YUNI = 0; YUNI < YABAI; YUNI++){
    for(int HODO = 0; HODO < WAYO; HODO++){
      if(OOTJNY.at(YUNI).at(HODO) == '#') continue;
      int PKRN = 0;
      
      for(int LINER = 0; LINER < 8; LINER++){
        const int OOT = YUNI + dy[LINER];
        const int JNY = HODO + dx[LINER];
        
        if(OOT < 0 || YABAI <= OOT){
          continue;
        }
        if(JNY < 0 || WAYO <= JNY) {
          continue;
        }
        if(OOTJNY.at(OOT).at(JNY) == '#'){
          PKRN ++;
        }
      }
      OOTJNY.at(YUNI).at(HODO) = char(PKRN + '0');
    }
  }
  
  for (int YUNI = 0; YUNI < YABAI; YUNI++){
    cout << OOTJNY.at(YUNI) << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll m;
    cin>>m;
    ll d;
    ll c;
    ll ans=0;
    queue<ll> q;
    for(int i=0;i<m;i++){
    	cin>>d>>c;
    	while(c){
    		if(d>=10){
    			d=d%10+d/10;
    			ans+=c;
    		}
    		else if(c%2==0){
    			d*=2;
    			c/=2;
    			ans+=c;
    		}
    		else{
    			q.push(d);
    			d*=2;
    			c/=2;
    			ans+=c;
    		}
    	}
    }
    d=q.front();
    q.pop();

    while(!q.empty()){
    	if(d>=10){
    		d=d%10+d/10;
    		ans++;
    	}
    	d+=q.front();
    	q.pop();
    	ans++;
    }
    if(d>=10){
    	ans++;
    }
    cout <<ans<<endl;

    return 0;
}


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



int main() {
  int n;

  string s;

  cin >> n >> s;

  int flag = 0;

  for(int i = 0; i<=n-3; i++){
    if(s.at(i) == 'A' && s.at(i+1) == 'B' && s.at(i+2) == 'C')
    flag++;
  }

  cout << flag;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>

int max(int,int);

int main(void){
  char str[200];
  int a,b,i;
  
  while(1){
    for(i=0;i<200;i++){
      str[i]='\0';
    }
    scanf("%[^\n]%*c",str);
    a=0;
    b=0;
    if(str[0]=='0')break;
    
    for(i=1;str[i]!='\0';i++){  
      if(str[i]=='A')a++;
      else if(str[i]=='B')b++;
    }
    
    if(a==max(a,b))a++;
    else if(b==max(a,b))b++;
    printf("%d %d\n",a,b);
  }
  
  return 0;
}

int max(int x,int y){
  return (x<y)?y:x;
}

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


int main()
{
  int N, M, a, d, X[200000], Y[200000], Z[200000], K;
  cin >> N;
  cin >> a >> d;
  cin >> M;
  for(int i = 0; i < M; i++) {
    cin >> X[i] >> Y[i] >> Z[i];
  }
  cin >> K;
  
  for(int i = M - 1; i >= 0; i--) {
    if(X[i] == 0) {
      if(Y[i] <= K && K <= Z[i]) {
        K = Y[i] + Z[i] - K;
      }
    }
  }

  long long value = a + (K - 1) * d;

  for(int i = 0; i < M; i++) {
    if(X[i] == 0) {
      if(Y[i] <= K && K <= Z[i]) {
        K = Y[i] + Z[i] - K;
      }
    } else if(X[i] == 1) {
      if(Y[i] <= K && K <= Z[i]) {
        ++value;
      }
    } else {
      if(Y[i] <= K && K <= Z[i]) {
        value /= 2;
      }
    }
  }
  cout << value << endl;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
    Int n, k;
    cin >> n >> k;
    vector<Int> a(n);
    for(auto &i:a) cin >> i;
    for(Int i=0; i<n; ++i)
        a[i] -= k;
    for(Int i=1; i<n; ++i)
        a[i] += a[i-1];
    vector<Int> b(a);
    b.push_back(0);
    sort(b.begin(), b.end());
    b.erase(unique(b.begin(), b.end()), b.end());
    map<Int, Int> mp;
    for(size_t i=0; i<b.size(); ++i)
        mp[b[i]] = i+1;
//    for(size_t i=0; i<b.size(); ++i)
//        cout << i << " " << b[i] << "\n";
    vector<Int> bit(b.size()+1);
    Int m = b.size();
    for(Int i=mp[0]; i<=m; i+=i&-i) ++bit[i];
    Int ans = 0;
    for(Int i=0; i<n; ++i){
        for(Int j=mp[a[i]]; j>0; j-=j&-j) ans += bit[j];
        for(Int j=mp[a[i]]; j<=m; j+=j&-j) ++bit[j];
//        cout << i << " " << ans << "\n";
    }
    cout << ans << "\n";
}

Measured memory_bytes: 18788
import itertools
N = int(input())
XY = [tuple([int(_) for _ in input().split()][::-1]) for _ in range(N)]
XY.sort()


def calc(a, b, c, d, e, f):
    if (c - a) * (e - a) + (d - b) * (f - b) < 0:
        return ((e - c)**2 + (f - d)**2) / 4
    if (e - c) * (a - c) + (f - d) * (b - d) < 0:
        return ((a - e)**2 + (b - f)**2) / 4
    if (a - e) * (c - e) + (b - f) * (d - f) < 0:
        return ((a - c)**2 + (b - d)**2) / 4

    if (e - a) * (b - d) == (c - a) * (b - f):
        vx = max([a, c, e]) - min([a, c, e])
        vy = max([b, d, f]) - min([b, d, f])
        return (vx**2 + vy**2) / 4
    Py = ((e - a) * (a**2 + b**2 - c**2 - d**2) - (c - a) *
          (a**2 + b**2 - e**2 - f**2)) / (2 * (e - a) * (b - d) - 2 * (c - a) *
                                          (b - f))
    if c - a:
        Px = (2 * (b - d) * Py - a**2 - b**2 + c**2 + d**2) / (2 * (c - a))
    else:
        Px = (2 * (b - f) * Py - a**2 - b**2 + e**2 + f**2) / (2 * (e - a))
    R2 = ((Px - a)**2 + (Py - b)**2)
    return R2


# ps = [(x, y), ...]: ソートされた座標list
def cross(a, b, c):
    return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0])


def convex_hull(ps):
    qs = []
    n = len(ps)
    for p in ps:
        while len(qs) > 1 and cross(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    t = len(qs)
    for i in range(n - 2, -1, -1):
        p = ps[i]
        while len(qs) > t and cross(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    return qs


XY = convex_hull(XY)[::-1]
N = len(XY)

ans = -1
if N == 2:
    a, b = XY[0]
    c, d = XY[1]
    print(((a - c)**2 + (b - d)**2)**0.5 / 2)
    exit()
for i, j, k in itertools.combinations(range(N), 3):
    a, b = XY[i]
    c, d = XY[j]
    e, f = XY[k]
    r2 = calc(a, b, c, d, e, f)
    if r2 > ans:
        ans = r2
print(ans**0.5)


Measured memory_bytes: 44380
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1,n,a,b,m;
    cin>>n;
    vector<ll> ar(n+1,0),dp(n+1,0);
    for(ll i=1;i<=n;i++)
        cin>>ar[i];
    /*
    State
    dp[i]: Denotes the minimum cost to reach the ith Stone
    Recurrence
    dp[i]=min(dp[i-1]+|ar[i]-ar[i-1]|,dp[i-2]+|ar[i]-ar[i-2]|) for all i>2
    dp[1]=0;
    dp[2]=|ar[1]-ar[2]|
    */
    dp[1]=0;
    dp[2]=abs(ar[1]-ar[2]);
    for(ll i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(ar[i]-ar[i-1]),dp[i-2]+abs(ar[i]-ar[i-2]));
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, m;
    cin >> n >> m;
    vector<int> like(m, 0);
    rep(i, n)
    {
        int k;
        cin >> k;
        rep(j, k)
        {
            int a;
            cin >> a;
            like[a - 1]++;
        }
    }
    int ans = 0;
    rep(i, m) if (like[i] == n) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <array>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errp(x) cerr << "["#x"]  {" << ((x).first) << ", " << ((x).second) << "}\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll getrnd(ll l, ll r) {
    return uniform_int_distribution<ll>(l, r)(rng);
}

template <typename T1, typename T2>
inline bool relax(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T1, typename T2>
inline bool strain(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

// :::::::::::::::::::::::::::::::

void solve() {
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    
    vector<int> pos;
    for (int i = 0; i < n; ++i)
        if (s[i] == 'o')
            pos.emplace_back(i);
    pos.emplace_back(1e9);
    
    int m = pos.size() - 1;
    vector<int> revdp(m + 1);
    for (int i = m - 1; i >= 0; --i) {
        int j = upper_bound(pos.begin(), pos.end(), pos[i] + c) - pos.begin();
        revdp[i] = revdp[j] + 1;
    }
    
    vector<int> dp(m), from(m + 1, -1);
    dp[0] = 1;
    for (int i = 1; i < m; ++i) {
        int j = lower_bound(pos.begin(), pos.end(), pos[i] - c) - pos.begin();
        if (j == 0)
            dp[i] = 1;
        else
            dp[i] = dp[j - 1] + 1;
        from[i] = j - 1;
    }
//    errv(dp);
//    errv(revdp);

    vector<int> predict;
    for (int i = 0; i < m; ++i) {
        if (predict.empty() || pos[predict.back()] + c < pos[i])
            predict.push_back(i);
    }
    
    vector<int> ans;
    int lst = -1;
    for (int i : predict) {
        if (revdp[i + 1] + (lst == -1 ? 0 : dp[lst]) < k)
            ans.emplace_back(pos[i]);
        lst = i;
    }
    
    for (int i : ans)
        cout << i + 1 << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    srand(time(0));
    
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    
    return 0;
}


Measured memory_bytes: 8912
#include <stdio.h>
#include <string.h>

#define FACE_LIMIT 6
#define FACE_NUMBER_LIMIT 100
#define COMMAND_LIMIT 100

enum FACE_DIRECTION {
	TOP
	,FORWARD
	,RIGHT
	,LEFT
	,BACKWORD
	,BOTTOM
};

typedef struct {
	int number[FACE_LIMIT];
	char command[COMMAND_LIMIT];
} Dice;

int InputDice(Dice* dice);
void Move(Dice* dice);
int CheckValidation(char* value);

int main(void) {
	Dice dice;

	while(InputDice(&dice));

	Move(&dice);

	printf("%d\n", dice.number[TOP]);
}

int InputDice(Dice* dice) {
	int size;
	int nums[FACE_LIMIT];
	char value[COMMAND_LIMIT];

	for (size = 0; size < 6; size++) {
		scanf("%d", &nums[size]);
		if (nums[size] < 0 || nums[size] > 100) {
			return -1;
		}
	}

	scanf(" %[^\n]s", value);
	if (!CheckValidation(value)) {
		return -1;
	}

	memcpy(dice->number, nums, sizeof(nums));
	memcpy(dice->command, value, sizeof(value));

	return 0;
}

void Move(Dice* dice) {
	int* pNum = dice->number;
	char* pCmd = dice->command;
	char cur;
	while((cur = *pCmd++)) {
		switch (cur) {
		case 'E':
		{
			int tmp1 = *(pNum + 2);
			*(pNum + 2) = *(pNum);

			int tmp2 = *(pNum + 5);
			*(pNum + 5) = tmp1;

			tmp1 = *(pNum + 3);
			*(pNum + 3) = tmp2;

			*(pNum) = tmp1;
			break;
		}

		case 'W':
		{
			int tmp1 = *(pNum);
			*(pNum) = *(pNum + 2);

			int tmp2 = *(pNum + 3);
			*(pNum + 3) = tmp1;

			tmp1 = *(pNum + 5);
			*(pNum + 5) = tmp2;

			*(pNum + 2) = tmp1;
			break;
		}

		case 'N':
		{
			int tmp1 = *(pNum + 4);
			*(pNum + 4) = *(pNum);

			int tmp2 = *(pNum + 5);
			*(pNum + 5) = tmp1;

			tmp1 = *(pNum + 1);
			*(pNum + 1) = tmp2;

			*(pNum) = tmp1;
			break;
		}

		case 'S':
		{
			int tmp1 = *(pNum);
			*(pNum) = *(pNum + 4);

			int tmp2 = *(pNum + 1);
			*(pNum + 1) = tmp1;

			tmp1 = *(pNum + 5);
			*(pNum + 5) = tmp2;

			*(pNum + 4) = tmp1;
			break;
		}

		}
	}
}

int CheckValidation(char* value) {
	int idx = 0;
	int res = 1;
	char cur;
	while((cur = *(value + idx++))) {
		if (cur != 'S' && cur != 'E' && cur != 'W' && cur != 'N') {
			res = 0;
			break;
		}
	}
	return res;
}


Measured memory_bytes: 2112
N,M,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a = [0]*(N+1)
b = [0]*(M+1)

for i in range(N):
    a[i+1] = a[i] + A[i]
for j in range(M):
    b[j+1] = b[j] + B[j]

n_b = M
best = 0

for n_a in range(N+1):
    if K < a[n_a]:
        break

    while  K < a[n_a] + b[n_b]:
        n_b -= 1

    best = max(n_a + n_b,best)

print(int(best))



Measured memory_bytes: 47372
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  std::string S; std::cin >> S;
  int r = 0, b = 0;
  for (char c : S) {
    if (c == '0') ++r;
    else          ++b;
  }

  std::cout << 2*std::min(r, b) << std::endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define RANGEOF(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

template <class T> T read() { T t; cin >> t; return t; }
template <class T> vector<T> read_n(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vector<vector<T>> read_nn(int n, int m) { vector<vector<T>> v; REP(i,n) { v.push_back(read_n<T>(m)); } return v; }
template <class T> void write(const T &t) { cout << t << endl; }
struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__
void solve();
int main() { solve(); return 0; }
/// template end ///

void solve()
{
	while (true)
	{
		READ(int, N);
		if (!N) { break; }
		
		auto gems = read_nn<int>(N, 2);
		READ(int, M);

		vector<int> pos(2, 10);
		gems.erase(remove(ALLOF(gems), pos), gems.end());

		REP(j, M)
		{
			READ(char, d);
			READ(int, l);

			int dx = 0, dy = 0;
			switch (d)
			{
			case 'N': dy = 1; break;
			case 'E': dx = 1; break;
			case 'W': dx = -1; break;
			case 'S': dy = -1; break;
			}

			REP(x, l)
			{
				pos[0] += dx;
				pos[1] += dy;
				gems.erase(remove(ALLOF(gems), pos), gems.end());
			}
		}
		write(gems.empty() ? "Yes" : "No");
	}
}

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

int main(){
    int N, M, ans=0;
    cin >> N >> M;
    
    priority_queue<int, vector<int>> day;
    vector<pair<int, int>> AB(N);
    
    for(int i=0; i<N; i++){
	cin >> AB[i].first >> AB[i].second;
    }
    sort(AB.begin(), AB.end());
    int j=0;
    for(int i=0;i<M;i++){
	while(i+1 == AB[j].first){
	    day.push(AB[j].second);
	    j++;
	}
	if(!day.empty()){
	    ans += day.top();
	    day.pop();
	}	
    }
    cout << ans << endl;
}





Measured memory_bytes: 1660
while gets do
  str = $_.chomp

  26.times.each do
    if str =~ /(the|that|this)/
      puts str
      break
    end

    str.length.times do |i|
      next if str[i] !~ /[a-z]/
      tmp = str[i].succ
      str[i] = (tmp.length > 1) ? "a" : tmp
    end
  end
end

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



Measured memory_bytes: 2496
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

value = 0
last = None
for a in A:
    idx = a - 1
    value += B[idx]
    if last is not None and last + 1 == idx:
        value += C[last]
    last = idx
print(value)

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

int main() {
	int N;
cin >>N;
int mochi[101]={};

for(int i=0; i<N;i++){
int m;
cin>>m;
mochi[m]=1;
}

int ans=0;
for(int i=0; i<101; i++){
ans+=mochi[i];
}

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

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

int main()
{
	int k, s;
	cin >> k >> s;

	int count = 0;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			if (s - x - y <= k && s - x - y >= 0) count++;
		}
	}

	cout << count << endl;
}

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

public class Main {
	private static void solve(){
	//Implement solution here.
		int n = ni();
		int l = String.valueOf(n).length();
		int result = 0;
		if(l == 1) {
			result = n;
		}else if(l == 2){
			result = 9;
		}else if(l == 3) {
			result += 9;
			result += n - 99;
		}else if(l == 4) {
			result = 909;
		}else if(l == 5) {
			result += 909;
			result += n - 9999;
		}else{
			result += 90909;
		}
		
		System.out.println(result);
	}

    //Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
            	br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        } 
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()

using namespace std;

ll power(ll a, ll n)
{
	ll ans=1;
	while(n)
	{
		if(n&1) ans=(ans*a)%mod;
		a=(a*a)%mod;
		n>>=1;
	}
	return ans;
}

ll fac[4001];

int main()
{
    IOS;
    fac[0]=1;
    repf(i,1,4001)
    {
        fac[i]=(fac[i-1]*i)%mod;
    }
    ll N,K;
    cin>>N>>K;
    ll n=(N-K+1);
    ll r;
    repf(i,1,K+1)
    {
        r=i;
        if(n<r) 
        {
            cout<<0<<endl;
            continue;
        }
        ll Nr=fac[n];
        ll Dr=(fac[n-r]*fac[r])%mod;
        ll ans=(Nr*power(Dr,mod-2))%mod;
        Nr=fac[K-1];
        Dr=(fac[K-i]*fac[i-1])%mod;
        ans=((ans*Nr)%mod*power(Dr,mod-2))%mod;
        cout<<ans<<endl;
    }
}
 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

//AGC012 A AtCoder Group Contest
//http://agc012.contest.atcoder.jp/tasks/agc012_a
class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            WillReturn.Add("5 2 8 5 1 5");
            //10
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("10");
            WillReturn.Add("1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000");
            //10000000000
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int N = int.Parse(InputList[0]);
        int[] AArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();

        Array.Sort(AArr);

        long Answer = 0;
        int UB = AArr.GetUpperBound(0);
        for (int I = UB - 1; N <= I; I -= 2) {
            Answer += AArr[I];
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 42956
#include<iostream>

using namespace std;

void swap(int&, int&);

int main(){
  int count;
  long x, y;

  while(1){
    cin >> x >> y;
    if(x == 0 && y == 0) break;

    if(x < y) swap(x, y);
    count = 0;
    while(y != 0){
      x %= y;
      swap(x, y);
      ++count;
    }

    cout << x << " " << count << endl;
  }
  return 0;
}

void swap(int& x, int& y){
  int z;
  z = x;
  x = y;
  y = z;
}

Measured memory_bytes: 0
#include <stdio.h>
 
int n, t, min, max, r, cnt;
int a[100001];
 
int main(void) {
 
    scanf("%d%d", &n, &t);
    scanf("%d", &a[0]);
    min=a[0];
    
    for(int i=1; i<n; i++) {
        scanf("%d", a+i);
        
        if(a[i]<a[i-1]) {
            if(a[i]<min) min=a[i];
        }
        
        if(a[i]>a[i-1]) {
            if((a[i]-min)>r) {
                r=a[i]-min;
                cnt=1;
            }
            else if((a[i]-min)==r) {
                cnt++;
            }
        }
    }
    printf("%d", cnt);
    
    return 0;
}

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

int main(){
    int H, W, K; cin >> H >> W >> K;
    vector<string> s(H); rep(i,H) cin >> s[i];
    vector<vector<int>> ans(H, vector<int>(W,0));
    int cnt = 1;
    vector<bool> notContained(H, false);
    rep(i,H){
        int judge = 1;
        rep(j,W){
            if(s[i][j] == '#'){
                if(!judge) cnt++; // 行で一番最初のイチゴじゃない
                ans[i][j] = cnt;
                judge = 0;
            }else{
                ans[i][j] = cnt;
            }
        }
        if(judge == 1){ // イチゴが含まれない行
            notContained[i] = true;
            rep(j,W) ans[i][j] = 0;
        }else cnt++;
    }

    // 含まれない行の処理 上端
    int up = -1;
    rep(i,H){
        if(!notContained[i]){ // 含まれたのが見つかったら終了
            up = i;
            break;
        }
    }
    for(int i = up-1; i >= 0; --i){
        rep(j,W) ans[i][j] = ans[i+1][j];
        notContained[i] = false;
    }
    // それ以外
    rep(i,H){
        if(!notContained[i]) continue;
        rep(j,W) ans[i][j] = ans[i-1][j];
    }

    rep(i,H){
        rep(j,W) cout << ans[i][j] << " ";
        cout << "\n";
    }
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
using namespace std;
int main(){
  int N;
  cin>>N;
  
  string S;
  cin>>S;
  int k=N/2;
  string T1;
  for(int i=0;i<k;i++){
    T1+=S[i];
  }
  string T2;
  for(int i=k;i<N;i++){
    T2+=S[i];
  }
  if(N%2==1) cout<<"No"<<endl;
  else if(S==T1+T1) cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
 return 0; 
}

Measured memory_bytes: 256
n, m = map(int, input().split())
cities = []
for i in range(m):
    p, y = map(int, input().split())
    cities.append([i, p, y])

cities.sort(key=lambda x: (x[1], x[2]))
now_p = cities[0][1]

j = 1
for i, l in enumerate(cities):
    if now_p != l[1]:
        now_p = cities[i][1]
        j = 1

    l.append(j)
    j += 1

cities.sort(key=lambda x: x[0])
for city in cities:
    print(str(city[1]).zfill(6)+str(city[3]).zfill(6))

Measured memory_bytes: 35484
input()
a, d = map(int, input().split())
x = [tuple(map(int, input().split())) for _ in range(int(input()))]
k = int(input())
for i in x[::-1]:
    if i[0] == 1:
        if i[1] == k:
            k = i[2]
    else:
        if i[1] == k:
            k = i[2]
        elif i[2] == k:
            k = i[1]
print(a + d * (k - 1))


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

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


Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))
count=0
for i in range(1,n):
    if a[i-1]<0:
        a[i-1]=0
    b=a[i-1]+a[i]
    if b>x:
        a[i]-=b-x
        count+=b-x
print(count)

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

const string YES = "YES";
const string NO = "NO";

void solve(std::string A, std::string B, std::string C){
  if(A.at(A.size() - 1) == B.at(0) && B.at(B.size() - 1) == C.at(0)){
    cout << "YES" << endl;
    return;
  }
  cout << "NO" << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string A;
    std::cin >> A;
    std::string B;
    std::cin >> B;
    std::string C;
    std::cin >> C;
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

struct BIT {
    ll n;
    VL dat;
    void init(ll n_input) {
        n = n_input + 1;
        dat.resize(n + 1);
        for (int i = 0; i <= n; i++) dat[i] = 0;
    }
    ll sum(ll i) {
        ll s = 0;
        while (i >= 0) {
            s += dat[i];
            i = (i & (i + 1)) - 1;
        }
        return s;
    }
    void add(ll i, ll x) {
        while (i <= n) {
            dat[i] += x;
            i |= i + 1;
        }
    }
};

int main() {
    ll n;
    cin >> n;
    VL a(n), sorted(n);
    FOR(i, 0, n) {
        cin >> a[i];
        sorted[i] = a[i];
    }
    SORT(sorted);
    int ok = 0, ng = n;
    BIT bit;

    ll border = ((n * (n + 1) / 2) + 1) / 2;
    while (ng - ok > 1) {
        int mid = (ng + ok) / 2;
        int midnum = sorted[mid];
        bit.init(2 * n + 1);
        int sum = 0;
        bit.add(sum + n, 1);
        ll result = 0;
        FOR(i, 0, n) {
            sum += (a[i] >= midnum ? 1 : -1);
            result += bit.sum(sum + n);
            bit.add(sum + n, 1);
        }
        if (result >= border)ok = mid;
        else ng = mid;
    }
    cout << sorted[ok] << endl;
}


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

enum color {red, blue};

vector<vector<int>> to(200001);
vector<int> v_red;
vector<int> v_blue;

void dfs(int v, color c, int prev)
{
  if (c == red) {
    v_red.push_back(v);
  } else {
    v_blue.push_back(v);
  }
  for (int next : to.at(v)) {
    if (next == prev) continue;
    dfs(next, c == red ? blue : red, v);
  }
}

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

  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    to.at(a).push_back(b);
    to.at(b).push_back(a);
  }

  dfs(1, red, 0);

  vector<int> v;
  if (int(v_red.size()) <= n / 3 || int(v_blue.size()) <= n / 3) {
    v.assign({3, 1, 2});
  } else {
    v.assign({1, 3, 2});
  }

  vector<int> v123;
  for (const auto& i : v) {
    for (int j = i; j <= n; j += 3) {
      v123.push_back(j);
    }
  }

  vector<int> vrb;
  if (v_red.size() < v_blue.size()) {
    vrb.assign(begin(v_red), end(v_red));
    vrb.insert(end(vrb), begin(v_blue), end(v_blue));
  } else {
    vrb.assign(begin(v_blue), end(v_blue));
    vrb.insert(end(vrb), begin(v_red), end(v_red));
  }

  vector<int> ans(n);

  for (int i = 0; i < n; i++) {
    ans[vrb[i] - 1] = v123[i];
  }

  for (int i = 0; i < n; i++) {
    cout << ans[i] << (i == n - 1 ? '\n' : ' ');
  }
}


Measured memory_bytes: 22896
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 123;
int ans[MAXN][MAXN];
int a[MAXN * MAXN];

int main() {
    int H, W, N;
    while (~scanf("%d %d", &H, &W)) {
          scanf("%d", &N);
          for (int i = 1; i <= N; i++) scanf("%d", &a[i]);
          int curidx = 0;
          int dir = 1;
          for (int i = 1; i <= N; i++) {
              while (a[i]) {
                    int x = curidx / W + 1;
                    int y = curidx % W + 1;
                    ans[x][y] = i;
                    a[i]--;
                    if (curidx % W == W - 1 && dir == 1) {
                       dir = -1;
                       curidx += W;
                    } else if (curidx % W == 0 && dir == -1) {
                       dir = 1;
                       curidx += W;
                    } else curidx += dir;
              }
          }
          for (int i = 1; i <= H; i++) {
              for (int j = 1; j <= W; j++) {
                  printf("%d ", ans[i][j]);
              }
              puts("");
          }
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
const int maxn = 100050;
using namespace std;
struct note{
    int id;
    int P, Y;
}a[maxn];
int belong[maxn], ans[maxn], ji[maxn];
bool cmp(struct note qian, struct note hou){
    return qian.Y < hou.Y;
}
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i=0; i<m; i++){
        scanf("%d%d", &a[i].P, &a[i].Y);
        belong[i] = a[i].P;
        a[i].id = i;
    }
    sort(a, a+m, cmp);
    for(int i=0; i<m; i++){
        int t = ++ji[ a[i].P ];
        ans[ a[i].id ] = t;
    }
    for(int i=0; i<m; i++){
        printf("%06d%06d\n", belong[i], ans[i]);
    }
    return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while(t--)
    {
        int a,b;
        cin >> a >> b;
        cout << ceil(1.0*a/b*1.0) << " " ;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int s;
    cin >> s;
    int hour = s / (60*60);
    int minute = (s - hour*60*60) / 60;
    int second = s % 60;
    cout << hour << ':' << minute << ':' << second << endl;
}


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

int main()
{
   long long int H,N;
   long long int sum=0;
   cin>>H>>N;
   long long int A[N];
   for(int i=0;i<N;i++){
       cin>>A[i];
   }
   for(int j=0;j<N;j++){
       sum+=A[j];
   }
   if(sum>=H){
       cout<<"Yes";
   }
   else{
       cout<<"No";
   }

    return 0;
}

Measured memory_bytes: 4348
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000000+7
typedef long long int lint;

int main(){
  lint X,now = 100,cnt = 0;
  cin >> X;
  for(;now < X;){
    now *= 1.01;
    cnt++;
  }
  co(cnt);
}

Measured memory_bytes: 3632
#include <atcoder/fenwicktree>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int n, q;
    scanf("%d %d", &n, &q);

    fenwick_tree<long long> fw(n);
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        fw.add(i, a);
    }

    for (int i = 0; i < q; i++) {
        int t;
        scanf("%d", &t);
        if (t == 0) {
            int p, x;
            scanf("%d %d", &p, &x);
            fw.add(p, x);
        } else {
            int l, r;
            scanf("%d %d", &l, &r);
            printf("%lld\n", fw.sum(l, r));
        }
    }
}


Measured memory_bytes: 8200
//Rextester.Program.Main is the entry point for your code. Don't change it.
//Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //Your code goes here
          var o = Console.ReadLine().ToCharArray();
          var e = Console.ReadLine().ToCharArray();

          var answer = "";
          var j = 0;
           var k = 0;
            
    
            while ( j <o.Length || k < e.Length) {
                if (j >= o.Length) {
                    answer += e[k ++];

                } else if (k >= e.Length) {
                                    answer += o[j++];

                } else {
                     answer += o[j++];
                    answer += e[k ++];
                }
             
            }
            
            Console.WriteLine(answer);
        }
    }
}

Measured memory_bytes: 11092
N=int(input())
A=list(map(int,input().split()))
B=[]
C=[]
D=[]

for i in range(N):
  if A[i]<0:
    B.append(A[i])
  elif A[i]==0:
    C.append(A[i])
  else:
    D.append(A[i])

ans=[]
anss=0

if len(B)>0 and len(D)>0:
  for i in C:
    ans.append((B[0],0))
  for i in range(len(D)-1):
    ans.append((B[0],D[i]))
    B[0]-=D[i]
  for i in range(len(B)):
    ans.append((D[-1],B[i]))
    D[-1]-=B[i]
  anss=D[-1]

elif len(C)>0:
  for i in range(len(C)-1):
    ans.append((0,0))
  for i in B:
    ans.append((anss,i))
    anss-=i
  if(len(D)>0):
    for i in range(len(D)-1):
      ans.append((anss,D[i]))
      anss-=D[i]
    ans.append((D[-1],anss))
    anss=D[-1]-anss

else:
  E=sorted(B,reverse=True)+sorted(D)
  anss=E[0]
  for i in range(len(E)-2):
    ans.append((anss,E[i+1]))
    anss-=E[i+1]
  if anss<=0:
    ans.append((E[-1],anss))
    anss=E[-1]-anss
  else:
    ans.append((anss,E[-1]))
    anss-=E[-1]

print(anss)
for i in ans:
  print(*i)

Measured memory_bytes: 20904
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}

int n, k;
u32 P;
u32 f[80], g[2][155][80];
u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
u64 power(u64 a, int b) {
	u64 ans=1;
	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
	return ans;
}
void once(int m) {
	u64 sum=0;
	for(int j=0; j<=m; ++j) sum+=f[j];
	for(int j=m; j>=1; --j) f[j]=f[j-1];
	f[0]=sum%P;
}
int main() {
	std::cin>>n>>k>>P;
	if(k%2==0) {
		u64 ans0;
		f[0]=1;
		for(int i=0; i<=(n+1)/2; ++i) {
			once(k/2);
			if(i==n/2) ans0=f[0];
		}
		std::cout<<ans0*f[0]%P<<"\n";
	} else {
		int t;
		auto G=g[0], H=g[1];
		f[0]=1;
		for(t=1; t<k; t+=2) once(k/2);
		memcpy(G[0], f, (k/2+1)*sizeof(int));
		for(t=1; t+k<=n; t+=2) {
			std::swap(G, H);
			for(int i=0; i<=k; ++i) memset(G[i], 0, (n/2+1)*sizeof(int));
			for(int i=0; i<=k; ++i)
				for(int j=0; j<=n/2; ++j)
					if(H[i][j]) {
						inc(G[i?i+1:j+1][j+1], H[i][j]);
						inc(G[0][j+1], H[i][j]);
						inc(G[i?i+1:0][0], H[i][j]);
						inc(G[0][0], H[i][j]);
					}
		}
		for(int i=0; i<=k; ++i) {
			u64 sum=0;
			for(int j=0; j<=n/2; ++j) sum+=G[i][j];
			f[i]=sum%P;
		}
		for(; t<=n; t+=2) {
			once(k);
			inc(f[0], f[1]);
			f[1]=0;
		}
		once(k);
		printf("%u\n", f[0]);
	}
	return 0;
}


Measured memory_bytes: 384