akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから

void solve(){
  int n;
  cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  vector<ll>sum(n+1),rsum(n+1);
  rep(i,n){
    sum[i+1]=gcd(sum[i],a[i]);
  }
  //rep(i,n+1)cerr<<sum[i]<<endl;
  rep(i,n){
    rsum[i+1]=gcd(rsum[i],a[n-1-i]);
  }
  //rep(i,n+1)cerr<<rsum[n-1-i]<<endl;
  ll ans=0;
  rep(i,n){
    chmax(ans,gcd(sum[i],rsum[n-i-1]));
  }
  cout<<ans;
}

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


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s;
    cin >> s;
    int cnt = 1;
    for (int i = 1; i < sz(s); ++i) {
        if (s[i-1] != s[i]) cnt++;
    }
    cout << cnt - 1 << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<utility>
#include<cstring>
using namespace std;
typedef pair < int , int > pii;
template < typename T > T MAX(T a,T b){
	return a<b?b:a;
}
template < typename T > T MIN(T a,T b){
	return a<b?a:b;
}
template < typename T > T ABS(T a){
	return a>0?a:-a;
}
int n,arr[100005],t;
pii premin[100005],sufmax[100005],fst,scd;
int main(){
	scanf("%d%d",&n,&t);
	int xb,x2;
	for(xb=0;xb<n;xb++) scanf("%d",arr+xb);
	fst=scd=make_pair(-1,-1);
	for(xb=0;xb<n;xb++){
		premin[xb]=make_pair(arr[xb],xb);
		if(xb) premin[xb]=MIN(premin[xb],premin[xb-1]);
	}
	for(xb=n-1;xb>=0;xb--){
		sufmax[xb]=make_pair(arr[xb],xb);
		if(xb<n-1) sufmax[xb]=MAX(sufmax[xb],sufmax[xb+1]);
	}
	for(xb=0;xb<n-1;xb++){
		if(sufmax[xb+1].first-premin[xb].first>scd.first-fst.first){
			fst=premin[xb];
			scd=sufmax[xb+1];
		}
	}
	int cv=scd.first-fst.first,cnt=0;
	for(xb=0;xb<n-1;xb++){
		if(sufmax[xb+1].first-arr[xb]==cv){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}


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

using namespace std;

// n の k 乗を mod で割った余りを計算
long long power_mod(long long n, long long k, long long mod) {
    long long result = 1;
    // k を右シフトしつつ n を 2 乗していく
    while (k > 0) {
        // k の最下ビットが 1 なら、今の n を答えに掛ける
        if ((k & 1) == 1) result = (result * n) % mod;
        n = n * n % mod;
        k >>= 1;
    }
    return result;
}

// 階乗・組み合わせの mod 逆数
class FactorialMod {
    // 逆元を計算
    void calc_inverse() {
        inverse[0] = 0;
        inverse[1] = 1;
        for (int i = 2; i <= max_num; i++) {
            inverse[i] = mod - ((mod / i) * inverse[mod % i] % mod);
        }
    }

    // i! を mod で割った余りと逆元を計算
    void calc_factorial_inverse() {
        factorial[0] = factorial_inverse[0] = 1;
        for (int i = 1; i <= max_num; i++) {
            factorial[i] = (factorial[i - 1] * i) % mod;
            factorial_inverse[i] = (factorial_inverse[i - 1] * inverse[i]) % mod;
        }
    }

  public:
    int max_num;                         // 扱う最大の値
    int mod;                             // mod の法（素数）
    vector<long long> inverse;           // 逆元
    vector<long long> factorial;         // 階乗
    vector<long long> factorial_inverse; // 階乗の逆元

    FactorialMod(int _max_num, int _mod) {
        max_num = _max_num;
        mod = _mod;
        inverse = vector<long long>(max_num + 1);
        factorial = vector<long long>(max_num + 1);
        factorial_inverse = vector<long long>(max_num + 1);
        calc_inverse();
        calc_factorial_inverse();
    }

    // nCk を mod で割った余りを計算
    long long combination_mod(int n, int k) {
        return (((factorial[n] * factorial_inverse[k]) % mod) * factorial_inverse[n - k]) % mod;
    }

    // nHk を mod で割った余りを計算
    long long multi_choose_mod(int n, int k) {
        return combination_mod(n + k - 1, k);
    }
};

const int MOD = 1000000007;

int main(void) {
    int n, k;
    cin >> n >> k;
    FactorialMod factorial_mod(1000, MOD);
    if (k < n) {
        cout << 0 << endl;
    } else {
        cout << factorial_mod.factorial[k] * factorial_mod.factorial_inverse[k - n] % MOD << endl;
    }
    return 0;
}


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

using namespace std;

bool op(int *b,int m,int x){
    for(int i=1;i<m;i++){
        if(b[i]<x){
            return false;
        }
    }
    return true;
}

int skill(int arr[15][15],int i,int *barr,int m,int n,int x){
    if(op(barr,m+1,x)){
        return 0;
    }
    if(i==n){
        return 100000000;
    }
    int a=skill(arr,i+1,barr,m,n,x);
    int carr[m+1]={0};
    
    for(int c=1;c<=m;c++){
        carr[c]=barr[c];
        carr[c]+=arr[i][c];
    }
    int b=arr[i][0]+skill(arr,i+1,carr,m,n,x);
    return min(a,b);
}

int main(){
    int n,m,x;
    cin>>n>>m>>x;
    int arr[15][15]={0};
    int barr[m+1]={0};
    for(int i=0;i<n;i++){
        for(int j=0;j<=m;j++){
            cin>>arr[i][j];
        }
    }
    int darr[m+1]={0};
    for(int i=0;i<n;i++){
        for(int j=1;j<=m;j++){
            darr[j]+=arr[i][j];
        }
    }
    if(op(darr,m+1,x)){
    cout<<skill(arr,0,barr,m,n,x);}else{
        cout<<"-1";
    }
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,m,n) for(int i=m;i<n;i++)
#define endre getchar(); getchar();return 0;
int a[200010];
signed main() {
	int n,m,ans=0;
	cin >> n>>m;
	rep(i, n) {
		cin >> a[i];
	}
	loop(i, 1, n) {
		if (a[i] - a[i - 1] < m)ans += a[i] - a[i - 1];
		else { ans += m; }
	}
	cout << ans+m << endl;
}

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


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



int main() {

    string s; cin >> s;
    stack<char> amari;
    char prev = 'n';
    int ans = 0;
    rep(i, s.size()) {
        if(prev == 'n') {
            prev = s[i];
            continue;
        }
        if(prev != s[i]) {
            ans += 2;
            prev = 'n';
        } else {
            if(!amari.empty() && amari.top() != prev) {
                ans += 2;
                prev = s[i];
                amari.pop();
            } else {
                amari.push(prev);
                prev = s[i];
            }
        }
    }

    if(!amari.empty() && prev != 'n') {
        if(prev != amari.top()) ans+=2;
    }



    cout << ans << endl;

    return 0;

}

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

void main_()
{
    int N;
    cin >> N;
    vector<string> Ws;
    copy_n(istream_iterator<string>(cin), N, back_inserter(Ws));
    vector<bool> cs;
    transform(
        begin(Ws), end(Ws) - 1, begin(Ws) + 1, back_inserter(cs),
        [](auto&& s1, auto&& s2) { return s1.back() == s2.front(); });
    sort(begin(Ws), end(Ws));
    if (unique(begin(Ws), end(Ws)) == end(Ws)
        && all_of(begin(cs), end(cs), [](int c) { return c; })) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

string s;

int main(){
    migmig

    cin >> s;
    for(int i = 0 ; i < s.size() ; i ++){
		if(s[i] == '?')s[i] = 'D';	
	}
	cout << s;
    
    
    return(0);
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> bool chmax(T &a, const T& b) {if (a < b) {a = b;return true;}return false; }
template <typename T> bool chmin(T &a, const T& b) { if (a > b) {a = b;return true;}return false; }

struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(0);
      cout << fixed << setprecision(17);
      cerr << fixed << setprecision(17);
    }
} IoSetup;
int winning(char c) {
  if (c == 'r') return 2;
  if (c == 's') return 0;
  return 1;
}

int main() {
  int n, k;
  cin >> n >> k;
  int r, s, p;
  cin >> r >> s >> p;
  string t;
  cin >> t;
  vector<int> score = {r, s, p};
  vector<char> judge = {'r', 's', 'p'};
  int sum = 0;
  vector<char> action(n, 'z');
  for (int i = 0; i < n; ++i) {
    if (i < k) {
      int c = winning((char)t[i]);
      action[i] = judge[c];
      sum += score[c];
    } else {
      int c = winning((char)t[i]);
      if (action[i-k] != judge[c]) {
        action[i] = judge[c];
        sum += score[c];
      }
    }
  }
  
  cout << sum << '\n';
}
















Measured memory_bytes: 512
#a,bの最大公約数
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

#a,bの最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

N = int(input())
A = list(map(int,input().split()))

l = A[0]
for i in range(1,N):
    l = lcm(l,A[i])

P = 10**9+7
ans = 0
for i in range(N):
    ans += l//A[i]
print(ans%P)


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef vector<vector<int>> Graph;

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

    string s;
    cin >> s;
    map<char, int> mp;
    for (auto c : s) {
        mp[c]++;
    }

    for (auto p : mp) {
        if (p.second & 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>

#define MAX_M 100010
#define MOD 1000000007

struct Matrix{
	int a[3][3];
	Matrix(){
		memset(a, 0, sizeof(a));
	}
	inline int *operator [](int x){
		return a[x];
	}
}m0, m1;

Matrix operator *(Matrix x, Matrix y){
	Matrix z;
	for(int i = 0; i < 3; i++)
		for(int j = 0; j < 3; j++)
			for(int k = 0; k < 3; k++)
				z[i][j] = (z[i][j] + 1ll * x[i][k] * y[k][j] % MOD) % MOD;
	return z;
}

Matrix operator *=(Matrix &x, Matrix y){
	return (x = x * y);
}

Matrix ksm(Matrix x, int y){
	Matrix z;
	z[0][0] = z[1][1] = z[2][2] = 1;
	for(; y; y >>= 1, x *= x)
		if(y&1) z *= x;
	return z;
}

int N, M, x[MAX_M];

int main(){
	m0[0][0] = m0[0][2] = m0[1][1] = m0[1][2] = m0[2][0] = m1[0][0] = m1[0][2] = m1[1][1] = m1[1][2] = m1[2][2] = 1;
	m0[0][1] = m0[2][1] = m0[2][2] = m1[0][1] = 2;
	scanf("%d%d", &N, &M);
	for(int i = 1; i <= M; i++)
		scanf("%d", &x[i]);
	Matrix ans = m1;
	for(int i = 1; i <= M; i++)
		ans *= ksm(m0, x[i]-x[i-1]-1) * m1;
	ans *= ksm(m0, N-x[M]-1);
	printf("%d\n", ans[0][2]);
	return 0;
}

Measured memory_bytes: 640
//by ciwomuli
//AK JSOI 2019
//I love wyt
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <sstream>
#define LL long long
using namespace std;
template <typename T>
inline void read(T &t)
{
    int f = 0, c = getchar();
    t = 0;
    while (!isdigit(c))
        f |= c == '-', c = getchar();
    while (isdigit(c))
        t = t * 10 + c - 48, c = getchar();
    if (f)
        t = -t;
}
template <typename T, typename... Args>
inline void read(T &t, Args &... args)
{
    read(t);
    read(args...);
}
int n;
char str[105];
int main(){
    read(n);
    if(n % 2 == 1){
        puts("No");
        return 0;
    }
    scanf("%s",str);
    bool a = true;
    for (int i = 0; i < n / 2;i++){
        if(str[i] != str[n/2 + i])
            a = false;
    }
    if(a)
        puts("Yes");
        else
            puts("No");
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,i,j,k;
  string s,t;
  cin >> s >> t;
  n=s.size();
  for(i=0;i<n;i++){
    for(k=i,j=0;j<n;j++,k++){
      if(k>=n) k-=n;
      if(s[j]!=t[k]) break;
    }
    if(j==n){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = str(input())
a = 0
c = len(s)//2
if n % 2 == 0:
  for i in range(c):
    if s[i] == s[c+i]:
      a += 1
  if a == n/2 :
    print("Yes")
  else :
    print("No")
else :
  print("No")

Measured memory_bytes: 9084
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    a, b, c, k = MII()
    if k <= a:
        print(k)
    elif k <= a+b:
        print(a)
    elif k <= a+b+c:
        print(a-(k-(a+b)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9440
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
typedef vector<int> vi;

int hit(vi a,vi b){
  int res = 0;
  rep(i,4) if(a[i] == b[i]) res++;
  return res;
}

int blow(vi a,vi b){
  int res = 0;
  rep(i,4) rep(j,4) if(i != j && a[i] == b[j]){
    res++;
    break;
  }
  return res;
}

int main(){
  vi a(4),b(4);
  while(1){
    rep(i,4) if(!(cin>>a[i])) return 0;
    rep(i,4) cin>>b[i];
    cout<<hit(a,b)<<" "<<blow(a,b)<<endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	for (int i = 0; i < S.length() - 1; i++) {
		if (S[i] == 'A' && S[i+1] == 'C') {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

}






Measured memory_bytes: 3628
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    def calcSumOfDigit(x):
        str_x = str(x)
        acc = 0
        for s in str_x:
            acc += int(s)
            acc %= 9
        return acc
    
    print("Yes" if calcSumOfDigit(N)==0 else "No")
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 9260
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] dice = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int q = int.Parse(Console.ReadLine());
            List<int[]> que = new List<int[]>();
            int[] ans = new int[q];

            for (int i = 0; i < q; i++)
            {
                int[] num = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                int dir = 0;
                for (int j = 0; j < 6; j++)
                {
                    if (num[0] == dice[j]) dir = j;
                }

                int d = dice[5-dir];
                dice[5 - dir] = dice[0];
                dice[0] = dice[dir];
                dice[dir] = dice[5];
                dice[5] = d;
                 
                if (dir == 5)
                {
                   int d2 = dice[2];
                   dice[2] = dice[3];
                   dice[3] = d2;
                }

                int[] side = { dice[1], dice[2], dice[4], dice[3], dice[1] };

                for (int j = 0; j < 4; j++)
                {
                    if (side[j] == num[1])  ans[i] = side[j + 1]; 
                }
            }
            
            foreach(int item in ans)
                Console.WriteLine(item);

        }
    }
}


Measured memory_bytes: 16328
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int n,a[100005],ans,i,k;
int main()
{
	cin>>n>>k;
	ans=1<<30;
	for(i=1;i<=n;++i) cin>>a[i];
	sort(a+1,a+n+1);
	for(i=1;i<=n-k+1;++i)
	{
		ans=min(ans,a[i+k-1]-a[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
time = [int(input()) for _ in range(5)]

from itertools import permutations
ans = 643

def kiriage(i):
    if i % 10 == 0:
        return i
    else:
        juu = i // 10
        return (juu + 1) * 10

for *ts, t5 in permutations(time, 5):
    time_took = 0
    for t in ts:
        time_took += kiriage(t)
    time_took += t5
    ans = min(ans, time_took)

print(ans)

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

using namespace std;
int main(){
  double i, n, k, ans = 0, prob;
  cin >> n >> k;
  for(i = 1;i < n + 1;i++){
    if(i < k){
      prob = log2((long double)k / i);
    }
    else{
      prob = 0;
    }
    if(prob != (int)prob){
      prob += 1;
    }
    ans += pow(0.5, (int)prob) / n;
    if((int)i % 20000 == 0){
    }
  }
  cout <<std::setprecision(10)<< ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>
using namespace std;
#define int long long
#define veb vector<bool>
#define vveb vector<veb>
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
void sor(vel &v) { sort(v.begin(), v.end()); }
void rev(vel &v) { reverse(v.begin(), v.end()); }
int zero(void) { return 0; }
signed main() {
	int n;
	cin >> n;
	vector<string> w(n);
	for (int i = 0; i < n; i++) { cin >> w[i]; }
	bool fr = true;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (w[i] == w[j]) { fr = false; }
		}
	}
	for (int i = 1; i < n; i++) {
		if (w[i][0] != w[i - 1][w[i - 1].size() - 1]) {
			fr = false;
		}
	}
	if (fr) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}

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

using namespace std;

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  int count_5 = 0;
  int count_7 = 0;
  for( int i = 0; i < 3; i++ ) {
    if( a[i] == 5 )
      count_5++;
    else if( a[i] == 7 )
      count_7++;
  }
  if( count_5 == 2 && count_7 == 1 )
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;


int main() {
	while (true) {
		char InputStr[201];
		char OutputStr[201];
		int h[101];
		int m;
		int Shuffle = 0;
		int StrNum = 0;

		cin >> InputStr;
		if (InputStr[0] == '-')break;
		while (InputStr[StrNum] != '\0')StrNum++;

		cin >> m;
		
		for (int i = 0; i < m; i++) {
			cin >> h[i];
			Shuffle += h[i];
		}
		Shuffle %= StrNum;

		for (int i = 0; i < StrNum; i++) {
			OutputStr[i] = InputStr[(Shuffle + i) % StrNum];
		}
		OutputStr[StrNum] = '\0';

		cout << OutputStr << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
    #include <string.h>
    #include <algorithm>
     
    #define lli long long int
     
    using namespace std;
     
    lli n, w[110], v[110], memo[110][100010];
     
    lli dp(lli id, lli cap) {
    	lli ret;
    	if (id == n)
    		return 0;
    	if (memo[id][cap] != -1)
    		return memo[id][cap];
    	ret = dp(id + 1, cap);
    	if (w[id] <= cap)
    		ret = max(ret, dp(id + 1, cap - w[id]) + v[id]);
    	memo[id][cap] = ret;
    	return ret;
    }
     
    int main() {
    	lli c, ans;
    	scanf("%lld %lld", &n, &c);
    	for (int i = 0; i < n; i++)
    		scanf("%lld %lld", &w[i], &v[i]);
    	memset(memo, -1, sizeof memo);
    	ans = dp(0, c);
    	printf("%lld\n", ans);
    	return 0;
    }

Measured memory_bytes: 86144
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

long long f(long long b, long long n) {
        if (b < 2) return -1;
        if (n < b) return n;
        return f(b, n / b) + n % b;
}

int main() {
        long long n, s;
        scanf("%lld %lld", &n, &s);
        if (n == s) { 
                printf("%lld\n", n + 1);
                return 0;
        }
        long long upper = min<long long> (n, sqrt(n) + 3LL);
        for (long long b = 2; b <= upper; b ++) {
                if (f(b, n) == s) {
                        printf("%lld\n", b);
                        return 0;
                }
        }
        for (long long p = upper; p >= 1; p --) {
                long long b = (n - s) / p + 1;
                if (f(b, n) == s) {
                        printf("%lld\n", b);
                        return 0;
                }
        }
        printf("%d\n", -1);
        return 0;
}



Measured memory_bytes: 256
def solver():
    N = int(input())
    S = list(input())

    rE = S.count('E')  # リーダーより右にいる人の数
    rW = N - rE

    lE = 0
    lW = 0

    c = N

    for s in S:
        if s == 'E':
            rE -= 1
            f = 1
        else:
            rW -= 1
            f = -1

        candidate = rE + lW
        # print(candidate)

        if candidate < c:
            c = candidate

        if f == 1:
            lE += 1
        else:
            lW += 1

    print(c)


solver()


Measured memory_bytes: 5920
#include <stdio.h>
#include <stdbool.h>

int main()
{
    int a, b, c, i;
    bool flag = false;
    scanf("%d%d%d", &a, &b, &c);
    for (i=1; i<10000000; i++)
    {
        if (a*i % b == c) {
            flag = true;
            break;
        }
    }
    if (flag) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
n=int(input())
s=[input() for _ in range(n)]
l='abcdefghijklmnopqrstuvwxyz'
ans=""

for i in l:
    t=10**9
    for j in range(n):
        if s[j].count(i)==0:
            break
        else:
            t=min(t,s[j].count(i))
    else:
        ans+=i*t

print(ans)
            


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=5e5+10;
int a[maxn];
 
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);int ans=0;
	for(int i=0;i<k;i++) ans+=a[i];
	cout<<ans;
	return 0;	
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int P = 1e9+7;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	vector<ll> v(n);
	for(auto &x: v)cin >> x;
	vector<ll> suf(n);
	suf[n-1] = v[n-1];
	for(int i = n-2;i >= 0;i--)
		suf[i] = (v[i] + suf[i+1])%P;
	int ans = 0;
	for(int i = 0;i < n-1;i++)
	{
		ans = (ans + (v[i] * suf[i+1])%P)%P;
	}
	cout << ans;
}


Measured memory_bytes: 6356
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a == b) {
        	System.out.println("Yes");
        }else {
        	System.out.println("No");
        }
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    map<string,int>mp;
    rep(i,n){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    ll ans=0;
    for(auto &p:mp){
        int a=p.second;
        ans+=(ll)a*(a-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11392
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	while(1){
		c=c-b;
		if(c<=0){
			printf("Yes\n");
			break;
		}
		a=a-d;
		if(a<=0){
			printf("No\n");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1660
import java.util.Scanner;

public class Main {
	
	static int sx;
	static int sy;
	static int tx;
	static int ty;
	
	static StringBuilder sb = new StringBuilder();

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		
		 sx = Integer.parseInt(sc.next());
		 sy = Integer.parseInt(sc.next());
		
		 tx = Integer.parseInt(sc.next());
		 ty = Integer.parseInt(sc.next());
		 
		 first();
		 second();
		 
		 String ans = sb.toString();
		 System.out.println(ans);
		
	}
	
	static void first() {
		int l = ty - sy;
		int w = tx - sx;
		
		int temp = 0;
		
		while(temp <= 1) {
		for(int i = 0 ; i < l ; i++) {
			if(temp == 0) {
				sb.append('U');
			}
			else {
				sb.append('D');
			}
		}
		for(int i = 0 ; i < w ; i++) {
			if(temp == 0) {
				sb.append('R');
			}
			else {
				sb.append('L');
			}
		}
		temp++;
	}
}
	
	static void second() {
		int l = ty - sy;
		int w = tx - sx;
		
		int temp = 0;
		
		while(temp <= 1) {
			if(temp == 0) {
				sb.append('L');
			}
			else {
				sb.append('R');
			}
		for(int i = 0 ; i <= l ; i++) {
			if(temp == 0) {
				sb.append('U');
			}
			else {
				sb.append('D');
			}
		}
		for(int i = 0 ; i <= w ; i++) {
			if(temp == 0) {
				sb.append('R');
			}
			else {
				sb.append('L');
			}
		}
		if(temp == 0) {
			sb.append('D');
		}
		else {
			sb.append('U');
		}
		
		temp++;
	}

	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i!=n;i++)

using namespace std;
int main(void){
    int a,b;
    cin >> a >> b;
    if(a!=1&&b!=1){
        cout << 1 << endl;
    }
    else if(a!=2&&b!=2){
        cout  << 2 << endl;
    }
    else{
        cout << 3 << endl;
    }
}


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

using namespace std;

int main()
{
  int n;
  while(cin >> n, n){
    string l;
    cin >> l;
    while(n--){
      string r = "";
      for(int i = 0; i < l.size(); i++){
	int cnt = 0;
	for(int j = i; j < l.size() && l[i] == l[j]; j++) cnt++, i = j;
	r += to_string(cnt);
	r += l[i];
      }
      //cout << r << endl;
      l = r;
    }
    cout << l << endl;
  }
  return 0;
}

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

using namespace std;

template<class T>
struct Graph
{
	struct Vertex {
		T cost;
		bool valid = false; // 到達不能または無限にコストが減るときfalse
		Vertex(T v1) : cost(v1) {}
		Vertex() {}
	};
	struct Edge {
		int from;
		int to;
		T cost;
		Edge(int t, T c) : to(t), cost(c) {}
		Edge(int t, int u, T c) : from(t), to(u), cost(c) {}
		Edge() {}
	};
	int sz;
	vector<Vertex> v;
	vector<vector<Edge>> e;
	vector<Edge> edges;
	Graph(int n) : sz(n), v(n), e(n) {}
	template<class... Args>
	inline void assign_vertex(int pos, Args... args) {
		v[pos] = V(args...);
	}
	// from, to, cost
	template<class... Args>
	inline void add_edge(int pos, Args... args) {
		e[pos].emplace_back(args...);
		edges.emplace_back(pos, args...);
	}
	inline int size() {
		return sz;
	}
};

template<class T>
struct Bellmanford : public Graph<T> {
	Bellmanford(int n) : Graph<T>(n) {};
	void Bellman_solve(int s, T INF_COST) {
		auto& v = this->v;
		auto& e = this->e;
		for (auto& vv : v) vv.cost = INF_COST, vv.valid = false;
		v[s].cost = 0, v[s].valid = true;
		for (int i = 0; i + 1 < (int) v.size(); i++) {
			for (auto& x: this->edges) {
				if (v[x.from].cost == INF_COST) continue;
				v[x.to].cost = min(v[x.to].cost, v[x.from].cost + x.cost);
				v[x.to].valid = true;
			}
		}
		auto valid_check = [&](auto f, int pos) {
			if (!v[pos].valid) return;
			v[pos].valid = false;
			for (auto& y: e[pos]) {
				f(f, y.to);
			}
		};
		for (int i = 0; i < (int) v.size(); i++) {
			for (auto& x: e[i]) {
				if (v[i].cost == INF_COST) continue;
				if (v[x.to].cost > v[i].cost + x.cost) {
					valid_check(valid_check, x.to);
				}
			}
		}
	}
};

/*
template<class V, class E>
void Bellmanford(Graph<V, E>& G, int s, bellman_cost INF_COST)
{
}
*/

void ABC137_E() {
	int N, M, P;
	cin >> N >> M >> P;
	Bellmanford<long long> B(N);
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		B.add_edge(a-1, b-1, P-c);
	}
	B.Bellman_solve(0, LLONG_MAX);
	if (B.v[N-1].valid) {
		cout << max(0LL, -B.v[N-1].cost) << endl;
	} else {
		cout << -1 << endl;
	}
}

int main() {
	ABC137_E();
}

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

using namespace std;

typedef long long ll;

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

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


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

  string A, B, C;
  cin >> A >> B >> C;

  ll a=0; ll b=0; ll c=0;
  char t = 'a';
  while(a+b+c<A.length()+B.length()+C.length()){
    if (t=='a'){
      if (a>=A.length()) { cout << "A" << "\n"; break; }
      t = A[a];
      a++;
    } else if (t=='b'){
      if (b>=B.length()) { cout << "B" << "\n"; break; }
      t = B[b];
      b++;
    } else if (t=='c'){
      if (c>=C.length()) { cout << "C" << "\n"; break; }
      t = C[c];
      c++;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	string s;
	int jo,io;
	
	while(getline(cin,s)){
		jo=0;
		io=0;
		for(int i=0;i<s.size();i++){
			if(s.substr(i,3)=="JOI")
			jo++;
			if(s.substr(i,3)=="IOI")
			io++;
		}
		printf("%d\n%d\n",jo,io);
	}
}

Measured memory_bytes: 3148
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    string s;
    cin >> s;

    cout << s.substr(0, 3) << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 3656
/* atcoder */
#include "bits/stdc++.h"
using namespace std;

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* main */
void Main(void)
{
    while (true)
    {
        int w, h;
        cin >> h >> w;
        if (w == 0 && h == 0)
        {
            break;
        }
        else
        {
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    if ((i + j) % 2 == 0)
                        cout << "#";
                    else
                        cout << ".";
                }
                cout << endl;
            }
            cout << endl;
        }
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}



Measured memory_bytes: 3088
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備
	s := Scan()
	t := Scan()
	fmt.Println(t + s)
}

Measured memory_bytes: 1776
#include <bits/stdc++.h>
#define pb push_back
#define boostup ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int ll;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
using namespace std;
double polyapothem(double n) 
{ 
  
    // Side and side length cannot be negative 
    // Degree converted to radians 
    return 1 / (2 * tan((180 / n) * 3.14159 / 180)); 
}
int main()
{
    boostup;
    ll k;
    cin>>k;
    string s;
    cin>>s;
    ll  n=s.size();
    if(n<=k)
    {
        cout<<s<<endl;
    }
    else
    {
        string r=s.substr(0,k);
        r+="...";
        cout<<r<<endl;
    }
}

Measured memory_bytes: 3672
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    ll aa[a],bb[b],cc[c];
    for(ll i=0;i<a;i++){
        cin>>aa[i];
    }
    for(ll i=0;i<b;i++){
        cin>>bb[i];
    }
    for(ll i=0;i<c;i++){
        cin>>cc[i];
    }
    sort(aa,aa+a,greater<ll>());
    sort(bb,bb+b,greater<ll>());
    sort(cc,cc+c,greater<ll>());
    multiset<ll>red,green;
    multiset<ll,greater<ll>>colorless;
    ll redSum=0,greenSum=0;
    for(ll i=0;i<x;i++){
        red.in(aa[i]);
        redSum+=aa[i];
    }
    for(ll i=0;i<y;i++){
        green.in(bb[i]);
        greenSum+=bb[i];
    }
    for(ll i=0;i<c;i++){
        colorless.in(cc[i]);
    }
    ll redMin=*red.begin(),greenMin=*green.begin(),cMax=*colorless.begin();
    while(cMax>redMin || cMax>greenMin){
        if(cMax>redMin && cMax>greenMin){
            if(redMin<greenMin){
                redSum+=(cMax - redMin);
                red.erase(red.begin());
                red.in(cMax);
                colorless.erase(colorless.find(cMax));
            }else{
                greenSum+=(cMax - greenMin);
                green.erase(green.begin());
                green.in(cMax);
                colorless.erase(colorless.find(cMax));
            }
        }else if(cMax>redMin){
            redSum+=(cMax - redMin);
            red.erase(red.begin());
            red.in(cMax);
            colorless.erase(colorless.find(cMax));
        }else{
            greenSum+=(cMax - greenMin);
            green.erase(green.begin());
            green.in(cMax);
            colorless.erase(colorless.find(cMax));
        }
        if(colorless.empty()){
            break;
        }
        redMin=*red.begin();
        greenMin=*green.begin();
        cMax=*colorless.begin();
    }
    cout<<redSum+greenSum<<"\n";
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

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

typedef struct{
  double x;
  double y;
}XY;

XY data[10000];

void kock(int,XY,XY);

int main(){
  int n;
  XY p1,p2;
  double z;

  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y=0;

  scanf("%d",&n);

  printf("%.8f %.8f\n",p1.x,p1.y);

  kock(n,p1,p2);

  p2.x=100;
  p2.y=0;

  printf("%.8f %.8f\n",p2.x,p2.y);
  
  return 0;
}

void kock(int n,XY p1,XY p2){
  XY s,u,t;

  if(n==0) return;

  s.x=(2*p1.x+p2.x)/3;
  s.y=(2*p1.y+p2.y)/3;
  t.x=(p1.x+2*p2.x)/3;
  t.y=(p1.y+2*p2.y)/3;
  u.x=(t.x-s.x)*cos(M_PI/3.0)-(t.y-s.y)*sin(M_PI/3.0)+s.x;
  u.y=(t.x-s.x)*sin(M_PI/3.0)+(t.y-s.y)*cos(M_PI/3.0)+s.y;

  kock(n-1,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);
  
  kock(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  
  kock(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  
  kock(n-1,t,p2);

}




Measured memory_bytes: 2144
// Problem : B - Not Found
// Contest : AtCoder - AtCoder Beginner Contest 071
// URL : https://atcoder.jp/contests/abc071/tasks/abc071_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
string s;cin>>s;
int fr[26]={0};
for(char c:s)
fr[c-'a']++;
for(int i=0;i<26;i++)
{
	if(!fr[i])
	{
		cout<<(char)(i+'a');
		return;
	}
}
cout<<"None";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  int res = 0;
  for (int i = 1; i * i < M + 1; i++) {
    if (M % i == 0) {
      if (i >= N) res = max(res, M / i);
      if (M / i >= N) res = max(res, i);
    }
  }
  cout << res << '\n';
  return 0;
}


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

void dfs(int v,set<int> &s,Graph &g){
    if(s.count(v)) return;
    s.insert(v);
    for(int i=0;i<g[v].size();i++){
        int to=g[v][i];
        dfs(to,s,g);
    }
    return;
}

int main(){
    int n,m;
    cin>>n>>m;
    Graph g(2*n);
    vector<vector<int>> adj(n,vector<int>(n,0));
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        adj[a][b]=true;
        adj[b][a]=true;
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i!=j && !adj[i][j]){
                g[i].push_back(j+n);
                g[i+n].push_back(j);
            }
        }
    }
    
    
    vector<int> av;
    vector<int> bv;
    vector<int> used(n,false);
    for(int i=0;i<n;i++){
        if(!used[i]){
            set<int> vs;
            dfs(i,vs,g);
            int a=0;
            int b=0;
            for(auto &e:vs){
                if(vs.count(e+n)){
                    cout<<-1<<endl;
                    return 0;
                }
                if(e<n){
                    used[e]=true;
                    a++;
                }
                else{
                    used[e-n]=true;
                    b++;
                }
            }
            av.push_back(a);
            bv.push_back(b);
        }
    }
    vector<vector<int>> dp(av.size()+1,vector<int>(n+1,0));
    dp[0][0]=true;

    for(int i=0;i<av.size();i++){
        for(int j=0;j<=n;j++){
            if(j+av[i]<=n) dp[i+1][j+av[i]]|=dp[i][j];
            if(j+bv[i]<=n) dp[i+1][j+bv[i]]|=dp[i][j];
        }
    }
    
    int res=1e8;
    for(int i=0;i<=n;i++){
        if(dp[av.size()][i]){
            res=min(res,max(i*(i-1)/2,0)+max((n-i)*(n-i-1)/2,0));
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 7936
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin


def main2():
    res = 0
    n = int(input())
    s = str(input())
    for i in range(n):
        for j in range(i+1, n):
            if s[i] == s[j]:
                continue
            else:
                for k in range(j+1, n):
                    if s[i] == s[k] or s[j] == s[k]:
                        continue
                    if j - i == k - j:
                        continue
                    res += 1
    print(res)


def main():
    res = 0
    n = int(input())
    s = str(input())
    r = [i for i in range(n) if s[i] == "R"]
    g = [i for i in range(n) if s[i] == "G"]
    b = [i for i in range(n) if s[i] == "B"]

    for i in range(n):
        if s[i] == "R":
            res += sum(x > i for x in g) * sum(x > i for x in b)
        elif s[i] == "G":
            res += sum(x > i for x in r) * sum(x > i for x in b)
        elif s[i] == "B":
            res += sum(x > i for x in r) * sum(x > i for x in g)
        for j in range(i+1, n):
            k = (j-i)+j
            if k >= n:
                continue
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                res -= 1
    print(res)


def input(): return stdin.readline().rstrip()


main()


Measured memory_bytes: 9560