akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 100005;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}

template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x + '0');
	else write(x / 10), putchar(x % 10 + '0');
}

struct edge {
	int to, nxt;
} tree[N << 1];
int n, head[N], deg[N], d[N], cnt = 0;
void addedge (int u, int v) {
	edge e = {v, head[u]};
	tree[head[u] = cnt++] = e;
}

bool cmp (vector<int> v1, vector<int> v2) {
	for (int i = 0; i < n; i++) {
		if (v1[i] < v2[i]) return true;
		if (v1[i] > v2[i]) return false;
	}
	return false;
}

vector<int> calc (vector<int> vec) {
	int cnt = 0;
	vector<int> res;
	for (int i = 0; i < vec.size(); i++) {
		for (int j = 1; j <= vec[i]; j++) res.push_back(cnt + 1 + j);
		res.push_back(cnt + 1), cnt += vec[i] + 1;
	}
	return res;
}

int main () {
	read(n);
	for (int i = 1; i <= n; i++) head[i] = -1, d[i] = deg[i] = 0;
	for (int i = 1; i < n; i++) {
		int u, v;
		read(u), read(v);
		addedge(u, v), addedge(v, u);
		deg[u]++, deg[v]++;
	}

	if (n == 1) puts("1");
	else if (n == 2) puts("1 2");
	else {
		bool valid = true;
		for (int i = 1; i <= n; i++) {
			if (deg[i] == 1) {
				for (int j = head[i]; ~j; j = tree[j].nxt) {
					d[tree[j].to]++;
				}
			}
		}

		for (int i = 1; i <= n; i++) {
			if (deg[i] >= 2 && deg[i] - d[i] >= 3) valid = false;
		}

		if (!valid) puts("-1");
		else {
			int s = 0, prv = 0;
			for (int i = 1; i <= n; i++) {
				if (deg[i] >= 2 && deg[i] - d[i] <= 1) s = i;
			}

			vector<int> deg_list;
			while (s) {
				int to = 0;
				for (int i = head[s]; ~i; i = tree[i].nxt) {
					int u = tree[i].to;
					if (deg[u] >= 2 && u != prv) to = u; 
				}
				deg_list.push_back(d[s]);
				prv = s, s = to;
			}

			vector<int> d, ans1, ans2, ans;
			if (deg_list.size() == 1) {
				d.push_back(0), d.push_back(deg_list[0] - 2), d.push_back(0);
				ans = calc(d);

				for (int i = 0; i < n; i++) write(ans[i]), putchar(' ');
				putchar('\n');
			}
			else {
				d.push_back(0), d.push_back(deg_list[0] - 1);
				for (int i = 1; i < deg_list.size() - 1; i++) d.push_back(deg_list[i]);
				d.push_back(deg_list[deg_list.size() - 1] - 1), d.push_back(0);

				ans1 = calc(d);
				reverse(d.begin(), d.end());
				ans2 = calc(d);

				ans = cmp(ans1, ans2) ? ans1 : ans2;
				for (int i = 0; i < n; i++) write(ans[i]), putchar(' ');
				putchar('\n');
			}
		}
	}
	return 0;
}

Measured memory_bytes: 6248
#include <bits/stdc++.h>
using namespace std;
int main() {
	string w;
	cin >> w;
	vector<bool> al(26, false);
	for (int i = 0; i < w.length(); i++) {
		int x = w.at(i) - 'a';
		al.at(x) = !al.at(x);
	}
	for (int i = 0; i < 26; i++) {
		if (al.at(i)) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int i,w,n,num[30],a,b,c;
	scanf("%d%d",&w,&n);
	for(i=0; i<w; i++){
		num[i]=i;
	}
	for(i=0; i<n; i++){
		scanf("%d,%d",&a,&b);
		c=num[a-1];
		num[a-1]=num[b-1];
		num[b-1]=c;
	}
	for(i=0; i<w; i++){
		printf("%d\n",num[i]+1);
	}
	return 0;
}

Measured memory_bytes: 596
//
// Created by 徳備彩人 on 2020/06/01.
//

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, W;
    vector<int> v;
    vector<int> w;
    cin >> N >> W;
    vector<vector<int>> dp(N+1, vector<int>(W+1, 0));

    for (int i=0;i<N;i++) {
        int a, b;
        cin >> a >> b;
        v.push_back(a);
        w.push_back(b);
    }

    for (int i=0;i<N;i++) {
        for (int j=0;j<=W;j++) {
            if (w[i] <= j) {
                dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j]);
            } else {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }

    cout << dp[N][W] << endl;

}


Measured memory_bytes: 6824
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <unordered_set>
//#include <unordered_map>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int h,w;
vvint vv;
pii s,g;
vvint used;
int dd[]={1,0,-1,0,1};
bool foo(pii a,int c){
	if(used[a.F][a.S]) return false;
	if(vv[a.F][a.S]!=c) return false;
	used[a.F][a.S]=1;
	if(a==g) return true;
	rep(i,4){
		pii next=a;
		next.F+=dd[i];
		next.S+=dd[i+1];
		if(0<=next.F&&next.F<h&&0<=next.S&&next.S<w){
			if(foo(next,c)) return true;
		}
	}
	return false;
}
void mainmain(){
	while(cin>>w>>h,w||h){
		initvv(vv,h,w,0);
		used=vv;
		cin>>s.S>>s.F>>g.S>>g.F;
		s.F--;s.S--;
		g.F--;g.S--;
		int n;
		cin>>n;
		rep(i,n){
			int a,b,c,d;
			cin>>a>>b>>d>>c;
			c--;
			d--;
			if(b==0){
				vv[c][d]=vv[c][d+1]=vv[c][d+2]=vv[c][d+3]=a;
				vv[c+1][d]=vv[c+1][d+1]=vv[c+1][d+2]=vv[c+1][d+3]=a;
			}
			else{
				vv[c][d]=vv[c+1][d]=vv[c+2][d]=vv[c+3][d]=a;
				vv[c][d+1]=vv[c+1][d+1]=vv[c+2][d+1]=vv[c+3][d+1]=a;
			}
		}
		rep(i,h){
			rep(j,w){

			}
		}
		if(vv[s.F][s.S]==0){
			cout<<"NG"<<endl;
		}
		else if(foo(s,vv[s.F][s.S])){
			cout<<"OK"<<endl;
		}
		else{
			cout<<"NG"<<endl;
		}
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

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

int main()
{
    int n,m;

    cin >> n >> m;

    int food[m], k = 0, a = 0, l = 0;
    rep(i,m) food[i] = 0;

    rep(j,n){
        cin >> k;

        rep(i,k){
            cin >> a;
            food[a-1] += 1;
        }
    }

    rep(i,m){
        if (food[i] == n) l += 1;
    }
    cout << l;

}

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

using namespace std;

int main() {
    string s;
    cin >> s;

    string ans;
    ans += s[0];
    for (int i = 1; i < s.length(); ++i) {
        if (ans[ans.length() - 1] == 'S' and s[i] == 'T') {
            ans.resize(ans.length() - 1);
        } else {
            ans += s[i];
        }
    }
    
    cout << ans.length() << endl;
    return 0;
}

Measured memory_bytes: 776
N,M = gets.split.map(&:to_i)
x = []
y = {}
M.times do |i|
    a,b = gets.split.map(&:to_i)
    if a == 1 then
        x.push b
    elsif b == N then
        y[a] = 1
    end
end
flag = false
x.each do |a|
    if y.has_key?(a) then
        flag = true
        break
    end
end
puts flag ? "POSSIBLE" : "IMPOSSIBLE"

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

use proconio::{input, fastout};
use proconio::marker::{Chars, Usize1};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        mut ps: [i64; n],
    }

    ps.sort_unstable();
    println!("{}", ps[0..k].iter().sum::<i64>());
}


Measured memory_bytes: 2208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;
 
int main() {
  ll n;
  cin >> n;
  vec a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
    a[i]--;
  }
  ll ans=0;
  for(ll i=0;i<n;i++) {
    if(a[a[i]]==i) ans++;
  }
  ans/=2;
  cout << ans << endl;
}

Measured memory_bytes: 1024
k = list(input())

if len(k) == 1:
    print(0)
elif len(k) == 2:
    if k[0] == k[1]:
        print(0)
    else:
        print(1)

elif len(k) % 2 == 0:
    count = 0
    for i in range(len(k)//2):
        if k[i] != k[len(k)-1-i]:
            count += 1
    print(count)

elif len(k) % 2 == 1:
    count = 0
    for i in range(len(k)//2):
        if k[i] != k[len(k)-1-i]:
            count += 1
    print(count)


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

public class AtCoder_155_A
{
    public static void Main()
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        int[] line1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int a = line1[0];
        int b = line1[1];
        int c = line1[2];

        if (a == b && a == c)
        {
            Console.WriteLine("No");
        }
        else if (a != b && b != c && c != a)
        {
            Console.WriteLine("No");
        }
        else
        {
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 13268
import collections

mod = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
fact = [1]*(n+1)
rfact = [1]*(n+1)
r = 1
for i in range(1, n+1):
  fact[i] = r = r * i % mod
rfact[n] = r = pow(fact[n], mod-2, mod)
for i in range(n, 0, -1):
  rfact[i-1] = r = r * i % mod

# nPk (mod MOD) を求める
def perm(n, k):
  return fact[n] * rfact[n-k] % mod

# nCk (mod MOD) を求める
def comb(n, k):
  return fact[n] * rfact[k] * rfact[n-k] % mod
already = [0] * (n+1)
k = 0
for key,v in enumerate(a):
  if already[v]:
    k = already[v] + n - key - 1
    break
  else:
    already[v] = key+1
for i in range(n+1):
  if i == n:
    print(1)
    exit()
  ans = comb(n,i) + comb(n,i+1)
  if i <= k:
    ans -= comb(k,i)
  ans %= mod
  print(ans)

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

int main(){
	long long int a , b , x;
	cin >> a >> b >> x;
	cout << max(a-x,0LL) ;
	x = max( x-a , 0LL) ;
	cout << " " << max(b-x, 0LL ) << endl ;
	return 0 ;
}


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

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        char[] d = S.toCharArray();
        int answer = 100000;
        for (int i = 0; i < d.length - 2; i++) {
            int x = (d[i]-'0')*100+(d[i+1]-'0')*10+(d[i+2]-'0');
            if (Math.abs(x-753) < answer) {
                answer = Math.abs(x-753);
            }
        }
        System.out.println(answer);
    }
}


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

using namespace std;

int main () {
	
	int n, m;
	cin >> n >> m;
	vector <string> v(n);
	
	int f = 0, t = 0, o = 0;
	
	if (n % 2 == 0 and m % 2 == 0) {
		f = (n / 2)  * (m / 2);
		
	}
	else if (n % 2 == 0 and m % 2 == 1) {
		f = (n / 2)  * (m / 2);
		t = n / 2;
	}
	
	else if (n % 2 == 1 and m % 2 == 0) {
		f = (n / 2)  * (m / 2);
		t = m / 2;
	}
	else {
		f = (n / 2)  * (m / 2);
		t = n + m - 2;
		t /= 2;
		o = 1;
	}
	
	// cout << f << " " << t << " " << o << endl;
	vector <int> a(26, 0);
	
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		for (char c : v[i]) {
			a[c - 'a']++;
		}
	}
	
	for (int i = 0; i < 26; i++) {
		while (a[i] >= 4 and f > 0) {
			f--;
			a[i] -= 4;
		}
		
		while (a[i] >= 2 and t > 0) {
			t--;
			a[i] -= 2;
		}
		
		while (a[i] >= 1 and o > 0) {
			o--;
			a[i]--;
		}
		
		
	}
	
	if (!o and !t and !f) {
		cout << "Yes" << endl;
	}
	else 
		cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
    char str[11], str2[12], str3[11];
    int i, j, k;
    scanf("%s %s %s", str, str2, str3);
    int l1 , l2, l3;
    l1 = strlen(str) - 1;
    l2 = strlen(str2) - 1;
    l3 = strlen(str3) - 1;
    if(str[l1] == str2[0] && str2[l2] == str3[0])
    {
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(a) push_back(a)
int main()
{
	int n;
	cin>>n;
	int x=n/2+(n%2);
	double r;
	r=(1.0*x)/n;
	cout<<r<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i)
#define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;++i)
#define per(i,a,b) for(int i=(b),i##_st=(a);i>=i##_st;--i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define dbg(x) cerr<<#x" = "<<x<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef long long ll;
typedef pair<int,int> pii;
const int inf=~0u>>1,MOD=1e9+7;
inline int rd() {
    int x,c,f=1;while(!isdigit(c=getchar()))f=c!='-';x=c-'0';
    while(isdigit(c=getchar()))x=x*10+c-'0';return f?x:-x;
}
const int N=1e5+11;
int n,K,a[N],b[N],d[N],q[N];
int main(){
	n=rd(),K=rd();
	rep(i,1,n)a[i]=rd();
	int ans=0;
	if(a[1]!=1)ans++,a[1]=1;
	if(K==1){
		rep(i,2,n){
			ans+=(a[i]!=1);
		}
		cout<<ans<<endl;
		return 0;
	}
	rep(i,2,n){
		d[a[i]]++;
	}
	int h=0,t=0;
	rep(i,2,n)if(!d[i]){
		q[t++]=i;
	}
	while(h<t){
		int x=q[h++];
		if(x==1)continue;
		b[x]=max(b[x],1);
		if(b[x]>=K)++ans;
		else b[a[x]]=max(b[a[x]],b[x]+1);
		if(!--d[a[x]]&&a[a[x]]!=1&&a[x]!=1){
			q[t++]=a[x];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

int main(){
    int a;
    cin >> a;
    string s;
    cin >> s;
    int cnt =0;
    int flags_i = 0b1111111111;
    for(int i = 0; i < a; i++){
        //cout << "flags_i:" << std::hex << flags_i << std::dec << endl;
        if(!(flags_i))break;
        //cout << "(int)(s[i]-'0'):" << (int)(s[i]-'0') << endl;
        //cout << "flags_i & 1 << (int)(s[i]-'0'):" << (flags_i & 1 << (int)(s[i]-'0')) << endl;
        if(!(flags_i & 1 << (int)(s[i]-'0')))continue;
        flags_i ^= 1 << (int)(s[i]-'0');
        int flags_j = 0b1111111111;
        for(int j = i + 1; j < a; j++){
            if(!(flags_j))break;
            if(!(flags_j & 1 << (int)(s[j]-'0')))continue;
            flags_j ^= 1 << (int)(s[j]-'0');
            int flags_k = 0b1111111111;
            for(int k = j + 1; k < a; k++){
                if(!(flags_k))break;
                if(!(flags_k & 1 << (int)(s[k]-'0')))continue;
                flags_k ^= 1 << (int)(s[k]-'0');
                cnt++;
            }
            //cout << " i:" << i << " j:" << j << " cnt:" << cnt << endl;
        }
        //cout << " i:" << i << " cnt:" << cnt << endl;
    }
    cout << cnt << endl;
    return 0;
}


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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

template<class T> T sum(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    T ans = T();
    for(typename vector<T>::iterator t = begin; t != end; t++) ans += *t;
    return ans;
}

template<class T> T min(const vector<T>& v) {
    return *min_element(v.begin(), v.end());
}

template<class T> T min(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *min_element(begin, end);
}

template<class T> T max(const vector<T>& v) {
    return *max_element(v.begin(), v.end());
}

template<class T> T max(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *max_element(begin, end);
}

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

    loop {
        int N = next<int>(), M = next<int>();
        unless(N && M) break;

        auto X = next<vector<int>>(N),
             Y = next<vector<int>>(M);

        int now = 0;
        times(M, i) {
            now += Y[i];
            now += X[now];
            // cout << now ln;
            if(now >= N - 1) {
                cout << i + 1 ln;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
#include <vector>
#include <queue>

using namespace std;

class Node
{
public:
	vector<int> visited;
	int count;
	int cur_pos;
	Node(int n_){
		count = 0;
		visited = vector<int>(n_, 0);
	}
};

class oneStrokePath
{
private:
	int n, m;
	vector<vector<int> > adj;
public:
	oneStrokePath(){
		cin >> n >> m;
		adj.resize(n);
		for (int i = 0; i < n; ++i)
		{
			adj[i].resize(n);
			for (int j = 0; j < n; ++j)
			{
				adj[i][j] = 0;
			}
		}

		for (int i = 0; i < m; ++i)
		{
			int tmp_a, tmp_b;
			cin >> tmp_a >> tmp_b;
			tmp_a--;
			tmp_b--;
			adj[tmp_a][tmp_b] = 1;
			adj[tmp_b][tmp_a] = 1;
		}
	}
	void execute();
};

void oneStrokePath::execute(){
	queue<Node> q;
	Node start = Node(n);
	start.visited[0] = 1;
	start.count = 1;
	start.cur_pos = 0;
	q.push(start);
	int ans = 0;
	while(!q.empty()){
		Node cur = q.front();
		q.pop();
		if(cur.count == n) ans++;
		for (int i = 0; i < n; ++i)
		{
			if(adj[cur.cur_pos][i] == 1 && cur.visited[i] == 0){
				Node next = cur;
				next.visited[i] = 1;
				next.count++;
				next.cur_pos = i;
				q.push(next);
			}
		}
	}
	cout << ans << endl;
}

int main(){
	oneStrokePath osp = oneStrokePath();
	osp.execute();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int X;
    int a = 0;
    cin >> X;
    vector<int> y = {8,27,32,125,128,216,243,256,343,512,1000};
    
    for(int n = 0; n < 11; n++){
        if(y[n] <= X){
            a = y[n];
        }else{
            break;
        }
    }
    int t;
    
    t = sqrt(X);
       
  
    if(t*t < a){
        cout << a << endl;
    }else{
        cout << t * t << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		for (int i = 0; i < S.length(); i++) {
			for (int j = i + 1; j < S.length(); j++) {
				if (S.charAt(i) == S.charAt(j)) {
					System.out.println("no");
					return;
				}
			}
		}
		System.out.println("yes");
	}
}



Measured memory_bytes: 21844
#include<stdio.h>

int main(void)
{
int H,A;
int i = 0;

scanf("%d", &H);
scanf("%d", &A);

while(1)
{
  H = H - A;
  i = i + 1;
  if(H <= 0)
  {
  break;
  }
}

printf("%d", i);

return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  
  int exist_a = 0, exist_b = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'a') {
      if (exist_a + exist_b < a + b) {
        cout << "Yes" << endl;
        exist_a++;
      }
      else cout << "No" << endl;
    }
    else if (s[i] == 'b') {
      if (exist_a + exist_b < a + b && exist_b < b) {
        cout << "Yes" << endl;
        exist_b++;
      }
      else cout << "No" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i < b; i++)
#define REPE(i,a,b) for (int i = a; i <= b; i++)

int main() {
	int n = 0, w = 0;
	scanf("%d%d", &n, &w);
	vector<vector<ll>> dp(n + 1, vector<ll>(w + 1, 0));
	vector<ll> p(n + 1, 0), we(n + 1, 0);
	int i = 0, j = 0;

	for (i = 0; i < n; i++)
		cin >> we[i], cin >> p[i];

	for (i = 0; i <= n; i++) {
		for (j = 0; j <= w; j++) {
			if (i == 0 || j == 0)
				dp[i][j] = 0;
			else if (we[i - 1] <= j)
				dp[i][j] = max(dp[i - 1][j], p[i - 1] + dp[i - 1][j - we[i - 1]]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	cout << dp[n][w] << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

char s[100050];
char t[100050];
int pos[30];
vector<int> G[30];

int main()
{
    scanf("%s%s",s,t);
    ll n = strlen(s);
    ll m = strlen(t);

    for(int i=0;i<n;i++){
        G[s[i]-'a'].push_back(i);
    }

    ll cnt = 0;
    int now = -1;
    for(int i=0;i<m;i++){
        int num = t[i]-'a';

        if(G[num].size()==0){
            printf("-1");
            return 0;
        }

        while(pos[num] < G[num].size() && G[num][pos[num]] < now){
            pos[num]++;
        }

        if( pos[num] < G[num].size() && G[num][pos[num]] > now ){
            now = G[num][pos[num]];
            pos[num] ++;
        }
        else{
            cnt++;
            for(int j=0;j<26;j++)pos[j]=0;
            pos[num]=1;
            now = G[num][0];
        }
    }
    cout<<cnt*n+now+1;

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

int main(void){
  char s[500];
  int i, flag = 0, num[100], top=0, m=0, a, b, ans;
  fgets(s, 500, stdin);
  for(i=0;i<strlen(s);i++){
    if('0' <= s[i] && s[i] <= '9'){
      m = m*10 + s[i]-'0';
      flag = 1;
    }
    else if(s[i] == ' '){
      if(flag == 1){
      num[top] = m;
      top++;
      m = 0;
      flag = 0;}
    }
    else if(s[i] == '\n'){}
    else{
      a = num[top-2]; b = num[top-1];
      //printf("%d, %d, %d\n", a, b, top);
      top-=2;
      if(s[i]=='+') num[top] = a+b;
      else if(s[i] == '-') num[top] = a-b;
      else if(s[i] == '*') num[top] = a*b;
      top++;
      flag = 0;
    }
    //printf("%c\n",s[i]);
  }
  printf("%d\n", num[0]);
  return 0;
}


Measured memory_bytes: 1992
#include <iostream>
using namespace std;
#define rep(i, a, n) for(int (i) = a; (i) < (n); i++) //繰り返し分を書く手間を省くため
typedef long long ll;

int n, k; //荷物の数とトラックの数
int w[100100]; //荷物の重さ

bool ch(int p){//引数には最大積載量になりうる値が与えられている
    ll sum = 0; //荷物の総重量
    int idx = 0;

    rep(i, 0, k){//k台のトラック分ループ
        sum = 0;
        while(w[idx] + sum <= p){
            sum += w[idx];
            idx++; //次の荷物
            if(idx == n) return true; //すべての荷物が積み終わった
        }
    }
    return false;
}

int main(void){
    cin >> n >> k;
    rep(i, 0, n) cin >> w[i];

    //二分探索によって、最大積載量がいくつになるかを求める
    ll left = 0, right = 1000000000; //最大積載量はわからないので、の初期値を大きめの1000000000とした
    while(left < right){
        ll mid = (left + right) / 2;
        if(ch(mid)) right = mid; //もしすべての荷物が詰め終わっても最大積載量以下であったならば、探索範囲を半分にする
        else left = mid + 1;
    }
    cout << right << endl;
}



Measured memory_bytes: 3492
x = int(input())
rate = 1
if 400 <= x and x <= 599:
  rate = 8
elif x <= 799:
  rate = 7
elif x <= 999:
  rate = 6
elif x <= 1199:
  rate = 5
elif x <= 1399:
  rate = 4
elif x <= 1599:
  rate = 3
elif x <= 1799:
  rate = 2

print(rate)

Measured memory_bytes: 9180
#include<stdio.h>
#include<string.h>
int main()
{
     char s[4];
     scanf("%s",&s);
     int c=0;
     for(int i=0;i<3;i++){
     if(s[i+1]=='B')
          c=1;
}
if(c==1)
     printf("ARC\n");
     else
          printf("ABC\n");

     return 0;
}


Measured memory_bytes: 1612
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "YES" : "NO"));}
//----------------------------------------------------------------

int main(void) {
  int n, m;
  cin >> n >> m;

  rep(i,m){
    if(n%2==1) prt2(i+2, n-i);
    else {
      if(2*(i+1)>n/2) prt2(i+2, n-i);
      else prt2(i+1, n-i);
    }
  }
}


Measured memory_bytes: 3628
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
#define dbg1(x) cout << #x <<"="<< x <<endl;
#define dbg2(x,y) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<endl;
#define dbg3(x,y,z) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<<endl;
#define dbg4(x,y,z,a) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<< ", "<<#a <<"="<<a << endl;
#define dbgarr(x) cout << #x<<endl;for(int i : x){cout << i <<" ";} cout <<endl;



void mymain(){
    string s;
    cin >> s;
    if(s=="AAA" || s=="BBB"){
        cout << "No" <<endl;
    }else{
        cout << "Yes" <<endl;
    }


}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
//cin>>t;
for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}
/*

*/


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

#define LL long long
#define ULL unsigned long long

#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) (((l)+(r))>>1)

const int MOD = (int) 1e9 + 7;
const double eps = (double) 1e-8;
const int maxn = (int) 1e5 + 20;
const double pi = (double) acos(-1.0);

int m, k;
vector<int> ans;

void work()
{
    cin >>m >>k;

    if((1 << m) <= k)
    {
        puts("-1");
        return ;
    }

    if(m == 1)
    {
        if(k == 1)
        {
            puts("-1");
        }
        else
        {
            puts("0 0 1 1");
        }
        return ;
    }

    ans.push_back(k);
    for(int i = 0; i < (1 << m); i++)
    {
        if(i != k)
            ans.push_back(i);
    }
    ans.push_back(k);
    for(int j = ans.size() - 1; j >= 0; j--)
    {
        if(ans[j] != k)
            ans.push_back(ans[j]);
    }

    for(int i = 0; i < ans.size(); i++)
    {
        if(i) putchar(' ');
        cout <<ans[i];
    }
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r" ,stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416

    int tc = 1;
//    scanf("%d", &tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 2932
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                             \
  cerr << __LINE__ << ": " << #x << " = {";          \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) { \
    cerr << ((hoge) ? "," : "") << x[hoge];          \
  }                                                  \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, X, Y;
  cin >> N >> X >> Y;
  X--, Y--;
  int distX[N], distY[N];
  const int INF = INT_MAX / 10;
  fill(distX, distX + N, INF);
  fill(distY, distY + N, INF);
  distX[X] = 0;
  distX[Y] = 1;
  distY[Y] = 0;
  distY[X] = 1;
  queue<pair<int, int>> que;
  que.push(make_pair(0, X));
  que.push(make_pair(1, Y));
  while (!que.empty()) {
    int v, d;
    tie(d, v) = que.front();
    que.pop();
    if (distX[v] < d) continue;
    if (v > 0 && distX[v - 1] > distX[v] + 1) {
      distX[v - 1] = distX[v] + 1;
      que.push(make_pair(distX[v - 1], v - 1));
    }
    if (v + 1 < N && distX[v + 1] > distX[v] + 1) {
      distX[v + 1] = distX[v] + 1;
      que.push(make_pair(distX[v + 1], v + 1));
    }
  }
  que.push(make_pair(0, Y));
  que.push(make_pair(1, X));
  while (!que.empty()) {
    int v, d;
    tie(d, v) = que.front();
    que.pop();
    if (distY[v] < d) continue;
    if (v > 0 && distY[v - 1] > distY[v] + 1) {
      distY[v - 1] = distY[v] + 1;
      que.push(make_pair(distY[v - 1], v - 1));
    }
    if (v + 1 < N && distY[v + 1] > distY[v] + 1) {
      distY[v + 1] = distY[v] + 1;
      que.push(make_pair(distY[v + 1], v + 1));
    }
  }
  int cnt[N];
  fill(cnt, cnt + N, 0);
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int k = min({j - i, distX[i] + distX[j], distY[i] + distY[j]});
      cnt[k]++;
    }
  }
  for (int k = 1; k < N; k++) cout << cnt[k] << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
#include<iomanip>
#include<iterator>
//#include<chrono>
//cout<<setprecision(12)
//fixed
//#include<random>
using namespace std;
typedef long long int llint;
typedef long double lldo;
const int big=1e9+100000;
const int mod=1e9+7;
const lldo eps=1e-9;
const long double pai=3.141592653589793238462643;
#define mt make_tuple
#define mp make_pair
#define fir first
#define sec second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define res resize
#define ins insert
#define era erase
#define dme(in) cout<<in<<endl;return 0
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int main(void){
	int n,r,l;scanf("%d %d %d",&n,&r,&l);
	vector<int>pot(n);//??????
	vector<int>tv(n);
	set<pair<int,int>>a;//???
	int mae=0;
	for(int i=0;i<n;i++){a.ins(mp(0,i));}
	while(r--){
		int d,t,x;scanf("%d %d %d",&d,&t,&x);
		tv[a.begin()->sec]+=t-mae;
		mae=t;
		d--;a.era(mp(-pot[d],d));
		pot[d]+=x;
		a.ins(mp(-pot[d],d));
	}
	tv[a.begin()->sec]+=l-mae;
	int ans=0;
	for(int i=0;i<n;i++){if(tv[ans]<tv[i]){ans=i;}}
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 8352
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 11;
int n;

vector<int> normalize(vector<int> s)
{
  int numMap[26];
  memset(numMap, -1, sizeof(numMap));
  for (int i = 0, c = 0; i < s.size(); i ++)
  {
    if (numMap[s[i]] == -1)
      numMap[s[i]] = c ++;
    s[i] = numMap[s[i]];
  }
  return s;
}

set<vector<int>> ans, nxt;
void solve()
{
  ans.clear(), nxt.clear();
  ans.insert({0});
  for (int i = 1; i < n; i ++)
  {
    nxt.clear();
    for (vector<int> s: ans)
    {
      s.push_back(0);
      for (int i = 0; i < 26; i ++)
      {
        s[s.size() - 1] = i;
        nxt.insert(normalize(s));
      }
    }
    ans = nxt;
  }
}

int main()
{
  int t = 0;
  while (scanf("%d", &n) != EOF)
  {
    if (t ++) printf("--------------------\n");
    solve();
    for (vector<int> s: ans)
    {
      for (int i = 0; i < n; i ++)
        printf("%c", 'a' + s[i]);
      printf("\n");
    }
  }
  return 0;
}
/*
aaa - 000
aab - 001
aba - 010
abb - 011
abc - 012
*/

Measured memory_bytes: 26880
N,M = map(int,input().split())
#l = [list(map(int,input().split())) for _ in range(N)]

K = []
A = []
for _ in range(N):
    tmp = list(map(int,input().split()))
    K.append(tmp[0])
    A += tmp[1:]
    #A.append(tmp[1:])
#print(sorted(A))
cnt = 0
for i in range(1,M+1):
    #print(A.count(i))
    if(A.count(i) == N):
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n=inp()
    if n%2==0:
        n = n//2
        ans = 0
        while n>0:
            ans += n//5
            n = n//5
        print(ans)
    else:
        print(0)
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 39148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
LL facctorialMethod(int k);
int main(){
//意味わからん
    int n, k;
    cin >> n >> k;
    set<int> st;
    rep (i, k) {
        int d;
        cin >> d;
        rep (j, d) {
            int x;
            cin >> x;
            st.insert(x);
        }
    }
    cout << n - (int)st.size() << endl;

    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 3608
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */
 
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>
 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 1000000007
 
const long double PI = 3.141592653589793236L;
 
typedef long long int ll;
typedef long double ld;

using namespace std;

void solve()
{   
    ll n, w;
    cin >> n >> w;

    vector<pair<ll, ll>> a(n + 1);

    for(int i = 1; i <= n; i++)
    {
        cin >> a[i].first >> a[i].second;
    }

    vector<vector<ll>> dp(n + 1, vector<ll>(w + 1));

    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            ll x = dp[i - 1][j];
            ll y = 0;
            if(j - a[i].first >= 0)
            {
                y = dp[i - 1][max(0LL, j - a[i].first)] + a[i].second;
            }
            dp[i][j] = max(x, y);
        }
    }

    cout << dp[n][w] << "\n";
    
}

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

    int T = 1;
    //cin >> T;
    
    while (T--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 83160
#include<cstdio>
#include<bits/stdc++.h> 
using namespace std; 
int main() 
{
    int a,b,c,x,d,e,f,s=0;
     cin>>a>>b>>c>>x;
     for(d=0;d<=a;d++){
     	for(e=0;e<=b;e++){
     		for(f=0;f<=c;f++){
     			if(d*500+e*100+f*50==x){
     				s+=1;
				 }
			 }
		 }
	 }
	 cout<<s;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll x; cin >> x;
	cout << 2 * (x / 11) + (x % 11 > 6 ? 2 : (x % 11 == 0 ? 0 : 1));
}


Measured memory_bytes: 3596
#include<iostream>
 #include<algorithm>
 #include<cmath>
 #include<iomanip>
 #include<cstring>
 #include<cmath>
 #include<map>
 #include<vector>
 #include<sstream>
 #include<queue>
using namespace std;

typedef long long ll;

int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b;
}

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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int N = 200005;

int k, n, A[N];

int getDist(int x, int y) {
    if (x > y) {
        return y + k - x;
    }
    return y - x;
}

int main() {
    
    scanf("%d %d", &k, &n);
    
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    
    int maxi = 0;
    for (int i = 0; i < n; i++) {
        maxi = max(maxi, getDist(A[i], A[(i + 1) % n]));
    }
    
    printf("%d\n", k - maxi);
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;
const int NMAX = 3030;
ll dp[NMAX][NMAX];
int main() {
for(int n; std::cin >> n; ) {
    std::vector<int> a(n);
    for (auto &it : a) std::cin >> it;
    for (int i = 0; i < n; i++) {
        dp[i][i] = a[i];
    }
    for (int len = 2; len <= n; len++) {
        for (int i = 0, j = len-1; j < n; i++,j++) {
            dp[i][j] = std::max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]);
        }
    }
    std::cout << dp[0][n-1] << std::endl;
}
    return 0;
}

Measured memory_bytes: 71936
#include <stdio.h>
#include <iostream>

using namespace std;

int bubbleSort(int *A, int N);
void display(int *A, int N);

int main(){
    int N;
    int A[100];
    int cnt;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    cnt = bubbleSort(A, N);
    display(A, N);
    cout << cnt <<endl;
}

int bubbleSort(int *A, int N){
    int cnt=0;
    int flag = 1;
    while(flag){
        flag =0;
        for(int j=N-1; j>0; j--){
            if (A[j] < A[j-1]){
                int tmp;
                tmp =A[j];
                A[j]=A[j-1];
                A[j-1]=tmp;
                flag = 1;
                cnt+=1;
            }
        }
    }
    return cnt;
}
void display(int *A, int N){
  for(int i=0; i<N-1 ;i++){
    cout <<A[i] << " ";
  }
  cout << A[N-1] << endl;
}



Measured memory_bytes: 3104
import os
import sys
from io import BytesIO, IOBase
from math import gcd
from collections import Counter as cc

def main():
    n=int(input())
    l=list(map(int,input().split()))
    sm=sum(l)
    cnt=cc(l)
    q=int(input())
    for _ in range(q):
        p,r=map(int,input().split())
        sm-=(p*cnt[p])
        cnt[r]+=cnt[p]
        sm+=(r*cnt[p])
        cnt[p]=0
        print(sm)



    


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 26844
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void shpsi(){
	int n;cin>>n;
	int t=10;
	int sum=0;
	if(n%2){
		cout<<0;
		return;
	}
	while(true){
		sum+=n/t;
		t*=5;
		if(n/t==0)
			break;
	}
	cout<<sum;
}

int32_t main()
{
	fast;int t=1;
	//cin>>t;
	while(t--){
		shpsi();
	}

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
  int i, j;
  int joi, ioi;
  int len;
  char str[100000], jd[256];

  memset(str,'\0',sizeof(str));
  memset(jd,'\0',sizeof(jd));

  while (scanf("%s", str) != EOF){
	
	len = strlen(str);
	
	joi = ioi = 0;
	
	for (i = 0;i < len - 2;i++){
	  if (str[i] == 'J' && str[i+1] == 'O' && str[i+2] =='I'){
		joi++;
	  }
	  if (str[i] == 'I' && str[i+1] == 'O' && str[i+2] =='I'){
		ioi++;
	  }
  }
	
	printf("%d\n%d\n", joi, ioi);
  }

  return 0;
}

Measured memory_bytes: 0
#include<iostream>

int main(){
    int n,a[10000];
    int i,j,max,min;
    long long int sum=0;

    std::cin>>n;

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

    max=min=a[0];

    for(i=0;i<n;i++){
        sum +=a[i];
        if(max<a[i]){
            max=a[i];
        }
        if(a[i]<min){
            min=a[i];
        }
    }

    std::cout<<min<<" "<<max<<" "<<sum<<std::endl;
    return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string>
using namespace std;

string s1, s2, s3, s4;
void set(int x1, int y1, int x2, int y2){
    if(x2 > x1 && y2 > y1){
        s1 = 'R';
        s2 = 'U';
        s3 = 'L';
        s4 = 'D';
    }
    else if(x2 > x1 && y2 < y1){
        s1 = 'R';
        s2 = 'D';
        s3 = 'L';
        s4 = 'U';
    }
    else if(x2 < x1 && y2 > y1){
        s1 = 'L';
        s2 = 'U';
        s3 = 'R';
        s4 = 'D';
    }
    else{
        s1 = 'L';
        s2 = 'D';
        s3 = 'R';
        s4 = 'U';
    }
}
/*
int direct(int x1, int y1, int x2, int y2){
    int d;

    if(x2 > x1 && y2 > y1){
        d = 0;
    }
    else if(x2 > x1 && y2 < y1){
        d = 1;
    }
    else if(x2 < x1 && y2 > y1){
        d = 2;
    }
    else{
       d = 3;
    }

    return d;
}*/

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    set(sx, sy, tx, ty);
    //int d = direct(sx, sy, tx, ty);

    for(int i = 0; i < abs(tx - sx); i++){
        cout << s1;
    }
    for(int i = 0; i < abs(ty - sy); i++){
        cout << s2;
    }
    for(int i = 0; i < abs(tx - sx); i++){
        cout << s3;
    }
    for(int i = 0; i < abs(ty - sy) + 1; i++){
        cout << s4;
    }

    for(int i = 0; i < abs(tx - sx) + 1; i++){
        cout << s1;
    }
    for(int i = 0; i < abs(ty - sy) + 1; i++){
        cout << s2;
    }
    cout << s3 << s2;
    for(int i = 0; i < abs(tx - sx) + 1; i++){
        cout << s3;
    }
    for(int i = 0; i < abs(ty - sy) + 1; i++){
        cout << s4;
    }
    cout << s1 << endl;

    return 0;
}

Measured memory_bytes: 256