akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
ll n;
cin >> n;
vector<vector<ll>> appear(n, vector<ll>(26, 0));
string s[n];
for (ll i = 0; i < n; i++) cin >> s[i];
for (ll i = 0; i < n;i++){
    for (ll j = 0; j < s[i].size();j++){
        appear[i][s[i][j] - 'a']++;
    }
}
for (ll i = 0; i < 26;i++){
    ll cnt = INF;
    for (ll j = 0; j < n;j++){
        chmin(cnt, appear[j][i]);
    }
    char moji = 'a' + i;
    for (ll i = 0; i < cnt; i++) cout << moji;
}
cout << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#define ll long long
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
#define N 100001
#define s second
#define pb(x) push_back(x)
#define f first
using namespace std;

ll pw(ll a, ll n)
{
    ll ans=1;
    while(n>0)
    {
        if (n%2!=0)
        {
            ans=ans*a;
        }
        a=a*a;
        n=n/2;
    }
    return ans;
}

int main()
{ //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(30);
    IOS;
    
    long double a, b, c;
    cin >> a >> b >> c;
    cout << (a+b+2*sqrtl(a*b)<c?"Yes":"No");

    cout.precision(30);

    return 0;
}

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

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//

template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
void printArr(int *a, int len){for(int i=0; i<len; i++){if(i)cout << " ";cout << a[i];}cout << endl;}

//----------//

bool solve(vector<int> res, vector<int> a,int mid, int n){
    bool ok = true;
    rep(i, n){
        int tmp = mid - res[i];
        if(tmp % a[i] != 0){
            ok = false;
        }
    }
    return ok;
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------/

    ll n, m;
    cin >> n >> m;
    vector<ll> v(n);
    rep(i, n){
        cin >> v[i];
        if(v[i] == 0){
            print(0);
            return 0;
        }
    }

    vector<ll> res(n);

    rep(i, n){
        res[i] = v[i] * 0.5;
    }

    ll tmp1 = 1;
    rep(i, n){
        tmp1 = lcm(tmp1, res[i]);
    }
    //print(tmp1);

    vector<ll> tmp2(n);
    rep(i, n){
        if(tmp1 / res[i] % 2LL == 0LL){
            print(0);
            return 0;
        }
        //print(tmp2[i]);
    }

    ll tmp4 = 1;
    rep(i, n){
        tmp4 = lcm(tmp4, v[i]);
    }
    m -= tmp1;
    if(m < 0){
        print(0);
        return 0;
    }

    ll ans = 0;
    ans = 1;
    ans += m / tmp4;
    cout << ans << endl;
    


    // int l = -1;
    // int r = 1e9+1;
    // while(r-l > 1){
    //     int mid = (r-l) / 2;
        
    // }
    
    
    return 0;
}


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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
//#define int long long
//#define double long double

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

    int a;
    cin >> a;
    
    if (a % 10 == 0 || a % 10 == 1 || a % 10 == 6 || a % 10 == 8)
        cout << "pon\n";
    else if (a % 10 == 3)
        cout << "bon\n";
    else
        cout << "hon\n";

    return 0;
}

//      *   *  *****  *   *  *   *
//     *   *  *      **  *  *   *
//    *****  *****  * * *  *   *
//   *   *      *  *  **  *   *
//  *   *  *****  *   *   ***

//      ***** ***** *   * *     ***** *   * ***** *****
//        *  *   * *   * *       *   **  *   *   *   *
//       *  *   * ***** *       *   * * *   *   *****
//   *  *  *   *   *   *       *   *  **   *   *
//  ****  *****   *   ***** ***** *   *   *   *


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
using namespace std;
const long long MOD=1e9+7;

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

    vector<int> oks(N+1,true);
    for (int i = 0;i<M;++i) {
        int a;cin>>a;
        oks[a]=false;
    }

    vector<long long> dp(N+1);
    dp[0] = 1;

    for(int now=0;now<N;++now) {
        for (int next=now+1;next<=min(N,now+2);++next) {
            if(oks[next]) {
                dp[next]+=dp[now];
                dp[next]%=MOD;
            }
        }
    }

    cout<<dp[N]<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>


using namespace std;

int main()
{
    long N;
    cin >> N;
    string str = "";

    while (N > 0) {
        N -= 1;
        char c = N % 26 + 97;
        str += c;
        N /= 26;
    }

    reverse(str.begin(), str.end());
    cout << str << endl;
}

Measured memory_bytes: 3152
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll lon, squ, tri, lle, lri, zri, zle;
	cin >> lon >> squ >> tri >> lle >> lri >> zri >> zle;
	ll tot1 = squ * 2;
	int sm = (lon & 1) + (lle & 1) + (lri & 1);
	if(lon && lle && lri && sm >= 2) tot1 += 6, lon--, lle--, lri--;
	tot1 += 4 * (lle / 2);
	tot1 += 4 * (lri / 2);
	tot1 += (lon / 2) * 4;
	ll tot = squ * 2;
	ll mn = min({lon, lle, lri});
	tot += mn * 6;
	lon -= mn;
	lri -= mn;
	lle -= mn;
	tot += (lon / 2) * 4;
	tot += (lle / 2) * 4;
	tot += (lri / 2) * 4;
	cout << max(tot1 / 2, tot / 2) << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3652
import std.stdio;
import std.string;
import std.conv;
import std.array;
import std.algorithm;

void main() {
    auto input = readln.split.map!(to!int);
    int K = input[0], S = input[1];

    int ans = 0;

    foreach (x; 0 .. K + 1) {
        foreach (y; 0 .. K + 1) {
            int z = S - (x + y);
            if (z >= 0 && K >= z) {
                ans++;
            }
        }
    }

    writeln(ans);
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    p = 2**n
    inf = 10**7
    dp = [inf]*p
    dp[0] = 0
    for _ in range(m):
        a, _ = map(int, input().split())
        c = sum([1<<(int(i)-1) for i in input().split()])
        for s in range(p):
                t = s|c
                new = dp[s] + a
                if dp[t] > new:
                    dp[t] = new
    ans = dp[-1]
    if ans == inf:
        ans = -1
    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
    int N, T;
    vector<int> c;
    int temp[2];

    cin >> N >> T;

    for(int i = 0; i < N; ++i){
        cin >> temp[0] >> temp[1];
        if(temp[1] <= T)    c.push_back(temp[0]);
    }

    if(c.size() == 0){
        cout << "TLE" << endl;
        return 0;
    }else{
        sort(c.begin(), c.end());
        cout << c[0] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector> 
#include<algorithm>
#include<numeric>
using namespace std; 
int main()
{
  vector<int> v;
int n,k;
cin>>n>>k;
v.resize(n);
for(int i=0;i<n;i++)
{
	cin>>v[i];
}
sort(v.begin(),v.end());
int sum=0;
cout<<accumulate(v.begin(),v.begin()+k,sum)<<"\n";

return 0;	
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using vc = vector<T>;
template<class T> using vvc = vc<vc<T>>;
constexpr ll ten(int n){return (n==0) ? 1 : 10 * ten(n-1);}
#define rng(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,N) for(int i=0;i<(int)(N);i++)
#define gnr(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define per(i,b) gnr(i,0,b)
#define a first
#define b second
#define eb emplace_back
#define pb push_back
#define bg begin()
#define ed end()
#define all(x) x.begin(),x.end()
template<class T, class U> void chmin(T& t, const U& u){ if(t>u) t = u;}
template<class T, class U> void chmax(T& t, const U& u){ if(t<u) t = u;}

#ifdef LOCAL
#define show(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

template<class T,class U>
ostream& operator<<(ostream& os, const pair<T,U>& p){
    return os << "P(" << p.fs << ", " << p.sc << ")";
}
template<class T> ostream& operator<<(ostream& os, const vc<T>& v){
    os << "[";
    for(auto d: v) os << d << ", ";
    return os << "]";
}

using vi=vector<int>;
using pi=pair<int,int>;

const int inf=INT_MAX/2-100;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int n=1000000;
    vi w(n,n);
    {
		int m;cin>>m;
		rep(_,m){
			int a,b;cin>>a>>b;
			rep($,2){
				chmin(w[a],(b+n-a)%n);
				swap(a,b);
			}
		}
	}
	per(ii,n*2){
		int i=ii%n,j=(i+1)%n;
		chmin(w[i],w[j]+1);
	}
	rotate(w.bg,max_element(all(w)),w.ed);
	
	vc<pi> dp(n,pi(-1,-1));
	rep(i,w[0])dp[i]=pi(0,i);
	int ans=n;
	rep(i,n){
		int j=i+w[i];
		if(n<=j)chmin(ans,dp[i].a+(n+dp[i].b<=j?1:2));
		chmin(j,n-1);
		while(dp[j].a==-1)
			dp[j--]=pi(dp[i].a+1,dp[i].b);
	}
	cout<<(ans+1)/2<<endl;
}



Measured memory_bytes: 14484
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>

using namespace std;

int main(int argc, char* argv[])
{
    double r, area, circle;

    cin >> r;

    area = (r * r) * M_PI;
    circle = r * 2 * M_PI;
    printf("%f %f\n", area, circle);
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;

// main() { UnionFind uf(N); }
struct UnionFind
{
    vector<int> par; //par[i]:= iの親の番号
    vector<int> siz; //siz[i]:= iの属する連結成分の大きさ
    UnionFind(int N) {
        par.resize(N);
        for(int i = 0; i < N; ++i) {
            par[i] = i;
        }
        siz.resize(N,1);
    }

    int root(int x){ // xが属する木の根を再帰で得る：root(x) = {xの木の根}
    if(par[x] == x) return x;
    else return par[x] = root(par[x]);
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        return root(x) == root(y);
    }

    bool unite (int x, int y) { // xとyの木を併合
        x = root(x); y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y); // merge technique 小を大にくっつける

        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    int size(int x) { // xの属する木の大きさを得る
        return siz[root(x)];
    }
};

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

ll n,m;
cin >> n >> m;
vl a(m),b(m);
rep(i,m) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
}

UnionFind uf(n);
vl ans;

ll cur = n *(n-1)/2;
drep(i,m) {
    ans.push_back(cur);
    if(uf.same(a[i], b[i])) continue;
    ll sa = uf.size(a[i]);
    ll sb = uf.size(b[i]);
    cur -= sa * sb;
    uf.unite(a[i], b[i]);
}

drep(i,m) cout << ans[i] << endl;
return 0;
}

Measured memory_bytes: 4596
function main(input) {
    var line = input.split(/\r?\n/g);
    var arr = line[0].split(" ");
    const S = arr[0], T = arr[1];
    arr = line[1].split(" ")
    var A = parseInt(arr[0]), B = parseInt(arr[1]);
    const U = line[2];
    if (S == U) A--;
    else B--;
    console.log(A + " " + B);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
	int n;
	scanf("%d", &n);
	vector<int> a(n);
	for(int i=0; i<n; i++) scanf("%d", &a[i]);
	//sort(a.begin(), a.end());
	long long ans = 0;
	int m = 0;
	for(int i=0; i<n; i++) {
		m = max(m, a[i]);
		ans += (m - a[i]);
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 3956
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int N, K, ans = 0;
    cin >> N >> K;
    vector<int> h(N);
    for(int i= 0; i < N; i++){
        cin >> h[i];
        if(h[i] >= K)   ans++;
    }
    cout << ans << endl;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int k, t;cin >> k >> t;
    vector<int> a(t);
    int ssum = 0;
    int mmax = 0;
    for(int i=0;i<t;i++){
        cin >> a[i];
        mmax = max(mmax, a[i]);
        ssum += a[i];
    }
    cout << max(0, mmax-(ssum-mmax)-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A1;
  int A2;
  int A3;
  cin >> A1 >> A2 >> A3;
 
  if ( A1 + A2 + A3 >= 22 ) {
    cout << "bust" << endl;
  } 
  else { 
    cout << "win" << endl;
  } }


Measured memory_bytes: 3512
console.log((args=>{
  const [[N],A] = args.trim().split`\n`.map(r=>r.split` `.map(v=>0|v));
  let trend = A[1] - A[0], count = 1;
  for ( let i = 2; i < N; i++ ) {
    const t = A[i] - A[i-1];
    if ( t === 0 ) continue;
    else if ( trend === 0 ) trend = t;
    else if (( t > 0 && trend > 0 ) || ( t < 0 && trend < 0 )) continue;
    else {
      count++;
      trend = 0;
    }
  }
  return count;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


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

std::string a, b;

int main(){
std::cin >> a >> b;
int a_size = a.size();
int b_size = b.size();

if(a_size > b_size){
	std::cout << "GREATER" << std::endl;
}
else if(a_size < b_size){
	std::cout << "LESS" << std::endl;
}
else{
if(a > b){
	std::cout << "GREATER" << std::endl;
}
else if(a == b){
	std::cout << "EQUAL" << std::endl;
}
else{
	std::cout << "LESS" << std::endl;
}
}
}


Measured memory_bytes: 256
//                             In The Name Of Allah
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long

using namespace std; 
 
const int N = 1e5 + 1100, OO = 1e9 + 7, M = 1e9 + 7, P = 769, sq = 360, lg = 23;
typedef pair <int, int> pii; 
int num[N], a[N];

int32_t main() {
    use_fast;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		num[a[i]]++;
	}
	sort(a, a + n);
	if(n == 1)
		return cout << "Impossible", 0;
	if(n == 2) {
		if(num[1] == 2)
			return cout << "Possible", 0;
		return cout << "Impossible", 0;
	} 
	for(int i = 0; i <= a[n - 1]; i++) {
		if(num[max(i, a[n - 1] - i)] == 0)
			return cout << "Impossible", 0;
		num[max(i, a[n - 1] - i)]--;
	}
	int mid = (a[n - 1] + 1) / 2 + 1;
	for(int i = 0; i < mid; i++) 
		if(num[i])
			return cout << "Impossible", 0;
	cout << "Possible" << endl;
	return 0;	
} 
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <cstring>
#include <algorithm>
#include <set>
#include <climits>
#include <numeric>

//usings
using namespace std;

//type def
typedef long long int64;
typedef pair<int, int> ii;

//consts
const int mod = 998244353;

//methods
template<typename T>
bool chmax(T& source, const T& compare_to) {
    if(source < compare_to) {
        source = compare_to;
        return true;
    }
    return false;
}

int modpow(int64 base, int n) {
    int64 ret = 1;
    while(n) {
        if(n & 1) ret = ret * base % mod;
        base = base * base % mod;
        n >>= 1;
    }
    return ret;
}

class Solution {
private:
public:
    int solve(int n, int k, vector<int>& arr) {
        vector<vector<vector<int64>>> dp(n + 1, vector<vector<int64>>(k + 1, vector<int64>(3)));
        dp[0][0][0] = 1;
        for(int i = 0; i < n; ++i) {
            for(int s = 0; s <= k; ++s) {
                (dp[i + 1][s][0] += dp[i][s][0]) %= mod;
                (dp[i + 1][s][1] += dp[i][s][0] + dp[i][s][1]) %= mod;
                (dp[i + 1][s][2] += dp[i][s][0] + dp[i][s][1] + dp[i][s][2]) %= mod;
                if(s + arr[i] <= k) {
                    (dp[i + 1][s + arr[i]][1] += dp[i][s][0] + dp[i][s][1]) %= mod;
                    (dp[i + 1][s + arr[i]][2] += dp[i][s][0] + dp[i][s][1]) %= mod;
                }
            }
        }
        return dp[n][k][2];
    }
};

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> arr(n);
    for(int i = 0; i < n; ++i) cin >> arr[i];
    Solution sol;
    auto ret = sol.solve(n, k, arr);
    cout << ret << endl;
}

Measured memory_bytes: 493056
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
# print('T:',T)

if N==1:
    f2 = T[0]

elif N==2:
    import math
    a,b = T[0], T[1]
    f=math.gcd(a,b)
    f2=a*b//f

else:
    import math
    a,b = T[0], T[1]
    f=math.gcd(a,b)
    f2=a*b//f
    for i in range(2,N):
        a,b=f2, T[i]
        f=math.gcd(a,b)
        f2=a*b//f

print(f2)


Measured memory_bytes: 62780
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int dis(int x, int y, int nx, int ny){
  if((x <= nx && y <= ny) || (x >= nx && y >= ny)){
    return max(abs(x-nx), abs(y-ny));
  }else{
    return abs(x-nx)+abs(y-ny);
  }
}

int main(){
  int W, H, N;
  scanf("%d%d%d", &W, &H, &N);
  int X, Y;
  int res = 0;
  scanf("%d%d", &X, &Y);
  rep(i, N-1){
    int nX, nY;
    scanf("%d%d", &nX, &nY);
    res += dis(X, Y, nX, nY);
    X = nX;
    Y = nY;
  }
  printf("%d\n", res);
  return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

int main() {
	ll x;
	cin >> x;
	ll now = x;
	ll ans = 1;
	while (now % 360 != 0) {
		now += x;
		ans++;
	}
	cout << ans << endl;
	
}


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

#define DEBUG(x) 			   cout << '>' << #x << ':' << x << endl;
#define D(x)        		   cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define DD(x,y)     		   cerr << __LINE__ << ": " << #x << " = " << x << "   " << #y << " = " << y << '\n'
#define DDD(x,y,z)  		   cerr << __LINE__ << ": " << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << '\n'
#define DBG         		   cerr << __LINE__ << ": Hi" << '\n'
#define fresh                  {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define read                   freopen("in.txt","rt",stdin)
#define write                  freopen("out.txt","wt",stdout)
#define PI                     3.1415926535897932384626433832795
#define mems(ds_name,val)      memset(ds_name,val,sizeof(ds_name))
#define ll					   long long



int main()
{
//    write;
    fresh;
//    read;

   int d;cin>>d;
   int arr[d+5];
   int maxm=INT_MIN;
   int ans=0;
   for(int i=0;i<d;i++){
        cin>>arr[i];
        maxm=max(maxm,arr[i]);
        ans+=arr[i];
   }
   ans-=maxm;
   maxm=maxm/2;
   ans+=maxm;

   cout<<ans<<endl;
}



Measured memory_bytes: 256
n, k = map(int,input().split())
r, s, p = map(int,input().split())
t = list(input())
score = 0
for i in range(k):
    if t[i] == "r":
        score += p
    elif t[i] == "s":
        score += r
    else:
        score += s
 
for i in range(k, len(t)):
    if t[i] != t[i-k]:
        if t[i] == "r":
            score += p
        elif t[i] == "s":
            score += r
        else:
            score += s
    else:
        t[i] = ""
 
print(score)

Measured memory_bytes: 4084
<?php
$n = (int)trim(fgets(STDIN));
$S = array_map('intval', explode(' ', trim(fgets(STDIN))));
$q = (int)trim(fgets(STDIN));
$T = array_map('intval', explode(' ', trim(fgets(STDIN))));

print count(array_intersect($T, $S)) . "\n";


Measured memory_bytes: 12404
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[5],k;
	for(int i=0;i<5;i++) cin>>a[i];
	cin>>k;
	int x=a[4]-a[0];
	if(x<=k) cout<<"Yay!";
	else cout<<":(";
	return 0;
}

Measured memory_bytes: 256
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n=int(input())
ans=100
for i in make_divisors(n):
  ans=min(ans,max(len(str(i)),len(str(n//i))))
print(ans)

Measured memory_bytes: 9176
#include<stdio.h>
int main(void){
int n,x,i,y,c,kazu;

	
		for(;;){
		kazu=0;

		scanf("%d %d",&n,&x);
		if(n==0&&x==0){
			break;
		}
		for(i=1;i<=n;i++){

			for(y=1;y<=n;y++){

				for(c=1;c<=n;c++){
					if(i!=y&&y!=c&&c!=i){
					if(i+y+c==x){
						kazu++;
						}
					}
				}
				
			}
			
		}
			printf("%d\n",kazu/6);
		}
		return 0;
}

Measured memory_bytes: 2740
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int a[5], k;
    for(int i = 0; i < 5; ++i)
    {
        scanf("%d", &a[i]);
    }
    scanf("%d", &k);
    int flag = 0;
    for(int i = 0; i < 5; ++i)
    {
        for(int j = i+1; j < 5; ++j)
        {
            if(a[j] - a[i] > k)
            {
                flag = 1;
                break;
            }
        }
        if(flag)
            break;
    }
    if(flag)
        printf(":(\n");
    else
        printf("Yay!\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int b = sc.nextInt();

        if (n == 1 && b == 2) System.out.println(3);
        else if (n == 1 && b == 3) System.out.println(2);
        else if (n == 2 && b == 3) System.out.println(1);
        else if (n == 2 && b == 1) System.out.println(3);
        else if (n == 3 && b == 1) System.out.println(2);
        else if (n == 3 && b == 2) System.out.println(1);

        sc.close();
    }

    public class Pair<F,S>
    {
        private final F first;
        private final S second;

        Pair(F first,S second)
        {
            this.first = first;
            this.second = second;
        }

        public void print() { System.out.println("("+this.first+","+this.second+")"); }

        //get
        public F first() {return this.first;}
        public S second() {return this.second;}

        @Override
        public boolean equals(Object object)
        {
            if (object instanceof Pair)
            {
                Pair pair = (Pair)object;
                return this.first==pair.first && this.second==pair.second;
            }else
            {
                return false;
            }
        }

        @Override
        public int hashCode()
        {
            return Objects.hash(first,second);
        }
    }
}

Measured memory_bytes: 21460
N = int(input())
S = list(input())
count = 0
if N%2==0:
    j = int(N/2)
    for i in range(j):
        if S[i]==S[i+j] :
            count+=1
    if count==j:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int N; cin >> N;
  
  vector<string> rec(N);
  int iter = 0;
  int ok = 0, ng = N, mid = 0;
  while (iter<=20){
    cout << mid << endl;
    string s; cin >> s;
    cout.flush();
    if (s=="Vacant") break;
    iter++;
    rec[mid] = s;

    if ((mid-ok)%2 == (rec[ok]!=rec[mid])) ok = mid;
    else ng = mid;

    mid = (ok+ng)/2;    
  }
  


  // cout << fixed << setprecision(10);
  
  return 0;
}

Measured memory_bytes: 6388
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++) 
#define ALL(n) begin(n),end(n)
using ULL=unsigned long long;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    bool flag = false;
    for( int i = 1; i <= 1000; i++ )
    {
        if( ( i * A ) % B == C )
        {
            flag = true;
            break;
        }
    }
    cout << ( flag ? "YES" : "NO" ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int tab[100001],n,dp[100001];
int solve(int idx){
    if(idx==(n-1))return 0;
    if(idx>n)return INF;
    if(dp[idx]!=-1)
        return dp[idx];
    int ans=INF;
    for (int i = 1; i <= 2; ++i)
        ans=min(ans,abs(tab[idx]-tab[idx+i])+solve(idx+i));
    return dp[idx]=ans;
}
int main(){
    boost;
    memset(dp,-1,sizeof dp);
    cin>>n;
    for (int i = 0; i < n; ++i)
        cin>>tab[i];
    cout<<solve(0);
    return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 4224
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

// struct fast_io {
	// fast_io(){
		// std::cin.tie(nullptr);
		// std::ios::sync_with_stdio(false);
	// };
// } fio;

#define x first.first
#define y first.second
#define p second

signed main(){
	cout<<fixed<<setprecision(10);
	
	
	int n[20], h[20], m[20], dis[20], dis2[20], dis3[20];
	vector<pair<pair<int,int>,int>> in;
	vector<int> ans;
	int N;
	
	cin>>N;
	
	in.resize(N);
	ans.resize(N+1, INF);
	
	for(int i = 0; i < N; i++){
		cin>>in[i].x>>in[i].y>>in[i].p;
	}
	
	for(int l = 0; l < N; l++){
		dis[l] = min(abs(in[l].x), abs(in[l].y));
	}
	// for(int l = 0; l < N; l++){
		// cout<<dis[l]<<" <- dis [1]"<<endl;
	// }
	for(int i = 0; i < 1<<N; i++){ //cout<<i<<endl;
		int c = 0, xc = 0;
		
		for(int j = 0; j < N; j++){
			if((i>>j)&1) {
				h[c] = j;
				c++;
			} else {
				n[xc] = j;
				xc++;
			}
		}
		
		
		// int tcost = 0;
			
		// for(int l = 0; l < N; l++){
			// tcost += dis[l] * in[l].p;
		// }
		
		for(int l = 0; l < N; l++){
			dis2[l] = dis[l];
		}
		
		for(int k = 0; k < c; k++){
			// cout<<h[k]<<" < "<<N<<endl;
			for(int l = 0; l < N; l++){
				dis2[l] = min(dis2[l], abs(in[h[k]].x - in[l].x));
			}
		}
		// for(int l = 0; l < N; l++){
			// cout<<dis2[l]<<" <- dis [2]"<<endl;
		// }
		for(int j = 0; j < 1<<xc; j++){
			int c2 = 0;
			
			for(int k = 0; k < xc; k++){
				if((j>>k)&1) {
					m[c2] = n[k];
					c2++;
				}
			}
			
			for(int l = 0; l < N; l++){
				dis3[l] = dis2[l];
			}
		
			
			for(int k = 0; k < c2; k++){
				for(int l = 0; l < N; l++){
					dis3[l] = min(dis3[l], abs(in[m[k]].y - in[l].y));
				}
			}
			
			int cost = 0;
			
			for(int l = 0; l < N; l++){
				cost += dis3[l] * in[l].p;
				// cout<<dis3[l]<<" <- dis"<<endl;
			}
			// cout<<"cost = "<<cost<<" "<<endl;
			
			ans[c + c2] = min(ans[c + c2], cost);
		}
	}
	
	for(int i = 0; i <= N; i++){
		cout<<ans[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main(){
  int a, b; cin >> a >> b;

  cout << ((a*b)%2 == 1 ? "Yes" : "No" ) << endl;

  return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int64_t A, B;
  cin >> A >> B;
  auto f = [](int64_t N) {
    vector<int64_t> res;
    for (int64_t i = 1; i * i < N + 1; i++) {
      if (N % i == 0) {
        res.emplace_back(i);
        res.emplace_back(N / i);
      }
    }
    sort(res.begin(), res.end());
    res.erase(unique(res.begin(), res.end()), res.end());
    return res;
  };
  vector<int64_t> C = f(A), D = f(B), E;
  for (auto c : C) {
    if (binary_search(D.begin(), D.end(), c)) E.emplace_back(c);
  }
  int res = 1;
  for (int i = 1; i < (int)E.size(); i++) {
    if (E[i] == -1) continue;
    res++;
    for (int j = i + 1; j < (int)E.size(); j++) {
      if (E[j] % E[i] == 0) E[j] = -1;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 512
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse = True)
#print(a)
status = True

goukei = sum(a)
c = goukei * 1/(4*m)

for _ in range(m):
    if a[0] >= c:
        a.pop(0)
    else:
        status = False

if status:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
using namespace std;

pll egcd(ll m, ll n) {
	if (n==0) return {1, 0};
	pll tmp = egcd(n, m%n);
	ll x = tmp.first, y = tmp.second;
	return {y, x - (m/n)*y};
}

ll my_ceil(ll x, ll y) {
	return x/y + (x%y>0);
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifdef LOCAL
//		freopen("in1.txt", "r", stdin);
//		freopen("in1.txt", "w", stdout);
	#endif
	ll n;
	cin >> n;
	if (n==1) {
		cout << 1 << '\n';
		return 0;
	}
	else if (n==2) {
		cout << 3 << '\n';
		return 0;
	}
	ll tmp = n;
	vector<pll> prm;
	int two = 1;
	while (tmp%2 == 0) {
		tmp /= 2;
		two++;
	}
	prm.push_back({2, two});
	for (ll i=2; i*i<=tmp; i++) {
		if (tmp%i == 0) {
			int cnt = 0;
			while (tmp%i==0) {
				tmp /= i;
				cnt++;
			}
			prm.push_back({i, cnt});
		}
	}
	if (tmp>1) prm.push_back({tmp, 1});
	
	int m = prm.size();
	vector<ll> num(m);
	for (int i=0; i<m; i++) {
		ll cur = 1;
		while (prm[i].second--) cur *= prm[i].first;
		num[i] = cur;
	}
	
	ll ans = n-1;
	int sz = (1<<m);
	for (int i=0; i<sz; i++) {
		ll p = 1, q = 1;
		for (int b=0, bit=1; b<m; b++, bit<<=1) {
			if (i&bit) p *= num[b];
			else q *= num[b];
		}
		if (p==1 || q==1) continue;
		pll sol = egcd(p, -q);
//		cout << p << ' ' << q << ' ' << sol.first << ' ' << sol.second << '\n';
		ll x = sol.first;
		x %= q;
		x = (x+q) % q;
		ans = min(ans, p*x);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B;
    cin >> A >> B;
    if(A+B>=10){
        cout << "error" <<"\n";
    }else{
        cout << (A+B) << "\n";
    }
    return 0;
}

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

int main()
{

	int n,a;
	cin >> n;
	vector <vector<int>> graph(n + 1, vector<int>());
	for (int i = 0; i < n - 1; i++) {
		cin >> a;
		graph[a - 1].push_back(1);
	}
	for (int i = 0; i < n; i++) {
		cout << graph[i].size() << "\n";
	}
}

Measured memory_bytes: 13996
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  vll A(9);
  FOR(i,0,n){
    ll a;
    	ci(a);
    if(a/400<=7) A[a/400]++;
    else A[8]++;
  }
  
  ll mini=0;
  ll maxi=0;
  FOR(i,0,8){
    if(A[i]!=0) mini++;   
  }
  if(mini==0) cout<<1<<" ";
  else cout<<mini<<" ";
  co(mini+A[8])
    }


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val aList = readLine()!!.split(' ').map(String::toLong)
    val queue = PriorityQueue<Long>(n, Comparator { o1: Long?, o2: Long? -> if (o1!! > o2!!) -1 else 1 })
    aList.forEach { queue.add(it) }
    for (i in 1..m) {
        val max = queue.poll()
        val ins = max / 2
        queue.add(ins)
    }
    println(queue.sum())
}

Measured memory_bytes: 71884
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int p = 15 - s.length();
    for(int i = 0; i < s.length(); i++) {
      if(s.charAt(i) == 'o') p++;
    }
    String ans = "YES";
    if(p < 8) ans = "NO";
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 15;
char cn[cm], * ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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

	fread_unlocked(cn, 1, cm, stdin);
	int N = getint(), K = getint(), Q = getint();
	ll A[2002];
	int LR[2002] = {};
	rep1(i, N) A[i] = ((ll)getint() << 16) + i;

	priority_queue<int> q;
	priority_queue<int, vector<int>, greater<int>> q2[1001];
	int q3[2002] = {};
	int kotae = 1e9;
	int saishou = 2e9;
	sort(A + 1, A + N + 1);
	const int m = (1 << 16) - 1;
	int qn = 1;

	for (int i = N; i >= 1; i--) {
		int a = A[i] >> 16;
		int k = A[i] & m;

		int l = !LR[k - 1] ? k : LR[k - 1];
		int r = !LR[k + 1] ? k : LR[k + 1];
		LR[l] = r;
		LR[r] = l;

		if (l == r) q3[l] = qn++;
		int kosuu = min(K - 1, k - l);
		int kosuu2 = min(K - 1, r - k);
		if (k + k < l + r) {
			swap(q3[l], q3[k + 1]);
			swap(kosuu, kosuu2);
		}

		auto L = q2 + q3[l];
		auto R = q2 + q3[k + 1];

		rep(j, kosuu2) {
			(*L).push((*R).top());
			(*R).pop();
			if (kosuu == K - 1) {
				q.push((*L).top());
				(*L).pop();
			}
			else kosuu++;
		}
		(*L).push(a);
		if (kosuu == K - 1) {
			q.push((*L).top());
			(*L).pop();
		}
		while (q.size() >= Q) {
			int tmp = q.top();
			chmin(saishou, tmp);
			q.pop();
		}
		chmin(kotae, saishou - a);
	}

	printf("%d", kotae);

	Would you please return 0;
}

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

int main() {
	int days, hw, hdays;
	cin >> days >> hw;
	int play = days;

	for (int i = 0; i < hw; i++) {
		cin >> hdays;
		play -= hdays;

		if (play < 0) {
			cout << -1 << endl;
			break;
		}
	}

	if (play >= 0) {
		cout << play << endl;
	}
}

Measured memory_bytes: 3636
import java.io.*;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int T = sc.nextInt();
        Integer[] a = new Integer[T];
        Integer sum = 0;
        for(int i = 0; i < T; ++i){
            a[i] = sc.nextInt();
            sum += a[i];
        }
        Arrays.sort(a, Collections.reverseOrder());
        sum -= a[0];
        int ans = Math.max(0, a[0] - sum-1);

        System.out.println(ans);
    }
}


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

typedef long long           ll;
typedef unsigned long long  ull;

#define sf                  scanf
#define pf                  printf
#define pb                  push_back
#define ppb                 pop_back
#define MP                  make_pair
#define PF                  first
#define PS                  second
#define si(n)               scanf("%d",&n)
#define sii(x,y)            scanf("%d %d",&x,&y)
#define siii(x,y,z)         scanf("%d %d %d",&x,&y,&z)
#define sl(n)               scanf("%lld",&n)
#define sll(x,y)            scanf("%lld %lld",&x,&y)
#define slll(x,y,z)         scanf("%lld %lld %lld",&x,&y,&z)
#define FOR(i,x,y)          for(int i=x;i<y;i++)
#define RFOR(i,x,y)         for(int i=x;i>=y;i--)
#define CLR(arr,val)        memset(arr,val,sizeof arr);
#define vout(v)             for(int ind=0;ind<v.size();ind++){ cout<<v[ind]; if(ind<v.size()-1) cout<<' '; else cout<<endl;}
#define TCL(test,t)         for(test=1;test<=t;test++)
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("input.txt", "w", stdout)
#define fastIO()            {ios_base::sync_with_stdio(false); cin.tie(NULL);}
#define MAXN                100005
#define MOD                 1000000000
#define PI                  acos(-1)

int main(){
    char c;
    cin>>c;
    c++;
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <cstdlib>
#include <vector>

int main() {
  int W, H;
  size_t N;
  scanf("%d %d %zu", &W, &H, &N);

  int x = 0;
  int y = 0;
  scanf("%d %d", &x, &y);
  intmax_t res = 0;
  for (size_t i = 1; i < N; ++i) {
    int X, Y;
    scanf("%d %d", &X, &Y);

    int dx = X-x;
    int dy = Y-y;
    if (dx == 0) {
      res += std::abs(dy);
    } else if (dx > 0) {
      if (dy < 0) {
        res += dx - dy;
      } else {
        res += std::max(dx, dy);
      }
    } else {
      if (dy < 0) {
        res += std::max(-dx, -dy);
      } else {
        res += dy - dx;
      }
    }

    x = X;
    y = Y;
  }
  printf("%jd\n", res);
}



Measured memory_bytes: 2696
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
#define vpp vector<pair<ll,ll>>
#define ff first
#define ss second
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;

ll dp[100005];
int main()
{
    rkc;
    ll n,k;
    cin>>n>>k;
    ll a[n];
    fl(i,0,n)cin>>a[i];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    fl(i,2,n)
    {   
        dp[i]=dp[i-1]+abs(a[i-1]-a[i]);
        fl(j,2,k+1)if(i-j>=0)
            dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
to_the_5 = [0, 1, 32, 243, 1024, 3125, 7776, 16807, 32768, 59049, 100000, 161051, 248832, 371293, 537824, 759375, 1048576, 1419857, 1889568, 2476099, 3200000, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176, 69343957, 79235168, 90224199, 102400000, 115856201, 130691232, 147008443, 164916224, 184528125, 205962976, 229345007, 254803968, 282475249, 312500000, 345025251, 380204032, 418195493, 459165024, 503284375, 550731776, 601692057, 656356768, 714924299, 777600000, 844596301, 916132832, 992436543, 1073741824, 1160290625, 1252332576, 1350125107, 1453933568, 1564031349, 1680700000, 1804229351, 1934917632, 2073071593, 2219006624L, 2373046875L, 2535525376L, 2706784157L, 2887174368L, 3077056399L, 3276800000L, 3486784401L, 3707398432L, 3939040643L, 4182119424L, 4437053125L, 4704270176L, 4984209207L, 5277319168L, 5584059449L, 5904900000L, 6240321451L, 6590815232L, 6956883693L, 7339040224L, 7737809375L, 8153726976L, 8587340257L, 9039207968L, 9509900499L, 10000000000L, 10510100501L, 11040808032L, 11592740743L, 12166529024L, 12762815625L, 13382255776L, 14025517307L, 14693280768L, 15386239549L, 16105100000L, 16850581551L, 17623416832L, 18424351793L, 19254145824L, 20113571875L, 21003416576L, 21924480357L, 22877577568L, 23863536599L, 24883200000L]

X = int(raw_input())

for i in range(len(to_the_5)):
	for j in range(len(to_the_5)):
		if to_the_5[i] - to_the_5[j]  == X:
			print '{} {}'.format(i, j)
			exit()
		if to_the_5[i] + to_the_5[j] == X:
			print '{} -{}'.format(i, j)
			exit()

Measured memory_bytes: 84684
(N, K), As = readlines.map{|l| l.split.map(&:to_i)}

h =  As.group_by{|a| a <=> 0}
(ns, nc), (_, zc), (ps, pc) = [-1, 0, 1].map{|v| h[v] || []}.map{|a| [a.sort_by(&:abs), a.size]}
x = nc*pc + zc*(N - zc) + zc*(zc - 1)/2
puts case K
     when 0 .. nc*pc
       (-(10**19) .. -1).bsearch{|v|
         c, r = 0, pc - 1
         ns.each do |n|
           r -= 1 while r >= 0 && n*ps[r] <= v
           c += pc - r - 1
         end
         c >= K
       }
     when nc*pc .. x
       0
     else
       (1 .. 10**19).bsearch{|v|
         c = x
         [ns, ps].each do |as|
           l, r = 0, as.size - 1
           while l < r
             r -= 1 while l < r && as[l]*as[r] > v
             c += r - l
             l += 1
           end
         end
         c >= K
       }
     end

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

typedef long long ll;

string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s;
	sort(s.begin(), s.end());
	if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3])
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

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

using namespace std;
int main() {
	long long n, m;
	cin >> n >> m;
	
	string s, t;
	cin >> s >> t;

	long long result = -1;
	
	long long ma = max(n, m);
	long long mi = min(n, m);
	
	long long limit = n * m + 1;
	
	long long y;
	for (long long i = ma; i > 0; --i) {
		if (n % i == 0 && m % i == 0) {
			y = i;
			break;
		}
	}
	
	for (long long i = mi; i <= limit; i += mi) {
		if (i % ma != 0) {
			continue;
		}
		
		bool ng = false;
		for (long long j = 0; j <= y; ++j) {
			if (s[j * n / y] != t[j * m / y]) {
				ng = true;
				break;
			}
		}
		
		if (!ng) {
			result = i;
			break;
		}
	}
	
	cout << result << endl;
}

Measured memory_bytes: 512