akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 
// 24 4 6 --> 2
// 24 4 6 2 --> 1
const int mxN = 1e6 + 2;
int mult[mxN];

void flag(int n){
	for(int i = n; i < mxN; i += n){
		mult[i] = 1;
	}
}

void solve(){
	int n; cin >> n;
	int a[n];
	forn(i,0,n) cin >> a[i];
	sort(a,a+n);
	
	// catch duplicates
	forn(i,1,n){
		if(a[i] == a[i-1] && !mult[a[i]]) flag(a[i]);
	}
	int ans = 0;
	forn(i,0,n){
		int elm = a[i];
		if(mult[elm]) continue;
		++ans;
		flag(elm);
	}
	cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


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

#define dbg(x) cerr << #x"=" << x << endl;


int main(){
    //freopen("in.txt", "r", stdin);
    int N,K;
    cin >> N >> K;
    int a = N/2;
    if(N&1) ++a;
    cout << ((a >= K) ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,K=mi()
    A= [0] + list(mi())

    for j in range(1,N-K+1):
        if A[K+j] > A[j]:
            print("Yes")
        else:
            print("No")



if __name__ == "__main__":
    main()

Measured memory_bytes: 104664
#include<stdio.h>
int main()
{
    int a,b,c=0;
    while(~scanf("%d%d",&a,&b))
    {
        if(a<=2*b)
            printf("0\n");
        else
        {
            c=a-2*b;
            printf("%d\n",c);
        }
    }
    return 0;
}


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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))

int main() {
    int a, b;
    string s;

    cin >> a >> b;
    cin >> s;
    string pattern = "[0-9]{" + to_string(a) + "}-[0-9]{" + to_string(b) + "}"; 

    if(regex_match(s, regex(pattern))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



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

using namespace std;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

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

struct UnionFind {
  vi par; //par[i] : iの親番号（例）par[3] = 2 : 3の親は2

  UnionFind(int N) : par(N) { //最初は全てが根として初期化
    rep(i,N) par[i] = i;
  }

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

  void unite(int x, int y){ //xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if(rx == ry)return; //xとyの根が同じ
    par[rx] = ry; //xとyの根が同じでない時、xの根rxをyの根にryにつける。
  }

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

int main(){

  vi v(3);
  rep(i,3)cin >> v[i];
  sort(all(v));
  cout << v[2] - v[1] + v[1] - v[0] << endl;

 return 0;

}

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

using namespace std;

vector<string> v;

void v_push(string str){
	bool checker;
	
	checker = true;
	for(int len = 0; len < v.size(); len++){
		if(v.at(len) == str){
			checker = false;
			break;
		}
	}
	if(checker){
		v.push_back(str);
	}
}

string str_int(int num){
	string str = "";
	if(num == 0){
		str = "0";
		return str;
	}
	while(true){
		if(num == 0){
			break;
		}
		string d = "D";
		d[0] = '0' + (num % 10);
		str = d + str;
		num /= 10;
	}
	return str;
}

int main(){
	
	int n, k;
	
	int num[20];
	
	while(true){
		
		cin >> n >> k;
		
		if(n == 0 && k == 0){
			break;
		}
		
		for(int i = 0; i < n; i++){
			cin >> num[i];
		}
		
		string str;
		
		if(k == 2){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					if(i == j){
						continue;
					}else{
						str = str_int(num[i]) + str_int(num[j]);
						v_push(str);
					}
				}
			}
		}else if(k == 3){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					for(int k = 0; k < n; k++){
						if(i == j || i == k || j == k){
							continue;
						}else{
							str = str_int(num[i]) + str_int(num[j]) + str_int(num[k]);
							v_push(str);
						}
					}
				}
			}
		}else if(k == 4){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					for(int k = 0; k < n; k++){
						for(int l = 0; l < n; l++){
							if(i == j || i == k || j == k || i == l || j == l || k == l){
								continue;
							}else{
								str = str_int(num[i]) + str_int(num[j]) + str_int(num[k]) + str_int(num[l]);
								v_push(str);
							}
						}
					}
				}
			}
		}
		
		printf("%d\n", v.size());
		
		v.erase(v.begin(), v.end());
	}
	
	return 0;
}

Measured memory_bytes: 1368
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <queue>

template<typename T>
class TBinaryHeap
{
    std::vector<T> FArray;
public:
    TBinaryHeap()
    {
        FArray.reserve(2000000);
        FArray.resize(1); // dummy
    }
    void push(const T& Value)
    {
        std::size_t Index = FArray.size();
        FArray.push_back(Value);
        std::size_t Parent;
        while(Index > 1){
            Parent = Index / 2;
            if(FArray[Index] < FArray[Parent]) return;
            std::swap(FArray[Index], FArray[Parent]);
            Index = Parent;
        }
    }
    void pop()
    {
        assert(FArray.size() >= 1);
        FArray[1] = FArray.back();
        FArray.pop_back();

        std::size_t Size = FArray.size();
        std::size_t Index = 1;
        while(Index < Size){
            std::size_t Left = Index * 2;
            std::size_t Right = Left + 1;
            if(Left >= Size) break;
            std::size_t Target = Right >= Size ? Left : FArray[Left] > FArray[Right] ? Left : Right;
            if(FArray[Target] <= FArray[Index]) break;
            std::swap(FArray[Index], FArray[Target]);
            Index = Target;
        }
    }
    const T& top()
    {
        return FArray[1];
    }
};
int main()
{
    char Line[19];
    int Value;

    // std::priority_queue<int> S;
    TBinaryHeap<int> S;
    while(1){
        std::fgets(Line, 19, stdin);
        if(Line[0] == 'i'){
            S.push(std::atoi(&Line[7]));
        }else
        if(Line[1] == 'x'){
            std::printf("%d\n", S.top());
            S.pop();
        }else{
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 6216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <stack>
#include <queue>
#include <set>

#define mod 1000000007
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m);
    ll x = 0;
    rep(i, m){
        cin >> a[i];
        x += a[i];
    }
    sort(a.begin(), a.end());
    if(x > n){
        cout << -1;
    } else {
        x = 0;
        rep(i, m){
            x+=a[i];
            if(x > n){
                x-=a[i];
                break;
            }
        }
        cout << n-x;
    }
    return 0;
}

Measured memory_bytes: 3696
#include<stdio.h>
main(){
  int a,i,j,k,smp;
  int yama[10];
  for(i=0;i<10;i++){
    scanf("%d",&yama[i]);
  }
  for(j=0;j<10;j++){
    for(k=j+1;k<10;k++){
      if(yama[j] < yama[k]){
	smp = yama[j];
	yama[j] = yama[k];
	yama[k] = smp;
      }
    }
  }
  for(a=0;a<3;a++){
    printf("%d\n",yama[a]);
  }
  return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int memo[210][210][210];
int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int k; cin >> k;
    ll ans = 0;
    REP(a,1,k+1) REP(b,1,k+1) REP(c,1,k+1){
        if(memo[a][b][c] != 0){
            ans += memo[a][b][c];
        }else{
            memo[a][b][c] = memo[a][c][b] = memo[b][a][c] = memo[b][c][a] = memo[c][a][b] = memo[c][b][a] = __gcd(a, __gcd(b, c));
            ans += memo[a][b][c];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 37204
#include <iostream>
#include <string>

using namespace std;


int main()
{
    int N; 
    cin >> N;
    string S; cin >> S;
    if (N % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    int middle = N / 2;
    for (int i = 0; i < middle; i++) {
        if (S[i] != S[i + middle]) {
            cout << "No" << endl;
            return 0;
        }
    }
    

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define max 1000007
#define ll long long int
using namespace std;
vector <ll> primes;
void sieve()
{
    bool isprime[max+1];
    for(ll i=0;i<=max;i++) {
        isprime[i] = true;
    }
    isprime[0]=false;
    isprime[1]=false;
    for(ll i=3;i*i<=(max);i=i+2)
    {
        if(isprime[i]) {
            for (ll j = i*i; j  <= max; j=j+i) {
                isprime[j] = false;
            }
        }
    }
    primes.push_back(2);
    for(ll i=3;i<max;i=i+2)
    {
        if(isprime[i])
            primes.push_back(i);
    }
}
int main() {
    sieve();
    ll n,d,b,i,flag,x;
   scanf("%lld %lld",&d,&b);
    n=__gcd(d%b,b);
    set <int> s;
    s.insert(1);
    for(i=0;primes[i]*primes[i]<=n;i++)
    {
        while(n%primes[i]==0)
        {
            s.insert(primes[i]);
            n=n/primes[i];
        }
    }
    if(n>1)
        s.insert(n);
    printf("%lu",s.size());
    return 0;
}

Measured memory_bytes: 5092
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int sol = -n;
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        sol += x;
    }
    cout << sol;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
int n,x,m,a,b,c,k;
int main(){
  for(cin>>x,a=-118;a<120;a++){
    ll a5=pow(a,5);
    for(b=-119;b<119;b++){
      ll b5=pow(b,5);
      if(a5-b5==x)return printf("%d %d",a,b),0;
    }
  }
}

Measured memory_bytes: 4132
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main() {
  string s;
  cin >> s;
  int len = 0;
  int ans = 0;
  for(char c : s) {
    if(c == 'A' || c == 'C' || c == 'G' || c == 'T') {
      len++;
    }
    else {
      len = 0;
    }
    ans = max(ans , len);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main () {
	int a, b;
	cin >> a >> b;
	if(a < b) {
		for(int i = 0; i < b; i++) {
			cout << a;
		}
	}else {
		for(int i = 0; i < a; i++) {
			cout << b;
		}
	}
	return 0;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
"""
Lining up the cards
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0546

"""
import sys


from itertools import permutations

def solve(cards, k):
    return len(set([''.join(c) for c in permutations(cards, k)]))


def main(args):
    while True:
        n = int(input())
        k = int(input())
        if n == 0 and k == 0:
            break
        cards = [input()  for _ in range(n)]
        ans = solve(cards, k)
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 6088
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    string str[3];
    
    cin>>N;
    rep(i,3) cin>>str[i];
    
    ll ans=0;
    rep(i,N){
        ll tmp=0;
        set<char> st;
        rep(j,3){
            st.insert(str[j][i]);
        }
        int x = st.size();
        ans+=x-1;
    }
    cout1(ans)
}

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

int main(){
    int r;
    cin >> r;
    cout << 3*r*r << endl;
    

    return 0;
}

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

int main() {
    int h, w, k; cin >> h >> w >> k;
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    x1--; y1--; x2--; y2--;
    string f[h];
    for (string &s : f) cin >> s;
    queue<tuple<int, int, int> > q;
    const int INF = 1<<30;
    vector<vector<vector<int> > > dist(
        h, vector<vector<int> >(w, vector<int>(4, INF)));
    const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
    for (int d = 0; d < 4; d++) {
        dist[x1][y1][d] = 0;
        q.push({x1, y1, d});
    }
    while (!q.empty()) {
        const auto [x, y, d] = q.front();
        q.pop();
        if (x == x2 && y == y2) {
            cout << dist[x2][y2][d] << endl;
            return 0;
        }
        // cerr << x << " " << y << " " << d << " " << dist[x][y][d] << endl;
        for (int j = 1; j <= k; j++) {
            int u = x + dx[d] * j, v = y + dy[d] * j;
            // if (0 <= u && u < h && 0 <= v && v < w)
            //     if (flg) cerr << " " << i << " " << j << " " << u << " " << v << " " << f[u][v] << " " << dist[u][v] << endl;
            if (!(0 <= u && u < h && 0 <= v && v < w && f[u][v] == '.')) break;
            for (int d1 = 0; d1 < 4; d1++) {
                if (dist[u][v][d1] == INF) {
                    dist[u][v][d1] = dist[x][y][d] + 1;
                    if (d1 == d && j < k) continue;
                    if ((d1 ^ 2) == d) continue;
                    q.push({u, v, d1});
                    // cerr << x << " " << y << " -> " << u << " " << v << endl;
                }
            }
        }
    }
    cout << "-1\n";
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

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(){
	//input
	ll A,B; cin>>A>>B;

	
	//output
	cout<<(A+B-3)/(A-1);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

const int MAX = 100000;
const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
    stack<int> S;
    S.push(r);
    color[r] = c;

    while( !S.empty() ) {
        int u = S.top();
        S.pop();
        rep(i, G[u].size()) {
            int v = G[u][i];
            if(color[v] == NIL) {
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor() {
    int id = 1;
    rep(i, n) {
        color[i] = NIL;
    }
    rep(u, n) {
        if(color[u] == NIL) {
            dfs(u, id++);
        }
    }
}
 
int main() {
    int s, t, m, q;

    cin >> n >> m;

    rep(i, m) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    assignColor();

    cin >> q;

    rep(i, q) {
        cin >> s >> t;
        if(color[s] == color[t]) {
            cout << "yes" << endl;
        }
        else {
            cout << "no" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 8916
n,k=map(int,input().split())
lst=[_ for _ in range(1,n+1)]
for i in range(k):
  x=int(input())
  a=list(map(int,input().split()))
  b=set(a)
  for j in b:
    if j in lst:
      lst.remove(j)
print(len(lst))

Measured memory_bytes: 9136
# coding: utf-8

array = gets.chomp.split(' ')

# ??????????????????????????????????????????
cnt = Hash.new(0)
array.each do |word|
  cnt[word] += 1
end
max_pres = cnt.sort_by {|k, v| v}.pop[0]

# ??????????????°????????????????????????
max_len = array.sort_by {|item| item.length}.pop

# ???????????????
puts "#{max_pres} #{max_len}"

Measured memory_bytes: 6096
#include<stdio.h>
#define N 200000

int main(){
  int n,i,R[N],maxv,minv;

  scanf("%d",&n);
  for( i=0 ; i<n ; i++){
    scanf("%d",&R[i]);
  }

  maxv = R[1]-R[0];
  minv = R[0];

  for( i=1; i<n ; i++){
    if( maxv < R[i]-minv) maxv = R[i]-minv;
    if( minv > R[i]) minv = R[i];
  }

  printf("%d\n",maxv);
  return 0;
}

Measured memory_bytes: 1376
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	int a,b ;
	cin >> a >> b ;
	vvc ans(100,vc(100,'.')) ;
	for(int i=0;i<50;i++) for(int j=0;j<100;j++) ans.at(i).at(j) = '#' ;
	a-- ; b-- ;
	for(int i=0;i<49&&a>0;i+=2){
		for(int j=0;j<100&&a>0;j+=2){
			a-- ;
			ans.at(i).at(j) = '.' ;
		}
	}
	for(int i=51;i<100&&b>0;i+=2){
		for(int j=0;j<100&&b>0;j+=2){
			b-- ;
			ans.at(i).at(j) = '#' ;
		}
	}
	cout << "100 100\n" ;
	for(auto i:ans){
		for(auto j:i) cout << j ;
		cout << endl ;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
int main() {
    string str;
    cin >> str;
 
    auto size = str.size();
    vector<int> vec;
    vec.reserve(size);
    char pre = str[0];
    int a = 1;
    for (auto i = 1; i < size; ++i) {
        if (str[i] == '<') {
            if (pre == '<') {
                a ++;
            } else {
                vec.push_back(a);
                a = 1;
                pre = '<';
            }
        } else {
            if (pre == '>') {
                a ++;
            } else {
                vec.push_back(a * -1);
                a = 1;
                pre = '>';
            }
        }
    }
    if (pre == '>') {
        vec.push_back(a);
    } else {
        vec.push_back(a * -1);
    }
 
    /*
    for (auto n: vec) {
        cout << n <<  " ";
    }
    cout << endl;
    */
 
    long long sum = 0, last = 0;
    for (auto n : vec) {
        if (n > 0) {
            if (n <= last) {
                sum += last;
                // cout << last << ">";
                n -= 1;
            }
            for (auto i = n; i > 0; --i) {
                sum += i;
                // cout << i << ">";
            }
            // cout << endl;
        } else {
            n *= -1;
            for (auto i = 0; i < n; ++i) {
                sum += i;
                // cout << i << "<";
            }
            // cout << endl;
            last = n;
        }
    }
    if (vec[vec.size() - 1] > 0) {
        sum += 0;
        // cout << 0 << endl;
    } else {
        sum += last;
        // cout << last << endl;
    }
    cout << sum << endl;
 
 
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  
  int count = 0;
  int min = n+1;
  
  for(int i=0; i<n; i++){
    if(a[i] <= min){
      min = a[i];
      count++;
    }
  }
  
  cout << count << endl;
    
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;


public class Main {
	
	enum Direction {N,E,W,S}
	
	class Dice {
		
		int t,l,r;
		
		public Dice(int t, int l) {
			init(t,l);
		}
		
		void init(int t, int l) {
			this.t = t;
			this.l = l;
			this.r = 
					((t == 2 && l == 3) || (t == 3 && l == 5) || (t == 5 && l == 4) || (t == 4 && l == 2)) ? 1 :
					((t == 4 && l == 6) || (t == 6 && l == 3) || (t == 3 && l == 1) || (t == 1 && l == 4)) ? 2 :
					((t == 1 && l == 2) || (t == 2 && l == 6) || (t == 6 && l == 5) || (t == 5 && l == 1)) ? 3 :
					((t == 5 && l == 6) || (t == 6 && l == 2) || (t == 2 && l == 1) || (t == 1 && l == 5)) ? 4 :
					((t == 1 && l == 3) || (t == 3 && l == 6) || (t == 6 && l == 4) || (t == 4 && l == 1)) ? 5 :
					6;
		}
		
		int n() {return 7-l;}
		int e() {return r;}
		int s() {return l;}
		int w() {return 7-r;}
		int t() {return t;}
		int b() {return 7-t;}
		
		void roll(Direction d) {
			switch(d) {
			case N:
				init(l,b());
				break;
			case S:
				init(n(),t);
				break;
			case W:
				init(e(),l);
				break;
			case E:
				init(w(),l);
				break;
			}
		}
	}
	
	class Column {
		int h = 0;
		Dice d;
		public Column() {}
		void put(Dice d) {
			this.d = d;
			h++;
		}
		int getTop() {
			if(d == null) return 0;
			return d.t;
		}
	}
	
	class Map {
		int len = 200;
		Column[][] map = new Column[len][len];
		
		Column getc(int x, int y) {
			if(map[y][x] == null) map[y][x] = new Column();
			return map[y][x];
		}
		
		void drop(int x, int y, Dice d) {
			int curh = getc(x,y).h;
			int nh = getc(x,y-1).h;
			int sh = getc(x,y+1).h;
			int eh = getc(x+1,y).h;
			int wh = getc(x-1,y).h;
			
			for(int i=6; i>3; i--) {
				if(d.n() == i && nh < curh) {
					d.roll(Direction.N);
					drop(x,y-1,d);
					return;
				}
				else if(d.s() == i && sh < curh) {
					d.roll(Direction.S);
					drop(x,y+1,d);
					return;
				}
				else if(d.e() == i && eh < curh) {
					d.roll(Direction.E);
					drop(x+1,y,d);
					return;
				}
				else if(d.w() == i && wh < curh) {
					d.roll(Direction.W);
					drop(x-1,y,d);
					return;
				}
			}
			getc(x,y).put(d);
		}
		
		void drop(Dice d) {
			drop(len/2,len/2,d);
		}
		
		void print() {
			int[] nums = new int[6];
			for(int i=0; i<len; i++) {
				for(int j=0; j<len; j++) {
					if(map[i][j] != null && map[i][j].d != null) {
						nums[map[i][j].getTop()-1]++;
					}
				}
			}
			StringBuilder sb = new StringBuilder();
			for(int i:nums){sb.append(i).append(" ");}
			System.out.println(sb.toString().trim());
		}
		
	}
	
	public Main() {
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()) {
			int n = scanner.nextInt();
			if(n == 0) break;
			Map map = new Map();
			for(int i=0; i<n; i++) {
				map.drop(new Dice(scanner.nextInt(), scanner.nextInt()));
			}
			map.print();
		}
		scanner.close();
	}
	
	public static void main(String[] args) {
		new Main();
	}

}

Measured memory_bytes: 60100
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int N(55);
struct edge { int x, y; } e[N];
std::vector<int> A[N], B[N], G[N];
int T, n, fa[N], fb[N], deg[N], d[N], pre[N], ans;

void dfs(int x, std::vector<int> *v, int *f)
	{ for (auto i : v[x]) if (i != f[x]) f[i] = x, dfs(i, v, f); }

int main()
{
	for (T = read(); T--; )
	{
		n = read(), ans = n + 1;
		std::memset(deg, 0, (n + 1) << 2);
		std::memset(pre, 0, (n + 1) << 2);
		for (int i = 1; i <= n; i++) A[i].clear();
		for (int i = 1; i <= n; i++) B[i].clear();
		for (int i = 1, a, b; i < n; i++)
			++deg[a = read()], ++deg[b = read()], pre[a] = b, pre[b] = a, e[i] = (edge) {a, b};
		for (int i = 1, a, b; i < n; i++)
			a = read(), b = read(), B[a].push_back(b), B[b].push_back(a);
		for (int x = 1; x <= n; x++) if (deg[x] == 1)
			for (int p = pre[x], y = 1, fl = 1; y <= n; fl = 1, y++) if (y != x)
			{
				for (int i = 1; i <= n; i++) A[i].clear();
				for (int i = 1; i < n; i++) if ((e[i].x != x || e[i].y != p) && (e[i].x != p || e[i].y != x))
					A[e[i].x].push_back(e[i].y), A[e[i].y].push_back(e[i].x);
				A[x].push_back(y), A[y].push_back(x);
				std::memset(fa, 0, (n + 1) << 2), dfs(x, A, fa);
				std::memset(fb, 0, (n + 1) << 2), dfs(x, B, fb);
				for (int i = 1; i <= n; i++)
					if (fa[i] == fb[i] && fa[fa[i]] != fb[fb[i]]) { fl = 0; break; }
				if (!fl) continue;
				for (int i = 1; i <= n; i++) G[i].clear(); std::memset(d, 0, sizeof d);
				for (int i = 1; i <= n; i++) if (fa[i] != fb[i] && fa[fa[i]] != fb[fa[i]]) G[i].push_back(fa[i]), ++d[fa[i]];
				for (int i = 1; i <= n; i++) if (fa[i] != fb[i] && fa[fb[i]] != fb[fb[i]]) G[fb[i]].push_back(i), ++d[i];
				std::queue<int> Q;
				for (int i = 1; i <= n; i++) if (d[i] == 0) Q.push(i);
				while (!Q.empty()) { int x = Q.front(); Q.pop(); for (auto i : G[x]) if (!--d[i]) Q.push(i); }
				for (int i = 1; i <= n; i++) if (d[i]) { fl = 0; break; }
				if (!fl) continue;
				int sum = 0;
				for (int i = 1; i <= n; i++) sum += fa[i] != fb[i];
				ans = std::min(ans, sum + (p != y));
			}
		if (ans == n + 1) ans = -1;
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3120
#include <iostream>
using namespace std;
int main()
{
	int i,j,H,W;
	while (1){
		cin >> H >> W;
		if ( H == 0 && W == 0 )break;
		for ( i = 1; i <= H; i++){
			for ( j = 1; j <= W; j++ ){
				cout << "#" ;
			}
				cout << endl;
		}
		cout << endl;
	}
	return 0;
	}

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

int main(void)
{
    int N, M, X, A[101];
    cin >> N >> M >> X;
    for(int i=0; i<M; i++){
        cin >> A[i];
    }

    int left=0, right=0;
    // A[i]の値がスタート地点Xより右(左)なら右(左)に加算
    for(int i=0; i<M; i++){
        if(A[i] < X){
            ++left;
        }else{
            ++right;
        }
    }

    cout << min(left, right) << endl;

    return 0;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    ll N;
    std::cin >> N;

    vector<ll> cap(5);
    REP(i, 5) {
        std::cin >> cap[i];
    }

    std::cout << (ll)ceil(N / (long double)*min_element(ALL(cap))) + 4 << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int n;
  cin >> n;
  char s[n];
  string ans="Three";
  REP(i,n) {
    cin >> s[i];
    if(s[i]=='Y') ans="Four";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<cstdio>

int main(){
	int i,j;
	for(int n;scanf("%d",&n),n;){
		int p[10]={};
		for(i=n;i;--i)
			scanf("%d",&j),++p[j];
		for(i=0;i<10;++i,puts("")){
			for(j=0;j<p[i];++j)
				printf("*");
			if(!p[i])printf("-");
		}
	}
}

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

int main() {
  string s;
  cin >> s;
  bool a,b;
  a = false;
  b = false;
  
  if (s[2] == s[3]){
    a = true;
  };
  
  if (s[4] == s[5]){
    b = true;
  };
  
  if (a && b) {
    cout << "Yes";
  } else {
    cout << "No";
  };
};

Measured memory_bytes: 256
a = gets.to_i

if a == 4 ||  a == 6 ||  a == 9 ||  a == 10||  a == 14 ||  a == 21 ||  a == 22||  a == 25 ||  a == 26
  p 2
elsif   a == 8 ||  a == 12 ||  a == 18 ||  a == 27
  p 5
elsif a == 16
  p 14
elsif a == 24
  p 15
elsif   a == 28 ||  a == 30
  p 4
elsif a == 32
  p 51
else
  p 1
end
  

Measured memory_bytes: 1788
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using namespace std;

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define NAME ""
#define int long long

const long long MOD = 1e9 + 7;
long long inq(long long a, long long b)
{
    if (b == 0) return 1;
    long long l = inq(a, b / 2);
    if (b % 2) return l * l % MOD * a % MOD;
    return l * l % MOD;
}

long long n;
long long x[500000];
long long len[500000];
long long k[500000];
signed main()
{
    cin >> n;
    for (int i = 0; i < n; i++) cin >> x[i];
    long long f = 1;
    long long ans = 0;
    for (int i = 0; i < n - 1; i++) len[i] = x[i + 1] - x[i];
    for (int i = 1; i <= n - 1; i++) f = f * i % MOD;
    for (int i = 0; i < n - 1; i++)
    {
        if (k > 0) k[i] = k[i - 1];
        k[i] = (k[i] + f * inq(i + 1, MOD - 2)) % MOD;
        //cout << k[i] << " ";
    }
    //cout << endl;
    for (int i = 0; i < n - 1; i++) ans = (ans + len[i] * k[i]) % MOD;
    cout << ans;
}


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


int main()
{
	string s;
	cin>>s;
	string t;
	cin>>t;
	int N_t=t.size();
	int N_s=s.size();
	if(N_t>N_s)
	{
		cout<<"UNRESTORABLE"<<endl;
		return 0;
	}
	bool is_match=false;
	for(int i=N_s-1;i>=N_t-1;i--)
	{
		bool flag=true;
		for(int j=0;j<N_t;j++)
		{
			if(!(s[i-j]=='?'||s[i-j]==t[N_t-1-j]))
			{
				flag=false;
				break;	
			}
		}
		if(flag)
		{
			is_match=true;
			for(int j=0;j<N_t;j++)
			{
				s[i-j]=t[N_t-1-j];
			}
			break;
		}
	}
	if(!is_match)
	{
		cout<<"UNRESTORABLE"<<endl;
	}
	else
	{
		rep(i,N_s)
		{
			if(s[i]=='?') s[i]='a';
		}
		cout<<s<<endl;
	}
	return 0;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> vec(M);
  for (int i = 0; i < M; i++) {
  cin >> vec.at(i);
} 
  for (int i = 0; i < M; i++){
    N -=vec.at(i);
  }
  if(N >= 0){
    cout << N << endl;
  }else{
    cout << "-1" << endl;
  }
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <algorithm>
#include <deque>
using namespace std;

deque<int> p[26];
char S[200200];
int b[200200],l;

void in(int x, int p)
{
	while (x <= l){
		b[x] += p;
		x += x & (-x);
	}
}

int out(int x)
{
	int r = 0;
	while (x){
		r += b[x];
		x -= x & (-x);
	}
	return r;
}

int main()
{
	scanf ("%s",S);
	while (S[l]) l++;
	for (int i=0;S[i];i++) p[S[i]-'a'].push_back(i+1), in(i+1,1);

	int u = 0;
	for (int i=0;i<26;i++) u += p[i].size() % 2;
	if (u > 1) puts("-1");
	else{
		long long r = 0; int v = l;
		for (int i=1;i<=l;i++) if (out(i) - out(i-1) == 1){
			auto &d = p[S[i-1]-'a'];
			if (d.size() == 1){
				r += v / 2;
				in(i,-1);
				d.clear();
				v--;
			}
			else{
				int x = d.front(); d.pop_front();
				int y = d.back(); d.pop_back();
				r += v - out(y);
				in(x,-1); in(y,-1);
				v -= 2;
			}
		}
		printf ("%lld\n",r);
	}
	return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    rep(0, n) {
        if (i == k - 1) cout << char(tolower(s[i]));
        else cout << s[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<cstring>
using namespace std;
long long A,B,C,D,n,now,x,i;
inline long long read()
{
    long long x=0,f=1;
    char ch=getchar();
    while (ch<'0'||ch>'9')
    {
        if (ch=='-') f=-1;
        ch=getchar();
    }
    while (ch<='9'&&ch>='0')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
inline void write(long long x)
{
    if (x<0) putchar('-'),x=-x;
    if (x>=10) write(x/10);
    putchar(x%10+'0');
}
int main()
{
				n=read();
				n--;
				now=A=read();
				B=read();
				C=read();
				D=read();
				for (i=1;i<=n;i++) now-=D;//,a[i]=-D;
				if (now>B)
				{
								puts("NO");
								return 0;
				}
				for (i=1;i<=n;i++)
								if (now+C+D<=B) now+=C+D;//,a[i]=C;
				x=D-C;
				for (i=1;i<=n;i++)
				{
								if (now+x<=B) now+=x;//,a[i]+=x;
								else
								{
										//		a[i]+=B-now;
												now=B;
												break;
								}
				}
				if (now==B) puts("YES");
				else puts("NO");
//				for (i=1;i<=n;i++) printf("%d ",a[i]);
}

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

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

  deque<char> dq;
  for(int i=0; i<S.size(); i++){
    dq.push_back(S[i]);
  }

  bool flag = false;
  for(int i=0; i<Q; i++){
    int T;
    cin >> T;
    if(T == 1){
      flag = !flag;
    }else{
      int F;
      char C;
      cin >> F >> C;
      if(F==1){
        if(!flag){
          dq.push_front(C);
        }else{
          dq.push_back(C);
        }
      }else{
        if(!flag){
          dq.push_back(C);
        }else{
          dq.push_front(C);
        }
      }
    }
  }

  string ans = "";
  if(flag){
    for(int i=dq.size()-1; i>=0; i--){
      ans += dq[i];
    }
  }else{
    for(int i=0; i<dq.size(); i++){
      ans += dq[i];
    }
  }

  cout << ans << endl;
}


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

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef vector<int> vi;

int main() {
    int N, tmp;
    vi d(N);

    cin >> N;
    REP(i, N) {
        cin >> tmp;
        d.emplace_back(tmp);
    }

    sort(d.begin(), d.end());

    int result = 0;

    if (d[N/2] > d[N/2-1]) {
        result = d[N/2] - (d[N/2-1]+1) + 1;
    }

    cout << result << endl;

    return 0;
}

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

int count=0; 
int BubbleSort(int A[],int N){
   
    bool flag=1;
    while(flag){
        flag=0;
        for(int j=N-1;j>=1;j--){
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                count++;
                flag=1;
            }
        }
    }
    return count;
}

int main(){
    int num=0;
    cin >> num;
    int array[num];
    for(int i=0;i<num;i++){
        cin >> array[i];
    }
    int i = BubbleSort(array,num);
    for(int i=0;i<num-1;i++){
        cout << array[i] << " ";
    }
    cout << array[num-1] << endl << count << endl;
    return 0;
     
}

Measured memory_bytes: 3088
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#define MAX(a,b) ((a)>(b)?(a):(b)) 


int main()
{
	int N,R;
	scanf("%d%d",&N,&R);
	if(N>=10)printf("%d",R);
	else printf("%d",R+100*(10-N));
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int N;
    cin >> N;
    map<string, bool>mp;
    int cnt = 0;
    for (int i=0; i<N; i++){
        string si;
        cin >> si;
        if(mp[si] == false)cnt++;
        mp[si] = true;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 19120
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
//#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int solve(int n){
    int ret=0;
    rep(i,1,n+1){
        if(n%i==0)ret++;
    }
    return ret;

}

int main(){
    int n;
    cin>>n;
    int ans=0;
    rep(i,1,n+1){
        if(i%2==1&&solve(i)==8)ans++;
    }
    cout<<ans<<endl;

}



    

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

public class Main {
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Main() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(j = 0; j < totalVertex; j ++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}
		}
		int u, v;
		for(i = 0; i < totalVertex; i ++) {
			u = in.nextInt();
			int degree = in.nextInt();
			for(j = 0; j < degree; j ++) {
				v = in.nextInt(); 
				adjMatrix[u][v] = 1;
				adjWeight[u][v] = in.nextInt();
			}	
		}
		in.close();
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	
	public int min(int x, int y) {
		if(x < y) {
			return x;
		}
		else {
			return y;
		}
	}
	
	//implement the following	
	public int[] Dijkstra(int s) {
		int[] curr = new int[totalVertex];
		
		int src = s;
		// set distances at max 
		for(int i = 0; i < totalVertex; i++) {
			curr[i] = Integer.MAX_VALUE;
		}
		// source is always zero and is automatically settled
		curr[src] = 0;
		
		int mv = getUnsettledNearest(curr);
		while (mv > -1) {
			ifSettled[mv] = true;
			LinkedList<Integer> neighbors = getUnsettledNeighbors(mv);
			for(Integer n : neighbors) {
				curr[n] = Math.min(curr[n], curr[mv] + getWeight(mv, n));
			}
			mv = getUnsettledNearest(curr);
		}
		
		return curr;
		
	}
	
	public static void main(String[] args) {
		
		Main g = new Main();
		g.loadAdjMatrix();
		int[] dist = g.Dijkstra(0);
		for(int i = 0; i < g.getTotalVertex(); i ++) {
			System.out.println(i + " " + dist[i]);
		}

	}

}



Measured memory_bytes: 40320
#import sys
#import math
#import numpy as np

'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
#n,l= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
a=int(input())
li=[int(x) for x in input().split()]
ans=ju=0
for i in range(a):
  ju=max(ju,li[i])
ans=sum(li)-ju
if ans-ju>0:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 2940
N = int(input())
A = list(map(int, input().split()))

A_dict = dict()
for i in range(N):
    if A[i] in A_dict:
        A_dict[A[i]] += 1
    else:
        A_dict[A[i]] = 1
        
sum_all = 0
for k, v in A_dict.items():
    sum_all += v*(v-1)//2
    
for i in range(N):
    num = A_dict[A[i]]
    ans = sum_all - (num*(num-1)//2) + ((num-1)*(num-2)//2)
    print(ans)


Measured memory_bytes: 26524