akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    int most = 0,more = 0;
    REP(i,N) {
        if (most <= A[i]) {
            more = most;
            most = A[i];
        }
        else if (more <= A[i]) {
            more = A[i];
        }
    }
    REP(i,N) {
        if (A[i] == most) {
            cout << more << endl;
        }
        else {
            cout << most << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2432
#include <stdio.h>

int main(void){
 int a,b,d,r;
 double f;

 scanf("%d %d",&a,&b);

 d = a/b;
 r = a%b;
 f = (double)a/(double)b;

 printf("%d %d %f10\n",d,r,f);

 return 0;
}

Measured memory_bytes: 636
/*
    mdsaqib
*/

#include <bits/stdc++.h>
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
using namespace std;

signed main(){
    fast;
    int n,k;
    cin >> n >> k;
    vector <int> A(n,0);
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    int cur=0;
    vector <int> V(n,0);
    int ct=0;
    int rec=0;
    bool b=true;
    while(k--){
        if(V[cur]!=0 && b){
            ct++;
            k=(k)%(ct-V[cur]);
            cur=A[cur]-1;
            b=false;
            
        }    
        else{
            ct++;
            V[cur]=ct;
            cur=A[cur]-1;
        }
    }
    cout << cur+1;
}


Measured memory_bytes: 6368
import  bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
#B.sort(reverse=True)
C.sort()
countA = [0]*(N+1)
countC = [0]*(N+1)

ans = 0
for b in range(N):
    countA = bisect.bisect_left(A, B[b])
    countC = N - bisect.bisect_right(C, B[b])
    ans += countA*countC
print(ans)



Measured memory_bytes: 29468
#include <bits/stdc++.h>
using namespace std;
#define ll long long
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}
const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i>n || i < 0) return 0; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){
      ans *=(n+1-j);
      ans /= j;
      ans %= MOD;} }return ans;}




void solve(){
    int n; cin >> n;
    int a[n];
    ll sum = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    ll snuke = a[0];
    ll ans = abs(snuke-sum+snuke);
    for(int i = 1; i < n-1; ++i){
        snuke += a[i];
        ans = min(ans, abs(snuke - sum + snuke));
    }
    cout << ans << endl;
}

int main(void){
    solve();
    return 0;
}


Measured memory_bytes: 4364
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (#x) << " is " << (x) << endl;
#define SPD_emergency ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " "; cout << endl;}
void PA(int v[], int n) { for (int i = 0 ; i < n ; i++)cout << v[i] << " " ; cout << endl;}
void IN(int a[], int n) {for (int i = 0; i < n; i++)cin >> a[i];}
void open() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
//continue break deque stack queue sort reverse accumulate  count lower_bound upper_bound
// next_permutation copy_n __builtin_popcount
///=========================================================================================================

signed  main() {
  SPD_emergency
  //open();
  //int t; cin >> t; int tt = 1; while (t--)
  {
    int k, n;
    cin >> k >> n;
    int a[n + 10], i, j, l, u = 0;
    for (int i = 0; i < n; ++i)
    {
      cin >> a[i];
    }
    u = a[0] + k - a[n - 1];
    vi v;
    v.pb(u);
    for (i = 1; i < n; i++) {
      u += a[i] - a[i - 1];
      v.pb(a[i] - a[i - 1]);
    }
    int ans = k;
    for (i = 0; i < v.size(); i++) {
      ans = min(ans, u - v[i]);
    }
    cout << ans << endl;
  }
  return 0;

}


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (auto&& i : a) {
		cin >> i;
	}
	sort(begin(a), end(a));
	vector<pair<int, int>> info(m);
	while (m--) {
		int b, c;
		cin >> b >> c;
		info.push_back(make_pair(c, b));
	}
	sort(rbegin(info), rend(info));
	long long p = 0;
	for (auto&& i : info) {
		for (int j = 0; p + j < n && j < i.second; j++) {
			if (a[p + j] > i.first) {
				p = n + 1;

				break;
			}
			a[p + j] = i.first;
		}
		p += i.second;
	}
	cout << accumulate(begin(a), end(a), 0ll) << "\n";
}


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


Measured memory_bytes: 2176
#include<stdio.h>
int main(){
  int unused __attribute__((unused));
  long long A, B, C, K, result = 0;
  unused = scanf("%lld %lld %lld %lld", &A, &B, &C, &K);

  if(K >= A){
    result += A;
    K  -= A;
  }else{
    result += K;
    K = 0;
  }
  K -= B;
  if(K > 0 && C >= K) result -= K;
  else if(K > 0 && C < K) result -= C;

  printf("%lld", result);
  return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

string s,t;
vector<char>sal[30],tal[30];
bool flg=true;

int main() {
	cin>>s>>t;
	for(int i=0;i<s.size();i++){
		sal[s[i]-'a'].push_back(t[i]);
		tal[t[i]-'a'].push_back(s[i]);
	}
	for(int i=0;i<30;i++){
		sal[i].erase(unique(sal[i].begin(),sal[i].end()),sal[i].end());
		tal[i].erase(unique(tal[i].begin(),tal[i].end()),tal[i].end());
		if(sal[i].size()>1||tal[i].size()>1)flg=false;
	}
	cout<<(flg?"Yes":"No")<<endl;
	return 0;
}



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

int main(){

    int a,b,c;
    cin >> a >> b >> c;

    if((a < c && c < b) || (b < c && c < a )){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

#define MAX 100

#define WHITE 0
#define GRAY 1
#define BLACK 2

int T;
int N;

int M[MAX][MAX];
int D[MAX], F[MAX], C[MAX];

void dfs(int u)
{
    C[u] = GRAY;
    D[u] = ++T;

    for (int i = 0; i < N; i++)
    {
        if(M[u][i] == 1 && C[i] == WHITE)
        {
            dfs(i);
        }        
    }
    C[u] = BLACK;
    F[u] = ++T;
}

int main ()
{
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        D[i] = 0;
        F[i] = 0;
        C[i] = WHITE;
        
        for (int j = 0; j < N; j++)
        {
            M[i][j] = 0;
        }
    }

    for (int i = 0; i < N; i++)
    {
        int u, k;
        cin >> u >> k;
        u--;

        for (int j = 0; j < k; j++)
        {
            int v;
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

/*
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (j > 0)
                cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }
*/
    T = 0;

    for (int i = 0; i < N; i++)
    {
        if (C[i] == WHITE)
        {
            dfs(i);
        }
    }

    /*
    stack<int> *S = new stack<int>;


    S->push(0);
    C[0] = GRAY;
    D[0] = ++time;

    while (S->size() > 0)
    {
        int u = S->top();
        int v = -1;

        // next 
        for (int i = 0; i < N; i++)
        {
            if (M[u][i] == 1)
            {
                if (C[i] == WHITE)
                {
                    v = i;
                    break;
                }
            }
        }

        if (v != -1)
        {
            C[v] = GRAY;
            D[v] = ++time;
            S->push(v);
        }
        else
        {
            S->pop();
            C[u] = BLACK;
            F[u] = ++time;
        }
    }
*/

    for (int i = 0; i < N; i++)
    {
        cout << i + 1 << " " << D[i] << " " << F[i] << endl;
    }
    return 0;
}





Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}





int main() {
  const double PI = acos(-1.0);
    double a, b, x;
    cin >> a >> b >> x;
    x /= a;
    cout << fixed << setprecision(10);
    if (x > a*b/2) cout << atan2((a*b-x)*2, a*a) * 180 / PI << endl;
    else cout << atan2(b*b, x*2) * 180 / PI << endl;

}

Measured memory_bytes: 4176
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

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

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

int N;

signed main()
{
	cin >> N;

	vector<int> a(N);
	rep(i, N) {
		cin >> a[i];
		a[i] -= i + 1;
	}

	sort(all(a));

	int mid = N % 2 == 0 ? (a[N / 2 - 1] + a[N / 2]) / 2 : a[N / 2];

	int ans = 0;
	rep(i, N) ans += abs(mid - a[i]);

	cout << ans << endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << (A + B >= C ? "Yes" : "No") << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while (x!=NIL){
      y=x;
      if(z->key < x->key){
          x=x->left;
      }else{
          x=x->right;
      }
  }
  
  z->parent =y;
  if(y==NIL){
      root=z;
  }else{
      if(z->key < y->key){
          y->left = z;
      }else{
          y->right=z;
      }
  }



}

void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}


int main(){
  int n, i, x;
  string com;
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    cin>>com;
    if ( com == "insert" ){
      scanf("%d", &x);
      insert(x);
    } else if ( com == "print" ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      
    }
  }

  return 0;
}


Measured memory_bytes: 26624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, X;
  int x[100000];
  cin>>N>>X;
  int ans;
  cin>>x[0];
  ans=abs(X-x[0]);
  for(int i=1;i<N;i++){
    cin>>x[i];
    ans=__gcd(ans,abs(X-x[i]));
  }
  cout << ans << endl;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int a[3]; cin >> a[0] >> a[1] >> a[2];
	cout << min({a[0]+a[1], a[0]+a[2], a[1]+a[2]});
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

namespace Atcoder
{
    class Program2
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] arg = Console.ReadLine().Split(' ');
            int[] h=new int[N];
            for(int i = 0; i < N; i++)
            {
                h[i] = int.Parse(arg[i]);
            }
            long sum = 0;
            for(int i = 0; i < N-1; i++)
            {
                if (h[i + 1] < h[i]){
                    sum += h[i ] - h[i+1];
                }
            }
            Console.WriteLine(sum + h[N - 1]);
        }
    }
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    string s;
    int k;
    cin >>s>>k;
    map<string,int>subs;

    rep(i,s.length()){
        string nstr=s.substr(i,1);
        rep1(j,0,k){
            if(i+j >= s.length())break;
            if(j!=0)nstr+=s[i+j];

            subs[nstr]=1;
            if(subs.size() > k){
                auto er=subs.end();--er;
                subs.erase(er);
            }
            string anser=subs.rbegin()->first;
            //db2(subs.size(),anser);ln;

        }
    }

    string anser=subs.rbegin()->first;
    //cout <<fixed<<setprecision(16)<< << endl;
    cout<< anser <<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

#include <iostream>
#include <algorithm>

#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>

#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>


using namespace std;
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#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);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false

bool comp(pair<double, string> p1, pair<double, string> p2) {
    if (p1.fi < p2.fi) return false;
    else if (p1.fi > p2.fi) return true;
    else return p1.se < p2.se;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;
        vector<pair<double, string>> ans(n);
        rep(i, n) {
            string l;
            double p, a, b, c, d, e, f, s, m;
            cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            double ti = a + b + c + (d + e) * m; 
            double tmp = (-p + s * f * m) / ti;
            ans[i].fi = tmp;
            ans[i].se = l;
        }
        sort(ans.begin(), ans.end(), comp);
        rep(i, n) {
            cout << ans[i].se << endl;
        }
        cout << '#' << endl;
    }


}

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


int main (){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    cout << d[n/2] -d[n/2-1] << endl;
    return 0;

}

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

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

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

int main(){
    int a,b,c,ans;
    int n;
    cin>>n;
    int arr[10001]={0};
    int s=100;

    for(int x=1;x<=s;x++){
       for(int y=1;y<=s;y++){
        for(int z=1;z<=s;z++){
       //cout<<x<<" "<<y<<" "<<z<<endl;
        ans=x*x + y*y + z*z + x*y + y*z + z*x;
        //cout<<ans<<endl;
        if(ans<10001){
        arr[ans]++;
        }

        }
        }
       }

     for(int i=1;i<=n;i++){
        cout<<arr[i]<<endl;
     }


    }



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

using namespace std;

int main(){
    int N,L,ans = 0;
    vector<int> v(0);
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> L;
        v.push_back(L);
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < N-1 ; ++i){
        for (int j = i + 1; j < N; ++j){
            int ll = i - distance(v.begin(), lower_bound(v.begin(), v.end(), v[j] - v[i] + 1));
        	ans += ll < 0? 0: ll;
        }
    }
    cout << ans;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,c=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=1;i<n-1;i++){
		if((a[i]>a[i-1]&&a[i]<a[i+1])||(a[i]<a[i-1]&&a[i]>a[i+1]))
		c++;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <array>
#include <bitset>
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define inf 0x3f3f3f3f3f3f3f3f
#define endl '\n'
using namespace std;

signed main() {
    fastio;
    string s;
    cin >> s;
    char l= s.back();
    if (l == 's') {
        cout << s + "es" << endl;
        return 0;
    }
    else {
        cout << s + "s" << endl;
        return 0;
    }
}

Measured memory_bytes: 3048
n = int(input())
t = str(input())
ans = 0
for i in range(1,len(t)):
    #print(t[:i], t[i:])
    left = list(t[:i])
    right = list(t[i:])
    #print(left,right)
    kyoutuu = set(left) & set(right)
    j = len(list(kyoutuu))
    if ans < j:
        ans = j
print(ans)
    


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

typedef struct point {double x, y;}p;

void koch(int n, p a, p b){
  if(n == 0) return;

  p s, t, u;
  double theta = M_PI/3;

  s.x = (2.0 * a.x + 1.0 * b.x)/3.0;
  s.y = (2.0 * a.y + 1.0 * b.y)/3.0;
  t.x = (1.0 * a.x + 2.0 * b.x)/3.0;
  t.y = (1.0 * a.y + 2.0 * b.y)/3.0;
  u.x = (t.x - s.x) * cos(theta) - (t.y - s.y) * sin(theta) + s.x;
  u.y = (t.x - s.x) * sin(theta) + (t.y - s.y) * cos(theta) + s.y;

  koch(n-1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n-1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n-1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n-1, t, b);
}

int main(){
  p a, b;
  int n;

  scanf("%d", &n);

  a.x = 0; a.y = 0;
  b.x = 100; b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}



Measured memory_bytes: 2088
//THE DOC

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define pb push_back
ll mod1=pow(10,9)+7;
int mod2=998244353;
ll inf=1e9;
ll maxxy=1e6+9;
typedef long double ld;
const double PI =  3.141592653589793238;

ll power(ll x, ll y, ll pp)
{
    ll res = 1;
    x = x % pp;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % pp;
        y = y>>1;
        x = (x*x) % pp;
    }
    return res;
}

ll modInverse(ll n, ll pp)
{
    return power(n, pp-2, pp);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll ans=0;
    for (int i = 0; i <s.size() ; ++i) {
        ans+=ll(s[i])-ll('0');
    }
    if(ans%9==0){
        cout<<"Yes"<<"\n";
    }
    else{
        cout<<"No"<<"\n";
    }
    return 0;
}


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

lli a, b, c;
lli x, y;

int main(void){
	cin >> a >> b >> c >> x >> y;
	c = 2*c;
	lli ans = INT_MAX;
	rep(i, 1e5+5){
		ans = min(ans, c*i+a*max(0LL, x-i)+b*max(0LL, y-i));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3536
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
long long combi(long long n, long long k) {
	if (n == k || k == 0)
		return 1;
	else {
		return combi(n - 1, k - 1) + combi(n - 1, k);
	}
}
long long gcd(long long a, long long b) {
	return a % b ? gcd(b, a%b) : b;
}
long long isPrime(long long x) {
	if (x <= 1) return 0;
	if (x == 2) return 1;
	for (int i = 2; i < sqrt(x); i++) {
		if (x % i == 0) return 0;
	}
	return 1;
}
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; }
int main() {
	int n;
	cin >> n;
	vector<int> h(n),d(n,0);
	REP(i, n) {
		cin >> h[i];
	}
	int k = 0, l = 0;
	while (l < n-1) {
		if (h[l] >= h[l + 1]) {
			d[k]++;
		}
		else k = l + 1;
		l++;
	}
	sort(all(d));
	cout << d.back() << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	string ss, tt;
	int64 nn, mm, kk;
	cin >> nn;
	if(nn < 600)
	{
		cout << 8 << endl;
		return 0;
	}
	if(nn < 800)
	{
		cout << 7 << endl;
		return 0;
	}
	if(nn < 1000)
	{
		cout << 6 << endl;
		return 0;
	}
	if(nn < 1200)
	{
		cout << 5 << endl;
		return 0;
	}
	if(nn < 1400)
	{
		cout << 4 << endl;
		return 0;
	}
	if(nn < 1600)
	{
		cout << 3 << endl;
		return 0;
	}
	if(nn < 1800)
	{
		cout << 2 << endl;
		return 0;
	}
	if(nn < 2000)
	{
		cout << 1 << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			int c = Integer.parseInt(chr[2]);
			System.out.println(a==b&&a==c?"1"
							  :a==b&&b!=c?"2"
							  :a==c&&b!=c?"2"
							  :b==c&&a!=c?"2"
							  :"3");
		}
	}
}


Measured memory_bytes: 25368
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int hash(const char *word)
{
	int code = 0;
	while(*word)
	{
		code <<= 2;
		switch(*word)
		{
			case 'A': code |= 0; break;
			case 'C': code |= 1; break;
			case 'G': code |= 2; break;
			case 'T': code |= 3; break;
		}
		++word;
	}
	return code;
}


int main()
{
	int n, p = 1;
	char *dic[12], cmd[8], word[16];
	
	for(int i = 0; i < 12; ++i)
	{
		p *= 4;
		dic[i] = malloc(p * sizeof(char));
		for(int j = 0; j < p; ++j)
		{
			dic[i][j] = 0;
		}
	}
	
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%s %s", cmd, word);
		if(strcmp(cmd, "insert") == 0)
		{
			dic[strlen(word)-1][hash(word)] = 1;
		}
		if(strcmp(cmd, "find") == 0)
		{
			printf(dic[strlen(word)-1][hash(word)] ? "yes\n" : "no\n");
		}
	}
	
	for(int i = 0; i < 12; ++i)
	{
		free(dic[i]);
	}
}



Measured memory_bytes: 23468
import math
from functools import reduce
 
def aaa(*numbers):
    return reduce(math.gcd, numbers)
 
num = int(input())
list = []
for i in range(1,num+1):
    for j in range(1,num+1):
        for k in range(1,num+1):
            list.append(aaa(i,j,k))
print(sum(list))

Measured memory_bytes: 189356
def solve():
    n = input()
    l = input().split()
    a = int(l.pop())
    for b in l:
        a = gcd(a,int(b))
    return a

def gcd(a,b):
    a,b = max(a,b), min(a,b)
    while b!=0:
        a,b = b,a%b
    return a

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

Measured memory_bytes: 11096
#include <cmath>
#include <functional>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector <int> a(n);
  ll tot = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    tot += a[i];
  }
  ll its = n * (ll) (n + 1) / 2;
  if (tot % its) {
    cout << "NO\n";
    return 0;
  }
  tot /= its;
  vector <ll> ders(n);
  for (int i = 0; i < n; i++) {
    ders[i] = a[(i + 1) % n] - a[i];
    ders[i] -= tot;
    if (ders[i] > 0 || ders[i] % n) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
}


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

int main(){
    int N;  cin >> N;
    map<int, int> mp;
    for(int i=0; i<N; i++){
        int a;  cin >> a;
        mp[a]++;
    }

    ll ans = 1;
    ll mod = 1e9 + 7;
    for(auto p : mp){
        int n = p.first;
        int cnt = p.second;
        if(N % 2 == 0 && n % 2 == 1 && cnt == 2){
            ans = (ans * 2)%mod;
            continue;
        }else if(N%2 == 1 && n % 2 == 0){
            if(n == 0 && cnt == 1){
                ans *= 1;
                continue;
            }else if(n > 0 && cnt == 2){
                ans = (ans * 2)%mod;
                continue;
            }
        }

        ans *= 0;
    }
    cout << ans << endl;
}   

Measured memory_bytes: 3200
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool compare_by_a(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    else return a.second<b.second;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
   vector<vector<ll>> a(3,vector<ll>(3));
   rep(i,3) rep(j,3) cin>>a[i][j];
   ll n;
   cin>>n;
   vector<ll> b(n);
    rep(i,n) {
        cin>>b[i];
        rep(j,3) rep(k,3){
            if(a[j][k]==b[i]) a[j][k]='.';
        }
    }
    if(a[0][0]=='.' && a[0][1]=='.' && a[0][2]=='.') {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(a[1][0]=='.' && a[1][1]=='.' && a[1][2]=='.') {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(a[2][0]=='.' && a[2][1]=='.' && a[2][2]=='.') {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(a[0][0]=='.' && a[1][0]=='.' && a[2][0]=='.') {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(a[0][1]=='.' && a[1][1]=='.' && a[2][1]=='.') {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(a[0][2]=='.' && a[1][2]=='.' && a[2][2]=='.') {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(a[0][0]=='.' && a[1][1]=='.' && a[2][2]=='.') {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(a[0][2]=='.' && a[1][1]=='.' && a[2][0]=='.') {
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
ls = [input().rstrip() for _ in range(h)]
ds = [[float('inf') for _ in range(w)] for _ in range(h)]
ds[0][0] = 1

dxdy = [(-1, 0), (1, 0), (0, -1), (0, 1)]

q = [[0, 0]]


def bfs():
    while q:
        x, y = q.pop()
        for i in range(4):
            dx, dy = dxdy[i]
            nx = x + dx
            ny = y + dy
            if 0 <= nx < w and 0 <= ny < h and ls[ny][nx] == '.':
                if ds[ny][nx] > ds[y][x] + 1:
                    ds[ny][nx] = ds[y][x] + 1
                    q.append([nx, ny])


bfs()
d = ds[h - 1][w - 1]
if d < float('inf'):
    s = sum([l.count('.') for l in ls])
    print(s - d)
else:
    print(-1)

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, K;
  cin >> N >> K;
  llvec S(N, 0);
  rep(i, K){
    ll d;
    cin >> d;
    rep(j, d){
      ll tmp;
      cin >> tmp;
      S[tmp-1]+=1;
    }
  }

  ll ans=0;
  rep(i, N){
    if(S[i]==0)ans++;
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
int main() {
    int n,x;
    while(cin>>n>>x&&n!=0){int cnt=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j)break;
            for(int k=1;k<=n;k++)
            {
                if(k==i)break;
                if(k==j)break;
                if(i+j+k==x)cnt++;
            }
        }
    }
        cout<<cnt<<endl;
    }}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define pc putchar
#define gc getchar
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void wri(ll x){write(x),pc(' ');}
void writeln(ll x){write(x);pc('\n');}
const int maxn = 500050;
const int mod = 1e9+7;
struct node{
	int x,v;
}a[maxn];
int l[maxn],r[maxn],f[maxn],pos[maxn];
bool operator < (node a,node b){
	return a.x < b.x;
}
bool cmp(int x,int y){
	return a[x].v < a[y].v;
}
int main(){
	int n = read();
	Rep(i,1,n){
		a[i].x=read(),a[i].v=read();
		pos[i] = i;
	}sort(a+1,a+1+n);
	sort(pos+1,pos+1+n,cmp);
	Rep(i,1,n) l[pos[i]]=r[pos[i]]=i;
	Rep(i,2,n) r[i]=max(r[i],r[i-1]);
	Dep(i,n-1,1) l[i]=min(l[i],l[i+1]);
	f[0]=1;
	for(int i=1,j=0,ans=1;i<=n;++i){
		while(j<l[i]-1) ans=(ans-f[j]+mod)%mod,j++;
		f[r[i]]=(f[r[i]]+ans)%mod;
		ans=(ans+ans)%mod;
	}writeln(f[n]);
	return 0;
}

Measured memory_bytes: 9344
/* Survive. Live. Win. Conquer.*/
 
 
#include<bits/stdc++.h>
using namespace std;
typedef long long LL ;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
#define ook order_of_key
#define fbk find_by_order
#define bug printf("TRUST\n");
#define pf printf
#define sf scanf
#define lp(i, n) for(int i = 0; i < n; i++)
#define rlp(n, i) for(int i = n - 1; i >= 0; i--)
#define bye vector<LL>
#define pb push_back
#define r0 return 0
#define ff first
#define ss second
#define mp make_pair
#define pii pair <int, int>
#define sz(a) ((int)a.size())
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define si(a) scanf("%d" , &a)
#define sl(a) scanf("%lld" , &a)
#define sii(a,b) scanf("%d %d" , &a , &b)
#define siii(a,b,c) scanf("%d %d %d" , &a , &b, &c)
#define sll(a,b) scanf("%lld %lld" , &a , &b)
#define slll(a,b,c) scanf("%lld %lld %lld" , &a , &b, &c)
#define FOR(i,a,b) for(LL i = (a) ; i <= (b) ; i++)
#define mod 1000000007
#define nod 200003
 
//using namespace __gnu_pbds;
//typedef tree < int, null_mapped_type ,less<int>,rb_tree_tag,tree_order_statistics_node_update > ordered_set;
 
void func(void)
{
        freopen("input.c","r",stdin);
        freopen("output.c","w",stdout);
}
 
map <char, LL> ch;
 
int main(){
//    ios_base::sync_with_stdio(0); cin.tie(0);
  //  system("COLOR F0");
    LL n, q, i,j = 0, temp, t, k, ans = 0, sum = 0, x, y, z, cnt = 0, m, fg = 0, mx = 0, mx1 = 0, mn = 8000000000000000000, mn1 = 8000000000000000000;
    string s;
    cin >> s;
    for(char c : s){
        ch[c]++;
    }
    for(char c = 'a'; c <= 'z'; c++){
        ans += (ch[c] * (ch[c] - 1))/2;
    }
   // cout << ans << endl;
    ans = (s.size() * (s.size() - 1))/2 - ans;
    cout << ans + 1 << endl;
   // cout << tt.size() << endl;
}

Measured memory_bytes: 644
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	auto n = IN<string>();
	if (n[0] == n[1] && n[1] == n[2])
		print("Yes");
	else if (n[1] == n[2] && n[2] == n[3])
		print("Yes");
	else
		print("No");
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;

int main() {

    int n;
    cin >> n;

    vector<int> A(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    int cnt = 1, type = 0;
    for (int i = 1; i < n; i++) {
        if (type == 0 && A[i] < A[i-1]) {
            type = 2;
        } else if (type == 0 && A[i] > A[i-1]) {
            type = 1;
        } else if (type == 2 && A[i] > A[i-1]) {
            type = 0; cnt++;
        } else if (type == 1 && A[i] < A[i-1]) { 
            type = 0; cnt++;
        }
    }
    
    cout << cnt << endl;

    return 0;
}

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

int main() {
    int N, T;
    cin >> N >> T;
    vector<pair<int, int>> p(N);
    rep(i, N) cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());
    int ans = 10000;
    rep(i, N) {
        if (p[i].second <= T) ans = min(p[i].first, ans);
    }
    if (ans == 10000) {
        cout << "TLE" << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}

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

int getPoint(int janken, int R, int S, int P){
    if (janken==0) return P;
    else if (janken==1) return R;
    else if (janken==2) return S;
    return 0;
}

int main(){
    int N, K, R, S, P;
    std::string T;
    cin >> N >> K >> R >> S >> P;
    cin >> T;

    int Tlist[N];
    std::string rock("r");
    std::string scissors("s");
    std::string paper("p");
    for (int i=0; i<N; i++){
        if (T.substr(i, 1)=="r") {
            Tlist[i] = 0;
        } else if (T.substr(i, 1)=="s") {
            Tlist[i] = 1;
        } else if (T.substr(i, 1)=="p") {
            Tlist[i] = 2;
        }
    }
    ll total = 0;
    int cur, prev;
    for (int i=0; i<K; i++){
        int index = i;
        prev = 3;
        while (true){
            cur = Tlist[index];
            if (cur != prev){
                total = total + getPoint(cur, R, S, P);
                prev = cur;
            } else {
                prev = 3;
            }
            index = index + K;
            if (index >= N) break;
        }
    }
    cout << total << endl;
}

Measured memory_bytes: 896
var
  a,b,i,j,k,s:longint;
begin
  readln(a,b);
  for i:=0 to a do
    for j:=0 to a do
      begin
        k:=b-i-j;
        if (k>=0)and(k<=a) then inc(s);
      end;
  writeln(s);
end.

Measured memory_bytes: 128
import sys
X,Y = map(int,input().split())
if (X+Y)%3 != 0:
    print(0)
    sys.exit()
A = Y - (X+Y)//3
B = X - (X+Y)//3
if A<0 or B<0:
    print(0)
    sys.exit()
N = A+B
def cmb(n, r, mod):
    inv = [0,1]
    for i in range(2, N + 1):
        inv.append((-inv[mod % i] * (mod // i)) % mod)
    cmd = 1
    for i in range(1,min(r,n-r)+1):
        cmd = (cmd*(N-i+1)*inv[i])%mod
    return cmd
    
a = cmb(N,A,10**9+7)
print(a)

Measured memory_bytes: 35228
#include<cstdio>
#include<algorithm>
using namespace std;

int n,t,ans=0x3fffffff;
int a[105];

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    for(int i=-100;i<=100;i++){
        int now=0;
        for(int j=1;j<=n;j++)
            now+=(a[j]-i)*(a[j]-i);
        ans=min(ans,now);
    }
    printf("%d",ans);
}


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

	public Main(){
		new AOJ0259().doIt();
	}
	
	class AOJ0259{
		String n;
		void solve(){
			int cnt = 0;
			while(n.equals("6174")==false){
				ArrayList<Integer> list = new ArrayList<Integer>();
				for(int i=0;i<4;i++)list.add(Integer.parseInt(n.charAt(i)+""));
				Collections.sort(list);
				String a="",b="";
				for(int i=3;i>=0;i--)a+=Integer.toString(list.get(i));
				for(int i=0;i<4;i++)b+=Integer.toString(list.get(i));
//				System.out.println(a+" "+b);
				n = Integer.toString((Integer.parseInt(a)-Integer.parseInt(b)));
//				System.out.println(n);
				cnt++;
				for(;n.length()!=4;)n="0"+n;
			}
			System.out.println(cnt);
		}
		
		void doIt(){
			while(in.hasNext()){
				n = in.next();
				if(n.equals("0000"))break;
				int a = 0;
				for(int i=0;i<4;i++)if(n.charAt(i)==n.charAt(0))a++;
				if(a!=4)solve();
				else System.out.println("NA");
			}
		}
	}
	
}

Measured memory_bytes: 72160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,m,n,a,b,sum=0,x=1000000;
    int arr[1000];
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    a=arr[0];
    b=arr[n-1];
    for(i=a;i<=b;i++)
    {
        sum=0;
        for(j=0;j<n;j++)
        {
            sum=sum+((i-arr[j])*(i-arr[j]));
        }
        if(x>sum)
        {
            x=sum;
        }



    }
    cout<<x;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    string  s,t;
    cin>>s>>t;
    int n=t.length();
    t=t.substr(0,n-1);
    if(s==t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;

int main(){
    long long N,a,b;
    a=2;
    b=1;
    scanf("%lld",&N);
    for (int i=0;i<N-1;i++){
        if (i%2==0){
                a += b;
        }else{
        b += a;
        }
        }
    if(N%2==0){
        printf("%lld\n",a);
    }else{
    printf("%lld\n",b);
    }
}


Measured memory_bytes: 384