akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
struct ti{
	int id,a;
}x[100010];
bool cmp(ti x,ti y){
	return x.a<y.a ;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x[i].a;
		x[i].id=i;	
	}
	sort(x+1,x+n+1,cmp);
	for(int i=1;i<=n;i++)cout<<x[i].id<<' ';cout<<endl;
	return 0;
}

Measured memory_bytes: 1536
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextInt64() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}


func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func (io *Io) PrintBool(b bool, trueS, falseS string) {
	if b {
		io.PrintLn(trueS)
	} else {
		io.PrintLn(falseS)
	}
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func absi(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func b2i(b bool) int {
	if b {
		return 1
	}
	return 0
}

type Int64s []int64
func (f Int64s) Len() int {
	return len(f)
}
func (f Int64s) Less(i, j int) bool {
	return f[i] < f[j]
}

func (f Int64s) Swap(i, j int) {
	f[i], f[j] = f[j], f[i]
}


func abcInt(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func gcdInt(a, b int) int {
	for a%b != 0 {
		a, b = b, a%b
	}
	return b
}

var (
	io *Io
)

type P struct {
	s string
	p int
	id int
}

type PS []P
func (f PS) Len() int {
	return len(f)
}
func (f PS) Less(i, j int) bool {
	if f[i].s != f[j].s {
		return f[i].s< f[j].s
	}
	return f[i].p > f[j].p
}

func (f PS) Swap(i, j int) {
	f[i], f[j] = f[j], f[i]
}

func solve() {
	a := io.NextInt()
	b := io.NextInt()

	io.PrintLn((a * 3 + b) / 2)
}


func main() {
	io = NewIo()
	f, err := os.Open("src/input")
	if err == nil {
		io.reader = bufio.NewReader(f)
	}
	defer io.Flush()

	solve()
}

Measured memory_bytes: 640
function main()
  
  N = parse(Int,readline())
  a = map(x -> parse(Int,x), split(readline()))
  
  ans = 0
  
  for i in a
    while i % 2 == 0
      ans += 1
      i = div(i,2)
    end
  end
        
  println(ans)
  
end

main()

Measured memory_bytes: 118760
h, w = map(int, input().split())

a = [input() for i in range(h)]

bh = [0] * h
bw = [0] * w

for i in range(h):
  for j in range(w):
    if a[i][j] == '#':
      bh[i] = 1
      bw[j] = 1
      
for i in range(h):
  if bh[i]:
    for j in range(w):
      if bw[j]:
        print(a[i][j], end='')
    print()

Measured memory_bytes: 4468
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 998244353
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    int res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;


        y = y>>1;
        x = x*x;
    }
    return res;
}
bool isPalindrome(string str)
{
    // Start from leftmost and rightmost corners of str
    int l = 0;
    int h = str.length()- 1;

    // Keep comparing characters while they are same
    while (h > l)
    {
        if (str[l++] != str[h--])
        {
            return false;
        }
    }
    return true;
}

signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
string s;
cin>>s;
int x=s.size();
string l="",r="";
for(int i=0;i<x/2;i++)
    l+=s[i];
for(int i=(x/2)+1;i<x;i++)
    r+=s[i];
if(isPalindrome(s)&&isPalindrome(l)&&isPalindrome(r))
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;
}









Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll num[4][4];
  for(int i=0;i<3;i++)for(int j=0;j<3;j++)cin>>num[i][j];
  if(num[0][0]-num[1][0]==num[0][1]-num[1][1]&&
     num[0][1]-num[1][1]==num[0][2]-num[1][2]&&
     num[1][0]-num[2][0]==num[1][1]-num[2][1]&&
     num[1][1]-num[2][1]==num[1][2]-num[2][2])
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
a=gets.chomp.to_i
b=gets.chomp.to_i
c=gets.chomp.to_i
x=gets.chomp.to_i

pay_a,pay_b=0,0
ways=0
sum=0
while pay_a<=a && pay_a*500<=x do
  while pay_b<=b && pay_a*500+pay_b*100<=x do
    sum=pay_a*500+pay_b*100
    if (x-sum)/50<=c then
      ways+=1
    end
    pay_b+=1
  end
  pay_b=0
  pay_a+=1
end
puts ways


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);

		// 整数nの取得
		int n = scanner.nextInt();

		long min = 1000000;
		long max = -1000000;
		long sum = 0;

		for (int i = 0; i < n; i++) {
			// 整数aの取得
			long a = scanner.nextLong();

			sum += a;

			if (min > a) {
				min = a;
			}

			if (max < a) {
				max = a;
			}

		}

		System.out.println(min + " " + max +  " " + sum);

	}

}



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

int main() {
	string a;
	cin>>a;
	int ans=0;
	for(int i=0;i<a.length();i++){
		if(a[i]=='o') ++ans;
	}
	if(ans+15-a.length()>=8) cout<<"YES";
	else cout<<"NO";
}

Measured memory_bytes: 256
import sys
from fractions import gcd

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]



n, m = na()
l, r = [0] * m, [0] * m
for i in range(m):
    l[i], r[i] = na()

if min(r) - max(l) < 0:
    ans = 0
else:
    ans = min(r) - max(l) + 1
print(ans)

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int sz = s.size();
    string ans(1, s[0]);
    char used[26] = {};
    used[s[0] - 'a'] = true;
    for (int j = 0; j + 3 < sz; j += 3) {
      if (used[s[j + 3] - 'a']) continue;
      used[s[j + 3] - 'a'] = true;
      if (s.substr(j + 1, 2) == "->") ans = ans + s[j + 3];
      else ans = s[j + 3] + ans;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3112
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！
ArrayList<String> in=new ArrayList<String>();
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
String s[]=line.split("",0);
for(int i=0;i<s.length;i++){
if(s[i].equals("1"))
in.add("1");

if(s[i].equals("0"))
in.add("0");
if(s[i].equals("B")&&in.size()!=0)
in.remove(in.size()-1);

}
for(int i=0;i<in.size();i++)
        System.out.print(in.get(i));System.out.println();
    }

}

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

int main() {
    ll n, sum = 0;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    ll toSub = (n + 1) * n / 2;
    if (sum % toSub != 0) {
        puts("NO");
        return 0;
    }
    a.push_back(a[0]);
    ll k = sum / toSub;
    rep(i, n) {
        ll diff = a[i + 1] - a[i];
        // diff = k - t * n
        diff = k - diff;
        if (diff < 0 || diff % n != 0) {
            puts("NO");
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 4756
import java.io.PrintWriter
import java.util.*
import java.math.*

val pw = PrintWriter(System.out)

fun main(args: Array<String>) {
    val (sx, sy, tx, ty) = readListOfInt()
    val upNum = ty - sy
    val rightNum = tx - sx
    val upString = (0 until upNum).fold("") { acc, i -> acc + "U" }
    val rightString = (0 until rightNum).fold("") {acc, i -> acc + "R" }

    val downString = (0 until upNum).fold("") {acc, i -> acc + "D" }
    val leftString = (0 until rightNum).fold("") {acc, i -> acc + "L" } + "L"

    val upString2 = upString + "U"

    val rightString2 = rightString + "RDR"
    val downString2 = downString + "D"
    val leftString2 = leftString + "U"

    val result = upString + rightString + downString + leftString + upString2 + rightString2 + downString2 + leftString2

    println(result)
    pw.flush()
}

fun inputList() = 
    readLine()!!.split(" ").map(String::toInt)

fun sum_digits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

/****** Decrared Functions ******/

// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }


fun println(value : Any) {
    pw.println(value)
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)


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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define TEST_CASE int tc;cin>>tc;while(tc--)


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



int main(int argv, char* argc[])
{
    FASTIO

    vii v(5);
    rep(i,5)
    cin>>v[i];
    int ans;

    rep(i,5)
    {
        if(!v[i])
            ans = i;
    }
    cout<<ans+1;


    return 0;
}


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

int main()
{
    string s, t;
    cin >> s >> t;
    int ans = 1e9;
    rep(i, s.size() - t.size() + 1)
    {
        int cnt = 0;
        rep(j, t.size())
        {
            if (s[i + j] != t[j])
                cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
n,m,q=map(int,input().split(" "))
arr=[list(map(int, input().split(" "))) for i in range(q)]
ans=0
for i1 in range(1,m+1):
	for i2 in range(i1,m+1):
		for i3 in range(i2, m+1):
			for i4 in range(i3, m+1):
				for i5 in range(i4, m+1):
					for i6 in range(i5, m+1):
						for i7 in range(i6, m+1):
							for i8 in range(i7, m+1):
								for i9 in range(i8, m+1):
									for i10 in range(i9, m+1):
										tmp=0
										arrs=[0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
										for a,b,c,d in arr:
											if arrs[b]-arrs[a]==c:
												tmp+=d
										ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 9264
#最大公約数
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
#最小公倍数
def lcm(a,b):
    x = gcd(a,b)
    return a*b//x
"""
from fractions import gcd
def lcm(a,b): 
    return a*b//gcd(a,b)
"""
n = int(input())
t=[]
for i in range(n):
    t.append(int(input()))
ans = 1
for i in range(n):
    ans = lcm(ans,t[i])
print(ans)


Measured memory_bytes: 3064
str = input()
str = str[::-1]
devide = ['dream', 'dreamer', 'erase', 'eraser']
devide = [s[::-1] for s in devide]
flag = True
length = []

for i in range(len(devide)):
    length.append(len(devide[i]))
maxlen = max(length)

while len(str) >= maxlen:
    delete = False
    for s in devide:
        if str[0:len(s)] == s:
            str = str[len(s):]
            delete = True
    if not delete:
        flag = False
        break

if flag:
    print('YES')
else:
    print('NO')


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

using namespace std;

int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int sum=0;
	while(k--) {
		if(a>0) {sum++; a--;}
		else if(b>0) {b--;continue;}
		else {sum--; c--;}
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 3556
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
 
        if(y >= r && y <= H-r && x >=r && x <= W-r){
            System.out.printf("Yes\n");
        }else{
            System.out.printf("No\n");
        }
    }
}


Measured memory_bytes: 26360
use proconio::input;

fn main() {
    input! {
        n: i64,
        uv: [(i64, i64); n - 1],
    };

    // \sum_{l=1}^{n} \sum_{r=l}^{n} r - l + 1
    let mut c_v = 0_i64;
    for l in 1..=n {
        c_v += l * (n - l + 1)
    }

    let mut c_e = 0_i64;
    for &(u, v) in uv.iter() {
        let (l, r) = if u < v { (u, v) } else { (v, u) };
        c_e += l * (n - r + 1)
    }

    let ans = c_v - c_e;
    println!("{}", ans);
}


Measured memory_bytes: 7652
c=p=0;b=[0]*1000000
for _ in range(int(input())):
    x=int(input())
    if (c==x and p!=x) or b[0]==1 or c>x:print('No');continue
    print('Yes')
    if x>=1000000:continue
    p+=1;b[x]+=1
    while b[x]>1:p-=1;b[x]-=2;b[x-1]+=1;x-=1
    while b[c+1]==1 and c<999999:c+=1

Measured memory_bytes: 15120
#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
#include <cmath>
using namespace std;

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

    int a[N];
    int res = 0;
    for(int i=0;i<N;i++){
        cin >> a[i];
        res += (a[i]-1);
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    
    int a = 0;
    int b = 0;
    int sum = 0;
    int sum2 = 0;
    scanf("%d",&a);
    scanf("%d",&b);
    
    if(0<a && b<101){
        sum = a*b;
        sum2 = (a+b)*2;
        printf("%d ",sum);
        printf("%d\n",sum2);
    }else{
        return 0;
    }
    
    return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	while (scanf("%d", &n) != EOF) {
		int i, j;
		int a;
		long long sum;
		int f[100005];
		sum = 0;
		memset(f, 0, sizeof(f));
		for (i = 0; i < n; i ++) {
			scanf("%d", &a);
			sum += a;
			f[a] ++;
		}
		
		int q;
		scanf("%d", &q);
		while (q --) {
			int b, c;
			long long d;
			scanf("%d%d", &b, &c);
			if (f[b] > 0) {
				d = c - b;
				sum = sum + (d * (long long) f[b]);
				f[c] += f[b];
				f[b] = 0;
			}
			printf("%lld\n", sum);
		}
	}
	return (0);
}


Measured memory_bytes: 2124
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int A, B;
  cin >> A >> B;
  cout << max(A-B, max(A+B, A*B)) << endl;
  return 0;
}

Measured memory_bytes: 3132
def gcd(a, b):
  if a < b:
    a, b = b, a
  if b == 0:
    return a
  c = a % b
  return gcd(b, c)
n, x = [int(i) for i in input().split()]
point = list(map(int, input().split()))
dif = []

if(len(point) == 1):
  ans = abs(point[0] - x)
else:
  gcd_now = abs(point[0] - x)
  for i in range(len(point) - 1):
    dif.append(abs(point[i+1] - point[i]))
    gcd_now = gcd(gcd_now, dif[i])
  ans = gcd_now
print(ans)


Measured memory_bytes: 14224
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  long double sum = 0;
  rep(i, N)
  {
    string x;
    string u;
    cin >> x >> u;
    if (u == "JPY")
    {
      sum += std::stoi(x);
    }
    else
    {
      sum += std::stold(x) * 380000.0f;
    }
  }

  cout << std::fixed << std::setprecision(10) << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
const int MOD = 1e9 + 7;
const int INF = 2e9;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int GCD(int x, int y) { return y ? GCD(y, x % y) : x; }
int LCM(int x, int y) { return x * y / GCD(x, y); }

int main(){
    int n;
    cin >> n;
    vi b(n), ans(n);
    for (int i = 0; i < n; i++){
        cin >> b[i];
        b[i]--;
    }
    int N = n;
    for(int i=0; i<n+i; i++){
        for(int j=n-1; j>=0; j--){
            if(b[j] == j){
                ans[i] = j;
                for (int k = j + 1; k<n; k++){
                    b[k - 1] = b[k];
                }
                n--;
                j = -1;
                // for(int k=0; k<n; k++){
                //     cout << b[k]+1 << ' ';
                // }
                // cout << endl;
            }
            if(j==0){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    reverse(ans.begin(), ans.end());
    for(auto v : ans){
        cout << v+1 << endl;
    }
}

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

#define FOR(i, a, b) for (int (i) = (a); (i) < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cerr << #x << " " << x << endl
#define eb push_back
#define _ << " " <<
typedef long long ll;
typedef std::pair<int, int> ii;
#define X first
#define Y second
#define double long double
typedef double db;
using namespace std;

const int MaxN = 110;
const int Mod = 1e9 + 7;

int N;
int mat[MaxN][MaxN];
vector<int> adj[MaxN];
vector<pair<int, int>> edges;
int been[MaxN], dep[MaxN];
int downDeg[MaxN];
int maxDegOnDepth[MaxN];

void dfs(int node, int depth){

  // 'been' already taken care of
  dep[node] = depth;

  for (auto v: adj[node]){
    
    if (!been[v]){
      been[v] = 1;
      downDeg[node]++;
      dfs(v, depth + 1);
    }
  }

  maxDegOnDepth[dep[node]] = max( maxDegOnDepth[dep[node]], downDeg[node] );

}


pair<ll, ll> solveCenterNode(int start){
  
  memset(been, 0, sizeof been);
  memset(dep, -1, sizeof dep);
  memset(downDeg, 0, sizeof downDeg);
  memset(maxDegOnDepth, -1, sizeof maxDegOnDepth);
  
  been[start] = 1;
  dfs(start, 0);

  int colorful = -1;
  ll numCurLeaves = 1;

  for (int i = 0; i < N + 4; i++){
    
    if (maxDegOnDepth[i] == 0){
      colorful = i + 1;    
      break;
    }

    numCurLeaves *= (ll)maxDegOnDepth[i];  
  }

  return {colorful, numCurLeaves};
}

pair<ll, ll> solveCenterEdge(pair<int, int> edge){

  memset(been, 0, sizeof been);
  memset(dep, -1, sizeof dep);
  memset(downDeg, 0, sizeof downDeg);
  memset(maxDegOnDepth, -1, sizeof maxDegOnDepth);
  
  been[edge.first] = 1;
  been[edge.second] = 1;
  dfs(edge.first, 0);
  dfs(edge.second, 0);

  int colorful = -1;
  ll numCurLeaves = 1;

  for (int i = 0; i < N + 4; i++){
    
    if (maxDegOnDepth[i] == 0){ //mutna linijica
      colorful = i + 1;    
      break;
    }

    numCurLeaves *= (ll)maxDegOnDepth[i];  
  }

  return {colorful, numCurLeaves * 2};
}

void solve() {
 
  ll minCol = 1e7;
  ll maxLeaves = -1;

  for(int i = 1; i <= N; i++){
    auto ans = solveCenterNode(i);
    if (ans.first < minCol){
      minCol = ans.first;
      maxLeaves = ans.second;
    }
    else if (ans.first == minCol){
      maxLeaves = min(maxLeaves, ans.second);
    }
  }

  for (auto edge: edges){
    auto ans = solveCenterEdge(edge);
    if (ans.first < minCol){
      minCol = ans.first;
      maxLeaves = ans.second;
    }
    else if (ans.first == minCol){
      maxLeaves = min(maxLeaves, ans.second);
    }
  }

  cout<<minCol<<" "<<maxLeaves<<endl;
}

void load() {
  cin>>N;
  int ta, tb;
  REP(i, N - 1){
    cin>>ta>>tb;
    mat[ta][tb] = 1;
    mat[tb][ta] = 1;
    adj[ta].eb(tb);
    adj[tb].eb(ta);
    edges.eb({ta, tb});
  }
}

int main(){
//  ios_base::sync_with_stdio(false);
  load();	
  solve();
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  ll ans = 0;
  rep(i, 0, N) {
    VAR(int, l, r);
    ans += r - l + 1;
  }
  print(ans);
}


Measured memory_bytes: 256
import sys
import math

N = int(input())
S = input()

wl = [0] * (N + 2)
er = [0] * (N + 2)

for i in range(N):
    wl[i + 1] = int(S[i] == 'W') + wl[i]
    er[N - i] = int(S[N - 1 - i] == 'E') + er[N - i + 1]

ans = N

S = ' ' + S
for i in range(1, N + 1):
    ans = min(wl[i - 1] + er[i + 1], ans)
print(ans)


Measured memory_bytes: 27348
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define inf (int)1e18+7
const int nmax = (int) 1e5 + 10;

vector< int > graph[nmax];
int ins[nmax], dist[nmax];
vector<int > topo;
bool vis[nmax];

void dfs(int u) {
    vis[u] = true;    
    for (auto v : graph[u]){
        if (vis[v]) continue;
        dfs(v);
    }
    topo.push_back(u);
}


int solve(int root) {
    topo.clear();
    memset(vis, 0, sizeof vis);
    dfs(root);
    
    memset(dist, 0, sizeof dist);

    for (int u : topo) {
        for (int v : graph[u]) {
            dist[u] = max(dist[u], dist[v] + 1);    
        }
    }
    
    return dist[root];
}




    
                     
signed main() {

    ios_base :: sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    while (m -- ) {
        int u, v;
        cin >> u >> v;
        ins[v] ++;
        graph[u].push_back(v);
    }

    vector<int > roots;
    for (int i = 1; i <= n; i ++) {
        if (ins[i] == 0) {
            roots.push_back(i);    
        }
    }

    int ans = 0;
    for (auto root: roots) {
        ans = max(ans, solve(root));
    }

    cout << ans << endl;
                                                                                                                                

    return 0;
}

Measured memory_bytes: 13044
using System;
 
namespace ConsoleApplication32
{
    class Program
    {
        static void Main(string[] args)
        {
			string str = Console.ReadLine();
			string r = "";
			foreach(char mizutani in str)
			{
				foreach(char yagi in r)
				{
					if(yagi == mizutani)
					{
						Console.WriteLine("no");
						return;
					}
				}
				r += mizutani;
			}
			Console.WriteLine("yes");
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
using namespace std;main(){int n,i,j,M;string p,m;for(cin>>n;n-->0;cout<<m<<endl){cin>>p>>m;M=m.size();for(i=p.size();i-->0;){if(p[i]==74)m=m[M-1]+m.substr(0,M-1);if(p[i]==67)m=m.substr(1,M-1)+m[0];if(p[i]==69){if(M&1)m=m.substr(M/2+1,M/2)+m[M/2]+m.substr(0,M/2);else m=m.substr(M/2,M/2)+m.substr(0,M/2);}if(p[i]==65)reverse(m.begin(),m.end());if(p[i]==80)for(j=M;j-->0;)if(isdigit(m[j]))m[j]=(m[j]-39)%10+48;if(p[i]==77)for(j=M;j-->0;)if(isdigit(m[j]))m[j]=(m[j]-47)%10+48;}}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n,a,b,c,d;
int ok[maxn];
char s[maxn];
int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	scanf(" %s",s+1);
	memset(ok,0,sizeof(ok)); ok[a] = 1;
	for(int i=a+1;i<=c;i++) if(s[i]=='.') ok[i] = ok[i-1] | ok[i-2];
	if(!ok[c]) return !printf("No");
	memset(ok,0,sizeof(ok)); ok[b] = 1;
	for(int i=b+1;i<=d;i++) if(s[i]=='.') ok[i] = ok[i-1] | ok[i-2];
	if(!ok[d]) return !printf("No");
	if(c>d) {
		int res = 0;
		for(int i=b;i<=d;i++) {
			if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.') res = 1;
		}
		if(res) printf("Yes");
		else printf("No");
		return 0;
	}
	printf("Yes");
}

Measured memory_bytes: 1280
import sys
import time
import math
st = time.perf_counter()
def inpl():
    return list(map(int, input().split()))
# ------------------------------

N = int(input())
d = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for _ in range(N):
	s = input()
	d[s] += 1
for k,v in d.items():
	print(k,'x',v)
	
	

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


Measured memory_bytes: 9200
from heapq import heappop, heappush
INF = 10**30

class Rmin():
	def __init__(self, size):
		#the number of nodes is 2n-1
		self.n = 1
		while self.n < size:
			self.n *= 2
		self.node = [INF] * (2*self.n-1)

	def Access(self, x):
		return self.node[x+self.n-1]

	def Update(self, x, val):
		x += self.n-1
		self.node[x] = val
		while x > 0:
			x = (x-1)//2
			self.node[x] = min(self.node[2*x+1], self.node[2*x+2])
		return

	#[l, r)
	def Get(self, l, r):
		L, R = l+self.n, r+self.n
		s = INF
		while L < R:
			if R & 1:
				R -= 1
				s = min(s, self.node[R-1])			
			if L & 1:
				s = min(s, self.node[L-1])
				L += 1
			L >>= 1
			R >>= 1
		return s

n = int(input())
a = list(map(int, input().split()))

even, odd = Rmin(n), Rmin(n)
for i in range(n):
	if i%2 == 0:
		even.Update(i, a[i]*(10**7) + i)
	else:
		odd.Update(i, a[i]*(10**7) + i)

d = dict()

def search(l, r):
	if l%2 == 0:
		p = even.Get(l, r+1)
		q = odd.Get(p%(10**7)+1, r+1)
	else:
		p = odd.Get(l, r+1)
		q = even.Get(p%(10**7)+1, r+1)
	return p, q

x, y = search(0, n-1)
d[x%(10**7)] = (y, 0, n-1)
que = [x]
ans = []

while que:
	x = heappop(que)
	y, l, r = d[x%(10**7)]
	ans += [x//(10**7), y//(10**7)]

	if l != x%(10**7):
		p, q = search(l, x%(10**7)-1)
		d[p%(10**7)] = (q, l, x%(10**7)-1)
		heappush(que, p)

	if r != y%(10**7):
		p, q = search(y%(10**7)+1, r)
		d[p%(10**7)] = (q, y%(10**7)+1, r)
		heappush(que, p)

	if x%(10**7)+1 != y%(10**7):
		p, q = search(x%(10**7)+1, y%(10**7)-1)
		d[p%(10**7)] = (q, x%(10**7)+1, y%(10**7)-1)
		heappush(que, p)

print(*ans)

Measured memory_bytes: 134012
a, b, c = map(int, input().split(' '))

left = 4 * a * b
right = c ** 2 + a ** 2 + b ** 2 - 2 * c * a + 2 * a * b - 2 * b * c

if c - a - b <= 0 or left >= right:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] input = new int[10];
        for(int i = 0; i < input.length; i++){
            input[i] = sc.nextInt();
        }
        Arrays.sort(input);
        for(int i = input.length; i > input.length-3; i--){
            System.out.println(input[i-1]);
        }
    }
}

Measured memory_bytes: 26084
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, Q;
  string S;
  int l[100000], r[100000];
  int c[100000];
  bool f[100000];
  for(int i = 0; i < 100000; i++){
    c[i] = 0;
    f[i] = false;
  }
  
  cin >> N >> Q >> S;
  for(int i = 0; i < Q; i++){
    cin >> l[i] >> r[i];
  }

  for(int i = 0; i < N - 1; i++){
    if(S[i] == 'A' && S[i + 1] == 'C'){
      c[i + 1] = c[i] + 1;
      f[i + 1] = true;
    }else{
      c[i + 1] = c[i];
    }
    
  }
  
  for(int i = 0; i < Q; i++){
    int ans;
    ans = c[r[i] - 1] - c[l[i] - 1];
    cout << ans << endl;
  }
}



Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define maxn 250020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

const ll mod = 1e9 + 7;
const ll p[7] = {19,37,59,97,107,109,91};
ll inv[7];

inline ll add(ll x,ll y){ return (x + y + mod) % mod; }
struct node{
	ll a[7];
	node() { memset(a,0,sizeof(a)); }
	bool operator < (node x)const{
		rep(i,0,6) if ( a[i] != x.a[i] ) return a[i] < x.a[i];
		return 0;	
	}
	node operator + (node x){
		node y;
		rep(i,0,6) y.a[i] = add(a[i],x.a[i]);
		return y;
	}
	node operator - (node x){
		node y;
		rep(i,0,6) y.a[i] = add(a[i],-x.a[i]);
		return y;
	}
	node operator * (const ll p[]){
		node y;
		rep(i,0,6) y.a[i] = a[i] * p[i] % mod;
		return y;
	}
	node operator * (node x){
		node y;
		rep(i,0,6) y.a[i] = a[i] * x.a[i] % mod;
		return y;
	}
	void print(){
		rep(i,0,6) cout<<a[i]<<" ";
		cout<<endl;
	}
}hash_[maxn],pos[maxn];
map <node,int> num;
char s[maxn];
int n;
ll ans;

inline ll power(ll x,ll y){
	ll res = 1;
	while ( y ){
		if ( y & 1 ) res = res * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
void init(){
	rep(i,0,6) inv[i] = power(p[i],mod - 2);
}
void solve(){
	rep(i,0,6) pos[0].a[i] = 1;
	rep(i,1,n){
		hash_[i] = hash_[i - 1] , pos[i] = pos[i - 1];
		if ( s[i] == '+' ) hash_[i] = hash_[i] + pos[i];
		else if ( s[i] == '-' ) hash_[i] = hash_[i] - pos[i];
		else if ( s[i] == '>' ) pos[i] = pos[i] * p;
		else if ( s[i] == '<' ) pos[i] = pos[i] * inv;
	}
	repd(i,n,1){
		num[hash_[i]]++;
		node cur = hash_[n] * pos[i - 1] + hash_[i - 1];
		ans += num[cur];
	}
	cout<<ans<<endl;
}
int main(){
	scanf("%d",&n);
	scanf("%s",s + 1);
	init();
	solve();
}



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

int main()
{
    int n; cin >> n;
    
    vector<pair<long long,long long>> pa(n);
    for (int i = 0; i < n; i++) {
        cin >> pa[i].second >> pa[i].first;
    }
    sort(pa.begin(), pa.end());

    long long tmpTime = 0;
    bool can = true;
    for (int i = 0; i < n; i++) {

        tmpTime += pa[i].second;

        if (pa[i].first < tmpTime) {
            can = false;
        }

    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
   
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[200001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
    return;
}
ll powe[60];
void power()
{
    powe[0]=1;
    REP(i,1,15)
    {
        powe[i]=2*powe[i-1];
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 
ll fact[100005];
void factorial()
{
    fact[0]=1;
    REP(i,1,100002)
    {
        fact[i]=mymod(i*fact[i-1], num);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
	cin>>n>>k;
	double A[300000];
	REP(i,0,n)
	{
		cin>>A[i];
	}
	double ans=0;
	double sum=0;
	REP(i,0,k)
	{
		sum+=(A[i]+1.0)/(2.0);
	}
	assmax(ans,sum);
	REP(i,k,n)
	{
		sum+=(A[i]+1.0)/(2.0);
		sum-=(A[i-k]+1.0)/(2.0);
		assmax(ans,sum);
	}
	cout<<fix(ans, 12);
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <memory>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

typedef pair<int, int> p;

int a, b, c, d;

int main(int argc, char *argv[]) {
    scanf("%d %d %d %d", &a, &b, &c, &d);
    printf("%d\n", min(a, b) + min(c, d));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)

//your code here!
ll lcm(ll A, ll B){
    ll w, gcd=A, b=B;
    if(gcd<b) swap(gcd, b);
    while(b){
        w=gcd%b;
        gcd=b;
        b=w;
    }
    return A*B/gcd;
}
int main(void){
    ll A, B, C, D;
    scanf("%lld %lld %lld %lld", &A, &B, &C, &D);
    A--;
    ll ans = B-A - B/C + A/C -B/D +A/D +B/lcm(C,D) -A/lcm(C,D);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
int main(){
	int n,minj,ret=0,b1,b2,list[101];
	bool isrev=true;
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>list[i];
	}
	for(int i=0;i<n;i++){
		minj=i;
		for(int j=i;j<n;j++){
			if(list[j]<list[minj])minj=j;
		}
		b1=list[i],b2=list[minj];
		list[i]=b2,list[minj]=b1;
		if(i!=minj)ret++;
	}
	for(int i=0;i<n;i++){
		std::cout<<list[i];
		if(i!=n-1)std::cout<<" ";
		else std::cout<<"\n";
	}
	std::cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main()
{
    string str;
    getline(cin, str);

    size_t pos = 0;
    while ((pos = str.find("apple", pos)) != string::npos) {
        str.replace(pos, 5, "xxxxx");
    }

    pos = 0;
    while ((pos = str.find("peach", pos)) != string::npos) {
        str.replace(pos, 5, "apple");
    }

    pos = 0;
    while ((pos = str.find("xxxxx", pos)) != string::npos) {
        str.replace(pos, 5, "peach");
    }

    cout << str << endl;
}

Measured memory_bytes: 1184
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		long Y = s.nextLong();
		
		for(int man = 0; man < N + 1; man++) {
			for(int gosen = 0; gosen < N + 1; gosen++) {
				if(0 <= Y - man*10000 - gosen*5000 && (Y - man*10000 - gosen*5000)/1000 == (N - man - gosen)) {
					System.out.print(man + " ");
					System.out.print(gosen + " ");
					System.out.println(N - man - gosen);
					return;
				}
			}
		}
		
		System.out.println("-1 -1 -1");
    }
}


Measured memory_bytes: 23124
#![allow(unused)]

use proconio::input;
use proconio::marker::{Bytes, Chars, Usize1};
use std::cmp::{Reverse, min, max};
use itertools::Itertools;

#[proconio::fastout]
fn main() {
    input! {
        a: i64,
        b: Chars,
    }

    println!(
        "{}",
        (a * (b[0].to_digit(10).unwrap() as i64) * 100
            + a * (b[2].to_digit(10).unwrap() as i64) * 10
            + a * (b[3].to_digit(10).unwrap() as i64)) / 100
    );
}


Measured memory_bytes: 2200
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = Counter(A)
ans = 0

for i in B.values():
  ans += i*(i-1)//2
for a in A:
  k = B[a]
  print(ans - (k*(k-1)//2)+((k-1)*(k-2)//2))

Measured memory_bytes: 25892
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) {
        cin >> a[i];
    }

    vector<int> v(n, 0);
    int cnt = 0;
    RREP(i, n, 1) {
        if (i * 2 > n) {
            v[i-1] = a[i-1];
        } else {
            int sum = 0;
            int j = i;
            while (j+i <= n) {
                j += i;
                sum += v[j-1];
            }
            v[i-1] = abs(a[i-1] - sum % 2);
        }
        cnt += v[i-1];
    }

    std::cout << cnt << '\n';
    REP(i, n) {
        if (v[i]) {
            std::cout << i+1 << ' ';
        }
    }
    if (cnt > 0) {
        std::cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 2432
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
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; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    ll n,m;
    cin >> n >> m;
    ll ans = 0;
    if(n==1)
    {
        if(m==1)
        {
            ans = 1;
        }   
        else if(m==2)
        {
            ans = 0;
        }
        else
        {
            ans = m-2;
        }
    }
    else if(n==2)
    {
        if(m==1)
        {
            ans = 0;
        }
        else if(m==2)
        {
            ans = 0;
        }
        else
        {
            ans = 0;
        }
    }
    else
    {
        if(m==1)
        {
            ans = n-2;
        }
        else if(m==2)
        {
            ans = 0;
        }
        else
        {
            ans = (n-2)*(m-2);
        }   
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
input_line = list(map(int,input().split()))

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)


result = Base_10_to_n(input_line[0], input_line[1])
print(len(result))

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

using lli = long long int;

using namespace std;

struct Drink {
    lli price, num;
};

struct Compare {
    bool operator()(const Drink &x, const Drink &y) { return x.price > y.price; }
};

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

    priority_queue<Drink, std::deque<Drink>, Compare> drinks;
    
    Drink drink_tmp{};
    for (lli i = 0; i < N; i++) {
        cin >> drink_tmp.price >> drink_tmp.num;
        drinks.emplace(drink_tmp);
    }

    lli money = 0;

    while (M > 0) {
        const auto top = drinks.top();
        drinks.pop();
        money += top.price * std::min(M, top.num);
        M -= top.num;
    }

    cout << money << endl;

    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
const int maxn=2001;
int sum[2][maxn][maxn];
int cnt[2][maxn][maxn];
int n,k;
int get_sum(int c,int x,int y)
{
    if(x<0 || y<0)
        return 0;
    if(sum[c][x][y]!=-1)
        return sum[c][x][y];
    else
        return sum[c][x][y]=get_sum(c,x-1,y)+get_sum(c,x,y-1)-get_sum(c,x-1,y-1)+cnt[c][x][y];
}
int get_sqr_sum(int c,int x,int y)
{
    int gx=min(x,2*k-1),gy=min(y,2*k-1);
    return get_sum(c,gx,gy)-get_sum(c,x-k,gy)-get_sum(c,gx,y-k)+get_sum(c,x-k,y-k);
}

int main()
{
    cin>>n>>k;
    memset(sum,-1,sizeof sum);
    while(n--)
    {
        int x,y;
        char ch;
        cin>>x>>y>>ch;
        cnt[ch=='B'][x%(2*k)][y%(2*k)]++;
    }
    int ans=0;
    for(int i=0;i<k;++i)
    {
        for(int j=0;j<k;++j)
        {
            ans=max(ans,get_sum(0,i,j)+get_sqr_sum(1,i+k,j)+get_sqr_sum(1,i,j+k)+get_sqr_sum(0,i+k+k,j)+get_sqr_sum(0,i,j+k+k)+get_sqr_sum(0,i+k,j+k)+get_sqr_sum(1,i+k,j+k+k)+get_sqr_sum(1,i+k+k,j+k)+get_sqr_sum(0,i+k+k,j+k+k));
            ans=max(ans,get_sum(1,i,j)+get_sqr_sum(0,i+k,j)+get_sqr_sum(0,i,j+k)+get_sqr_sum(1,i+k+k,j)+get_sqr_sum(1,i,j+k+k)+get_sqr_sum(1,i+k,j+k)+get_sqr_sum(0,i+k,j+k+k)+get_sqr_sum(0,i+k+k,j+k)+get_sqr_sum(1,i+k+k,j+k+k));
        }
    }
    cout<<ans<<endl;
}

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

int main(){
	
	int d[5][2]={0};
	int max,u;
	while(cin>>d[0][0]>>d[0][1]){
	if(d[0][0]!=d[0][1]!=0){
		max=d[0][0]+d[0][1];
		u=0;
		for(int i=1;i<5;i++){
			cin>>d[i][0]>>d[i][1];
			int s=d[i][0]+d[i][1];
			if(max<s){
			max=s;
			u=i;
			}
		}
		switch(u){
		case 0: cout<<"A"<<" "<<max<<endl; break;
		case 1: cout<<"B"<<" "<<max<<endl; break;
		case 2: cout<<"C"<<" "<<max<<endl; break;
		case 3: cout<<"D"<<" "<<max<<endl; break;
		case 4: cout<<"E"<<" "<<max<<endl; break;
		}
	}
		else
			break;
		
	}
		
	
}

Measured memory_bytes: 1160
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if a == b:
    print("YES")
    exit()

if v <= w:
    print("NO")
    exit()

if (v - w) * t >= abs(a - b):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9184
#include <iostream>
#include <string.h>

using namespace std;

#define size 50

int main(){
	char O[size], E[size];

	scanf("%s %s", O, E);

	for(int i = 0; i < (int)(strlen(O)); i++){
		printf("%c", O[i]);
		if(i < (int)strlen(E)){
			printf("%c", E[i]);
		}
	}
	printf("\n");

	return 0;
}


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

//https://atcoder.jp/contests/keyence2020/tasks/keyence2020_d

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = (ull)1e9 + 7;

int main(void)
{
	ll a, b;
	cin >> a >> b;
	stringstream s1,s2;
	rep(i, b) {
		s1 << a;
	}
	rep(i, a) {
		s2 << b;
	}
	set<string> s;
	s.insert(s1.str());
	s.insert(s2.str());

	cout << *s.begin() << endl;
	return 0;
}


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

int main(){

  int W, H;
  cin>>W>>H;

  int x, y, r;
  cin>>x>>y>>r;

  if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main() {
	int l,r,d;
	cin>>l>>r>>d;
	int res=0;
	for(int i=l;i<=r;i++){
	    if(i%d==0){res++;}
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 3592