akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (b); i > (a); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada ios_base::sync_with_stdio(false)
#define int long long
int power(int x, int p)
{
    if (p == 0)
        return 1;
    int y = power(x, p / 2);
    y *= y;
    // y %= M;
    if (p % 2 == 0)
        return y;
    y *= x;
    // y %= M;
    return y;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

signed main()
{

    rootdada;
    int n;
    cin >> n;
    vector<pair<int, int>> p;
    rep(i,0,n)
    {
        int x;
        cin>>x;
        p.push_back(make_pair(i+1,x));
        // cout<<p[i].first<< " "<<p[i].second<<endl;

        
    }
    sort(p.begin(),p.end(),sortbysec);
    rep(i,0,n)
        cout<<p[i].first<< " ";

}

Measured memory_bytes: 2544
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Contexts;
using System.Text;
using System.Threading;
using System.Xml.Schema;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public ulong NextUlong()
        {
            return ulong.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int N, K;
        private int[] H;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            K = sc.NextInt();
            H = new int[N];
            for (int i = 0; i < N; i++)
            {
                H[i] = sc.NextInt();
            }
        }

        public void Solve()
        {
            Scan();
            Array.Sort(H);
            int ans = int.MaxValue;
            for (int i = 0; i <= N - K; i++)
            {
                ans = Math.Min(ans, H[i + K - 1] - H[i]);
            }
            Console.WriteLine(ans);
        }

        static void Main() => new Program().Solve();
    }


}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int tc; cin>>tc; while(tc--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define yes cout<<"YES\n";
#define no cout<<"NO\n";

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();
    
    int k;
    cin>>k;
    while(k--)
        cout << "ACL";
    nl;

    return 0;
}




Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
using namespace std;

int main()
{
    long long int n, m, ans;
    cin >> n >> m;
    if(2*n > m) {
        ans = m/2;
    } else {
        ans = (2*n + m)/4;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
from collections import deque
queue = deque([])
n = int(input())
for _ in range(n):
    command = input()
    if command == "deleteFirst":
        _ = queue.popleft()
    elif command == "deleteLast":
        _ = queue.pop()
    elif "delete" in command:
        _, x = command.split()
        try:
            queue.remove(x)
        except ValueError:
            pass
    else:
        _, x = command.split()
        queue.appendleft(x)
print(" ".join(queue))

Measured memory_bytes: 71888
def solve():
    Ss = input().rstrip()
    Ts = input().rstrip()

    lenS, lenT = len(Ss), len(Ts)

    ans = lenS
    for i in range(lenS-lenT+1):
#        print('# Ss:', Ss[i:i+lenT], '/ Ts:', Ts)
        num = sum([S != T for S, T in zip(Ss[i:i+lenT], Ts)])
        if num < ans:
            ans = num

    print(ans)


solve()


Measured memory_bytes: 8948
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long c = in.nextLong();
        long[] x = new long[n+1], v = new long[n+1];
        for(int i = 1; i <= n; i++) {
            x[i] = in.nextLong();
            v[i] = in.nextLong();
        }
        long sum = 0;
        long[] maxa1 = new long[n+1], maxa2 = new long[n+1];
        for(int i = 1; i <= n; i++) {
            sum += v[i];
            maxa1[i] = Math.max(maxa1[i-1], sum - x[i]);
            maxa2[i] = Math.max(maxa2[i-1], sum - x[i] * 2);
        }
        sum = 0;
        long[] maxb1 = new long[n+2], maxb2 = new long[n+2];
        for(int i = n; i > 0; i--) {
            sum += v[i];
            maxb1[i] = Math.max(maxb1[i-1], sum - (c - x[i]));
            maxb2[i] = Math.max(maxb2[i-1], sum - (c - x[i]) * 2);
        }
        long ans = 0;
        for(int i = n+1; i > 0; i--) {
            ans = Math.max(ans, Math.max(maxb2[i] + maxa1[i-1], maxa2[i-1] + maxb1[i]));
        }
        System.out.println(ans);
    }
}

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

int main()
{
	int D;
	cin >> D;
	if (D == 25) {
		puts("Christmas");
	}
	else if (D == 24) {
		puts("Christmas Eve");
	}
	else if (D == 23) {
		puts("Christmas Eve Eve");
	}
	else {
		puts("Christmas Eve Eve Eve");
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
typedef long long int ll;


int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	YesNo(s=="abc");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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 (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin >> n >> k;
    vector<ll> a(n);
    REP(i,n){
        cin >> a[i];
        if(i>=k){
            if(a[i]>a[i-k]){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
        }
    }
}

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

int main(void)
{
	int N;
	int K = 0;

	cin >> N;
	vector<int> d(N);
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	
	if (d[N / 2 - 1] < d[N / 2]) {
		K = d[N / 2] - d[N / 2 - 1];
	}
	cout << K << endl;

	return 0;
}

Measured memory_bytes: 640
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 524288
#define P 200003

constexpr ulli PRIME = 0xffffffffff000001;
constexpr ulli ntt_add(ulli a, ulli b)
{
    ulli res = 0;
    if(__builtin_uaddll_overflow(a,b,&res))
        res -= PRIME;
    return res;
}
constexpr ulli ntt_sub(ulli a, ulli b)
{
    ulli res = 0;
    if(__builtin_usubll_overflow(a,b,&res))
        res += PRIME;
    return res;
}
constexpr ulli ntt_mul(ulli a, ulli b)
{
    constexpr ulli magic = -PRIME;
    unsigned __int128 k = (unsigned __int128)a*b;
    k = (k>>64<<24) + (ulli)k - (k>>64);
    ulli res = 0;
    if(__builtin_uaddll_overflow((k>>64)*magic,(ulli)k,&res))
        res += magic;
    return res;
}
constexpr ulli ntt_pow(ulli a, ulli b)
{
    ulli r = 1;
    while(b)
    {
        if(b&1) r = ntt_mul(r,a);
        a = ntt_mul(a,a);
        b >>= 1;
    }
    return r;
}
constexpr ulli ntt_find()
{
    ulli res = 2;
    while(ntt_pow(res,PRIME/2) != PRIME-1) ++res;
    return res;
}
constexpr ulli OMEGA = (ntt_pow(ntt_find(),PRIME/N));
static_assert(__builtin_popcount(N) == 1);
static_assert(PRIME%N == 1);
static_assert(ntt_pow(OMEGA,N/2) == PRIME-1);
uint ricr(uint k)
{
    k ^= (N-1);
    k ^= -1u >> 1 >> __builtin_clz(k);
    return k;
}
void ntt(ulli *a, ulli ow=OMEGA)
{
    for(int i=0,ii=0;i<N;++i,ii=ricr(ii))
        if(i<ii) std::swap(a[i],a[ii]);
    for(int n2=1,n=2;n2<N;n2=n,n*=2)
    {
        ulli w = ntt_pow(ow,N/n);
        for(ulli *p=a; p!=a+N; p+=n)
        {
            ulli k = 1;
            for(int i=0,j=n2;i<n2;++i,++j)
            {
                ulli e = p[i], o = p[j];
                ulli ok = ntt_mul(o,k);
                p[i] = ntt_add(e,ok);
                p[j] = ntt_sub(e,ok);
                k = ntt_mul(k,w);
            }
        }
    }
}
void ntt_inv(ulli *a)
{
    ntt(a,ntt_pow(OMEGA,PRIME-2));
    for(int i=0;i<N;++i) a[i] = ntt_mul(a[i],ntt_pow(N,PRIME-2));
}

int lo[N];
ulli a[N];

int main()
{
    for(int i=0, k=1; i<P-1; ++i, k=k*2<P?k*2:k*2-P)
        lo[k] = i;
    int n;
    lli ans = 0;
    scanf("%d", &n);
    for(int i=0;i<n;++i)
    {
        int k;
        scanf("%d", &k);
        if(!k) continue;
        ++a[lo[k]];
        ans -= (lli)k*k % P;
    }
    ntt(a);
    for(int i=0;i<N;++i) a[i] = ntt_mul(a[i],a[i]);
    ntt_inv(a);
    for(int i=0,k=1;i<N;++i, k=k*2<P?k*2:k*2-P)
    {
        if(a[i] >= PRIME) a[i] -= PRIME;
        ans += k * a[i];
    }
    assert(ans%2==0);
    ans /= 2;
    printf("%lld\n", ans);
    return 0;
}


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

std::unordered_map<char, char> create_win_map() {
    auto m = std::unordered_map<char, char>();
    m['r'] = 'p';
    m['s'] = 'r';
    m['p'] = 's';
    return m;
}

std::unordered_map<char, uint64_t> create_score_map(const uint64_t r, const uint64_t s, const uint64_t p) {
    auto m = std::unordered_map<char, uint64_t>();
    m['r'] = r;
    m['s'] = s;
    m['p'] = p;
    return m;
}

int main() {
    uint64_t n, k, r, s, p;
    std::cin >> n >> k >> r >> s >> p;

    std::string t;
    std::cin >> t;

    auto history = std::vector<char>();
    history.reserve(n);

    const auto win_map = create_win_map();
    const auto score_map = create_score_map(r, s, p);


    uint64_t score = 0;

    for(uint64_t i = 0; i < n; ++i) {
        const char win = win_map.at(t[i]);

        if(k <= i) {
            const char prohibited = history[i - k];

            if(win != prohibited) {
                score += score_map.at(win);
                history.push_back(win);
            } else {
                history.push_back('_');
            }

        } else {
            score += score_map.at(win);
            history.push_back(win);
        }
    }

    std::cout << score << std::endl;

    return 0;
}


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

#define pb push_back
#define ll long long
#define fi first
#define se second

const ll M = 1000000007;

void solve()
{
	int n;
	cin>>n;
	cout<<n*n*n;
}

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

Measured memory_bytes: 256
from collections import Counter
n,a=map(int,input().split())
X=sorted(list(map(lambda x:int(x)-a,input().split())))
ans=Counter([0])
for x in X:
    tmp=Counter()
    for i,j in ans.items():
        tmp[i+x]+=j
    ans+=tmp
print(ans[0]-1)



Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n-1;i++){
        int x;
        cin >> x;
        vec[x-1]++;
    }
    for(int i=0;i<n;i++){
        cout << vec[i] << endl;
    }
}

Measured memory_bytes: 3996
while True:
 n,x = list(map(int, input().split() ))
 if n==0 and x==0:
  break
 nways = 0
 for i1 in range(1,n+1):
  if i1*3+3>x:
   break
  for i2 in range(i1+1,n+1):
   if i1+i2+i2+1>x:
     break
   for i3 in range(i2+1,n+1):
    if i1+i2+i3 == x:
     nways = nways + 1
     break
    elif i1+i2+i3>x:
     break
 print(nways)

  


Measured memory_bytes: 5596
/*Program from Luvwgyx*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define int long long
#define write(x) printf("%lld\n",x)
using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
signed main(){
    int a=read();char s[20];
    scanf("%s",s);
    if(a>=3200)printf("%s\n",s);
    else puts("red");
    return 0;
}


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

int main(){
    int x;
    cin >> x;
    int y = x / 500;
    x -= y*500;
    int z = x / 5;
    int ans = y*1000 + z*5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

LL n, ans;
string s;

map<pair<string, string>, LL>a;

int main() {
	cin >> n >> s;
	REP(i, 1 << n) {
		string x, y;
		REP(j, n)(i >> j & 1 ? x : y).push_back(s[j]);
		a[make_pair(x, y)]++;
	}
	REP(i, 1 << n) {
		string x, y;
		REP(j, n)(i >> j & 1 ? y : x).push_back(s[n + j]);
		reverse(ALL(x));
		reverse(ALL(y));
		ans += a[make_pair(x, y)];
	}
	cout << ans << endl;
}

Measured memory_bytes: 87040
(setq l (read))
(setq r (read))
(setq d (read))
(prog (ans now)
  (setq ans 0)
  (setq now l)
  loop
  (cond ((> now r) (princ ans) (return ans)))
  (cond ((equal 0 (mod now d)) (setq ans (+ 1 ans))))
  (setq now (+ now 1))
  (go loop)
)


Measured memory_bytes: 24348
#date: 2020-03-15 21:21
import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    if s == "Sunny":
        print("Cloudy")
    elif s == "Cloudy":
        print("Rainy")
    else:
        print("Sunny")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
typedef long long int ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fora(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define mp make_pair 
#define sc second 
#define f first 
#define kek cout<<"\n" 
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
const ll MOD = 1e9 + 7;
const int MAXN = 100005;
const int INF = 1e8;
using namespace std;
int main()

{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 fast;
int n,m;
cin>>n>>m;
pair<int,char> arr[m];
for(int i=0;i<m;i++) cin>>arr[i].f>>arr[i].sc;
string s;
for(int i=0;i<1000;i++)
{
          s=to_string(i);
          int k=s.size();
          bool ok=1;
          if(k!=n) continue;
          for(int j=0;j<m;j++) if(s[arr[j].f-1]!=arr[j].sc) ok=0;
          if(ok)
          {
                    cout<<s;
                    return 0;
          }
}
cout<<-1;
return 0;
  
     
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,i,j,k;
	cin>>n;
	int a[n][3];
	for(i=0;i<n;i++)
	{
	    for(j=0;j<3;j++)
	    cin>>a[i][j];
	}
	for(i=1;i<n;i++)
	{
	    a[i][0]=a[i][0]+max(a[i-1][1],a[i-1][2]);
	    a[i][1]=a[i][1]+max(a[i-1][0],a[i-1][2]);
	    a[i][2]=a[i][2]+max(a[i-1][0],a[i-1][1]);
	}
	k=INT_MIN;
	for(i=0;i<3;i++)
	{
	    k=max(a[n-1][i],k);
	}
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 1408
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		int min = 10000;
		int kouho = 0;
		ArrayList<Integer> forbiddenList = new ArrayList<>();
		for(int i = 0 ; i < n ; i++) {
			forbiddenList.add(sc.nextInt());
		}
		for(int i = -3 ; i < 105 ; i++) {
			if((forbiddenList.contains(i)))
				continue;
			int sa = Math.abs(i - x) ;
			if(sa > min)
				continue;
			if(sa < min)
				kouho = i;
			if(sa == min)
				kouho = Math.min(kouho, i);

			min = sa;
		}
		System.out.println(kouho);
	}


}



Measured memory_bytes: 35816
#include<stdio.h>

int main(void){
  int A[100],n,i,j,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<n;i++){
    for(j=0;j<n-1;j++){
      printf("%d ",A[j]);
    }
    printf("%d",A[n-1]);
    printf("\n");
    v = A[i];
    j = i-1;
    while(j >= 0 && A[j] > v ){
      A[j+1] = A[j];
      j--;
     }
    A[j+1] = v;
  }
  for(i=0;i<n-1;i++){
      printf("%d ",A[i]);
  }
  printf("%d",A[n-1]);
  printf("\n");
}





Measured memory_bytes: 2144
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

typedef long long ll;

int N, K;
map<int, int> bmap;

int main()
{
    cin >> N >> K;
    for (int i = 0; i < N; ++i)
    {
        int a;
        cin >> a;
        bmap[a] = bmap.find(a) != bmap.end() ? bmap[a] + 1 : 1;
    }

    if (bmap.size() <= K)
    {
        cout << 0 << endl;
        return 0;
    }

    vector<int> v;
    for (auto kv : bmap) v.push_back(kv.second);
    sort(v.begin(), v.end());

    int ans = 0;
    for (int i = 0; i < v.size() - K; ++i)
    {
        ans += v[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10748
def resolve():
    A,B,C,X = [int(input()) for i in range(4)]

    res = 0
    for a in range(A+1):
        for b in range(B+1):
            for c in range(C+1):
                total = 500*a + 100*b + 50*c
                if total == X:
                    res += 1

    print(res)
    
resolve()

Measured memory_bytes: 3064
// #pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma vector temporal
// #pragma simd
// #pragma GCC diagnostic ignored "-W"

#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<sstream>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<vector>
#include<utility>
#include<functional>
#include<complex>
#include<climits>

// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define ll long long
#define ld long double
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vint vector<int>
#define SS stringstream
#define PQ priority_queue
#define MS(x,v) memset((x),(v),sizeof(x))
#define RZUNI(x) sort(x.begin(),x.end()), x.resize(unique(x.begin(),x.end())-x.begin())
#define FLH fflush(stdout)
#define CPPinput ios_base::sync_with_stdio(0); cin.tie(0)
#define FIN(fname) freopen(fname,"r",stdin)
#define FOUT(fname) freopen(fname,"w",stdout)

#define tm Ovuvuevuevue
#define y1 Enyetuenwuevue
#define left Ugbemugbem
#define ws Osas
#define dec tetteterette
#define exp expexpexpexp
#define expl explexplexpl

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl

#ifdef WEAK
#include"/home/edison/Coding/cpp/template/debug.cpp"
#define DEB(...) printf(__VA_ARGS__),fflush(stdout)
#define WHR() printf("%s: Line %d",__PRETTY_FUNCTION__,__LINE__),fflush(stdout)
#define LOG(...) printf("%s: Line %d ",__PRETTY_FUNCTION__,__LINE__),printf(__VA_ARGS__),fflush(stdout)
#define DEBUG 1
#define exit(x) cout<<"exit code "<<x<<endl, exit(0)
#else
#define PDE(...) ;
#define DEB(...) ;
#define WHR() ;
#define LOG(...) ;
#define DEBUG 0
#endif

#define lowbit(x) ((x)&(-(x)))

#if __cplusplus >= 201103L
#include<unordered_map>
#include<unordered_set>
#include<tuple>
#endif

void JIZZ(string output=""){cout<<output; exit(0);}

const ld PI=3.14159265358979323846264338327950288;
const ld eps=1e-13;
const ll mod=1e9+7;

int a[200005];

int main(){
    CPPinput;
    int n; cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i],a[i]-=i;
    sort(a+1,a+1+n);
    int x=a[(n+1)/2];
    ll ans=0;
    for(int i=1;i<=n;++i)ans+=abs(x-a[i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<(n); i++)
#define int long long
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
int C[110][110];
int T[110][110];
int m,n,q,f,to,t,c,r;
        
signed main(void){
    while(true){
        cin>>m>>n;
        if(m==0&&n==0)break;
        rep(i,110)rep(j,110){
            C[i][j]=INF;T[i][j]=INF;
        }
        rep(i,m){
            cin>>f>>to>>c>>t;f--;to--;
            C[f][to]=c;C[to][f]=c;
            T[f][to]=t;T[to][f]=t;
        }
        rep(k,n)rep(i,n)rep(j,n){
            C[i][j]=min(C[i][j],C[i][k]+C[k][j]);
            T[i][j]=min(T[i][j],T[i][k]+T[k][j]);
        }
        
        cin>>q;
        rep(i,q){
            cin>>f>>to>>r;f--;to--;
            if(r==0)cout<<C[f][to]<<endl;
            if(r==1)cout<<T[f][to]<<endl;
        }
        
    }
}


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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int &x : p)
    cin >> x;

  vector<double> e(n);
  for (int i = 0; i < n; i++)
    e.at(i) = double(p.at(i) * (p.at(i) + 1)) / 2.0 / (double)p.at(i);

  double total = 0.0;
  for (int i = 0; i < k; i++)
    total += e.at(i);

  double max = total;

  for (int i = 0; i < n - k; i++)
  {
    total += e.at(i + k) - e.at(i);
    if (max < total)
      max = total;
  }
  cout << fixed << setprecision(10) << max << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    int a,b; cin>>a>>b;
    if(a==1) a=14;
    if(b==1) b=14;
    if(a<b){
        cout<<"Bob"<<endl;
    }else if(a>b){
        cout<<"Alice"<<endl;
    }else{
        cout<<"Draw"<<endl;
    }
    
}


Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

// mod.m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}


int main(){
    int n;
    cin >> n;
    vll a(n);
    vll inv_a(n);
    rep(i,n) cin >> a[i];
    inv_a[n-1] = a[n-1];
    ll ans = 0;
    for(int i=n-2; i >= 0; i--) {
        ans += a[i] * inv_a[i+1];
        ans = ans % mod;
        inv_a[i] = (inv_a[i+1] + a[i]) % mod;
    }
    if(ans < 0) ans += mod;
    cout << ans << endl;
}



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

template<class T>
struct BIT {
    int NN;
    vector<T> data;
    BIT(int N) {
        data = vector<T>(N + 1);
        NN = N;
    }

    void add_at(int idx, T val) {
        for (int i = idx + 1; i <= NN; i += (i & (-i))) {
            data[i] += val;
        }
    }

    T sum_to(int idx) {
        T res = 0;
        for (int i = idx + 1; i > 0; i -= (i & (-i))) {
            res += data[i];
        }
        return res;
    }

    T sum_in(int l, int r) { // [l, r]
        return sum_to(r) - sum_to(l - 1);
    }
};

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

    int N, Q; 
    cin >> N >> Q;

    vector<int> C(N, -1);
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }

    vector<vector<tuple<int, int, int>>> queries(N);
    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        queries[r].push_back(tuple<int, int, int>(l, r, i));
    }

    auto bit = BIT<int>(N);
    auto V = *max_element(C.begin(), C.end());
    auto last = vector<int>(V + 1, -1);
    auto ans = vector<int>(Q, -1);

    for (int i = 0; i < N; i++) {
        if (last[C[i]] != -1) {
            bit.add_at(last[C[i]], -1);
        }

        bit.add_at(i, +1);
        last[C[i]] = i;

        for (auto& [l, r, idx] : queries[i]) {
            ans[idx] = bit.sum_in(l, r);
        }
    }

    for (auto x: ans) {
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 34164
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{    
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> a(m);
    rep(i,m) cin >> a[i];

    int cost_0 = 0;
    int cost_n = 0;
    rep(i,m)
    {
        if(a[i]<x) cost_0++;
        else if(a[i]>x) cost_n++;
    }
    cout << min(cost_0,cost_n) << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
const ld pi = acos(-1);
const ll mod = 1000000007;
const ll inf = 1LL << 60;

int main(){
    ll n,m;
    cin>>n>>m;
    dsu d(n);
    ll cnt=0;
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        d.merge(a-1,b-1);
    }
    rep2(i,1,n){
        if(d.same(0,i)==0){
            d.merge(0,i);
            cnt+=1;
        }
    }
    cout<<cnt<<endl;
}

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

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

    int cnt=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            int sum=0;
            for(int k=0;k<D;k++){
                int dx=X[i][k]-X[j][k];
                sum+=dx*dx;
            }
            for(int l=1;l<1000;l++){
                if(l*l==sum) cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 998244353;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;
 
template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M) % M;
}

int main() {
    double A,B;
    int H,M;
    cin >> A >> B >> H >> M;
    double cnt = abs(30 * H + 0.5 * M - 6 * M);
    if(cnt > 180) {
        cnt = 360 - cnt;
    }
    cnt = cnt * PI / 180;
    double ret = A * A + B * B - 2 * A * B * cos(cnt);
    cout << fixed;
    cout << setprecision(20) << sqrt(ret) << endl;
}

Measured memory_bytes: 4224
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	ar := make([]int, n)
	for i := range ar {
		fmt.Scan(&ar[i])
	}
	ans := -1000000000
	for i := 0; i <= k && i <= n; i++ {
		for j := 0; j <= k-i && j <= n-i; j++ {
			br := make([]int, 0, i+j)
			for k := 0; k < i; k++ {
				br = append(br, ar[k])
			}
			for k := 0; k < j; k++ {
				br = append(br, ar[n-1-k])
			}
			sort.Ints(br)
			sum := 0
			de := k - i - j
			for _, v := range br {
				if v >= 0 {
					sum += v
				} else {
					if de > 0 {
						de--
					} else {
						sum += v
					}
				}
			}
			if ans < sum {
				ans = sum
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 896
#include <stdio.h>
#define MN 100005
int n,m,a,b,cnt[MN];
bool ans=true;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&a,&b);
		++cnt[a],++cnt[b];
	}
	for(int i=1;i<=n;i++)
		if(cnt[i]&1)ans=false;
	puts(ans?"YES":"NO");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,count;
  cin >> N >> K;
  vector<int> A(100010);
  for(int i=1;i<=N;i++){cin >> A[i];}
  for(int i=1;i<=N;i++){
    if(A[i]==1){count=i;}
  }
  int sum=0;
  sum+=(count-1)/(K-1);
  sum+=(N-count)/(K-1);
  if((count-1)%(K-1)!=0){sum++;}
  if((N-count)%(K-1)!=0){sum++;}
  int a=(count-1)%(K-1); int b=(N-count)%(K-1);
  if(a!=0 && b!=0 && a+b<=K-1){sum--;}
  cout << sum << endl;
}

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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;

typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

//constexpr long long MOD = (ll) 1e9+7;
constexpr long long MOD = 998244353;

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;
}

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

template<class Abel> struct PotentialUnionFind {
 vector<int> par;
 vector<int> rank;
 vector<Abel> diff_weight;

 PotentialUnionFind(int n = 1, Abel SUM_UNITY = 0) {
  init(n, SUM_UNITY);
 }

 void init(int n = 1, Abel SUM_UNITY = 0) {
  par.resize(n); rank.resize(n); diff_weight.resize(n);
  for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
 }

 int root(int x) {
  if (par[x] == x) {
   return x;
  }
  else {
   int r = root(par[x]);
   diff_weight[x] += diff_weight[par[x]];
   return par[x] = r;
  }
 }

 Abel weight(int x) {
  root(x);
  return diff_weight[x];
 }

 bool issame(int x, int y) {
  return root(x) == root(y);
 }

 bool merge(int x, int y, Abel w) {
  w += weight(x); w -= weight(y);
  x = root(x); y = root(y);
  if (x == y) return false;
  if (rank[x] < rank[y]) swap(x, y), w = -w;
  if (rank[x] == rank[y]) ++rank[x];
  par[y] = x;
  diff_weight[y] = w;
  return true;
 }

 Abel diff(int x, int y) {
  return weight(y) - weight(x);
 }
};


void solve() {
    ll n,m;
    cin>>n>>m;
    PotentialUnionFind<ll> uni(n);
    bool flag=true;
    REP(i,m){
        ll l,r,d;
        cin>>l>>r>>d;
        l--;r--;
        if(uni.issame(l,r)){
            if(uni.diff(l,r)!=d) flag=false;
        }else{
            uni.merge(l,r,d);
        }
    } 

    if(flag) cout<<"Yes"<<en;
    else cout<<"No"<<en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 0071
public class Main {
	static Scanner sc = new Scanner(System.in);
	static char[][] cs = new char[8][8];
	public static void main(String[] args) {
		int TC = sc.nextInt();
		for (int tc = 1; tc <= TC; tc++) {
			for (int i = 0; i < 8; i++) cs[i] = sc.next().toCharArray();
			rec(sc.nextInt() - 1, sc.nextInt() - 1);
			System.out.println("Data " + tc + ":");
			for (int i = 0; i < 8; i++) System.out.println(String.valueOf(cs[i]));
		}
	}
	
	static int[] dx = {0, 1, 0, -1}, dy = {1, 0, -1, 0};
	public static void rec(int x, int y) {
		cs[y][x] = '0';
		for (int k = 0; k < 4; k++) {
			for (int C = 1; C <= 3; C++) {
				int nx = x + dx[k] * C, ny = y + dy[k] * C;
				if (inField(ny, nx) && cs[ny][nx] == '1') {
					rec(nx, ny);
				}
			}
		}
	}
	
	public static boolean inField(int x, int y) {
		return (x >= 0 && x < 8 && y >= 0 && y < 8);
	}
}

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

int main(){
   int d[10]={0};
   string s;
   cin>>s;
   for(int i=0;i<s.size();i++){ 
      if(s[i]=='N') d[0]=1;
      else if(s[i]=='S') d[1]=1;
      else if(s[i]=='W') d[2]=1;
      else d[3]=1;
   }
   if(d[0]==d[1]&&d[2]==d[3]) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;cin>>a>>b;
  for(ll i=1;i<=111111;i++){
    if(i*8/100 == a && i*10/100 == b){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np
N,K = map(int,input().split())
A = list(map(int,input().split()))
A = np.array(A)
ans = np.array([float('inf')]*N)
ans[0] = 0
K = min(N-1,K)
ans[1:K+1] = np.abs(A[0]-A[1:K+1])
for i in range(K+1,N):
  ans[i] = np.min(ans[i-K:i+1]+np.abs(A[i]-A[i-K:i+1]))
print(int(ans[N-1]))

Measured memory_bytes: 22808
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,d,i,cnt;
    int a[101];
    cin>>n>>k;
    if(n>=1&&n<=100&&k>=1&&k<=100)
    {
        for(i=1;i<=n;i++)
            a[i]=0;
        while(k>0)
        {
            cin>>d;
            if(d>=1&&d<=n)
            {
                while(d>0)
                {
                    cin>>i;
                    a[i]=1;
                    d--;
                }
            }
            k--;
        }
    }
    cnt=0;
    for(i=1;i<=n;i++)
    {
        if(a[i]==0)
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3636
def solve():
    n, x = map(int, input().split())
    L = list(map(int, input().split()))
    bounce = [0]
    pos = 0
    for i in L:
        pos += i
        bounce.append(pos)
    return len([b for b in bounce if b <= x])


if __name__ == "__main__":
    print(solve())


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

int main() {
    string s; cin >> s;
    int k; cin >> k;
    int n = s.length();
    vector<string> subs;
    for(int i = 0; i < n; i ++) {
        string tmp = "";
        for(int j = i; j < min(n,k+i); j ++) {
            tmp += s[j];
            subs.push_back(tmp);
        }
    }
    sort(subs.begin(), subs.end());
    unique(subs.begin(), subs.end());
    cout << subs[k-1] << endl;
}

Measured memory_bytes: 1660
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<int> xv(n);
    vector<int> yv(m);
    for (int i = 0; i < n; i++) cin >> xv[i];
    for (int i = 0; i < m; i++) cin >> yv[i];

    sort(xv.begin(), xv.end());
    sort(yv.begin(), yv.end());

    int z = max(xv.back(), x) + 1;


    bool ans = z<=y &&  z <= yv[0];
    cout << (ans ? "No War" : "War") << endl;
}

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

int main()
{
   int sum = 0, n, nn;
   cin>>n;
   nn = n;
   while(nn)
   {
       sum+=(nn%10);
       nn/=10;
   }
   if(n%sum==0)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        Integer numSize = scan.nextInt();
        List<Integer> array = new ArrayList<Integer>();
        for(int i = 0; i < numSize; i++) {
            array.add(scan.nextInt());
        }
        int numOfAnswer = 0;
        
        for(int i = 0; i < numSize - 2; i ++) {
            if(array.get(i) < array.get(i + 1) && array.get(i + 1) < array.get(i + 2) || array.get(i) > array.get(i + 1) && array.get(i + 1) > array.get(i + 2)) {
                numOfAnswer++;
            }
        }
        System.out.println(numOfAnswer);
    }
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    priority_queue<ll> pq;
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        pq.push(a);
    }

    for (int i = 0; i < m; i++) {
        ll x = pq.top();
        pq.pop();
        x >>= 1;
        pq.push(x);
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll x = pq.top();
        pq.pop();
        ans += x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x;
	cin >> x;
	long long A[6209];
	for (int i = 0; i < 6209; i++)
	{
		A[i] = pow(i, 5);
	}
	for (int i = 0; i < 6209; i++)
	{
		for (int j = 0; j < 6209; j++)
		{
			if (A[i] + A[j] == (long long)x)
			{
				cout << i << " -" << j << endl;
				return 0;
			}
			else if (A[i] - A[j] == (long long)x)
			{
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4196
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

vector<P>p;
vector<int> G[10010];
vector<int>c;
bool visited[10010];
bool leaf[10010];
void dfs(int n) {
	int cnt = 0;
	visited[n] = true;
	for (auto x : G[n]) {
		cnt++;
	}
	p.push_back(make_pair(cnt, n));
	for (auto x : G[n]) {
		if (!visited[x]) {
			dfs(x);
		}
	}
}
int ans[10010];
int res = 0;
void dfs2(int n) {
	visited[n] = true;
	for (auto x : G[n]) {
		if (!visited[x]) {
			res += min(ans[n], ans[x]);
			dfs2(x);
		}
	}
}
set<int>rem;
vector<int>v;
void dfs3(int n) {
	visited[n] = true;
	bool found = 0;
	for (auto x : G[n]) {
		if (!visited[x]) {
			if (!leaf[x]) {
				found = true;
				dfs3(x);
			}
		}
	}
	if (!found) {
		v.pb(n);
		leaf[n] = true;
		auto itr = rem.erase(n);
	}
}
signed main() {
	/*cin.tie(0);
	ios::sync_with_stdio(false);*/
	int N;
	cin >> N;
	REP(i, N - 1) {
		int a, b; cin >> a >> b;
		a--, b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	REP(i, N) {
		rem.insert(i);
		int C; cin >> C;
		c.pb(C);
	}
	VSORT(c);
	m0(visited);
	bool ok = false;
	while (rem.size() != 0) {
		m0(visited);
		auto itr = rem.begin();
		dfs3(*itr);
	}
	REP(i, N) {
		ans[v[i]] = c[i];
	}

	//VSORT(c);// VREVERSE(c);
	//m0(visited);
	//dfs(0);
	//VSORT(p);
	//REP(i, N) {
	//	ans[p[i].second] = c[i];
	//}
	m0(visited);
	dfs2(0);
	print(res);
	REP(i, N) {
		pe(ans[i]);
	}cout << endl;
}


Measured memory_bytes: 2048
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
#include <chrono>
#include <fstream>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    string s;
    cin >> s;
    int res = 0;
    rep(i, s.size()) res += s[i] - '0';
    cout << (res % 9 == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<vector>
#include<memory>
using namespace std;
int n,m,a[100005],dp[100005],k;
long long sol(int x){
	if(x>=n-1)return 0;
	if(dp[x]!=-1){
		return dp[x];
	}else {
		int min=sol(x+1)+abs(a[x+1]-a[x]);
		for(int i=2;i<=k;i++){
			if(x<n-i){
				int y=sol(x+i)+abs(a[x+i]-a[x]);
				if(y<min){
					min=y;
				}
			}
			
		}	
		dp[x]= min;
		return dp[x];
	}
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		dp[i]=-1;
	}
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	long long r=sol(0);
	cout<<r;
}

Measured memory_bytes: 5760