akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,l; cin>>n>>l;
  vector<string> s(n);
  rep(i,n){
    cin>>s[i];
  }
  vsort(s);
  rep(i,n){
    cout<<s[i];
  }
  cout<<endl;
  
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(int(1e6))


class BIT:
	def __init__(self, n):
		self.n = n
		self.data = [0] * (n + 1)

	def get_sum(self, i):
		ret = 0
		while i > 0:
			ret += self.data[i]
			i -= (i & -i)
		return ret

	def add(self, i, w):
		if i == 0:
			return
		while i <= self.n:
			self.data[i] += w
			i += (i & -i)

def dfs(u, cnt):
	cnt += 1
	l[u] = cnt
	for c in tree[u]:
		cnt = dfs(c, cnt)
	cnt += 1
	r[u] = cnt
	return cnt

n = int(input())
l, r = [0] * n, [0] * n
tree = [set(map(int, input().split()[1:])) for _ in range(n)]

bit = BIT(dfs(0, 1))

q = int(input())
for _ in range(q):
	line = list(map(int, input().split()))
	if line[0]:
		print(bit.get_sum(r[line[1]] - 1))
	else:
		bit.add(l[line[1]], line[2])
		bit.add(r[line[1]], -line[2])


Measured memory_bytes: 143728
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    new Main().c();

  }

  private void c() {
    try (Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)))) {

      String s = in.nextLine();

      System.out.println(solve(s));
    }
  }

  private String solve(String s) {

    int index = s.length();

    while (index > 0) {
      if (s.regionMatches(index - 7, "dreamer", 0, 7)) {
        index -= 7;
      } else if (s.regionMatches(index - 6, "eraser", 0, 6)) {
        index -= 6;
      } else if (s.regionMatches(index - 5, "dream", 0, 5) || s.regionMatches(index - 5, "erase", 0, 5)) {
        index -= 5;
      } else {
        return "NO";
      }
    }

    return "YES";
  }
}


Measured memory_bytes: 13688
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define maxn 15
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,a[maxn],sum,maxi;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum += a[i];
		maxi = max(maxi,a[i]);
	}
	printf("%d\n",sum - (maxi >> 1));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<ll> &v) {
    std::for_each(v.begin(), v.end(), [](ll x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string S;
    cin >> S;
    string T;
    REP(i, S.length()) {
        if(i + 1 < S.length() and S[i] == 'B' and S[i + 1] == 'C') {
            T += 'D';
            i += 1;
        } else {
            T += S[i];
        }
    }
    // cout << T << endl;
    // Dより前に連続して存在するA
    ll res = 0;
    int cnt = 0;
    REP(i, T.length()) {
        if(T[i] == 'D') {
            res += cnt;
        } else if(T[i] == 'A') {
            cnt++;
        } else {
            cnt = 0;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

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; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;
string s;
vector<pair<char, int>> q;

int solve(int x) {
    for(const auto &it : q) {
        char c; int d; tie(c, d) = it;
        if (s[x] == c) x += d;
    }
    return x;
}

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(cin >> n >> m >> s){
        s = "." + s + ".";
        REP(i, m) {
            char t, d;
            cin >> t >> d;
            q.emplace_back(t, d == 'L' ? -1 : 1);
        }
        int left, right;
        {
            int l = 0, r = n + 1;
            while (l + 1 < r) {
                int mid = (l + r) / 2;
                if (solve(mid) == 0) l = mid;
                else r = mid;
            }
            left = r;
        }
        {
            int l = 0, r = n + 1;
            while (l + 1 < r) {
                int mid = (l + r) / 2;
                if (solve(mid) == n + 1) r = mid;
                else l = mid;
            }
            right = r;
        }
        cout << right - left << endl;
        q.clear();
    }
    return 0;
}


Measured memory_bytes: 3020
#include <stdio.h>

int main(void)
{
  int a[5];
  int k;
  bool f = true;
  for(int i = 0;i<5;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&k);
  for(int i=0;i<4;i++){
    for(int j = i+1;j < 5;j++){
      if(a[j]-a[i] > k){
        f=false;
      }
    }
  }
  if(f){
    printf("Yay!");
  }
  else{
    printf(":(");
  }
  return 0;
}


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

using namespace std;

typedef long long LL;

int N;
int a[100010];
int mi,ma,cntmi,cntma;

int main()
{
	mi = 100000000;
	ma = -1;
	scanf("%d",&N);
	for (int i=1;i<=N;i++)
	{
		scanf("%d",&a[i]);
		mi = min(mi,a[i]);
		ma = max(ma,a[i]);
	}
	if (ma > mi+1) return 0*puts("No");
	cntmi = cntma = 0;
	for (int i=1;i<=N;i++)
	{
		if (a[i] != mi && a[i] != ma) return 0*puts("No");
		if (a[i] == mi)
			cntmi++;
		if (a[i] == ma)
			cntma++;
	}
	bool res = true;
	if (mi == ma)
	{
		res = (mi * 2 <= N) || (mi == N-1);
	}
	else //ma = mi + 1
	{
		//printf("%d %d\n",cntmi-1+1,mi);
		int nd = mi - (cntmi - 1);
		res = (nd*2 <= cntma && nd>0);
	}
	puts(res?"Yes":"No");
}

Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		TreeSet<Time> ts = new TreeSet<>();
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			ts.add(new Time(sc.nextInt(), sc.nextInt()));
		}
		int m = sc.nextInt();
		for (int i = 0; i < m; i++) {
			ts.add(new Time(sc.nextInt(), sc.nextInt()));
		}

		out.print(ts.pollFirst());
		for (Time t : ts) {
			out.print(" " + t.toString());
		}
		out.println();
		out.flush();
	}

	static class Time implements Comparable<Time> {
		int h, m;

		public Time(int h, int m) {
			this.h = h;
			this.m = m;
		}

		@Override
		public int compareTo(Time t) {
			return (h * 60 + m) - (t.h * 60 + t.m);
		}

		@Override
		public String toString() {
			return String.format("%d:%02d", h, m);
		}
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) { return false; }
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		if (!hasNext()) { throw new NoSuchElementException(); }
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) { throw new NumberFormatException(); }
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i)
#define rrep(i, k, n) for (int i = (int)(n) - 1; i >= (int)(k); --i)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vv_ii;
typedef pair<int,ii> i_ii;
typedef vector<i_ii> vi_ii;

template <class T>
inline ostream& operator<<(ostream & o, vector<T> const& v) {
    for (int i = 0; i < (int)(v.size()) - 1; ++i)
        o << v[i] << ' ';
    if (!v.empty())
        o << v.back();
    return o;
}

template <class T, class Q>
inline ostream& operator<<(ostream & o, pair<T,Q> const& p) {
    o << "(" << p.fi << "," << p.se << ")";
    return o;
}

inline bool fun(string & s, int l, int r) {
    //cerr << "l -> " << l << "  r -> " << r << endl;
    rep(i, l, r)
        if (s[i] != s[r-i-1])
            return false;
    return true;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    string s;
    cin >> s;
    int n = (int)(s.size());
    cout << (fun(s, 0, n) && fun(s, 0, ((n-1)>>1)) && fun(s, ((n+3)>>1)-1, n) ? "Yes\n" : "No\n");

    return 0;
}

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

namespace ABC121A
{
    public partial class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var H = ss.Next(int.Parse);
            var W = ss.Next(int.Parse);
            var h = ss.Next(int.Parse);
            var w = ss.Next(int.Parse);
            sw.WriteLine((H - h) * (W - w));
            //---------------------------------
        }
    }

    public class StreamScanner
    {
        static readonly char[] Separator = { ' ' };
        readonly StreamReader streamReader;

        string[] line = new string[0];
        int index = 0;

        public StreamScanner(Stream stream)
        {
            this.streamReader = new StreamReader(stream);
        }

        public string Next()
        {
            return Next(s => s);
        }

        public string[] Next(int x)
        {
            return Next(s => s, x);
        }

        public string[][] Next(int x, int y)
        {
            return Next(s => s, x, y);
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (index < line.Length) return parser(line[index++]);
            index = 0;
            line = streamReader.ReadLine()?.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }

    public partial class Program
    {
        static void Main()
        {
            Excute(Console.OpenStandardInput(), Console.OpenStandardOutput());
        }

        public static void Excute(Stream input, Stream output)
        {
            var ss = new StreamScanner(input);
            var sw = new StreamWriter(output);
            new Program().Solve(ss, sw);
            sw.Flush();
        }
    }
}

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

int main(){
    string S;
    cin >> S;
    if(S[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    int cnt = 0;
    for(int i = 2; i < S.size()-1; i++) {
        if(S[i] == 'C') {
            cnt++;
        }
    }
    if(cnt != 1) {
        cout << "WA" << endl;
        return 0;
    }
    for(int i = 1; i < S.size(); i++) {
        if(S[i] == 'C') {
            continue;
        }
        else if(S[i] >= 'a' && S[i] <= 'z') {
            continue;
        }
        else {
            cout << "WA" << endl;
            return 0;
        }
    }
    cout  << "AC" << endl;
}



Measured memory_bytes: 256
n = int(input())
mod = 10**9+7
memo = [{} for _ in range(n+1)]

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i],t[i-1] = t[i-1],t[i]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True

def dfs(cur,last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == n:
        return 1
    ret = 0
    for i in 'ACGT':
        if ok(last3 + i):
            ret = (ret + dfs(cur+1,last3[1:]+i)) % mod
    memo[cur][last3] = ret
    return ret

print(dfs(0,'TTT'))


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

int main()
{
	string s;
	cin>>s;
	if(s=="SUN") cout<<"7"<<endl;
	if(s=="MON") cout<<"6"<<endl;
	if(s=="TUE") cout<<"5"<<endl;
	if(s=="WED") cout<<"4"<<endl;
	if(s=="THU") cout<<"3"<<endl;
	if(s=="FRI") cout<<"2"<<endl;
	if(s=="SAT") cout<<"1"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

	int main(void){

	int a, b, c;
	while(1){
		scanf("%d %c %d", &a, &c, &b);
			if(c == '+'){
			 printf("%d\n", a + b);
			}
			if(c == '-'){
			 printf("%d\n", a - b);
			}
			if(c == '*'){
			 printf("%d\n", a * b);
			}
			if(c == '/'){
			 printf("%d\n", a / b);
			}
			if(c == '?'){
			 break;
			}
	}
	return 0;
}

Measured memory_bytes: 600
import math
import sys

x,k,d=map(int,input().split())

if x<0:
  x*=-1

num=math.floor(x/d)

if num>k:
  print(x-k*d)
  sys.exit()

n=x-num*d
remaining=k-num

if remaining%2==0:
  if n>0:
    print(n)
    
  else:
    print(n*-1)
    
else:
  if n>0:
    n-=d
    if n>0:
      print(n)
      
    else:
      print(n*-1)
      
  else:
    n+=d
    if n>0:
      print(n)
      
    else:
      print(n*-1)

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

const long double pi = acos(-1.0);
signed main(){
	long double a, b, h, m; cin >> a >> b >> h >> m;
	long double c1 = 360.0 * h / 12.0 + 30.0 * m / 60.0, c2 = 6.0 * m;
	long double c = abs(c1 - c2);
	long double ans = a * a + b * b -  2.0 * a * b * cos(c * pi / 180.0);
	cout << setprecision(20) << sqrt(ans) << endl;

}


Measured memory_bytes: 4176
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
import core.bitop;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    auto as = readln.split.to!(long[]);

    auto c = long.max;
    foreach (x; 0..(1<<N)) {
        if (popcnt(x) < K) continue;

        long cc, last;
        foreach (i, a; as) {
            if (a > last) {
                last = a;
            } else if (x & (1<<i)) {
                cc += last - a + 1;
                last += 1;
            }
        }
        c = min(c, cc);
    }
    writeln(c);
}

Measured memory_bytes: 256
// Copyright (C) 2018 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back


int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int ans = 1e9;

    for (int i = 0; i <= int(2e5); i += 2)
        ans = min(ans, i * c + a * max(0, x - i / 2) + b * max(0, y - i / 2));

    cout << ans << "\n";
    
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

  ll N, K;
  cin >> N;
  cin >> K;

  vl h(N, 0);

  FOR(i, 0, N) cin >> h[i];

  vl dp(N, oo);

  dp[0] = 0;
  FOR(j, 1, N)FOR(i, j-K, j) if(i >= 0) dp[j] = min(dp[j], dp[i]+abs(h[i]-h[j]));

  cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::vector<long long> p, std::vector<long long> q){
    vector<int> a(n);
    iota(a.begin(), a.end(), 1);
    int x = 0, y = 0;
    int i = 0;
    do{
        ++i;
        bool fx = true, fy = true;
        for(int j = 0; j < n; ++j){
            fx &= (a[j] == p[j]);
            fy &= (a[j] == q[j]);
        }
        if(fx)
            x = i;
        if(fy)
            y = i;
    }while(next_permutation(a.begin(), a.end()));
    cout << abs(x - y) << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    std::vector<long long> Q(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&Q[i]);
    }
    solve(N, std::move(P), std::move(Q));
    return 0;
}


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

using namespace std;

/*
int main(){
	int n;
	cin >> n;
	
	vector<int> t, v;
	int sum = 0;
	for(int i = 0;i < n;i++){
		int ti, vi;
		cin >> ti >> vi;
		sum += ti;
		t.push_back(sum);
		
		v.push_back(vi);
	}
	v.push_back(0);
	
	int p = 0;
	int vt = 0;
	double l = 0;
	while(p < n){
		int maxp = 0;
		double maxv = -1;
		for(int i = p+1;i < n;i++){
			double vi = max(v[i], vt + (t[i]-t[p])/2 - abs(vt-v[i+1])/2);
			if(maxv < vi){
				maxv = vi;
				maxp = i;
			}
		}
		
		
	}
	
	return 0;
}
*/

int main(){
	string s, t;
	cin >> s >> t;
	
	bool did = false;
	for(int i = (signed int)s.size()-(signed int)t.size();i >= 0;i--){
		did = true;
		string ans = s;
		for(int j = 0;j < t.size();j++){
			if(s[i+j] != '?' && s[i+j] != t[j]){
				did = false;
			}else{
				ans[i+j] = t[j];
			}
		}
		
		if(did){
			for(int j = 0;j < ans.size();j++){
				if(ans[j] == '?'){
					ans[j] = 'a';
				}
			}
			cout << ans << endl;
			break;
		}
	}
	
	if(!did) cout << "UNRESTORABLE" << endl;
	
	return 0;
}

Measured memory_bytes: 256
type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI32()]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI64()]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF32()]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF64()]

    member public __.Tuple2List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]]
    
    member public __.Tuple3List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]]

end

[<EntryPoint>]
let main _ =
    let scanner = Scanner()
    let a = scanner.NextI32()
    let x = scanner.NextI32()

    if a * 500 < x then "No" else "Yes"
    |> printfn "%s"

    0


Measured memory_bytes: 14040
#include<bits/stdc++.h>
#define ll long long 
#define ull unsigned long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define repr(i,n) for (int i = n; i >= 0; --i)
#define P pair<int, int>
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;
using namespace std;

ull lcm(ull a,  ull b) {
	return a/__gcd(a,b)*b;
}

int main() 
{
	int n;
	cin >> n;
	ull LCM = 1LL;
	rep(i,n) {
		ull period;
		cin >> period;
		LCM=lcm(LCM, period);
	}
	cout << LCM << endl;
}

Measured memory_bytes: 3608
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int numNode = sc.nextInt();
		int numEdge = sc.nextInt();
		ArrayList<ArrayList<Integer>> go = new ArrayList<>();
		for(int i = 0; i < numNode; i ++) {
			go.add(new ArrayList<Integer>());
		}
		for(int i = 0; i < numEdge; i ++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			go.get(a).add(b);
		}
		int start = sc.nextInt() - 1;
		int goal = sc.nextInt() - 1;

		long need[] = new long[numNode];
		for(int i = 0; i < numNode; i ++) {
			need[i] = -1;
		}
		boolean visited[][] = new boolean[numNode][3];
		for(int i = 0; i < numNode; i ++) {
			for(int j = 0; j < 3; j ++) {
				visited[i][j] = false;
			}
		}

		Deque<Integer> stack = new ArrayDeque<Integer>();
		stack.addFirst(start);

		long count = 0;
		while (!stack.isEmpty()) {
			int size = stack.size();
			for(int a = 0; a < size; a ++) {
				int crt = stack.removeFirst();
				if(visited[crt][(int)(count % 3)]) { continue; }
				if(count % 3 == 0) { need[crt] = need[crt] >= 0 ? Math.min(need[crt], count / 3) : count / 3; }
				visited[crt][(int)(count % 3)] = true;
				for(int i = 0; i < go.get(crt).size(); i ++) {
					stack.addLast(go.get(crt).get(i));
				}
			}
			if(need[goal] >= 0) { break; }
			count ++;
		}

		System.out.println(need[goal]);
	}
}

Measured memory_bytes: 104548
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll dp[333][333][333];

void mod_add(ll &a, ll b){
	a += b;
	a %= MOD;
}

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

	string str;cin >> str;
	ll K;cin >> K;
	K = min(K, 303LL);
	str += "0";
	vector<ll> v;

	ll now = 0;
	REP(i, str.size()){
		if(str[i] == '1'){
			now++;
		}
		else {
			v.PB(now);
			now = 0;
		}
	}
	ll n = v.size();
	reverse(ALL(v));
	//SHOW1d(v, n);

	dp[0][0][0] = 1;
	REP(i, n)REP(j, K + 1)REP(k, K + 1){
			if(dp[i][j][k] == 0)continue;
			for(ll ii = 0;ii <= v[i];ii++){
				if(K < j + ii)break;
				mod_add(dp[i+1][j + ii][k], dp[i][j][k]);
			}
			for(ll ii = 1;ii <= K;ii++){
				if(j < k + ii)break;
				mod_add(dp[i+1][j][k + ii], dp[i][j][k]);
			}
	}

	ll ans = 0;
	REP(i, K+1){
		//cout << i << " dp: " << dp[n][i][i] << endl;
		mod_add(ans, dp[n][i][i]);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 34000
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
const char newline = '\n';

int main()
{
	int i = 0, j = 0, k = 0;
	ll l = 0;
	char c;
	cin >> c;
  	if(c=='a'  || c=='e' || c=='i' || c=='o' || c=='u')
      cout << "vowel" << newline;
  	else
      cout << "consonant" << newline;
}

Measured memory_bytes: 3660
g = set()
lists = list(map(int, input().split())) #１行の入力をi[0],i[1]というように空白で分けてを取得し、iに値を入れる
for i in range(lists[1]):
    
    d = int(input())
    a = list(map(int, input().split())) #１行の入力をi[0],i[1]というように空白で分けてを取得し、iに値を入れる
    for j in range(d):
        g.add(a[j])

print(lists[0] - len(g))


Measured memory_bytes: 67632
//I am so vegetable
//#define _LOCAL_
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 1e5+5;
const int MOD = 10000;
const double eps = 1e-6;
const double pi = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }

 int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
	int n;cin>>n;
	ll ans = 0;
	_for(i,1,n+1){
		if(i%3&&i%5)ans+=i;
	}
	cout<<ans;
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	while (s.length() > 0) {
		// cout << "s=" << s << endl;
		if (s.length() < 5) {
			cout << "NO" << endl;
			return 0;
		}
		if (s.substr(0, 5) == "erase") {
			if (s.length() >= 6 && s[5] == 'r' && (s.length() == 6 || (s.length() >= 11 && (s.substr(6, 5) == "erase" || s.substr(6, 5) == "dream")))) {
				s.erase(0, 6);
			} else {
				s.erase(0, 5);
			}
		} else if (s.substr(0, 5) == "dream") {
			if (s.length() >= 7 && s.substr(5, 2) == "er" && (s.length() == 7 || (s.length() >= 12 && (s.substr(7, 5) == "erase" || s.substr(7, 5) == "dream")))) {
				s.erase(0, 7);
			} else {
				s.erase(0, 5);
			}
		} else {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MAX=100005;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a, b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define dbgarv(n,arrv) rep(i,n){rep(j,arrv[i].size()){cout<<arrv[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}


const ll MAXN = 1005;
const ll MAXV = MAXN*MAXN-1;
ll id[MAXN][MAXN];
ll dp[MAXV];
Vec to[MAXV];

bool visited[MAXV];
bool calculated[MAXV];

ll dfs(ll v){
    if(visited[v]){
        if(!calculated[v])return -1;
        return dp[v];
    }
    visited[v]=true;
    dp[v]=1;
    Each(u,to[v]){ //それぞれの1つ前+1の最大
        ll res = dfs(u);
        if(res==-1) return -1;
        dp[v]=max(dp[v],res+1);
    }
    calculated[v]=true;
    return dp[v];
}
ll toId(ll i,ll j){
    if(i>j){
        swap(i,j);
    }
    return  id[i][j];
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    VV sche(n,Vec(n-1));
    rep(i,n){
        rep(j,n-1){
            cin >> sche[i][j];
            sche[i][j]--;
        }
    }
    ll V = 0;
    rep(i,n){
        rep(j,n){
            if(i<j){
                id[i][j] = V++;
            }
        }
    }

    rep(i,n){
        rep(j,n-1){
            sche[i][j] = toId(i,sche[i][j]);
        }
        rep(j,n-2){
            to[sche[i][j+1]].pb(sche[i][j]);
        }
    }

//    dbgarr(n,n,sche);
//    dbgarv(6,to);
    ll ans = 0;
    rep(i,V){
        ll res = dfs(i);
        if(res==-1){
            cout<<-1<<endl;
            return 0;
        }
        ans = max(ans,res);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 61952
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

typedef struct dnode{
  int v;
  int64 val;
} node;

int cmp(node *a,node *b){
  return a->val<=b->val?1:0;
}

void swap(node *a,node *b){
  node t=*a;
  *a=*b;
  *b=t;
  return;
}

void push(node *h,int v,int64 val){
  h[++h[0].v].v=v;
  h[h[0].v].val=val;
  int k=h[0].v;
  while(k>1){
    if(cmp(h+k/2,h+k)) break;
    swap(h+k/2,h+k);
    k/=2;
  }
  return;
}

int pop(node *h){
  int res=h[1].v;
  h[1]=h[h[0].v--];
  int k=1;
  while(2*k+1<=h[0].v){
    if(cmp(h+k,h+2*k) && cmp(h+k,h+2*k+1)) break;
    int next=cmp(h+2*k,h+2*k+1)?2*k:2*k+1;
    swap(h+k,h+next);
    k=next;
  }
  if(2*k<=h[0].v && !cmp(h+k,h+2*k)) swap(h+k,h+2*k);
  return res;
}

void dijkstra(int from,int64 *array,int *start,int *vertex,int *cost,int *next,int n){
  int *used=(int *)malloc(sizeof(int)*(n+1));
  int i;
  for(i=0;i<=n;i++){
    array[i]=10000000000000000LL;
    used[i]=0;
  }
  node *h=(node *)malloc(sizeof(node)*100001);
  h[0].v=0;
  array[from]=0;
  push(h,from,0);
  while(h[0].v>0){
    int v=pop(h);
    if(used[v]) continue;
    used[v]=1;
    int p=start[v];
    while(p>0){
      int u=vertex[p];
      if(array[v]+cost[p]<array[u]){
	array[u]=array[v]+cost[p];
	push(h,u,array[u]);
      }
      p=next[p];
    }
  }
  free(used);
  free(h);
  return;
}

#define ADD(i,u,v,a,b) do{vertex[i]=v;costA[i]=a;costB[i]=b;next[i]=start[u];start[u]=i;}while(0)

void run(void){
  int n,m,s,t;
  scanf("%d%d%d%d",&n,&m,&s,&t);
  int i;
  int *start=(int *)malloc(sizeof(int)*(n+1));
  int *vertex=(int *)malloc(sizeof(int)*(2*m+1));
  int *costA=(int *)malloc(sizeof(int)*(2*m+1));
  int *costB=(int *)malloc(sizeof(int)*(2*m+1));
  int *next=(int *)malloc(sizeof(int)*(2*m+1));
  next[0]=0;
  for(i=0;i<=n;i++) start[i]=0;
  for(i=1;i<=m;i++){
    int u,v,a,b;
    scanf("%d%d%d%d",&u,&v,&a,&b);
    ADD(2*i-1,u,v,a,b);
    ADD(2*i,v,u,a,b);
  }
  int64 *sTo=(int64 *)malloc(sizeof(int64)*(n+1));
  dijkstra(s,sTo,start,vertex,costA,next,n);
  int64 *tTo=(int64 *)malloc(sizeof(int64)*(n+1));
  dijkstra(t,tTo,start,vertex,costB,next,n);
  int64 *min=(int64 *)malloc(sizeof(int64)*(n+1));
  min[n]=sTo[n]+tTo[n];
  for(i=n-1;i>=1;i--){
    min[i]=MIN(min[i+1],sTo[i]+tTo[i]);
  }
  const int64 mm=1000000000000000LL;
  for(i=1;i<=n;i++){
    printf("%lld\n",mm-min[i]);
  }
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 7748
#include <iostream>
#include <cmath>
using namespace std;
static const int MAX_N=100000;

typedef struct{
    int a;
    int b;
    int c;
}happiess;

int main(void){
    int N;
    happiess H[MAX_N];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> H[i].a >> H[i].b >> H[i].c;
    }

    int dp[N][3];// dp[i][j]はi+1日目に行動jをした時にi+1日目までで得られる最大の幸福度
    // j=0はa、 j=1はb、 j=2はcにそれぞれ対応
    dp[0][0] = H[0].a;
    dp[0][1] = H[0].b;
    dp[0][2] = H[0].c;

    for(int i=0; i<N; i++){
        for(int j=0; j<3; j++){
            if(j==0){
                dp[i+1][j] = max(dp[i][1]+H[i+1].a, dp[i][2]+H[i+1].a);
            }
            else if(j==1){
                dp[i+1][j] = max(dp[i][0]+H[i+1].b, dp[i][2]+H[i+1].b);
            }
            else if(j==2){
                dp[i+1][j] = max(dp[i][0]+H[i+1].c, dp[i][1]+H[i+1].c);
            }
        }
    }

    //答えはdp[N-1][0],dp[N-1][1],dp[N-1][2]の最大値
    int ans = 0;
    for(int i=0; i<3; i++){
        if(ans<dp[N-1][i]){
            ans = dp[N-1][i];
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;

int main(){
	string s;
	cin >> s;
	s = "0" + s + "0";

	int ans = s.size() - 2;
	range(i,1,s.size() - 1){
		if(s[i] != s[i + 1]){
			ans = min(ans, max<int>(i, s.size() - 2 - i));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
    string S;
    cin >> S;
    int Q;
    cin >> Q;

    char str[500000];
    for (int i = 0; i < S.length(); ++i) str[200000 + i] = S[i];

    bool zengo = true;
    int start = 200000;
    int end = 200000 + (S.length()) - 1;

    for (int i = 0; i < Q; ++i) {
        int qType;
        cin >> qType;
        if (qType == 1) {
            zengo = 1 - zengo;
        }
        else {
            int F;
            char C;
            cin >> F >> C;
            if (F == 1) {
                if (zengo) {
                    str[start - 1] = C;
                    start--;
                }
                else {
                    str[end + 1] = C;
                    end++;
                }
            }
            else {
                if (zengo) {
                    str[end + 1] = C;
                    end++;
                }
                else {
                    str[start - 1] = C;
                    start--;
                }
            }
        }
    }
    if (zengo){
        for (int i = start; i <= end; ++i) {
            cout << str[i];
        }
    }
    else {
        for (int i = end; i >= start; --i) {
            cout << str[i];
        }
    }
    return 0;
}


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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int A = nextInt();




		System.out.println(A<=999?"ABC":"ABD");

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21204
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
        --A[i];
    }
    vector<int> B(n);
    for (int i = 0; i < n; ++i) {
        cin >> B[i];
        --B[i];
    }

    vector<int> cntsA(n, 0);
    vector<int> cntsB(n, 0);
    for (int i = 0; i < n; ++i) {
        cntsA[A[i]] += 1;
    }
    for (int i = 0; i < n; ++i) {
        cntsB[B[i]] += 1;
    }

    bool ok = true; 
    for (int i = 0; i < n; ++i) {
        if (cntsA[i] > n - cntsB[i]) {
            ok = false;
            break;
        }
    }
    if (!ok) {
        cout << "No\n";
        return 0;
    }

    vector<int> cnts(n, 0);
    vector<vector<int>> pos(n);
    for (int i = 0; i < n; ++i) {
        if (A[i] == B[i]) {
            pos[A[i]].push_back(i);
            ++cnts[A[i]];
        }
    }

    priority_queue<pair<int,int>> pq;
    for (int i = 0; i < n; ++i) {
        if (cnts[i] > 0) {
            pq.emplace(cnts[i], i);
        }
    }

    while (pq.size() > 1) {
        int x = pq.top().second;
        int cx = pq.top().first;
        pq.pop();
        int y = pq.top().second;
        int cy = pq.top().first;
        pq.pop();

        {
            int a = pos[x].back();
            int b = pos[y].back();
            swap(B[a], B[b]);
            pos[x].pop_back();
            --cx;
            pos[y].pop_back();
            --cy;
        }
        if (cx > 0) {
            pq.emplace(cx, x);
        }
        if (cy > 0) {
            pq.emplace(cy, y);
        }
    }

    if (!pq.empty()) {
        int x = pq.top().second;
        vector<int> C;
        for (int i = 0; i < n;++i) {
            if (A[i] != x && B[i] != x) {
                assert(A[i] != B[i]);
                C.push_back(i);
            }
        }
        
        assert(C.size() >= pos[x].size());
        while (pos[x].size() > 0) {
            int a = pos[x].back();
            pos[x].pop_back();
            int b = C.back();
            C.pop_back();
            swap(B[a], B[b]);
        }
    }

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

    return 0;
}

Measured memory_bytes: 20100
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main
{
	public static void main (String[] args) throws Exception
	{
		BufferedReader stdReader =
		new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(stdReader.readLine());
		String A[] = stdReader.readLine().split(" ",0);
		int j = 0;
		System.out.println(String.join(" ",A)); 
		for (int i = 1; i < N; i++) {
			String v = A[i];
			j = i - 1;
			while (j >= 0 && Integer.parseInt(A[j]) > Integer.parseInt(v)) {
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			System.out.println(String.join(" ",A)); 
		}
	}
}

Measured memory_bytes: 27416
#include <stdio.h>
int main(void){
    // Your code here!
    int n, m, i, a[1000000];
    
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;i++){
       scanf("%d",&a[i]);
       n=n-a[i];
    }
    
    if(n>=0) printf("%d\n",n);
    else printf("-1\n");
    
    return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<int> v(n);
	long long ans = 0;
	cin>>v[0];
	for(int i=1;i<n;++i)
	{
		cin>>v[i];
		if(v[i]<v[i-1])
			ans += 1LL*(v[i-1]-v[i]),v[i] = v[i-1];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3984
using namespace std;
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define N 100001
struct dian{
	int x,y,no;
}xx[N],yy[N];
bool cmpx(dian hh,dian aa)
{
	return hh.x<aa.x;
}
bool cmpy(dian hh,dian aa)
{
	return hh.y<aa.y;
}

int x[N],y[N];
struct edge{
	int from,to,val;
}E[N];
bool cmp(edge hh,edge aa)
{
	return hh.val<aa.val;
}
int cnt=0;
int fa[N];
int ans;
int getf(int no)
{
	return fa[no]==no?no:fa[no]=getf(fa[no]);
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&x[i],&y[i]);
	}
	for(int i=1;i<=n;i++) 
	{
		xx[i].x=x[i];xx[i].y=y[i];xx[i].no=i;
	}
	sort(xx+1,xx+n+1,cmpx);
	for(int i=1;i<=n-1;i++)
	{
		E[++cnt].from=xx[i].no;
		E[cnt].to=xx[i+1].no;
		E[cnt].val=xx[i+1].x-xx[i].x;
	}
	sort(xx+1,xx+n+1,cmpy);
	for(int i=1;i<=n-1;i++)
	{
		E[++cnt].from=xx[i].no;
		E[cnt].to=xx[i+1].no;
		E[cnt].val=xx[i+1].y-xx[i].y;
	}
	sort(E+1,E+cnt+1,cmp);
	for(int i=1;i<=n;i++) fa[i]=i;
	int zkx=0;
	for(int i=1;i<=cnt;i++)
	{
		if(getf(E[i].from)!=getf(E[i].to))
		{
			fa[fa[E[i].from]]=fa[E[i].to];
			ans+=E[i].val;
			zkx++;
		}
		if(zkx==n-1) break;
	}
	cout<<ans<<endl; 
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vii vector<vector<int>>
#define FOR(i, n) for(int i = 0; i < n; i++)
#define For(i, k, n) for(int i = k; i < n; i++)
#define MOD 1000000007
#define deb(n) cout << "[ "#n << " = " << n << " ]" << endl;
#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const long long  MAX = 1 << 18;
int case_no = 1;
#define w(x) int x; cin>>x; while(x--)

int main() {
	FIO
	int d, t, s;
	cin >> d >> t >> s;
	if(d <= s * t) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3644