akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: f64,
        b: f64
    }

    let a_l = (a / 0.08).ceil();
    let a_u = ((a + 1.0) / 0.08).floor();
    let b_l = (b / 0.10).ceil();
    let b_u = ((b + 1.0) / 0.10).floor();

    let mut ans = a_l;
    let mut flag = false;
    while ans < a_u && ans < b_u.ceil() {
        if a_l <= ans && ans < a_u && b_l <= ans && ans < b_u {
            println!("{}", ans as u64);
            flag = true;
            break;
        }
        ans = ans + 1.0;
    }

    if !flag {
        println!("-1");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}
int main()
{
	int K;
	string S;
	cin>>K>>S;
	int s_size = S.size();
	if(s_size <= K)
	{
		cout<<S<<endl;
	}
	else
	{
		cout<<S.substr(0, K)<<"..."<<endl;
	}
	
}

Measured memory_bytes: 3632
X = int(input())
A = input()

char_list = list(A)

num2alpha = lambda c: chr(c+64)
alpha2num = lambda c: ord(c) - ord('A') + 1
char = ''

for item in char_list:
    num = alpha2num(item)+X
    if num > 26: 
       char = char + num2alpha(num-26)
    else:
       char = char + num2alpha(num)

print(char)


Measured memory_bytes: 3060
#include <stdio.h>

int main(){
    char str[3];
    scanf("%s",&str);

    if(str[2]=='\0'){
        printf("%s\n",str);
    }else{
        int i;
        for(i=2;i>=0;i--){
            printf("%c",str[i]);
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int n, ma, mb;
int dp[50][500][500];

signed main() {
    cin >> n >> ma >> mb;
    int a[50], b[50], c[50];
    rep(i,0,n) {
        cin >> a[i] >> b[i] >> c[i];
    }

    repq(i,0,n) rep(j,0,500) rep(k,0,500) dp[i][j][k] = INF;
    dp[0][0][0] = 0;

    rep(i,0,n) rep(j,0,500) rep(k,0,500) {
        dp[i+1][j][k] = dp[i][j][k];
        if(j - a[i] < 0 || k - b[i] < 0) continue;
        dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j-a[i]][k-b[i]] + c[i]);
    }

    int ans = INF;
    rep(i,1,500) rep(j,1,500) {
        if(ma * j == mb * i) {
            // printf("i = %lld, j = %lld, dp = %lld\n", i, j, dp[n][i][j]);
            ans = min(ans, dp[n][i][j]);
        }
    }
    if(ans != INF) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 82176
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	A
# CreatedDate:  2020-08-22 20:51:47 +0900
# LastModified: 2020-08-22 21:02:01 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n, x, y = map(int, input().split())
    a = n / x
    if a.is_integer():
        print(n//x*y)
    else:
        print(n//x*y+y)


if __name__ == "__main__":
    main()


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


using ull = unsigned long long;


using namespace std;


void dump(vector<ull> &apples) {
    for (auto e : apples) {
        cout << e << " ";
    }
    cout << endl;
}


int main() {
    ull X, Y, A, B, C;

    cin >> X >> Y >> A >> B >> C;

    ull p;
    vector<ull> apples;
    vector<ull> red;
    vector<ull> green;
    vector<ull> none;

    for (ull i = 0; i < A; i++) {
        cin >> p;
        red.push_back(p);
    }

    for (ull i = 0; i < B; i++) {
        cin >> p;
        green.push_back(p);
    }

    for (ull i = 0; i < C; i++) {
        cin >> p;
        none.push_back(p);
    }

    sort(red.rbegin(), red.rend());
    sort(green.rbegin(), green.rend());
    sort(none.rbegin(), none.rend());

    for (ull i = 0; i < X; i++) {
        apples.push_back(red[i]);
    }
    // for (ull i = 0; i < Y; i++) {
    //     apples.push_back(green[i]);
    // }
    apples.insert(apples.begin(), green.begin(), green.begin() + Y);
    for (ull i = 0;i < C; i++) {
        apples.push_back(none[i]);
    }
    sort(apples.rbegin(), apples.rend());
    ull ans = 0;
    for (ull i = 0; i < X + Y; i++) {
        ans += apples[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 6836
n, q = map(int, input().split())
s = input()
t = [0] * (n + 1)

count = 0
for i in range(n - 1):
    if s[i:i+2] == 'AC':
        t[i + 1] = t[i] + 1
    else:
        t[i + 1] = t[i]

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

Measured memory_bytes: 6060
using System;
using System.Linq;

namespace relay_a
{
    class Program
    {
        static void Main(string[] args)
        {
            double[] x = Console.ReadLine().Split().Select(double.Parse).ToArray();
            Console.WriteLine(x[0] * x[1] / (x[0] + x[1]));
        }
    }
}

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

int main ()
{
  int n, i, j, key, ary[101];

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

  for (i = 0; i < n; i++)
  {
    key = ary[i];
    j = i - 1;
    while (j >= 0 && key < ary[j]) {
      ary[j+1] = ary[j];
      j--;
    }
    ary[j+1] = key;

    for (j = 0; j < n; j++) {
      if (j) {
        cout << ' ';
      }
      cout << ary[j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import sys
sys.setrecursionlimit(500000)

def f(num):
    if memo[num] != 0 and memo[num] != -1:return memo[num]

    if memo[num] == -1:
        return f(num-1)
    if memo[num-1] == -1:
        memo[num] = f(num-1)
    elif memo[num-2] == -1:
        memo[num] = f(num-1)
    elif num > 1:memo[num] = f(num-1)+memo[num-2]
    else:memo[num] = f(num-1)


    return memo[num]

n,m = map(int,input().split())
memo = [0 for _ in range(n+1)]
for i in [int(input()) for _ in range(m)]:
    memo[i] = -1
    if memo[i] == -1 and memo[i-1] == -1:print(0);exit()
memo[0] = 1
print(f(n)%(10**9+7))

Measured memory_bytes: 494128
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int a[]=new int[n];
			int b[]=new int[n];

			for(int i=0; i<n;i++)
			{
				a[i]=in.nextInt();
				b[i]=in.nextInt();
			}
			for(int i=0;i<n;i++)
			{
				int m=i;
				for(int j=i;j<n; j++)
				{
					if(b[j]<b[m])
						m=j;
				}
				int tmp =b[i];
				b[i] = b[m];
				b[m] = tmp;
				tmp =a[i];
				a[i]=a[m];
				a[m]=tmp;
			}
			boolean flag=true;
			int T=0;
			int W=0;
			for(int i=0;i <n;i++)
			{
				T+=a[i];
				W=b[i];
				if(T>W)
					flag=false;
			}
			if(flag)
				System.out.println("Yes");
			else
				System.out.println("No");
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[8] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy[8] = {1, 0, -1, 1, -1, 1 ,0 ,-1};
lli repow(lli n,lli k,lli m){
  if(k==0)return 1;
  if(m==0)return 0;
  else if(k%2==1)return repow(n,k-1,m)*n%m;
  else{
    lli temp=repow(n,k/2,m);
    return temp*temp%m;
  }
}
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> N >> M;
  rep(i,0,M){
    cin >> A;
    sum+=A;
  }
  if(sum>N)Out(-1);
  else Out(N-sum);
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;

#define OUT(x)  cerr << #x << " = " << x << endl;
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

//V以下の素数列挙。O(V log log V)
int V = 2200; //V * V * V >= 10^10
vector<int> prime;
void init() {
        vector<bool> is_prime(V + 1, true);
        is_prime[0] = is_prime[1] = false;
        for (int i = 2; i <= V; i ++) {
                if (is_prime[i]) {
                        prime.push_back(i);
                        for (int j = i + i; j <= V; j += i) is_prime[j] = false;
                }
        }
}

int main() {
        init();
        int n;
        cin >> n;
        vector<ll> a(n);
        for (int i = 0; i < n; i ++) cin >> a[i];
        unordered_map<ll, pll> cnts; //その数字の個数と、その数字のペア的なやつの数
        for (auto v : a) {
                ll val = 1, another = 1;
                for (auto p : prime) {
                        if (v % p != 0) continue;
                        int cnt = 0;
                        while (v % p == 0) {
                                cnt ++;
                                v /= p;
                        }
                        cnt %= 3;
                        if (cnt == 1) {
                                val *= p;
                                another *= p * p;
                        } else if (cnt == 2) {
                                val *= p * p;
                                another *= p;
                        }
                }
                if (v > 1) {
                        ll tmp = sqrt(v);
                        ll root = 0;
                        for (int i = -1; i < 2; i ++) if ((tmp + i) * (tmp + i) == v) root = tmp + i;
                        if (root) {
                                val *= v;
                                another *= root;
                        } else {
                                val *= v;
                                another *= v * v;
                        }
                }
                cnts[val].second = another;
                cnts[val].first ++;
        }
        auto tmp = cnts;
        ll ans = 0;
        for (auto u : tmp) if (u.first != 1 && cnts[u.second.second] < u.second) ans += u.second.first;
        if (cnts[1].first != 0) ans ++;
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 18120
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
long long GCD(long long a,long long b){
    if(b==0) return a;
    return GCD(b,a%b);
}
int main() {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll e=c/GCD(c,d)*d;
    ll x=b/c-(a-1)/c,y=b/d-(a-1)/d,z=b/e-(a-1)/e;
    cout<<b-a+1-(x+y-z);
}

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

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

  if (L > R) {
    cout << "Left" << endl;
  }
  if (L == R) {
    cout << "Balanced" << endl;
  }
  if (L < R) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
my $MAX=100000;

my ($n) = split(/\s/, <STDIN>);

my @a;

for ($r=6; $r<$MAX; $r*=6) { push @a, $r; }
for ($r=9; $r<$MAX; $r*=9) { push @a, $r; }

@a = sort { $a <=> $b  } (@a);

#print join(" ", @a), "\n";

for my $i (@a) { $key{$i} = 1; }

for (1..10) {
    my @k = keys(%key);
    for my $i (@a) {
	for my $j (@k) {
	    if ($j <= $n) {
		unless (defined($key{$i+$j})) {
		    $key{$i+$j} = 1+$key{$j};
		}
	    }
	}
    }
}

#print join(" ", sort {$a <=> $b} keys(%key)), "\n";

my $min = $n;
for (keys(%key)) {
    my $s = $n - $_;
    if ($s >= 0 && $min > $s+$key{$_}) { $min = $s+$key{$_}; }
}
print "$min\n";


Measured memory_bytes: 12032
n, m = map(int, input().split())

# ボール個数、赤いボールがある可能性を管理
b = [1] * n
red = [1] + [0] * (n - 1)

for i in range(m):
    x, y = map(int, input().split())

    # 移す元に赤いボールがある可能性があれば、移す先に赤いボールが渡る可能性がある
    if red[x - 1] == 1:
        red[y - 1] = 1

    # ボール数の足し引き
    b[x - 1] -= 1
    b[y - 1] += 1

    # xのボールが0になったら赤いボールがある可能性が消える
    if b[x - 1] == 0:
        red[x - 1] = 0

ans = len([x for x in red if x > 0])

print(ans)

Measured memory_bytes: 6116
#include<iostream>
using namespace std;
int n, i, j;
char a[1005][1005];
int main(){
    cin>> n;
    for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++){
            a[i][j] = '.';
        }
    }
    if(n % 2 == 0){
        if(n == 2){
            cout<< -1;
            return 0;
        }
        for(i = 1; i < n; i += 2){
            a[i][i] = a[i + 1][i] = 'a';
            a[i][i + 1] = a[i + 1][i + 1] = 'b';
        }
        for(i = 1; i < n - 2; i += 2){
            a[i][i + 2] = a[i][i + 3] = 'c';
            a[i + 1][i + 2] = a[i + 1][i + 3] = 'd';
        }
        a[n - 1][1] = a[n - 1][2] = 'c';
        a[n][1] = a[n][2] = 'd';
    }
    else{
        if(n == 5 || n > 9){
            a[1][1] = a[1][2] = a[1][5] = a[2][5] = a[2][3] = a[3][3] = a[4][1] = a[4][2] = a[5][4] = a[5][5] = 'e';
            a[1][3] = a[1][4] = a[5][1] = a[5][2] = 'f';
            a[2][4] = a[3][4] = a[4][3] = a[5][3] = 'g';
            a[3][5] = a[4][5] = 'i';
            for(i = 6; i < n; i += 2){
                a[i][i] = a[i + 1][i] = 'a';
                a[i][i + 1] = a[i + 1][i + 1] = 'b';
            }
            for(i = 6; i < n - 2; i += 2){
                a[i][i + 2] = a[i][i + 3] = 'c';
                a[i + 1][i + 2] = a[i + 1][i + 3] = 'd';
            }
            a[n - 1][6] = a[n - 1][7] = 'c';
            a[n][6] = a[n][7] = 'd';
        }
        if(n == 3 || n == 9){
            for(i = 1; i < n; i += 3){
                for(j = 1; j < n; j += 3){
                    a[i][j] = a[i][j + 1] = 'a';
                    a[i + 1][j + 2] = a[i + 2][j + 2] = 'b';
                }
            }
        }
        if(n == 7){
            a[1][2] = a[1][3] = a[2][1] = a[3][1] = 'a';
            a[1][4] = a[1][5] = a[4][1] = a[5][1] = 'b';
            a[1][6] = a[1][7] = a[6][1] = a[7][1] = 'c';
            a[2][2] = a[2][3] = a[3][4] = a[3][5] = a[4][2] = a[5][2] = a[6][6] = a[7][6] = 'e';
            a[2][4] = a[2][5] = a[3][6] = a[3][7] = a[4][3] = a[5][3] = a[6][7] = a[7][7] = 'f';
        }
    }
    for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++){
            cout<< a[i][j];
        }
        cout<<"\n";
    }
}


Measured memory_bytes: 2176
import java.util.Scanner;


public class Main{

	static Scanner sc = new Scanner(System.in);
	
	static int n;
	static long ans;
	
	public static void main(String[] args) {
		
		while(read()){
			solve();
		}
		
	}
	
	public static boolean read(){
		if(!sc.hasNext()) return false;
		
		n = sc.nextInt();
		
		if(n < 1 || n > 20) return false;
		
		return true;
	}
	
	public static void solve(){
		
		ans = 1;
		for(int i = n; i > 0; i--){
			ans *= i; 
		}
		
		System.out.println(ans);
		
	}

}

Measured memory_bytes: 12000
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define M 1000000
#define N 10000
 
int main(){
     
    int i;
    int count=0;
    int *ans;
    int str_length;
    int cmp_length;
    char *str;
    char *cmp;
     
    str = (char *)malloc(sizeof(char) * M);
    cmp = (char *)malloc(sizeof(char) * N);
    ans = (int *)malloc(sizeof(int) * M);
     
    scanf("%s %s",str,cmp);
     
    str_length = strlen(str);
    cmp_length = strlen(cmp);
     
     for(i=0;i<str_length;i++){
    if( strncmp(str+i,cmp,cmp_length) ==0 ){
    ans[count] = i;
    count++;
     }
    }
     
    for(i=0;i<count;i++){
    printf("%d\n",ans[i]);
    }
     
    return 0;
}

Measured memory_bytes: 5476
a,b,c,d = list(map(int,input().split()))

t_win_turn = c // b
if c % b > 0:
  t_win_turn += 1

a_win_turn = a // d
if a % d > 0:
  a_win_turn += 1

if t_win_turn <= a_win_turn:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 9104
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k;
    cin >> k;
    cout << a[k-1] << endl;

    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
// clang-format on

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

  ll n, k;
  cin >> n >> k;

  ll a = n % k;
  ll mid = abs(a - k);
  if (mid >= 0 && mid < a) {
    cout << mid << endl;
  } else {
    cout << a << endl;
  }

  return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef int64_t ll; typedef vector<int> VI;typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
ll n,k;
vector<ll> a;

bool ckf(int cr){
	if(a[cr] >=k) return true;
	vector<char> tbl(k+3,0);
	tbl[0] = 1;
	rep(j,n) if(j != cr) repr(p,k-1,0) if(tbl[p] >0){
		tbl[min<ll>(k, p+a[j])]=1;
	}
	int ok=0;
	rep2(j, k-a[cr],k) if(tbl[j]>0) ok=1;
	//for(auto x :tbl) printf("%d ",x); ;
	return ok;
}



int main()
{

	//cin.tie(0); ios_base::sync_with_stdio(false);
	cin >>n >>k;
	a.assign(n,0);
	rep(i,n) cin >>a[i];
	
	sort(all(a));
	int hi=n, lw=0-1;
	while(hi-lw>1){
		int md = (hi+lw)/2;
		bool ok = ckf(md);
		if(ok) hi=md; else lw=md;
		//printf("   md=%d(%lld)    ok=%d\n",md,a[md],ok);
	}
	cout << hi << endl;
	return 0;

}


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

using namespace std;

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int main(){

	long long int x, y, ux=0, uy=0, ans=1, div=1000000007;
	//vector<long long int> a, b;

	cin>> x >> y;

	while (1) {
		if (x == y) {
			if (x % 3 == 0) {
				ux += x / 3;
				uy += x / 3;
				break;
			}
			else {
				cout << "0" << endl;
				return 0;
			}
		}
		else {
			if (x > y) {
				x -= 2;
				y -= 1;
				ux++;
			}
			else {
				x -= 1;
				y -= 2;
				uy++;
			}
		}
		if (x<0 || y<0) {
			cout << "0" << endl;
			return 0;
		}
	}

	/*a.resize((int)(ux + uy));
	b.resize((int)(ux + uy));
	for (int i = 0;i < a.size();i++) {
		a[i] = i + 1;
	}
	for (int i = 0;i < ux;i++) {
		if (i < ux) a[i] = i + 1;
		else a[i] = i - ux + 1;
	}*/

	for (long long int i = max(ux, uy)+1;i <= ux + uy;i++) {
		ans *= i;
		ans = ans % div;
	}

	for (long long int i = 2;i <= min(ux, uy);i++) {
		ans *= modinv(i, div);
		ans = ans % div;

	}

	cout<< ans << endl;


}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<queue>
#include<cstring>
#define maxn 400010
using namespace std;
int a[maxn],n,i,j,g[maxn][18],gg[maxn][18],h[maxn][18],hh[maxn][18],head,tail=1,log[maxn],y,x;
struct type
{
	int l,r,x;
}t;
bool operator < (type x,type y)
{
	return x.x>y.x;
}
priority_queue<type>f;
int get(int l,int r)
{
	if(gg[l][log[(r-l+1)/2]]<gg[r-(1<<log[r-l+1])+1][log[(r-l+1)/2]])return hh[l][log[(r-l+1)/2]];else return hh[r-(1<<log[r-l+1])+1][log[(r-l+1)/2]];
}
int main()
{
	scanf("%d",&n);
	log[0]=-1;
	for(i=1;i<=n;i++)
		log[i]=log[i>>1]+1;
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	memset(g,0x3f,sizeof(g));
	memset(gg,0x3f,sizeof(gg));
	for(i=1;i<n;i++)
	{
		g[i][0]=a[i+1];
		h[i][0]=i+1;
	}
	for(i=1;i<=n;i++)
	{
		gg[i][0]=a[i];
		hh[i][0]=i;
	}
	for(j=1;j<=17;j++)
		for(i=1;i<=n;i++)
		{
			if(g[i][j-1]<g[i+(1<<j)][j-1])
			{
				g[i][j]=g[i][j-1];
				h[i][j]=h[i][j-1];
			}else
			{
				g[i][j]=g[i+(1<<j)][j-1];
				h[i][j]=h[i+(1<<j)][j-1];
			}
			if(gg[i][j-1]<gg[i+(1<<j)][j-1])
			{
				gg[i][j]=gg[i][j-1];
				hh[i][j]=hh[i][j-1];
			}else
			{
				gg[i][j]=gg[i+(1<<j)][j-1];
				hh[i][j]=hh[i+(1<<j)][j-1];
			}
		}
	f.push((type){1,n,a[get(1,n)]});
	for(i=1;i<=n/2;i++)
	{
		t=f.top();
		f.pop();
		x=get(t.l,t.r);
		printf("%d ",t.x);
		if(g[x][log[(t.r-x+1)/2]]<g[t.r-(1<<log[t.r-x+1])+1][log[(t.r-x+1)/2]])y=h[x][log[(t.r-x+1)/2]];else y=h[t.r-(1<<log[t.r-x+1])+1][log[(t.r-x+1)/2]];
		printf("%d ",a[y]);
		if(t.l<x)f.push((type){t.l,x-1,a[get(t.l,x-1)]});
		if(x<y-1)f.push((type){x+1,y-1,a[get(x+1,y-1)]});
		if(y+1<t.r)f.push((type){y+1,t.r,a[get(y+1,t.r)]});
	}
}

Measured memory_bytes: 91640
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#include<vector>
using namespace std;

int main()
{
    int bingocard[3][3] = {};

    for(int i = 0; i<3;i++)
    {
        cin >> bingocard[i][0] >> bingocard[i][1] >> bingocard[i][2];
    }

    int N;
    cin >> N;

    int b[128];
    for(int i=0; i<N;i++)
    {
        cin >> b[i];
    }
    
    bool aki[3][3] = {false};

    for(int i=0; i<N;i++)
    {
        for(int j=0;j<3;j++)
        {
            for(int k=0;k<3;k++)
            {
                if(bingocard[j][k] == b[i])
                    aki[j][k] = true;
                //printf("bingocard[%d][%d] = %d, b[%d] = %d, aki=[%d][%d] = %d\n",j,k,bingocard[j][k],i,b[i],j,k,aki[j][k]);
            }
        }
    }

    // ビンゴを確認
    if(aki[0][0] && aki[0][1] &&aki[0][2])
        cout << "Yes" << endl;
    else if(aki[1][0] && aki[1][1] &&aki[1][2])
        cout << "Yes" << endl;
    else if(aki[2][0] && aki[2][1] &&aki[2][2])
        cout << "Yes" << endl;
    else if(aki[0][0] && aki[1][0] &&aki[2][0])
        cout << "Yes" << endl;
    else if(aki[0][1] && aki[1][1] &&aki[2][1])
        cout << "Yes" << endl;
    else if(aki[0][2] && aki[1][2] &&aki[2][2])
        cout << "Yes" << endl;
    else if(aki[0][0] && aki[1][1] &&aki[2][2])
        cout << "Yes" << endl;
    else if(aki[0][2] && aki[1][1] &&aki[2][0])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solution solver = new Solution();
        solver.solve(1, in, out);
        out.close();
    }

    static class Solution {
        public void solve(int testNumber, InputReader in, PrintWriter out) {

            int a = in.nextInt();
            int money = 1000;
            int res = 0;
            int change = a % money;
            if (change != 0) {
                res = money - change;
            }

            System.out.print(res);
        }
    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String nextLine() {
            String inputLine = "";
            try {
                inputLine = reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return inputLine;
        }
    }
}





Measured memory_bytes: 32636
#include <bits/stdc++.h>
using namespace std;
typedef long long llint;
const llint MOD = 998'244'353;

int main() {
    int S, W;
    cin >> S >> W;
    if(W >= S) {
        cout << "unsafe";
    }
    else {
        cout << "safe";
    }
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int N;
ll K;
vector<ll> A,F;

bool solve(ll X){
  ll res=K;
  for(int i=N-1;i>=0;i--){
    ll a=A[i],f=F[N-1-i];
    if(a*f>X){
      res-=(a*f-X)/f+((a*f-X)%f!=0);
    }
  }
  return (res>=0);
}

int main(){
  cin>>N>>K;
  rep(i,N){
    int a; cin>>a;
    A.push_back(a);
  }
  rep(i,N){
    int f; cin>>f;
    F.push_back(f);
  }
  sort(A.begin(),A.end());
  sort(F.begin(),F.end());
  ll ok=1e18,ng=-1;
  while(ok-ng>1){
    ll mid=(ok+ng)/2;
    if(solve(mid)) ok=mid;
    else ng=mid;
  }
  cout<<ok<<endl;
  return 0;
}

Measured memory_bytes: 4848
#include "bits/stdc++.h"
#include <cmath>

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    string N;
    cin >> N;
    int sum = N[0] - '0';
    bool flag = true;
    for(int i = 1; i < (int)N.size(); i++){
        if(N[i] != '9'){
            flag = false;
            break;
        }
    }
    sum += ((int)(N.size()) - 1) * 9;
    if(!flag) sum--;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,i,j,n;
    int num;
    bool cards[4][13] = {false};
    char pat;
    char pattern[4] = {'S','H','C','D'};
    cin>>n;

    for(a=0;a<n;a++){
        cin>>pat>>num;    
        for(j=0;j<4;j++){
            if(pat==pattern[j]){
                cards[j][num-1] = true;
                break;
            }   
        }
    }

    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(!cards[i][j]){
                cout<<pattern[i]<<" "<<j+1<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3096
X, N = map(int, input().split())
P = list(map(int, input().split()))
differ=[]

if N == 0:
    print(X)
else:
    for i in range(0,102):
        if i not in P:
            differ.append(abs(X - i))
        else:
            differ.append(1000)
    ans = differ.index(min(differ))
    print(ans)


Measured memory_bytes: 9184
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  long long k; cin >> k;
  if (s.length() == 1) {
    cout << k / 2 << '\n';
    return 0;
  }
  set<char> st;
  for (char c : s) st.emplace(c);
  if (st.size() == 1) {
    long long len = k * s.length();
    cout << len / 2 << '\n';
    return 0;
  }
  string ss = s + s + s;
  long long pre = 0, mid = 0, ato = 0;
  vector<bool> keshita(ss.length(), false);
  FOR(i, 1, s.length()) {
    if (ss[i] == ss[i - 1]) {
      if (!keshita[i - 1]) {
        keshita[i] = true;
        ++pre;
      }
    }
  }
  FOR(i, s.length(), s.length() + s.length()) {
    if (ss[i] == ss[i - 1]) {
      if (!keshita[i - 1]) {
        keshita[i] = true;
        ++mid;
      }
    }
  }
  FOR(i, s.length() + s.length(), ss.length()) {
    if (ss[i] == ss[i - 1]) {
      if (!keshita[i - 1]) {
        keshita[i] = true;
        ++ato;
      }
    }
  }
  long long ans = pre;
  if (k >= 2) ans += mid;
  if (k >= 3) ans += (k - 2) * ato;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
from collections import deque
n,x,y=map(int,input().split())

L=[[1]]
for i in range(1,n-1):
	L.append([i-1,i+1])
L.append([n-2])
L[x-1].append(y-1)
L[y-1].append(x-1)

R=[0]*n

def bfs(j):
	V=[-1]*n
	que=deque([])
	que.append(j)
	V[j]=0
	while que:
		p=que.popleft()
		for np in L[p]:
			if V[np]==-1:
				que.append(np)
				V[np]=V[p]+1
	for i in range(n):
		R[V[i]]+=1
	
for j in range(n):
	bfs(j)
for i in range(1,n):
	print(R[i]//2)

Measured memory_bytes: 47964
#include<bits/stdc++.h>
using namespace std;
int main() {
	int s; cin >> s;
	vector<bool> is_appeared(1001001, false);
	int a = s;
	is_appeared[a] = true;
	for (int i = 2; ; i++)
	{
		if(a % 2 == 0) a /= 2;
		else a = 3 * a + 1;
		if(is_appeared[a]) {
			cout << i << endl;
			return 0;
		}
		else is_appeared[a] = true;
	}
	
	return 0;
}


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

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		int r=in.nextInt();
		int st=in.nextInt();
		int p=in.nextInt();
		String s=in.next();
		int [] used = new int [n];
		long ans=0;
		for(int i=0;i<n;i++)
		{
			if(i<k||(s.charAt(i-k)==s.charAt(i)&&used[i-k]==0)||s.charAt(i-k)!=s.charAt(i))
			{
				used[i]=1;
				if(s.charAt(i)=='r')
				{
					ans=ans+p;
				}
				if(s.charAt(i)=='s')
				{
					ans=ans+r;
				}
				if(s.charAt(i)=='p')
				{
					ans=ans+st;
				}
			}
			else
			{
				used[i]=0;
			}
		}
		System.out.println(ans);	
	}
}
	

Measured memory_bytes: 28760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var nk = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var n = nk[0];
            var k = nk[1];

            var a = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var dict = new Dictionary<long, int>();

            for(int i = 0; i < n; i++) {
                if (dict.ContainsKey(a[i]) == false) {
                    dict.Add(a[i], 0);
                }

                dict[a[i]]++;
            }

            var dList = dict.ToList();
            dList.Sort((x, y) => x.Value - y.Value);

            var removeNum = dList.Count - k;

            var sum = 0L;

            for(int i = 0; i < removeNum; i++) {
                sum += dList[i].Value;
            }

            Console.WriteLine(sum);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 56688
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin>>str;
    string tmp=str;
    reverse(str.begin(),str.end());
    for(string::iterator it=str.begin();it!=str.end();++it)
        switch(*it)
        {
            case 'p':*it='q';break;
            case 'q':*it='p';break;
            case 'b':*it='d';break;
            case 'd':*it='b';break;
        }
    if(str==tmp) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main() {
  int s;
  cin>>s;
  vector<int> a;
  a.push_back(s);
  for(int i=0; ; i++){
    if(s%2==0) s/=2;
    else s=3*s+1;
    for(int j=0; j<i; j++){
      if(s==a[j]) {
        cout<<a.size()+1;
        return 0;
      }
    }
    a.push_back(s);
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    vector<int> h(n);
    for (int &hi: h) cin >> hi;
    vector<int> dp(n, 0);
    for (int i = 1; i < n; i++) {
        if (h[i - 1] >= h[i]) chmax(dp[i], dp[i - 1] + 1);
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main() {
	int l, m = 0;
	string s;

	cin >> s;
	
	l = (int)s.size();

	//cout << l << s << endl;

	for (int i = 0; i < l; i++) {
		m += static_cast<int>(s[i]-'0');
		//cout << m << endl;
	}

	(m*2 - l)>0 ? cout << l-(m*2-l) << endl: cout << l-(l-m*2) << endl;

	return 0;
}

Measured memory_bytes: 512
<?php

fscanf(STDIN, '%d', $N);
fscanf(STDIN, '%s', $S);

$temp = substr_count($S, '.');
$min = $temp;

for ($i=0; $i < $N; $i++) { 
    if ( $S[$i] == '.' ) {
        $temp--;
    } else {
        $temp++;
    }
    $min = min($min,$temp);
}

echo $min;


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

#define N 8
static const int cap[N] = {4, 1, 4, 1, 2, 1, 2, 1};

int main(){
    int Q[N];
    while( cin >> Q[0] ){
	for ( int i = 1; i < N; i++ ) cin >> Q[i];

	int min = INT_MAX;
	int minv = INT_MAX;
	int start;

	for ( int s = 0; s < N; s++ ){
	    int sum = 0;
	    for ( int i = 0; i < N; i++ ){
		int rem = Q[i] - cap[(i+s)%N];
		if ( rem > 0 ) sum += rem;
	    }
	    int value = 0;
	    int p = 1;
	    for ( int i= N-1; i >= 0; i-- ){
		value += p * cap[(i+s)%N];
		p *= 10;
	    }

	    if ( sum == min ) {
		if ( value < minv ){
		    min = sum;
		    minv = value;
		    start = s;
		}
	    } else if ( sum < min ){
		min = sum;
		minv = value;
		start = s;
	    }
	}

	int j = 0;
	for ( int i = start; i < N + start; i++ ){
	    if ( j ) cout << " ";
	    cout << cap[i%N];
	    j++;
	}
	cout << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

    #pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    /*#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #pragma GCC target ("avx2")*/

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

ll MAX = 1e15;
double PI = 3.141592653589793238463;
//double PI = acos(-1);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


void solve(){
    ll n,k,c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    ll amount = (n+c)/(c+1);
    vector<ll> L, R;
    for(ll i=0; i<n; i++){
        if(s[i]=='o'){
            L.push_back(i);
            i+=c;
        }
    }
    for(ll i=n-1; i>=0; i--){
        if(s[i]=='o'){
            R.push_back(i);
            i-=c;
        }
    }
    reverse(R.begin(), R.end());
    if(L.size()>k || R.size()>k){
        return;
    }
    for(ll i=0; i<L.size(); i++){
        if(L[i]==R[i]){
            cout << L[i]+1 << "\n";
        }
    }

}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif


    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }


    return 0;
}


Measured memory_bytes: 8036
import bisect as bi

n = int(input())
lia = list(map(int,input().split()))
lib = list(map(int,input().split()))
lic = list(map(int,input().split()))
lia = sorted(lia)
lib = sorted(lib)
lic = sorted(lic)

ans = 0
for i in range(n):
  tmpa = bi.bisect_left(lia,lib[i])
  tmpc = n - bi.bisect_right(lic,lib[i])
  ans += tmpa*tmpc
print(ans)

Measured memory_bytes: 23232
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    long long int n2;
  
  int i=0,co=0;
  cin>>n;
  vector<long long int>v(n);
  for(i=0;i<n;i++)
  {
    cin>>n2;
    v[i] = n2;
  }

//cout<<v.size()<<endl;
  
  
  if(n<3)
  {
    cout<<"0"<<endl;
  }
 
else{
  sort(v.begin(),v.end());
  
  int j=0;
  int fin=0;
  int k=0,k1=0,k2=0;
  for(i=0;i<n-2;i++){
      
  for(j=i+1;j<n-1;j++){
  

     k1 = j;
      while(k1 < (n-1) && (v[k1]==v[i]))
      {
          k1++;
      }
      j = k1;

     if(j==(n-1)){
         break;
     }
  
    long long int sum = v[i]+v[j];

   for(fin=j+1;fin<n;fin++)
   {
       
       k2 = fin;
       while(k2 < (n) && (v[k2] == v[j]))
       {
           k2++;
       }
       fin = k2;
       
       if(fin == n){
           break;
       }
       
       if(sum > v[fin]){
           co++;
       }
       
   }
  
  }
  
  
  }
  
  cout<<co<<endl;
}
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  int x, y, z;
  cin >> S;
  ;
}
void solve() {
  int ans = true;
  for (int i = 0; i < S.size();) {
    if (S.substr(i, 11) == "dreameraser") {
      i += 11;
    } else if (S.substr(i, 10) == "dreamerase") {
      i += 10;
    } else if (S.substr(i, 6) == "eraser") {
      i += 6;
    } else if (S.substr(i, 5) == "erase") {
      i += 5;
    } else if (S.substr(i, 7) == "dreamer") {
      i += 7;
    } else if (S.substr(i, 5) == "dream") {
      i += 5;
    } else {
      ans = false;
      break;
    }
  };
  cout << (ans ? "YES" : "NO") << endl;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 512
def partition(A,p,r):
    x = int(A[r][2:])
    i = p-1
    for j in range(p,r):
        if int(A[j][2:]) <= x:
            i = i + 1
            A[i],A[j] = A[j],A[i]
    A[i+1],A[r] = A[r],A[i+1]
    return i + 1
    
def quicksort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quicksort(A, p, q-1)
        quicksort(A, q+1, r)


    
n = int(input())
A = [input() for i in range(n)]
stable = sorted(A, key=lambda x:
int(x.split()[1]))
B = A[:]
quicksort(A,0,n-1)
print("Stable" if stable == A else "Not stable")

for c in A:
    print(c)


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(x,n) for(auto& (x) : n)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define inf 1000000000
#define llinf 1000000000000000
#define MAX 1000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;
typedef pair<int,pint> P;

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

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

int main()
{
	char c;
	cin >> c;

	string alp = "abcdefghijklmnopqrstuvwxyz";
	bool flag = false;
	char ans;
	for (char alp_ele : alp) {
		if (flag) {
			ans = alp_ele;
			flag = false;
		}
		if (alp_ele == c) {
			flag = true;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
a = [int(input()) for i in range(5)]
from itertools import permutations

ans = float('inf')

def calc(i):
    ret = i[0]
    for i in i[1:]:
        if ret % 10 != 0:
            ret += (10 - ret % 10) + i
        else:
            ret += i
    return ret

for i in permutations(a, 5):
    ans = min(ans, calc(i))

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数list 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(ALL(v));
  return v;
}

int main() {
    int h,w;
    string s;
    cin>>h>>w;
    auto f = false;
rep(i, 2000001){
    auto y = i-1000000;
    if(abs(y - w) < h) {
        if(f) cout<<" ";
        f=true;
        cout<<y;
    }

}

    pr("");
    return 0;
}


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

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	ll k;
	cin>>k;
	ll s = 0;
	for (ll a = 1; a<=k; a++){
		for (ll b = 1; b<=k; b++){
			for (ll c = 1; c<=k; c++){
				s+=__gcd(__gcd(a,b),c);
			}
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3600