akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define N 100005
#define MOD 1000000007
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define pb push_back
#define LL long long

int n,k;
LL ans;
int cnt[N];
vector<int> e[N];
void dfs(int x,int last)
{
	int i;
	rep(i,e[x].size())
	{
		int y=e[x][i];
		if(y==last) continue;
		cnt[x]++;
		cnt[y]++;
		ans*=k-cnt[x];
		ans%=MOD;
		dfs(y,x);
	}
}

int main()
{
	
	int i;
	scanf("%d%d",&n,&k);
	rep(i,n-1)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		u--; v--;
		e[u].pb(v);
		e[v].pb(u);
	}
	ans=k;
	dfs(0,0);
	printf("%lld\n",ans);
	
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX_N 41

using namespace std;

typedef unsigned long long ull;

struct Country{
  int index,power;
  Country(int index=IINF,int power=IINF):index(index),power(power){}
  bool operator < (const Country& c)const{ return power > c.power; }
};

int N,answer,V,sum[MAX_N];
ull adj_bitmask[MAX_N];
Country c_list[MAX_N];

inline void input(){
  V = 0;
  int dex = 0,i_tmp;
  map<string,int> getIndex;
  set<string> ban;
  string s_tmp;
  rep(i,N){
    cin >> s_tmp >> i_tmp;
    if( ban.find(s_tmp) != ban.end() ){
      cin >> i_tmp;
      rep(i,i_tmp)cin>>s_tmp;
      continue;
    }
    if( getIndex.find(s_tmp) == getIndex.end() ) getIndex[s_tmp] = dex++;
    int from = getIndex[s_tmp];
    if( from == 0 ) answer = i_tmp;
    c_list[from] = Country(from,i_tmp);
    adj_bitmask[from] = 0ULL;
    cin >> i_tmp;
    rep(j,i_tmp){
      cin >> s_tmp;
      if( from == 0 ){
	ban.insert(s_tmp);
	continue;
      }
      if( ban.find(s_tmp) != ban.end() ) continue;
      if( getIndex.find(s_tmp) == getIndex.end() ) getIndex[s_tmp] = dex++;
      int to = getIndex[s_tmp];
      adj_bitmask[from] |= (1ULL<<to);
    }
  }
  V = dex;
}

void dfs(int sp,int power,ull friend_bitmask,ull enemy_bitmask){
  if( power + sum[sp] <= answer )return;
  answer = max(answer,power);
  if( sp >= V ) return;
   
  REP(i,sp,V){
    if( ((friend_bitmask|enemy_bitmask)>>(ull)(c_list[i].index)) & 1ULL ) continue;
    if( friend_bitmask & adj_bitmask[c_list[i].index] ) continue;
    dfs(i+1,power+c_list[i].power,friend_bitmask|(1ULL<<c_list[i].index),enemy_bitmask|adj_bitmask[c_list[i].index]);
    dfs(i+1,power,friend_bitmask,enemy_bitmask);
    break;
  }

}

int main(){
  while(cin>>N,N){
    input();
    sort(c_list,c_list+V);
    rep(i,V)sum[i] = 0;
    sum[V-1] = c_list[V-1].power;
    for(int i=V-2;i>=0;i--) sum[i] = sum[i+1] + ((c_list[i].index==0)?0:c_list[i].power);
    dfs(0,answer,1,0);
    cout << answer << endl;
  }
  return 0;
}

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

int main(){
    int l,r,d;
    cin >> l >> r >> d;
    int i,cnt=0;
    for(i=l;i<=r;i++){
        if(i%d==0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3628
// 枝刈り愚直撃墜ケースチェック用の再提出
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, d, a;
  cin >> n >> d >> a;
  
  vector<pair<ll, ll>> m(n);
  for(int i = 0; i < n; i++) cin >> m.at(i).first >> m.at(i).second;
  
  sort(m.begin(), m.end());
  
  ll ans = 0, nowdmg = 0, ite = 0;
  vector<pair<ll, ll>> x;
  for(int i = 0; i < n; i++){
    if(nowdmg > 0 && ite < x.size()){
      while(m.at(i).first > x.at(ite).first){
        nowdmg -= x.at(ite).second;
        ite++;
        if(ite == x.size()) break;
      }
    }
    
    if(m.at(i).second <= nowdmg) continue;
    
    ans += ((m.at(i).second - nowdmg) + a - 1) / a;
    ll keep = a * (((m.at(i).second - nowdmg) + a - 1) / a);
    nowdmg += keep;
    x.push_back(make_pair(m.at(i).first + 2 * d, a * ((keep + a - 1) / a)));
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 8688
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char b;
    while(scanf("%c",&b)!=EOF)
    {
        char c;
        scanf("%c",&c);
        if(b=='A')
            printf("T\n");
        else if(b=='T')
            printf("A\n");
        else if(b=='C')
        printf("G\n");
        else
            printf("C\n");
    }
    return 0;
}

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

bool is_squere(long N) {
        long r = (long) floor(sqrt(N));
        return (r * r) == N;
}

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


    for(int i = N; i > 0; i--) {
        if(is_squere(i)) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3668
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1<<50LL
#define FOR(i,a,b) for(auto i=(a);i<(b);i++)
#define RFOR(i,a,b) for(auto i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;

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

  int a,b;
  cin >> a >> b;
  
  if(a <= 0 && b >= 0) cout << "Zero" << endl;
  else if(b < 0 && (b-a)%2 == 1 || a > 0) cout << "Positive" << endl;
  else  cout << "Negative" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    lint D, A;
    cin >> N >> D >> A;

    // X, event_type, monster_health or bomb_counter to decrement.
    priority_queue<pair<lint, pair<int, lint> > > eventq;
    FOR(i, 0, N) {
        lint X, H;
        cin >> X >> H;
        eventq.push(PAIR(-X, PAIR(1, H)));
    }

    lint bombs = 0, ret = 0;
    while (!eventq.empty()) {
        auto event = eventq.top();
        eventq.pop();

        lint X = -event.first;
        int type = event.second.first;
        lint V = event.second.second;

        if (type == 0) {
            bombs -= V;
        } else {
            lint active = bombs * A;
            // active + more * A >= V
            // bombs + more > (V - 1) / A
            lint more = max(1 + (V - 1) / A - bombs, 0LL);
            ret += more;
            bombs += more;
            eventq.push(PAIR(-(X + 2 * D), PAIR(0, more)));
        }
    }

    cout << ret << endl;
    return 0;
};

Measured memory_bytes: 8304
def gen(n):
  if n < 10:
    yield n
  else:
    for m in gen(n/10):
      yield m
    yield n%10

N=int(input())

A=1
B=N-A
min_val=N
while A < N:
	A_num=[int(i) for i in gen(A)]
	B_num=[int(i) for i in gen(B)]
	#print('A='+str(A),end=' ')
	#print('B='+str(B),end=' ')
	#print(A_num,end=' ')	
	#print(B_num,end=' ')
	val=sum(A_num)+sum(B_num)
	#print(val)
	if val < min_val:
		min_val=val
		#print(val)
	A+=1
	B=N-A

print(min_val)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        
        if((N+1)/2 >= K){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 23764
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){
	double x1,y1,x2,y2;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	printf("%.8lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}

//naotoさん


Measured memory_bytes: 2728
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N, C = li_input()

    A = [[0] * 100001 for _ in range(C)]
    S = [0] * 100001

    for i in range(N):
        s, t, c = li_input()

        for j in range(s - 1, t):
            A[c - 1][j] += 1

    for a in A:
        for i in range(1, len(a)):
            if a[i]:
                S[i] += 1

    print(max(S))


main()


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

vector<int> prime(int n){
    vector<int> t;
    vector<bool> x(n+1, true);
    t.push_back(2);

    int i;
    for(i = 3; i * i <= n; i += 2){
        if(!x[i]){
            continue;
        }
        t.push_back(i);
        for(int j = i; j <= n; j += i){
            x[j] = false;
        }
    }
    for(; i <= n; i += 2){
        if(x[i]){
            t.push_back(i);
        }
    }
    return t;
}

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

    vector<int> t = prime(55555);

    vector<int> ans;
    int i = 0;
    while((int)ans.size() != n){
        if(t[i] % 5 == 1){
            ans.push_back(t[i]);
        }
        i++;
    }
    for(int i = 0; i < (int)ans.size(); i++){
        cout << ans[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 256
// Problem : B - Trick or Treat
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//look at my code
//my code is amazing
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007 //998244353
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define nl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<nl
#define cout2(a,b) cout<<a<<" "<<b<<nl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<nl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<nl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<nl
#define x first
#define y second
#define vc vector
#define pb push_back
#define ar array
#define all(a) (a).begin(), (a).end()
#define ms(v,n,x) fill(v,v+n,x);
#define init(c,a) memset(c,a,sizeof(c))
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define inf 9e18
#define cases ll T;cin>>T;while(T--)
#define BLOCK 500
//const double PI = 3.141592653589793238460;
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
// const int N=;

int32_t main()
{
    
	fast
	ll n,k;
	cin>>n>>k;
	vc<vll> v(n);
	f(i,k){
		ll d;
		cin>>d;
		f(j,d){
			ll x;
			cin>>x;
			x--;
			
			v[x].pb(1);
		}
		
	}
	
	ll ans=0;
	f(i,n)
	if(v[i].size()==0)
	ans++;
	
	cout<<ans;
	
	

	



    

	return 0;
    
}

Measured memory_bytes: 3656
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int Q = sc.nextInt();
    int array[] = new int[N];
    for (int i = 0; i < N; i++) {
      array[i] = sc.nextInt();
    }
    solve(N, K, Q, array);
  }

  private static void solve(int N, int K, int Q, int array[]) {
    List<Integer> list = new ArrayList<>();
    List<Integer> bigList = new ArrayList<>();
    int ans = Integer.MAX_VALUE;

    for (int i = 0; i < N; i++) {
      int selected = array[i]; // smallest
      for (int j = 0; j < N; j++) {
        if (array[j] >= selected) {
          list.add(array[j]);
        } else {
          addToBigList(list, bigList, K);
        }
      }
      addToBigList(list, bigList, K);
      if (bigList.size() >= Q) {
        bigList.sort(Integer::compare);
        int qthSmallest = bigList.get(Q-1);
        int tmp = qthSmallest - selected;
        if (tmp < ans) {
          ans = tmp;
        }
      }
      bigList.clear();
    }
    System.out.println(ans);
  }
  
  private static void addToBigList(List<Integer> list, List<Integer> bigList, int K) {
    if (list.size() >=  K) {
      list.sort(Integer::compare);
      bigList.addAll(list.subList(0, list.size()-K+1));
    }
    list.clear();
  }
}


Measured memory_bytes: 63600
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String n = sc.next();

    if(n.toCharArray()[0]==n.toCharArray()[1] || n.toCharArray()[1]==n.toCharArray()[2] || n.toCharArray()[2]==n.toCharArray()[3]){
      System.out.println("Bad");
    }else{
      System.out.println("Good");
    }

  }
}

Measured memory_bytes: 23892
#include <cstdio>
using namespace std;

int H, W, N, a[10005];
int c[105][105];

int main() {
  scanf("%d%d%d", &H, &W, &N);
  for (int i = 1; i <= N; ++i) scanf("%d", &a[i]);
  int x = 0, y = 0, clr = 1;
  for (int i = 0; i != H * W; ++i) {
    if (a[clr]) c[x][y] = clr;
    else c[x][y] = ++clr;
    --a[clr];
    if (x & 1) {
      if (--y == -1) ++x, y = 0;
    } else {
      if (++y == W) ++x, y = W - 1;
    }
  }
  for (int i = 0; i != H; ++i) {
    for (int j = 0; j != W - 1; ++j) {
      printf("%d ", c[i][j]);
    }
    printf("%d\n", c[i][W - 1]);
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000

int main()
{
  int a, b, c, d; cin >> a >> b>> c >> d;
  REP(i, INF) {
    c -= b;
    a -= d;
    if (c <= 0) {
      cout << "Yes" << endl;
      break;
    } else if (a <= 0) {
      cout << "No" << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3620
string=list(input())
n=len(string)
s=set()
ans=10**4

for target in string:
    if target in s:
        continue
    
    cnt=0
    tmp_max=0
    for i in string:
        if i!=target:
            cnt+=1
        else:
            tmp_max=max(tmp_max,cnt)
            cnt=0
    tmp_max=max(tmp_max,cnt)
    ans=min(ans,tmp_max)
        
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

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

	int mi = 9999;
	for (int i = 0; i < N; i++)
	{
		int suma = 0;
		int sumb = 0;
		for (int j = 0; j <= i; j++)
		{
			suma += w[j];
		}

		for (int k = i + 1; k < N; k++)
		{
			sumb += w[k];
		}

		mi = min(mi, abs(suma - sumb));
	}
	cout << mi;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

def partition(arr, p: int, r: int):
    x = int(arr[r][1])
    i = p - 1
    for j in range(p, r):
        if int(arr[j][1]) <= x:
            i += 1
            arr[i], arr[j] = arr[j], arr[i]
    arr[i + 1], arr[r] = arr[r], arr[i + 1]
    return i + 1

def quick_sort(arr, p: int, r: int):
    if p < r:
        q = partition(arr, p, r)
        quick_sort(arr, p, q - 1)
        quick_sort(arr, q + 1, r)

n = int(input())
arr = [input().split() for _ in range(n)]
stable_dict = defaultdict(list)
stable_list = []

for a in arr:
    stable_dict[int(a[1])].append(a[0])

stable_dict = sorted(stable_dict.items(), key = lambda x: x[0])

for key, values in stable_dict:
    for v in values:
        stable_list.append([v, str(key)])

quick_sort(arr, 0, n - 1)

is_stable = 'Stable'
for (a, s) in zip(arr, stable_list):
    if ''.join(a) != ''.join(s):
        is_stable = 'Not stable'
        break
print(is_stable)

for a in arr:
    print(*a)



Measured memory_bytes: 47948
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================
/*
vi g[N];
int a[N];

int main() {
    ios_base::sync_with_stdio(0);
    int t, i, j, k, p, q, r, x, y, u, v, n, m;

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

*/
int main()
{
	  int k;
	  cin>>k;
	  string s;
	  cin>>s;
	  int t  = s.length();
	  if(t<=k)
	  {
	  	cout<<s<<endl;
	  }
	  else
	  {
	  	string p;
	  	p.append(s,0,k);
	  	p+=".";
	  	p+=".";
	  	p+=".";
	  	cout<<p<<endl;
	  }
}


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

using ll = long long;

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

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

    int N, Q;
    string S;
    cin >> N >> S >> Q;
    vector<int> K(Q); cin >> K;

    vector<int> sumd(N), summ(N), ic;
    vector<ll> sumdm(N);
    sumd[0] = S[0] == 'D';
    summ[0] = S[0] == 'M';
    sumdm[0] = 0;
    for (int i = 1; i < N; i++) {
        char ch = S[i];
        sumd[i] = sumd[i-1] + (ch == 'D');
        summ[i] = summ[i-1] + (ch == 'M');
        sumdm[i] = sumdm[i-1] + (ch == 'M' ? sumd[i] : 0);
        if (ch == 'C') ic.push_back(i);
    }

    for (const int& k : K) {
        ll ans = 0;
        for (const int& i : ic) {
            ll dm = sumdm[i-1];
            int p = i-k;
            if (p >= 0) {
                dm -= sumdm[p];
                dm -= (ll)sumd[p] * (summ[i-1] - summ[p]);
            }
            ans += dm;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 22808
import sys
n,m=map(int,input().split())
if m != 0:
  a=set(map(int,sys.stdin.read().split()))
else:
  a=set()

modx=10**9+7

dp=[0]*(n+10)
dp[0]=1

for i in range(n+1):
  if i+1 not in a:
    dp[i+1]= (dp[i]+dp[i+1]) % modx
  if i+2 not in a:
    dp[i+2]= (dp[i]+dp[i+2]) % modx

print(dp[n])

Measured memory_bytes: 25216
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v), std::end(v)
#define REP(i, k) for (decltype(k) i = 0; i < k; i++)
#define LOOP(k) REP (ngtkana_is_a_genius, k)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    u64 lim = std::cbrt(1e10) + 1;
    vec<u64> primes; {
        vec<u64> sieve(lim);
        for (u64 p=2; p<lim; p++) if (!sieve.at(p)) {
            primes.push_back(p);
            for (u64 i=p*p; i<lim; i+=p) sieve.at(i) = true;
        }
    }

    usize n;
    std::cin >> n;
    std::map<tuple<u64, u64, u64>, u64> map;
    u64 one = 0;
    LOOP (n) {
        u64 x; std::cin >> x;
        u64 a = 1, b = 1;
        for (u64 p: primes) {
            u64 q = p * p;
            u64 r = p * p * p;
            for (; x%r==0; x/=r);
            if (x%q==0) {
                b *= p;
                x /= q;
            }
            if (x%p==0) {
                a *= p;
                x /= p;
            }
        }
        if (a==1 && b==1 && x==1) {
            one++;
        } else {
            map[std::make_tuple(a, b, x)]++;
        }
    }

    u64 ans = n - (one ? one - 1 : 0);
    for (auto&& p: map) {
        u64 a, b, c; std::tie(a, b, c) = p.first;
        u64 m = p.second;
        if (c != 1 || a < b) {
            auto it = map.find(std::make_tuple(b, a, c * c));
            if (it==map.end()) continue;
            ans -= std::min(m, it->second);
        }
    }
    std::cout << ans << '\n';
}

Measured memory_bytes: 8064
'use strict';

function main(input) {
  const args = input.split(' ');

  const a = parseInt(args[0], 10);
  const b = parseInt(args[1], 10);

  const add = a + b;
  const sub = a - b;
  const mul = a * b;
  let max = 0;

  max = add > sub ? add : sub;
  max = max > mul ? max : mul;
  
  console.log(parseInt(max));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
	string s;
	cin >> s;
	if (s == "Sunny") s = "Cloudy";
	else if (s == "Cloudy") s = "Rainy";
	else s = "Sunny";
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
someSums = 0
for i in range(1, N+1):
    if A <= (i // 10000) % 10 + (i // 1000) % 10 + (i // 100) % 10 + (i // 10) % 10 + (i % 10) <= B:
        someSums += i
print(someSums)


Measured memory_bytes: 2940
# BFS queue
import queue
import copy

import time
H, W = map(int,input().split())
b = [list(input()) for _ in range(H)]
dist = [[10**9 for _ in range(W)] for _ in range(H)]
start = (-1,-1)
qq = queue.Queue()
l = 0
# start把握
for i in range(H):
    for j in range(W):
        if b[i][j] == '.':
            qq.put((i,j))
            l += 1
if l == H*W:
    print(H+W-2)
    exit()
far = 0
move = [(-1,0), (0,-1), (1,0), (0,1)]
def BFS(start, bb):
    dist = [[10**9 for _ in range(W)] for _ in range(H)]
    far = 0
    q = queue.Queue()
    q.put(start)
    dist[start[0]][start[1]] = 0
    # BFS
    while 1:
        now = q.get()
        x = now[0]
        y = now[1]
        bb[x][y] == '#'
        for elem in move:
            dx = elem[0]
            dy = elem[1]
            if x+dx>=0 and x+dx<= H-1 and y+dy>=0 and y+dy<=W-1 and abs(dx-dy)==1:
                if bb[x+dx][y+dy] != '#':
                    if dist[x+dx][y+dy] > dist[x][y]:
                        dist[x+dx][y+dy] = dist[x][y] + 1
                        if dist[x+dx][y+dy] > far:
                            far = dist[x+dx][y+dy]
                        q.put((x+dx,y+dy))
        if q.empty():
            break
    return far
res = 0
while 1:
    now = qq.get()
    res = max([res, BFS(now, copy.deepcopy(b))])
    if qq.empty():
        break
print(res)


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

using namespace std;

const int N = 100010;

int n;
long long a[N];
long long b[N];
long long c[N];

int main (int argc, char const *argv[]) {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%lld", a + i);
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++i) {
		a[i] += a[i - 1];
	}
	for (int i = 1; i < n; ++i) {
		b[i] = 3ll * a[i] - a[i + 1];
	}
	int ans = 0;
	for (int i = n - 1; i; --i) {
		if (b[i] < 0) {
			ans = i;
			break;
		}
	}
	printf("%d\n", n - ans);
	return 0;
}



Measured memory_bytes: 1792
h,w = gets.split(" ").map { |e| e.to_i }
s = [Array.new(w+2) {"0"}]
for i in 0..h-1 do
  si = "0" + gets.chomp + "0"
  si = si.split("")
  s << si
end
s << Array.new(w+2) {"0"}

flag = 0 #0でok
each_flag = 0
array = [-1, 0, 1]
for i in 0..h-1 do #行
  break if flag != 0
  for j in 0..w-1 do #列
    break if flag != 0
    if s[i][j] == "#"
      around = [s[i][j-1], s[i][j+1], s[i-1][j], s[i+1][j]]
      if !around.include?("#")
        flag = 1
      end
    end
  end
end

if flag == 1
  puts "No"
else
  puts "Yes"
end


Measured memory_bytes: 4092
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int h[n+1];
	for(int i=1;i<=n;i++)
		cin >> h[i];
	int dp[n+1];
	dp[1] = 0;
	dp[2] = abs(h[1]-h[2]);
	for(int i=3;i<=n;i++){
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout << dp[n] << "\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back
#define vv vector<ll>
#define fr(i,x) for(int i=0;i<x;i++)
#define MAX 10000005
int dx[4] = {-1,0,0,1};
int dy[4] = {0,-1,1,0};

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    
    if(a.first == b.first) return a.second<b.second;
    return (a.first < b.first); 
}

ll a[MAX];
void sieve(){
    for (int i = 1; i < MAX; i++)
    {
        for (int j = i; j <= MAX; j+=i)
        {
            a[j]++;
        }
        
    }
    
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
    

    ll n,x,m,r,cnt = 0,k,y;
    
    cin >> n;
    sieve();
    for (int i = 1; i <= n; i++)
    {
        cnt += (i*a[i]);
    }
    cout << cnt << endl;
    
    
    
    
    
    
    
    
}

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

ll cache[105][2][5];
string s;
ll k;
ll dp(ll n,ll f,ll cnt)
{
	if(cnt>k)
		return 0;
	if(n==s.size())
	{
		if(cnt==k)
		{
			return 1;
		}
		return 0;
	}

	if(cache[n][f][cnt]!=-1)
		return cache[n][f][cnt];
	ll m;
	if(f==1)
		m=9;
	else
		m=s[n]-'0';
	ll ans=0;
	for(ll i=0;i<=m;i++)
	{
		if(i!=0)
		{
			if(i!=m)
				ans+=dp(n+1,1,cnt+1);
			else
				ans+=dp(n+1,f,cnt+1);

		}
		else
		{
			if(i!=m)
				ans+=dp(n+1,1,cnt);
			else
				ans+=dp(n+1,f,cnt);
		}


	}
	return cache[n][f][cnt]=ans;
}

int main()
{
	cin>>s;
	cin>>k;
	memset(cache,-1,sizeof(cache));
	cout<<dp(0,0,0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,k;
    int a[200000];
    cin >>n>>k;
    int j;
    for(int i=0;i<n;i++){
        cin >>a[i];
        if(a[i]==1) j=i;
    }
    if((n-1)%(k-1)==0){
        cout <<(n-1)/(k-1)<<endl;
    }else{
         cout <<(n-1)/(k-1)+1<<endl;
    }
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll a,b;
    scanf("%lld %lld",&a,&b);
    if(a==1||b==1)
    {
        printf("1\n");
        return 0;
    }
    if(a%2==0)
    {
        printf("%lld",a*b/2);
    }
    else
    {
        if(b%2==0)
        {
            printf("%lld",b*a/2);
        }
        else
        {
            printf("%lld",(a*b+1)/2);
        }
    }
    
    return 0;
}



Measured memory_bytes: 256
N = int(input())

RL = []
for i in range(N):
  x, l = map(int, input().split())
  RL.append([x+l, x-l])

RL.sort()
right = -10**9

ans = 0
for r, l in RL:
  if l >= right:
    right = r
    ans += 1
    
print(ans)

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> mat(h);
  rep(i,h) cin>>mat[i];

  string ss="";
  rep(i,w-1) ss+="#";

  // output RED : 先頭に#
  rep(i,h){
    if(i%2==0) cout<<ss+'.';
    else {
      rep(j,w){
        if(j==0) printf("%c", '#');
        else printf("%c", mat[i][j]);
      }
    }
    printf("\n");
  }

  printf("\n");

  // BLUE : 末尾に#
  rep(i,h){
    if(i%2==1) cout<<'.'+ss;
    else {
      rep(j,w){
        if(j==w-1) printf("%c", '#');
        else printf("%c", mat[i][j]);
      }
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 1024
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


S = S()

while 1:
    for flag in ("erase", "eraser", "dream", "dreamer"):
        if S.endswith(flag):
            S = S[:-len(flag)]
            break
    else:
        print('NO')
        break
    if not S:
        print('YES')
        break


Measured memory_bytes: 134296
T = [
  ['black', 0x00, 0x00, 0x00],
  ['blue', 0x00, 0x00, 0xff],
  ['lime', 0x00, 0xff, 0x00],
  ['aqua', 0x00, 0xff, 0xff],
  ['red', 0xff, 0x00, 0x00],
  ['fuchsia', 0xff, 0x00, 0xff],
  ['yellow', 0xff, 0xff, 0x00],
  ['white', 0xff, 0xff, 0xff]
]
loop do
  s = gets.chomp
  break if s == ?0
  cs = s.each_char.drop(1).each_slice(2).map {|as| as.join.to_i 16 }
  puts T.min_by {|_, *ds| cs.zip(ds).map {|c, d| (c - d)**2 }.reduce(0, :+) }[0]
end

Measured memory_bytes: 8852
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = new String();
		str=br.readLine();
		System.out.println(irekae(str));
	}
	
	public static String irekae(String str){
		int i;
		String str2 = new String();;
		StringBuilder sb = new StringBuilder(str2);
		char[]  moji = new char[20];
		
		for(i=0;i<str.length();i++){
			moji[i]=str.charAt(i);
		}
		for(i=0;i<str.length();i++){
			sb.append(moji[str.length()-i-1]);
		}
		return sb.toString();
	}

}

Measured memory_bytes: 23872
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */

#define MOD ((int64_t)998244353)
#define MAXN (200000)

// BIT
typedef int BIT_T;
//BIT_T* bit;
BIT_T bit[MAXN+1];
int bitN;
void BITinit(int n)
{
   bitN = n;
//   bit = (BIT_T*)malloc( (bitN+1)*sizeof(BIT_T));
}

void BITadd(int i,BIT_T val)
{
    for(;i<=bitN;i+=i&-i) bit[i]+=val;
}

BIT_T BITget(int i)
{
    BIT_T val = 0;
    for(;i;i-=i&-i) val += bit[i];
    return val;
}

void BITreset(void)
{
    for(int i=0;i<=bitN;i++) bit[i] = 0;
}

typedef struct 
{
    int x;
    int y;
}P;

int acsY(const void *a, const void *b){return ((P*)a)->y - ((P*)b)->y;} /* 1,2,3,4.. */
int acsX(const void *a, const void *b){return ((P*)a)->x - ((P*)b)->x;} /* 1,2,3,4.. */

int64_t c2[MAXN+1];
void setC(void)
{
    int64_t c = 1;
    c2[0] = 0;
    for(int i=1;i<=MAXN;i++)
    {
        c = (c*2) % MOD;
        c2[i] = (c + MOD -1) % MOD;
    }
}

P ps[MAXN];
int a[MAXN]={0};
int b[MAXN]={0};
int c[MAXN]={0};
int d[MAXN]={0};

int main(void)
{
    int n;
    scanf("%d",&n);
// n=200000;    
    for(int i=0;i<n;i++)scanf("%d %d", &(ps[i].x), &(ps[i].y));
    qsort(ps, n, sizeof(P), acsY);
    for(int i=0;i<n;i++) ps[i].y = i+1;
    qsort(ps, n, sizeof(P), acsX);
//  printf("sort\n");       
    //BA
    //CD
    BITinit(n);
    for(int i=0;i<n;i++)
    {
        int g = BITget(ps[i].y);
        b[i] += g;
        c[i] += i-g;
        BITadd(ps[i].y,1);
    }
    BITreset();
    for(int i=n-1;i>=0;i--)
    {
        int g = BITget(ps[i].y);
        a[i] += g;
        d[i] += (n-1-i)-g;
        BITadd(ps[i].y,1);
    }
// printf("BIT\n");  
    setC();
// printf("C2\n");      
    int64_t t;
    t = 0;
    for(int i=0;i<n;i++)
    {
        // ABCD
        // ABC
        // AB D
        // A CD
        //  BCD
        //  B D
        // A C
        int64_t ca = c2[a[i]];
        int64_t cb = c2[b[i]];
        int64_t cc = c2[c[i]];
        int64_t cd = c2[d[i]];
        t += (((((ca * cb)%MOD)*cc)%MOD)*cd)%MOD;
        t %= MOD;
        t += ((((ca * cb)%MOD)*cc)%MOD);
        t %= MOD;
        t += ((((ca * cb)%MOD)*cd)%MOD);
        t %= MOD;
        t += ((((ca * cc)%MOD)*cd)%MOD);
        t %= MOD;
        t += ((((cb * cc)%MOD)*cd)%MOD);
        t %= MOD;
        t += (cb * cd)%MOD;
        t %= MOD;
        t += (ca * cc)%MOD;
        t %= MOD;
        //自分を含む組み合わせ
        t += c2[n-1]+1;
        t %= MOD;
    }
    printf("%ld\n", t);
    
    return 0;
}




Measured memory_bytes: 8804
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long deliciousness = 0;
        long targetRed = sc.nextLong();
        long targetGreen = sc.nextLong();
        long totalRed = sc.nextLong();
        long totalGreen = sc.nextLong();
        long totalColorless = sc.nextLong();
        PriorityQueue<Long> redpq = new PriorityQueue<>();
        PriorityQueue<Long> greenpq = new PriorityQueue<>();
        PriorityQueue<Long> colorlesspq = new PriorityQueue<>();

        for (long i=0;i<totalRed;i++){
            redpq.add(sc.nextLong());
        }
        for (long i=0;i<totalGreen;i++){
            greenpq.add(sc.nextLong());
        }
        for (long i=0;i<totalColorless;i++){
            colorlesspq.add(sc.nextLong());
        }
        while (redpq.size() > targetRed) {
            redpq.poll();
        }
        while (greenpq.size() > targetGreen) {
            greenpq.poll();
        }

        while (!colorlesspq.isEmpty()) {
            long top = colorlesspq.poll();
            long redTop = redpq.peek();
            long greenTop = greenpq.peek();
            if (top > redTop || top > greenTop) {
                if ((top - redTop) > (top - greenTop)) {
                    redpq.poll();
                    redpq.add(top);
                } else {
                    greenpq.poll();
                    greenpq.add(top);
                }
            }
        }

        while(!greenpq.isEmpty()) {
            deliciousness += greenpq.poll();
        }
        while(!redpq.isEmpty()) {
            deliciousness += redpq.poll();
        }
        System.out.println(deliciousness);
    }
}


Measured memory_bytes: 59044
#142c
N = int(input())
A_list = list(map(int, input().split()))

#高橋くんは N人の生徒たちのいるクラスの担当教師です。
#生徒たちには 1から Nまでの出席番号が重複なく割り当てられています。
#今日は全ての生徒たちが相異なるタイミングで登校しました。
#高橋くんは、出席番号 iの生徒が登校した時点で、教室に Ai 人の生徒たちがいたことを記録しています(出席番号 iの生徒を含む)。
#記録された情報を元に、生徒たちの登校した順番を復元してください。

#出力 生徒たちの出席番号を登校した順に出力せよ。

#8
#出席番号
#1 2 3 4 5 6 7 8
#登校時の人数
#8 2 7 3 4 5 6 1

#8 2 4 5 6 7 3 1

index_list = [i for i in range(1,N+1)]
class_dict = dict(zip(A_list,index_list))

#print(' '.join(map(str, [A_list.index(i)+1 for i in range(1,N+1)])))

class_sorted = sorted(class_dict.items(),key=lambda x:x[0])
ans = [i[1] for i in class_sorted]
print(' '.join(map(str, ans)))

Measured memory_bytes: 32068
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

struct Node{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x){
    while(x -> left != NIL)x = x -> left;
    return x;
}

Node * treeSuccessor(Node *x){
    if(x -> right != NIL)return treeMinimum(x -> right);
    Node *y = x -> parent;
    while(y != NIL && x == y -> right){
        x = y;
        y = y->parent;
    }
    return y;
}

Node * find(Node *u, int k){
    while(u != NIL && k != u -> key){
        if(k < u -> key) u = u -> left;
        else u = u -> right;
    }
    return u;
}

void treeDelete(Node *z){
    Node *y, *x;
    if(z -> left == NIL || z -> right == NIL)y = z;
    else y = treeSuccessor(z);
    if(y -> left != NIL)x = y -> left;
    else x = y -> right;
    if(x != NIL)x -> parent = y -> parent;
    if(y -> parent == NIL)root = x;
    else{
        if(y == y->parent->left)y -> parent -> left = x;
        else y -> parent -> right = x;
    }
    if(y != z)z -> key = y -> key;
    free(y);
}

void insert(int k){
    Node *y = NIL, *x = root, *z;
    z = (Node*)malloc(sizeof(Node));
    z -> key = k;
    z -> right = NIL;
    z -> left = NIL;
    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x -> left;
        }
        else{
            x = x -> right;
        }
    }
    z -> parent = y;
    if(y == NIL) root = z;
    else{
        if(z -> key < y -> key){
            y -> left = z;
        }
        else{
            y -> right = z;
        }
    }
    return;
}

void inParse(Node *u){
    if(u == NIL)return;
    inParse(u -> left);
    cout << " " << u -> key;
    inParse(u -> right);
}

void preParse(Node *u){
    if(u == NIL)return;
    cout << " " << u -> key;
    preParse(u -> left);
    preParse(u -> right);
}

int main() {
    int n, x;
    string q;
    cin >> n;
    rep(i, n){
        cin >> q;
        if(q == "insert"){
            cin >> x;
            insert(x);
        }
        else if(q == "print"){
            inParse(root);
            cout << endl;
            preParse(root);
            cout << endl;
        }
        else if(q == "delete"){
            cin >> x;
            treeDelete(find(root, x));
        }
        else {
            cin >> x;
            if(find(root, x) != NIL)cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 21864
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

ll euclid(ll a, ll b){
  while (b>1){
    a = a % b;
    swap(a,b);
  }
  return a;
}

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

  string s;
  cin >> s;
  
  if (s.length()==2) {
    cout << ((s[0]==s[1]) ? "1 2\n" : "-1 -1\n");
    return 0;
  }

  REP(i, s.length()-2){
    if (s[i]==s[i+1] || s[i+1]==s[i+2] || s[i+2]==s[i]) {
      cout << i+1 << " " << i+3 << "\n";
      return 0;
    } 
  }

  cout << "-1 -1" << "\n";
  return 0;
}


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

int main()
{
   int n ;
   cin >> n ;
   int p[n] ;
   for(int i=0;i<n;i++)cin >> p[i] ;
   
   int ind=0;
  for(int i=0;i<n-1;i++){
    if(p[i]!=i+1)
      ind++;
  }
    
  if(ind>2)
    cout << "NO" << endl;
  else 
    cout << "YES" << endl; 
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		long N = reader.nextLong();
		long M = reader.nextLong();
		long ans = Math.min(N, M/2);
		N -= ans;
		M -= ans*2;
		if (N == 0) {
			ans += M/4;
		}


		System.out.println(ans);
		reader.close();

	}

}





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

using namespace std; 
int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>> data(n, vector<int>(2)); 
  vector<vector<int>> data2(m, vector<int>(2)); 
  for (int i = 0; i <n ; i++) { 

for (int j = 0; j <2; j++) { 

cin >> data.at(i).at(j); 
  
}
  }
    for (int i = 0; i < m; i++) { 

for (int j = 0; j <2; j++) { 

cin >> data2.at(i).at(j); 
  
}
  }
  for(int i=0;i<n;i++){
    int z;
    int64_t a=1000000000;
    for(int j=0;j<m;++j){
    int b=abs(data.at(i).at(0)-data2.at(j).at(0))+abs(data.at(i).at(1)-data2.at(j).at(1));
    if(a>b) {
      z=j;
      a=b;
    }
    }
    cout<<z+1<<endl;
  }

}

Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define M (1000000000 + 7)

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> m(h, vector<char>(w));
    string s;
    vector<vector<ll>> dp(h, vector<ll>(w));

    rep(i, h) {
        cin >> s;
        rep(j, w) { m[i][j] = s[j]; }
    }

    dp[0][0] = 1;
    rep(i, h) {
        rep(j, w) {
            if (m[i][j] == '#')
                continue;
            if (i > 0 && j > 0) {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % M;
            } else if (i > 0) {
                dp[i][j] = dp[i - 1][j];
            } else if (j > 0) {
                dp[i][j] = dp[i][j - 1];
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;

    return 0;
}


Measured memory_bytes: 9088
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 55
using namespace std;

int main(){
	int i;
	char odd[55],even[55];
	fgets(odd,MAXN,stdin);//从键盘上读入一行，最大长度为MAXN
	fgets(even,MAXN,stdin);//从键盘上读入一行，最大长度为MAXN
	for(i=0;odd[i]!='\0'&&even[i]!='\0';i++){
		printf("%c",odd[i]);
		printf("%c",even[i]);
	}
	if(odd[i]!='\0'){
		printf("%c",odd[i]);
	}
	if(even[i]!='\0'){
		printf("%c",even[i]);
	}
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> ans(100000+10,0);
  rep(i,n){
    int x;
    cin >> x;
    if(x == 0){
      ans[0]++;
      ans[1]++;
      continue;
    }
    ans[x-1]++;
    ans[x]++;
    ans[x+1]++;
  }
  int fin_ans = *max_element(ans.begin(),ans.end());
  cout << fin_ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[2]*10+a[1]+a[0]<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if(N/10==111||N/10==222||N/10==333||N/10==444||N/10==555||N/10==666||N/10==777||N/10==888||N/10==999){
    cout << "Yes" << endl;
  }else if(N%1000==111||N%1000==222||N%1000==333||N%1000==444||N%1000==555||N%1000==666||N%1000==777||N%1000==888||N%1000==999||N%1000==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" <<endl;
  }
  // ここにプログラムを追記
}

Measured memory_bytes: 256
# coding: utf-8
N, A, B = map(int, input().split())
# A < B が保証

if (B - A) % 2 == 1:
    # どっちの角による
    if B - A >= 3:
        ans = 0
        if A - 1 < N - B:
            ans += A - 1
            B = B - (A - 1)
            B -= 1
            ans += 1
            A = 1
            print(ans + (B - A) // 2)
        else:
            ans += N - B
            # A += N - B + 1
            A = A + (N - B)
            B = N
            A += 1
            ans += 1
            print(ans + (N - A) // 2)
    else:
        print(min(N - A, B - 1))
else:
    print((B - A) // 2)

Measured memory_bytes: 3064