akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
ll longinf=1ll<<60;
int inf=1<<29;
int dh[]={1,-1,0,0};
int dw[]={0,0,1,-1};
//mleしなければぜんぶllでかく。

vector<int> parent[100000];
vector<int> child[100000];
int goodparent[100000];
int main(){
      cin.tie(0);
      ios::sync_with_stdio(false);
      int n,m;
      cin>>n>>m;
      //vector<int> parent[100000];
      //vector<int> child[100000];
      rep0(i,n+m-1){
            int a,b;
            cin>>a>>b;
            --a;--b;
            parent[b].push_back(a);
            child[a].push_back(b);
      }
      priority_queue<P,vector<P>,greater<P>> que;
      rep0(i,n){
            if(!parent[i].size()){
                  P p={0,i};
                  que.push(p);
                  goodparent[i]=-1;
            }
      }
      bool v[n];
      fill(v,v+n,false);
      int parentsize[n];
      rep0(i,n){
            parentsize[i]=parent[i].size();
      }
      while(que.size()){
            P now=que.top();
            que.pop();
            int node=now.second;
            int pos=now.first;
            int sizenode=child[node].size();
            rep0(i,sizenode){
                  int newnode=child[node][i];
                  goodparent[newnode]=node;
                  parentsize[newnode]--;
                  if(parentsize[newnode]==0){
                        P nexted={pos+1,newnode};
                        que.push(nexted);
                  }
            }
      }
      rep0(i,n){
            cout<<goodparent[i]+1<<endl;
      }
      return 0;
}

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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    map<string, int> days;
    days["SUN"] = 0;
    days["MON"] = 1;
    days["TUE"] = 2;
    days["WED"] = 3;
    days["THU"] = 4;
    days["FRI"] = 5;
    days["SAT"] = 6;

    string input;
    cin >> input;
    cout << (0 - days[input]) % 7 + 7 << endl;
}

Measured memory_bytes: 256
#ifndef HOME
	#pragma GCC target("avx")
	#pragma GCC optimize("Ofast")
	#pragma GCC optimize("unroll-loops")
	#pragma comment(linker, "/stack:200000000")
	#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

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

#define MAX(a, b) __builtin_ia32_pmaxsd128(a, b)
#define MIN(a, b) __builtin_ia32_pminsd128(a, b)

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

using namespace __gnu_cxx;
using namespace __gnu_pbds;

template <class key_type>
using superTree = tree<key_type, null_type, less<key_type>, 
					   rb_tree_tag, tree_order_statistics_node_update>;
using v4si = int __attribute__ ((vector_size(16)));

const int MOD = 1000000007;

inline int _(int x, int y) {
	x += y;
	if (x >= MOD) { return x - MOD; }
	if (x < 0)    { return x + MOD; }
	return x; }

inline void __(int &x, int y) {
	x = _(x, y); }

/*
 * TO DO:
 *	
 * - long long instead of int
 * - bigger array sizes
 * - array / list instead of map / set
 * - can bruteforce with tricks pass system tests? 
 *
 * - NEVER STOP THINKING / CODING !!!
 */

const int DIM = 200005;

int arr[DIM];
map<int, int> mmp;

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#ifdef HOME
	freopen("cf.in", "r", stdin);
	freopen("cf.out", "w", stdout);
#endif		
	int n; cin >> n;	
	for (int i = 1; i <= n; ++i) {
		cin >> arr[i]; }
	sort(arr + 1, arr + n + 1);
	int ans = 0;
	for (int i = n; i >= 1; --i) {
		bool ok = true;
		for (long long x = 2; x <= 2000000000; x *= 2) {
			if (x > arr[i] and mmp[x - arr[i]] > 0) {
				--mmp[x - arr[i]]; ok = false; break; } }
		mmp[arr[i]] += ok; ans += !ok; }
	cout << ans;
	return 0; }


Measured memory_bytes: 29824
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 * N
 *  人の社員からなる会社があり、各社員には
 * 1
 * ,
 * .
 * .
 * .
 * ,
 * N
 *  の社員番号が割り当てられています。
 *
 * 社員番号
 * 1
 *  の社員以外の全ての社員には、自分より社員番号が小さい直属の上司がちょうど
 * 1
 *  人います。
 *
 * X
 *  さんが
 * Y
 *  さんの直属の上司であるとき、
 * Y
 *  さんは
 * X
 *  さんの直属の部下であるといいます。
 *
 * 社員番号
 * i
 *  の社員の直属の上司の社員番号が
 * A
 * i
 *  であることが与えられます。各社員について直属の部下が何人いるか求めてください。
 */
public class Main {

    public static void main(String args[]) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());

        int[] ans = new int[N];
        Arrays.fill(ans, 0);
        for (String An: br.readLine().split(" ")) {
            ans[Integer.valueOf(An) - 1]++;
        }

        for (int i: ans) {
            System.out.println(i);
        }
    }
}

Measured memory_bytes: 66168
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define las(v) v[v.size()-1]
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

ll N,M;
ll K[10];
ll P[10];
vector<ll> T[10];
ll a[10];

int main()
{
  cin>>N>>M;
  rep(i, M){
    cin>>K[i];
    ll x;
    rep(j, K[i]){
      cin>>x;
      x--;
      T[x].push_back(i);
    }
  }
  rep(i, M) cin>>P[i];
  ll ans = 0;
  rep(i, 1<<N){
    rep(j,M) a[j] = P[j];
    rep(j,N){
      if((i>>j)&1){
        rep(k, T[j].size()){
          a[ T[j][k] ] ^= 1;
        }
      }
    }
    bool b = 1;
    rep(j,M){
      if(a[j]==1) b=0;
    }
    if(b) ans++;
  }
  cout<<ans<<endl;
}

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

using namespace std;
// using namespace atcoder;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

vector<ll> isPrime;
vector<ll> X;

vector<int> sieveOfEratosthenes(int n) {
    X.resize(n, 0);
    vector<int> res;
    for (ll i = 1; i <= n; i++) {
        for (ll j = i; j <= n; j++) {
            X[j] ++;
        }
    }
    return res;
}


void solve() {
    ll N;
    cin >> N;
    ll ans = 0;
    vector<ll> cnt(N + 1, 0);

    rep2(i, 1, N + 1) {
        for (ll j = i; j <= N; j += i) {
            cnt[j] ++;
        }
    }
    rep2(c, 1, N) {
        ll R = N - c;
        ll x = cnt[R];
        ans += x;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 11052
#include <stdio.h>

int main()
{
	char input1[5];
	char input2[5];
	scanf("%s",input1);
	scanf("%s",input2);

	if(input1[0]==input2[2] && input1[1] == input2[1] && input1[2] == input2[0])
	{
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scanner=new Scanner(System.in);
        int A=scanner.nextInt();
        int B=scanner.nextInt();
        int X=scanner.nextInt();
        if(X>=A&&A+B>=X){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 23764
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n,d;
double a[101][101];
inline int read(){
    int x=0;bool f=0;char c=getchar();
    while(c<'0'||c>'9'){if(c=='0')f=!f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return f?-x:x;
}

int main(){
    int sum=0;
    n=read(),d=read();
    for(int i=1;i<=n;++i){
        for(int j=1;j<=d;++j){
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            if(i!=j){
                double ans=0;
                for(int k=1;k<=d;++k){
                    ans+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
                }
                ans=sqrt(ans);
                int qwq=int(ans);
                if(qwq==ans) sum++;
            }
        }
    }
    printf("%d\n",sum/2);
    return 0;
}

Measured memory_bytes: 256
//D
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
ll f[maxn];
int w[105],v[105];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,W;
	cin >> n >> W;
	for(int i = 1;i <= n;i++)cin >> w[i] >> v[i];
	for(int i = 1;i <= n;i++){
		for(int j = W;j >= 0;j--)if(j >= w[i])f[j] = max(f[j],f[j - w[i]] + v[i]);
	}
	cout << f[W];
	return 0;
}


Measured memory_bytes: 4420
patterns = [[5, "dream"], [7, "dreamer"], [5, "erase"], [6, "eraser"]]

s = input()

idx = len(s)
while idx > 0:
    for sub, pat in patterns:
        n_idx = idx - sub
        if pat == s[n_idx:idx]:
            idx = n_idx
            break
        else:
            continue
    if idx != n_idx:
        break

print("YES" if idx == 0 else "NO")


Measured memory_bytes: 40048
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll arr[2000200];
int main()
{
    ll k,n,ans=0x3f3f3f3f3f3f3f3f;
    scanf("%lld %lld",&k,&n);
    for(int i=1;i<=n;++i) {
        scanf("%lld", &arr[i]);
        arr[i + n] = arr[i] + k;
    }
    for(int i=1;i<=n;++i)
    {
        ans=min(arr[i+n-1]-arr[i],ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
using namespace std;
const int MAX = 1e5 + 10;
const ll MOD = 1e9 + 7;
int N, M, K, Q;
int A[2 * MAX];

int main()
{
	int i, j, k;
	int T;
	scanf("%d%d", &N, &T);
	for (i = 0; i < N; ++i) scanf("%d", &A[i]);
	int to = T;
	int sum = T;
	for (i = 1; i < N; ++i) {
		int tcur = A[i];
		if (tcur <= to) {
			sum += (tcur + T - to);
			to = tcur + T;
		}
		else {
			sum += T;
			to = tcur + T;
		}
	}
	printf("%d\n", sum);
}


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

const int MAXN = 100055;

ll dp[MAXN], ds[MAXN];
int ud[MAXN];

vector<int> G[MAXN];
int A[MAXN], B[MAXN], O[MAXN];
bitset<MAXN> chk;

int N, M;

int uf(int i) { return i == ud[i] ? i : (ud[i] = uf(ud[i])); }
void uf(int a, int b) {
	b = uf(b);
	if(uf(a) == b) return;
	ll t = max(dp[b] + ds[b], ll(A[a])) - ds[b];
	a = uf(a);
	ds[a] += ds[b];
	if(t < dp[a]) dp[a] = t;
	ud[b] = a;
}

int main() {
	ios::sync_with_stdio(false);

	cin >> N >> M;
	for(int i = 1; i <= N; i++) {
		cin >> A[i] >> B[i];
		A[i] = max(0, A[i] - B[i]);
	}
	for(int i = 0, a, b; i < M; i++) {
		cin >> a >> b;
		G[a].eb(b);
		G[b].eb(a);
	}

	iota(O, O+N+1, 0); sort(O+1, O+N+1, [&](int a, int b) {
		return A[a] < A[b];
	});

	iota(ud, ud+N+1, 0);
	for(int oi = 1, i; oi <= N; oi++) {
		i = O[oi];
		dp[i] = A[i];
		ds[i] = B[i];
		chk[i] = true;
		for(int v : G[i]) if(chk[v]) uf(i, v);
	}

	cout << dp[uf(1)] + ds[uf(1)] << endl;
	return 0;
}

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int main(){
  string S; cin>>S;
  int w; cin>>w;
  for(int i=0;i<S.length();i+=w) cout<<S[i];
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;



int main(){
  int w=1,n=0;

  cin>>w>>n;
  int a_b[n][2];
  int out[n+1];//don't use out[0]
  for(int i=0;i<n;i++){
    cin>>a_b[i][0];
    cin.ignore();
    cin>>a_b[i][1];
  }
  
  for(int i=0; i<w; i++){
    int now=i+1;//I want to use out[] from 1 because now start 1
    for(int j=0; j<n; j++){
      if(a_b[j][0]==now)now = a_b[j][1];
      else if(a_b[j][1]==now)now = a_b[j][0];
     
    }
    out[now]=i+1;
  }
  for(int i=1;i<=w; i++){
    cout<<out[i]<<endl;
  }

}

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

#ifdef _DEBUG
    #include "/home/v-o_o-v/deb.h"
    #define deb(x...)cerr << "[" << #x << "] = [";_print(x);
#else
    #define deb(x...)
#endif

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int cnt[55];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> ans;
    for(int i = 1; i <= 1e5; i++){
        if(a % i == 0 && b % i == 0){
            ans.pb(i);
        }
    }
    reverse(all(ans));
    k--;
    cout << ans[k] << '\n';
    return 0;
}
// Write Here


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
     ll d,t,s;cin>>d>>t>>s;
     double f=double(d)/double(s);
     if(f<=double(t)){
     	cout<<"Yes"<<"\n";
	 }
	 else{
	 	cout<<"No"<<"\n";
	 }
     
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

const int N = 1000010;
const int MOD = 1e9 + 7;
const ll P[2] = {97, 1000003};

ll bigMod (ll a, ll e) {
  if (e == -1) e = MOD - 2;
  ll ret = 1;
  while (e) {
    if (e & 1) ret = ret * a % MOD;
    a = a * a % MOD, e >>= 1;
  }
  return ret;
}

int n, id[N], len[N];
char tmp[N]; string a[N];
map <ll, vector <int>> cnt;
ll pwr[2][N], inv[2][N], h[2][N];

inline ll get (int l, int r) {
  if (l > r) return 0;
  ll one = (h[0][r] - h[0][l - 1]) * inv[0][l] % MOD;
  ll two = (h[1][r] - h[1][l - 1]) * inv[1][l] % MOD;
  if (one < 0) one += MOD; if (two < 0) two += MOD;
  return (one << 31LL) | two;
}

int main() {
  for (int it = 0; it < 2; ++it) {
    pwr[it][0] = inv[it][0] = 1;
    ll cur = P[it], inv_cur = bigMod(cur, -1);
    for (int i = 1; i < N; ++i) {
      pwr[it][i] = pwr[it][i - 1] * cur % MOD;
      inv[it][i] = inv[it][i - 1] * inv_cur % MOD;
    }
  }
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    id[i] = i;
    scanf("%s", tmp);
    a[i] = tmp, len[i] = strlen(tmp);
  }
  sort(id + 1, id + n + 1, [] (int i, int j) {
    return len[i] < len[j];
  });
  ll ans = 0;
  for (int _i = 1; _i <= n; ++_i) {
    int i = id[_i], l = len[i];
    for (int it = 0; it < 2; ++it) {
      h[it][0] = 0;
      for (int j = 1; j <= l; ++j) {
        h[it][j] = (h[it][j - 1] + (a[i][j - 1] - 'a' + 1) * pwr[it][j]) % MOD;
      }
    }
    int prv = 1 << (a[i][0] - 'a');
    for (int j = 1; j <= l; ++j) {
      ll cur = get(j + 1, l);
      if (cnt.find(cur) != cnt.end()) { 
        vector <int> vec = cnt[cur];
        for (int k = 0; k < 26; ++k) if (prv & 1 << k) {
          ans += vec[k];
        }
      }
      if (j < l) prv |= 1 << (a[i][j] - 'a');
    }
    ll cur = get(2, l);
    if (cnt.find(cur) == cnt.end()) cnt[cur] = vector <int> (26, 0);
    ++cnt[cur][a[i][0] - 'a'];
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 93760
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main() {
  int a,p;
  cin>>a>>p;
  
  cout << (3*a+p)/2 <<endl;
  
  return 0;
}

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

using ll = long long;

int main() {
  ll N, M;

  std::cin >> N >> M;

  std::vector<ll> A(N);

  for (int i=0; i<N; i++) std::cin >> A[i];

  std::map<ll, ll, std::greater<ll>> nums;

  for (int i=0; i<M; i++) {
    ll b, c;
    std::cin >> b >> c;
    nums[c] += b;
  }

  for (int i=0; i<N; i++) nums[A[i]]++;

  ll ans = 0;

  for (auto p: nums) {
    ll b, c;
    std::tie(c, b) = p;

    if (N < b) {
      ans += N * c;
      break;
    } else {
      ans += b * c;
    }

    N -= b;
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 13568
import itertools
N, K = [int(_) for _ in input().split()]
TD = sorted([[int(_) for _ in input().split()] for _ in range(N)],
            key=lambda x: -x[1])
neta = set()
dupl = []
ans = [0]
for t, d in TD[:K]:
    ans[0] += d
    if t in neta:
        dupl += [d]
    else:
        neta.add(t)
x = len(neta)
ans[0] += x**2
for t, d in TD[K:]:
    if not t in neta and dupl:
        neta.add(t)
        ans += [ans[-1] - x**2 + (x + 1)**2 - dupl.pop() + d]
        x += 1
print(max(ans))


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()
{

    ll n;
    cin >> n;
    vector<ll> v;
    ll s1=0,s2=0;
    for(ll i  =0; i < n; i++)
    {

        ll x;
        cin >> x;
        v.pb(x);
    }
    sort(all(v));
    reverse(all(v));
    for(ll i=  0; i < n; i+=2)
    {

        s1+=v[i];
    }
    for(ll i = 1; i < n; i+=2) s2+=v[i];
    cout << s1-s2;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int K,N,L;
string S;

struct SuffixArray {
	int N; vector<int> rank,lcp,sa,rsa; string S;
	
	void init(string S_){
		S=S_;
		int i,h=0; vector<int> tmp;
		N=S.size(); rank.resize(N+1); sa.resize(N+1); tmp.resize(N+1);
		FOR(i,N+1) sa[i]=i, rank[i]=i==N?-1:S[i];
		
		for(int k=1; k<=N; k<<=1) {
			auto pred2 = [k,this](int& a,int &b)->bool{ return (((a+k<=N)?rank[a+k]:-1)<((b+k<=N)?rank[b+k]:-1));};
			auto pred = [pred2,k,this](int& a,int &b)->bool{ return (rank[a]!=rank[b])?(rank[a]<rank[b]):pred2(a,b);};
			int x=0;
			if(k!=1) for(i=1;i<N+1;i++) if(rank[sa[i]]!=rank[sa[x]]) sort(sa.begin()+x,sa.begin()+i,pred2), x=i;
			sort(sa.begin()+x,sa.end(),pred);
			FOR(i,N+1) tmp[sa[i]]=(i==0)?0:tmp[sa[i-1]]+pred(sa[i-1],sa[i]);
			swap(rank,tmp);
		}
		lcp.resize(N+1); rsa.resize(N+1);
		FOR(i,N+1) rsa[sa[i]]=i;
		FOR(i,N) {
			int j=sa[rsa[i]-1];
			for(h=max(h-1,0);i+h<N && j+h<N; h++) if(S[j+h]!=S[i+h]) break;
			lcp[rsa[i]-1]=h;
		}
	}
};
SuffixArray sa;

int ok(int v) {
	int take=N%(K+1);
	int cur=0;
	
	while(cur<N && take) {
		if(cur+L+1>N) return 0;
		
		if(sa.rsa[cur]<=sa.rsa[v]) {
			cur+=L+1;
			take--;
		}
		else {
			cur+=L;
		}
	}
	
	return take==0;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K>>S;
	N=S.size();
	sa.init(S);
	
	L=N/(K+1);
	if(N%(K+1)==0) {
		string R="";
		FOR(i,K+1) R=max(R,S.substr(i*L,L));
		cout<<R<<endl;
		return;
	}
	vector<int> cand;
	FOR(i,N+1) if(sa.sa[i]+L+1<=N) cand.push_back(sa.sa[i]);
	
	int L2=-1,R2=cand.size()-1;
	
	while(R2-L2>=2) {
		int M=(L2+R2)/2;
		if(ok(cand[M])) R2=M;
		else L2=M;
	}
	cout<<S.substr(cand[R2],L+1)<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 2888
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

int main() {
  int A, B, T;
  cin >> A >> B >> T;
  cout << T / A * B << endl;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] x = new int[N];
        int[] y = new int[N];
        int[] h = new int[N];
        boolean existionOfZero = false;
        for (int i = 0; i < N; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            h[i] = sc.nextInt();
            if (h[i] == 0) {
                existionOfZero = true;
            }
        }
        int Cx = -1;
        int Cy = -1;
        int H = -1;
        if (existionOfZero) {
            loop: for (int i = 0; i <= 100; i++) {
                for (int j = 0; j <= 100; j++) {
                    for (int j2 = 1; j2 <= 200; j2++) {
                        boolean ok = true;
                        for (int k = 0; k < N; k++) {
                            int m = j2 - Math.abs(x[k] - i) - Math.abs(y[k] - j);
                            if (h[k] == 0) {
                                if (m > 0) {
                                    ok = false;
                                }
                            } else {
                                if (m != h[k]) {
                                    ok = false;
                                }
                            }
                        }
                        if (ok) {
                            Cx = i;
                            Cy = j;
                            H = j2;
                            break loop;
                        }
                    }
                }
            }
        } else {
            loop: for (int i = 0; i <= 100; i++) {
                for (int j = 0; j <= 100; j++) {
                    Set<Integer> set = new HashSet<>();
                    for (int j2 = 0; j2 < N; j2++) {
                        int preH = Math.abs(x[j2] - i) + Math.abs(y[j2] - j) + h[j2];
                        set.add(preH);
                    }
                    if (set.size() == 1) {
                        Cx = i;
                        Cy = j;
                        for (int integer : set) {
                            H = integer;
                        }
                        break loop;
                    }
                }
            }
        }
        System.out.println(Cx + " " + Cy + " " + H);
        sc.close();
    }
}

Measured memory_bytes: 41512
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;++i){
        if(i != 0){
            cout<<' ';
        }
        cin>>a[i];
        cout<<a[i];
    }
    cout<<endl;

    for(ll i=1;i<n;++i){
        ll j = i - 1;
        while(j >= 0 and a[j] > a[j+1]){
            swap(a[j], a[j+1]);
            j--;
        }

        for(ll k=0;k<n;++k){
            if(k != 0){
                cout<<' ';
            }
            cout<<a[k];
        }
        cout<<endl;
    }

    return 0;
}


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

int main(){
  int i,j,cnt=0;
  ll q,h,s,d,n;
  cin>>q>>h>>s>>d;
  cin>>n;
  ll a[7];
  for(i=0;i<7;i++)a[i]=LLONG_MAX;
  a[0]=4*q*n;
  a[1]=2*h*n;
  a[2]=s*n;
  if(n%2==0)a[3]=(n/2)*d;
  else{
    a[3]=LLONG_MAX;
    a[4]=(n/2)*d+s;
    a[5]=(n/2)*d+2*h;
    a[6]=(n/2)*d+4*q;
  }
  ll mi=LLONG_MAX;
  for(i=0;i<7;i++)mi=min(mi,a[i]);
  cout<<mi;
}

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

int main()
{
  char c[7];
  scanf("%s",c);
  
  int len = strlen(c);
  scanf("%s",c+len);

  int x = atoi(c);

  for(int i=0; i<330; i++){
    if(i*i == x){
      printf("Yes");
      return 0;
    }
  }
  printf("No");
  return 0;

}



Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



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

	vector< pair<int,int> >red(n);
	vector< pair<int, int> >blue(n);
	//どの赤がマッチング済みか
	vector<int> fl(n, 0);
	rep(i, 0, n) {
		int a, b;
		cin >> a >> b;
		red[i] = { a,b };
	}
	rep(i, 0, n) {
		int a, b;
		cin >> a >> b;
		blue[i] = { a,b };
	}

	sort(blue.begin(), blue.end());
	int ans = 0;
	rep(i, 0, n) {
		vector< pair<int, int> > v;
		rep(j,0,n){
			if (blue[i].first > red[j].first && blue[i].second > red[j].second && fl[j]!= 1) {
				v.push_back({red[j].second,j});
			}
		}
		if (v.size() > 0) {
			sort(v.begin(), v.end());
			reverse(v.begin(), v.end());
			fl[v[0].second] = 1;
			ans++;
		}
	}

	cout << ans << endl;



	return 0;

}


Measured memory_bytes: 256
n,t=map(int,input().split())
t1=list(map(int,input().split()))
ans=0
for i in range(1,n):
    if t1[i]-t1[max(i-1,0)]<=t:
        ans+=t1[i]-t1[max(i-1,0)]
    else:
        ans+=t
print(ans+t)




Measured memory_bytes: 26708
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var I = G;
		int A = I[0], B = I[1];
		var P = G;
		var c = new int[3];
		foreach (var p in P) if (p <= A) c[0]++; else if (p <= B) c[1]++; else c[2]++;
		WriteLine(c.Min());
	}
}


Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<iomanip>
#include<algorithm>

using namespace std;

int main(){

    int a,b,ans=0,x=200001;
    cin >> a;
    
    for(int i=0;i<a;i++){
        cin>>b;
        if(b<x){ans+=1;}
        x=min(b,x);
    }
    

    cout << ans << endl;

}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;
ll INF = 1e12+10;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
vector<pair<ll, ll> > pairs;
#define print1(x) cerr << "x = " << x << endl;
#define print2(x, y) cerr<< "x,y = "  << x << "," << y << endl;
#define print3(x, y, z) cerr << "x,y,z = " << x << "," << y << "," << z << endl;
#define print4(x, y, z, w) cerr << "x,y,z,w = " << x << "," << y << "," << z << "," << w << endl;

ll A[400000];
ll cnt[64];

ll mod = ll(1e9 + 7);

int main()
{
    ll N, M, V, P, sum = 0;
    cin >> N >> M >> V >> P;
    vector<ll> A(N);
    rep(i, N)cin >> A[i];
    
    sort(A.begin(),A.end(),greater<ll>());
    //for (int i = 0; i < N; i++){
    //    cout << A[i] << endl;
    //}
    ll ans = P;
    
    for (int i = P - 1; i < N; i++){
        sum += A[i];
    }
    for (int i = N - 1; i >= P /*P*/; i--){
        //if (A[i] + M >= A[P - 1]){
        //    fprintf(stderr, "i = %d, sum = %d, %d * %d - %d >= %d * %d\n",
        //        i, sum, A[i] + M, N - P + 1, sum, V - P + 1,  M);
        //}
        if (A[i] + M >= A[P - 1] && 
            (A[i] + M) * ( N - P + 1) - (sum + A[i] * (N - 1 - i))>= (V - P + 1) * M){
            //sum >= (N - P + 1) * A[i] + (N - V) * M){
            ans++;
        }
        sum -= A[i];
        
    }
    cout << ans;       
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
		int N;
		cin >> N;
		int x[N], y[N], h[N];
		for (int i = 0; i < N; i++) {
				cin >> x[i] >> y[i] >> h[i];
		}

		for (int posY = 0; posY <= 100; posY++) {
				for (int posX = 0; posX <= 100; posX++) {
						int needH = -1;
						for (int i = 0; i < N; i++) {
								if (h[i] > 0) {
										int t = abs(x[i] - posX) + abs(y[i] - posY) + h[i];
										if (needH == -1) {
												needH = t;
										} else {
												if (t != needH) {
														needH = -2;
														break;
												}
										}
								}
						}

						if (needH == -2) continue;

						for (int i = 0; i < N; i++) {
								if (h[i] == 0) {
										int dist = abs(x[i] - posX) + abs(y[i] - posY);
										if (dist < needH) needH = -2;
								}
						}

						if (needH == -2) continue;
						cout << posX << " " << posY << " " << needH << endl;
				}
		}

		return 0;
}


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

		int N = sc.nextInt();
		long[] A = new long[N];
		long ans = 1;
		long LL = 1000000000000000000L;
		for( int i=0; i<N; i++ ){
			A[i] = sc.nextLong();
		}
		Arrays.sort(A);
		for( int i=0; i<N; i++ ){
			if( A[i]==0 || ans==0 ){
				System.out.println(0);
				break;
			}else if( ans>LL/A[i] ){
				System.out.println(-1);
				break;
			}else{
				ans = ans * A[i];
			}
			if( i==N-1 ){
				System.out.println(ans);
			}
		}
	}
}

Measured memory_bytes: 61652
fun solve(S: String, T: String, A: Int, B: Int, U: String) {
    var a = A
    var b = B
    if(S == U){
        a -= 1
    } else {
        b -= 1
    }
    println("%d %d".format(a, b))
}

fun main() {
//    val S = readLine()!!
//    val N = readLine()!!.toInt()
    val (S, T) = readLine()!!.split(" ")
    val (A, B) = readLine()!!.split(" ").map { it.toInt() }
    val U = readLine()!!
//    val A = readLine()!!.split(" ").map { it.toInt() }
    solve(S, T, A, B, U)
}

Measured memory_bytes: 37504
/**
 * C - Coloring Colorfully
 * https://atcoder.jp/contests/abc124/tasks/abc124_c
 **/
#include<iostream>
#include<algorithm>
#include<string.h>

using namespace std;

int main() {
    string S;
    cin >> S;
    int p1 = 0, p2 = 0;

    for(int i=0; i<S.length(); i++) {
        if(i%2==0) {
            if(S[i] != '0') {
                p1 += 1;
            } else {
                p2 += 1;
            }
        } else {
            if(S[i] != '1') {
                p1 += 1;
            } else {
                p2 += 1;
            }
        }
    }
    cout << min(p1, p2) <<endl;
}

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author dauom
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    ACalc solver = new ACalc();
    solver.solve(1, in, out);
    out.close();
  }

  static class ACalc {
    public final void solve(int testNumber, InputReader in, PrintWriter out) {
      int a = in.nextInt();
      out.println(a + a * a + a * a * a);
    }
  }

  static final class InputReader {
    private final InputStream stream;
    private final byte[] buf = new byte[1 << 16];
    private int curChar;
    private int numChars;

    public InputReader() {
      this.stream = System.in;
    }

    public InputReader(final InputStream stream) {
      this.stream = stream;
    }

    private final int read() {
      if (this.numChars == -1) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return -1;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public final int nextInt() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {}

      byte sgn = 1;
      if (c == 45) { // 45 == '-'
        sgn = -1;
        c = this.read();
      }

      int res = 0;

      while (c >= 48 && c <= 57) { // 48 == '0', 57 == '9'
        res *= 10;
        res += c - 48; // 48 == '0'
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }

      throw new InputMismatchException();
    }

    private static final boolean isSpaceChar(final int c) {
      return c == 32 || c == 10 || c == 13 || c == 9
          || c == -1; // 32 == ' ', 10 == '\n', 13 == '\r', 9 == '\t'
    }
  }
}


Measured memory_bytes: 32496
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ


		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int a1 = sc.nextInt();
		int a2 = sc.nextInt();

		if(a+a1+a2 >= 22) {
			System.out.println("bust");
		}
		else {
			System.out.println("win");
		}
		sc.close();
	}

}


Measured memory_bytes: 35712
//B
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int main() {
    reg int n = read();
    for (reg int i = 1; i <= 9; i++) {
        for (reg int j = 1; j <= 9; j++) {
            if (i * j == n) { puts("Yes"); return 0;}
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long
#define mod 1000000007;


int main() {
	string s;
	cin >> s;
	bool f = true;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0 && s[i] == 'L') f = false;
		else if (i % 2 == 1 && s[i] == 'R')f = false;
	}
	if (f)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_c>
問題文============================================================
 りんごさんは N 頂点 の連結な無向グラフを持っています。
 このグラフにはすでに M 本の辺があり、i 本目の辺は頂点 Ai と頂点 Bi を繋いでいます。
 
 りんごさんは以下の操作を行うことで、辺を追加しようと思っています。
 
 操作：頂点 u から辺をちょうど 3 本辿ることによって頂点 v に辿り着けるような u,v(u≠v) をとり、
 頂点 u と頂点 v の間に辺を追加する。
 ただし、すでに頂点 u と頂点 v の間に辺が存在する場合は辺を追加することはできない。
 りんごさんが追加できる辺の本数の最大値を求めて下さい。

=================================================================

解説=============================================================

 与えられたグラフで二部グラフを作ることができれば
     完全二部グラフになる
 作ることができなければ
     完全グラフになる
================================================================
*/
ll N,M;
vector<vector<ll>> G;
vector<int> checked; // 1 : l / 2 : r
set<ll> l,r;

bool check(ll n,bool f){
    if(f){
        if(checked[n] == 1) return false;
        if(checked[n] == 2) return true;
        checked[n] = 1;
        for(auto &v:G[n]){
            if(check(v,false)) return true;
            l.insert(v);
        }
    }else{
        if(checked[n] == 2) return false;
        if(checked[n] == 1) return true;
        checked[n] = 2;
        for(auto &v:G[n]){
            if(check(v,true)) return true;
            r.insert(v);
        }
    }
    return false;
}

ll solve(){
    ll ret = 0;
    cin >> N >> M;
    G.resize(N); checked.resize(N);
    for(int i = 0; i < M;i++){
        ll A,B; cin >> A >> B; A--; B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    bool f = check(0,true);
    if(f) ret =  (N*(N-1)/2) - M;
    else ret = l.size()*r.size() - M;
    return ret;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;

int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    int cnt=0;
    f1(i,n){
        int a;
        cin >> a;
        if(a!=i) cnt++;
    }
    if(cnt==2 || cnt==0) cout <<"YES"<< endl;
    else cout << "NO" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> a(2 * n - 1, 0);
    if (n == 2)
    {
        if (x == 2)
        {
            cout << "Yes" << endl;
            cout << "1 2 3" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
        return 0;
    }
    if (x == 1 || x == 2 * n - 1)
    {
        cout << "No" << endl;
        return 0;
    }
    if (x == 2 || x == 2 * n - 2)
    {
        cout << "Yes" << endl;
        if (x == 2 * n - 2)
        {
            a[n - 1] = x;
            a[n - 2] = x - 1;
            a[n - 3] = x - 2;
            a[n] = x + 1;
            a[n + 1] = x - 3;
            int k = 1;
            for (int i = 0; i < a.size(); i++)
            {
                if (a[i] == 0)
                {
                    a[i] = k;
                    k++;
                }
            }
        }
        if (x == 2)
        {
            a[n - 1] = 2;
            a[n - 2] = 1;
            a[n - 3] = 5;
            a[n] = 4;
            a[n + 1] = 3;
            int k = 6;
            for (int i = 0; i < a.size(); i++)
            {
                if (a[i] == 0)
                {
                    a[i] = k;
                    k++;
                }
            }
        }
        for (auto e : a)
        {
            cout << e << endl;
        }
        return 0;
    }
    cout << "Yes" << endl;
    a[n - 1] = x;
    a[n - 2] = x - 1;
    a[n] = x + 1;
    a[n + 1] = x - 2;
    int k = 1;
    if (x == 3)
    {
        k = 5;
    }
    for (int i = 0; i < a.size(); i++)
    {
        if (a[i] == 0)
        {
            a[i] = k;
            k++;
            if (k == x - 2)
            {
                k = x + 2;
            }
        }
    }
    for (auto e : a)
    {
        cout << e << endl;
    }
}


Measured memory_bytes: 2304
def examC():
    n,m,d = LI()
    ans = float(1/n)*(m-1)
    if d>0:
        ans += float(1/n)*((n-d*2)/n)*(m-1)
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


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

main(){
    int a,b;
    cin>>a>>b;
    if(a>b){
        cout<<"a > b"<<endl;
    }else if(a==b){
        cout<<"a == b"<<endl;
    }else if(a<b){
        cout<<"a < b"<<endl;
    }
}


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

int main() {
int N,D;
  cin>>N>>D;  
  vector<vector<int>> vec(N,vector<int>(D));
 for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin>> vec.at(i).at(j);
    }    
  }
int counter=0;

for(int A=0;A<N;A++){
  for(int B=0;B<N;B++){if(A<B){
   int sum=0;
    
    for(int j=0;j<D;j++){
   sum+=(vec.at(A).at(j)-vec.at(B).at(j))*(vec.at(A).at(j)-vec.at(B).at(j));
    }
 
      if(ceil(sqrt(sum))==floor(sqrt(sum))){
        counter++;}
      
  }}}
    
      

  cout << counter<<endl;
}


Measured memory_bytes: 256
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    vector<ll> sss; sss.reserve(n * (n+1) / 2);
    REP(i, n) {
        ll ss = 0;
        RANGE(j, i, n-1) {
            sss.push_back(ss += a[j]);
        }
    }
    
    ll ans = 0;
    DSRNG(i, 40, 0) {
        ll bnum = 0;
        for (auto &sssi : sss) {
            if (sssi & (1LL << i)) {
                ++bnum;
            }
        }
        if (bnum >= k) {
            ans |= 1LL << i;
            sss.erase(remove_if(ALL_OF(sss), [&](ll &x) { return !(x & (1LL << i)); }), sss.end());
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 4224
// Lucas number
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
using namespace std;
using ll = long long;
using P = pair<int,int>;

ll Lucas_number(int x){//計算できるけど再帰だと遅い．．
    if(x==0) return 2;
    if(x==1) return 1;
    return Lucas_number(x-1) + Lucas_number(x-2); 
}

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

    ll ans=0;
    ll l_0=0,l_1=0;
    for(int i=0; i<=n; ++i){
        if(i==0) l_0 = 2;
        else if(i==1){
            l_1 = 1;
        }
        else{
            ll dummy = l_1;
            l_1 = l_0 + l_1;
            l_0 = dummy;
        }
    }
    ans = l_1;
    cout<<fixed<<setprecision(19);
    cout(ans);
    
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"

	"sort"
	"strconv"
)

func solve(in io.Reader, out io.Writer) error {
	sc := bufio.NewScanner(in)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}

	sort.Ints(a)

	nearJ := 0
	nearD := a[n-1] / 2
	for j := n - 1 - 1; j >= 0; j-- {
		d := abs(a[n-1]/2 - a[j])
		if nearD > d {
			nearJ = j
			nearD = d
		}
	}

	fmt.Fprintf(out, "%d %d\n", a[n-1], a[nearJ])

	return nil
}

func abs(a int) int {
	if a < 0 {
		return -a
	}

	return a
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	err := solve(os.Stdin, os.Stdout)
	if err != nil {
		log.Fatal(err)
	}
}


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

const ll MAX = 10000000;  // TLEならば小さくする
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {

	ll x, y; cin >> x >> y;
	if ((x + y) % 3 != 0) {
		cout << 0 << endl;
		return 0;
	}
    ll  m = (2 * x - y) / 3;
    ll n = (-x + 2 * y) / 3;
    COMinit(); // 前処理
    cout << COM(m + n, m) << endl;
}

Measured memory_bytes: 237972