akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <numeric>
#include <limits>

const long long int Z = 1000000007;
const long long int INF = 1 << 30;
int flag = 0;
const int V = 10;
struct edge { int to, cost; };
std::vector<edge>v[100];
typedef std::pair<int, int>p;

int main() {
	long long int h, w, ans = 100000000000000;
	std::cin >> h >> w;
	if (h == 2 && w == 2) {
		std::cout << 1 << std::endl;
	}
	else {
		for (int i = 1;i < h - 1;i++) {
			long long int a, b, c, max = 0, min = 100000000000;
			a = i*w;
			if (max < a) {
				max = a;
			}
			if (min > a) {
				min = a;
			}
			b = (h - i)*(w / 2);
			if (max < b) {
				max = b;
			}
			if (min > b) {
				min = b;
			}
			c = (h - i)*(w - w / 2);
			if (max < c) {
				max = c;
			}
			if (min > c) {
				min = c;
			}
			if (ans > max - min) {
				ans = max - min;
			}
		}
		for (int i = 1;i < h - 1;i++) {
			long long int a, b, c, max = 0, min = 100000000000;
			a = i*w;
			if (max < a)max = a;
			if (min > a)min = a;
			b = ((h - i) / 2) * w;
			if (max < b)max = b;
			if (min > b)min = b;
			c = (h - i - (h - i) / 2)*w;
			if (max < c)max = c;
			if (min > c)min = c;
			if (ans > max - min) {
				ans = max - min;
			}
		}
		for (int i = 1;i < w - 1;i++) {
			long long int a, b, c, max = 0, min = 100000000000;
			a = h*i;
			if (max < a)max = a;
			if (min > a)min = a;
			b = (h / 2)*(w - i);
			if (max < b)max = b;
			if (min > b)min = b;
			c = (h - h / 2)*(w - i);
			if (max < c)max = c;
			if (min > c)min = c;
			if (ans > max - min) {
				ans = max - min;
			}
		}
		for (int i = 1;i < w - 1;i++) {
			long long int a, b, c, max = 0, min = 100000000000;
			a = h*i;
			if (max < a)max = a;
			if (min > a)min = a;
			b = h  * ((w - i) / 2);
			if (max < b)max = b;
			if (min > b)min = b;
			c = h * (w - i - (w - i) / 2);
			if (max < c)max = c;
			if (min > c)min = c;
			if (ans > max - min) {
				ans = max - min;
			}
		}
		std::cout << ans << std::endl;
	}
	return 0;
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, a, b;
  cin >> n >> a >> b;
  int x[n];
  rep(i, n) cin >> x[i];
  int ans = 0;
  reps(i, 1, n) {
    ans += min((x[i]-x[i-1])*a, b);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	rep(i,n){
		if(s[i]==s[i+1]&&i+1<n){
			cout << i+1 <<" " << i+1+1 << endl;
			return 0;
		}else if(s[i]==s[i+1+1]&&i+1+1<n){
			cout << i+1 <<" " << i+1+1+1 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[100100];

li fold_l[100100];
li fold_r[100100];

int main() {
    li n;
    cin >> n;
    rin{
        cin >> a[i];
    }

    fold_l[0] = a[0];
    repp(i, 1, n) {
        fold_l[i] = __gcd(fold_l[i - 1], a[i]);
    }

    fold_r[n - 1] = a[n - 1];
    for (li i = n - 2; i >= 0; i--) {
        fold_r[i] = __gcd(fold_r[i + 1], a[i]);
    }

    li res = max(fold_r[1], fold_l[n - 2]);
    repp(i, 1, n - 1) {
        res = max(res, __gcd(fold_l[i - 1], fold_r[i + 1]));
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

class Main{
    public static void main(String[] a){
    	int x, y ,tmp;
    	Scanner in = new Scanner(System.in);
      while (true){
      	x = in.nextInt();
      	y = in.nextInt();
      	if(x == 0 && y == 0) break;
      	if(x<y)
        	System.out.println(x + " " + y);
        else
        	System.out.println(y + " " + x);
      }
    }
}

Measured memory_bytes: 34888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200001 ;
vector<ll>v[N] ;
ll a[N] ;
ll ans[N] ;
vector<ll>tl(N) ;
ll len=0 ;
void dfs(ll i,ll p){
    ll f=0 ;
    ll in,pre ;
     if(len==0){
         f=1 ;
         tl[len++]=a[i] ;
     }
     else{
        auto st=tl.begin(),ed=tl.begin()+len ;
        auto it=lower_bound(st,ed,a[i]) ;
        if(it==tl.begin()+len)
        {
            tl[len++]=a[i] ;
            f=1 ;
        }
        else
        {
            pre=*it ;
            *it=a[i] ;
            in=(ll)(it-tl.begin()) ;
        }
     }

     ans[i]=len ;
     for(ll j:v[i]){
        if(j==p){
            continue ;
        }
        dfs(j,i) ;
     }
     if(f==1)
     {
         len-- ;
     }
     else
     {
         tl[in]=pre ;
     }
}
int main()
{
   fast ;
   ll n ; cin>>n ;
   for(ll i=1;i<=n;i++) cin>>a[i] ;

   for(ll i=0;i<n-1;i++){
    ll x,y ; cin>>x>>y ;
    v[x].pb(y) ;
    v[y].pb(x) ;
   }
   dfs(1,-1) ;
   for(ll i=1;i<=n;i++) cout<<ans[i]<<endl ;


}



Measured memory_bytes: 33208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
using vi = vector<int>;
using vll = vector<ll>;
const ll INF = 1LL<<60;

int main(){
  int n; cin >> n;
  string ans = "No";
  for(int i = 0; i < 100; i++){
    for(int j = 0; j < 100; j++){
      int now = 4 * i + 7 * j;
      if(now == n) ans = "Yes";
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void BFS(vector<vector<long long>>&Graph, vector<bool>&reach, long long start) {
    queue<long long>Q;
    Q.push(start);
    reach.at(start)=true;
    while(!Q.empty()) {
        long long v = Q.front(); Q.pop();
        for (auto next_v : Graph[v]) {
            if (reach.at(next_v)) continue;
            reach.at(next_v)=true;
            Q.push(next_v);
        }
    }
}
typedef pair<long long, long long> P;
int main() {
  long long N, M; cin>>N>>M;
  vector<P>A(M);
  vector<vector<long long>>Graph(N);
  for (long long i = 0; i < M; i++) {
      cin >> A.at(i).first >> A.at(i).second;
      Graph.at(A.at(i).first - 1).push_back(A.at(i).second - 1);
      Graph.at(A.at(i).second - 1).push_back(A.at(i).first - 1);
  }
  long long ans = 0;
  vector<bool>reach(N, false);
  for (long long i = 0; i < N; i++) {
      if (!reach.at(i)) {
          ans++;
          BFS(Graph, reach, i);
      }
  }
  cout << ans - 1 << endl;
}

Measured memory_bytes: 10916
import sys

def input(): return sys.stdin.readline()[:-1]

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

#N = int(input())
_, S = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = tuple(map(int, input().split()))
#S = [list(map(int, input().split())) for i in range(N)]
mod=998244353

ans=0
dp=[0]*(S+1)
for a in map(int, input().split()):
    dp[0]+=1
    for i in range(S,a-1,-1):
        dp[i]+=dp[i-a]
        dp[i]%=mod
    ans+=dp[-1]
    ans%=mod
    #print(dp)

print(ans)


Measured memory_bytes: 9424
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#include <numeric>
#include <stdio.h>
#include <map>
#include <iomanip>
#include <sstream>
//#include <boost/math/common_factor_rt.hpp>
#include<fstream>
#define EPS (1e-7)
using namespace std;
#define ll long long



class Employee {
public:
	int id;
	int parent;
	vector<int> children;
	int salary;

	Employee() {
		
	}

	Employee(int num, int nparent) {
		id = num;
		parent = nparent;
		salary = -1;
	}



};



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



int main() {
	ll N;
	cin >> N;
	ll ans;
	if (N == 1) {
		ans = 0;
	}
	else{
		ans = (1 + N - 1) * (N - 1) / 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#define MAX_N 100005
#define pii pair<int,int>
#define ll long long
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
using namespace std;
int n, m, src;
vector<pair<int, int> >g[MAX_N];
ll dis[MAX_N];
bool vis[MAX_N];
void dfs(int u)
{
    for(int i=0;i<g[u].size();i++)
    {
        int v=g[u][i].first;
        if(vis[v]==0)
        {
            vis[v]=1;
            dis[v]=min(dis[v],dis[u]+g[u][i].second);
            dfs(v);
        }
    }
}
int main()
{
    //FREI;
    std::ios::sync_with_stdio(false);
    cin>>n;
    int u,v,cost;
    for(int i=0;i<n-1;i++)
    {
        cin>>u>>v>>cost;
        g[u].push_back(pii(v,cost));
        g[v].push_back(pii(u,cost));
    }
    for (int i = 0; i <= n; i++) dis[i] = 1LL<<63-1;
	memset(vis, 0, sizeof(vis));
    int q,k;
    cin>>q>>k;
    src=k;
    vis[k]=1;
    dis[k]=0;
    dfs(k);
    for(int i=0;i<q;i++)
   {
       cin>>u>>v;
       cout<<dis[u]+dis[v]<<endl;
   }
    return 0;
}


Measured memory_bytes: 12800
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = new String[n];
        for(int i = 0 ; i < n ; i++){
            s[i] = sc.next();
        }
        sc.close();
        boolean ebishu = true;
        for(int i = 1 ; i < n && ebishu ; i++){
            if(s[i - 1].charAt(s[i - 1].length() - 1) != s[i].charAt(0)) ebishu = false;
        }
        Arrays.sort(s);
        for(int i = 1 ; i < n && ebishu ; i++){
            if(s[i - 1].equals(s[i])) ebishu = false;
        }
        if(ebishu){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35888
n = int(input())
a = list(map(int, input().split()))
 
def gcd(n, m):
    if(m): return gcd(m, n%m)
    else: return n
 
def lcm(n, m):
    return n // gcd(n, m) * m
 
LCM = a[0]
for i in range(1, n):
    LCM = lcm(a[i], LCM)
 
res = 0
MOD = 1000000007
for i in range(n):
    res += LCM//a[i]
    
print(res % MOD)

Measured memory_bytes: 4084
S = input()
S_list = ["" for i in range(len(S) - 2)]
for i in range(len(S)-2):
    S_list[i] = S[i:i+3]
min = 999
for i in range(len(S) - 2):
    a = int(S_list[i]) - 753
    if a < 0:
        a = a * (-1)
    if a < min:
        min = a

print(min)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int h[10];
  rep(i,10){
    cin >> h[i];
  }
  sort(h,h+10);
  reverse(h,h+10);
  rep(i,3){
    cout << h[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 100005
#define pb push_back
#define vit vector<int>::iterator
typedef pair<lint,lint> pii;
map<lint,lint>M;
vector<lint> V[MAX];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int sum=0;
    string S;
    cin>>S;
    for(auto c:S){
        sum+=c-'0';
    }
    if(sum%9) cout<<"No";
    else cout<<"Yes";
    return 0;
}


Measured memory_bytes: 5860
s = input()
num = len(s)
n1 = s[0:(num-1) // 2]
n2 = s[(len(s)+3) // 2-1:]

if s == s[::-1] and n1 == n1[::-1] and n2 == n2[::-1]:
  print("Yes")
else:
  print("No")
  

Measured memory_bytes: 9092
import math
import itertools
n = int(input())
pos_lis = []
for i in range(n):
  x, y = map(int,input().split())
  pos_lis.append({'pos':(x,y)})
for k in range(n-1):
  x1 = pos_lis[k]['pos'][0]
  y1 = pos_lis[k]['pos'][1]
  for l in range(k+1,n):
    x2 = pos_lis[l]['pos'][0]
    y2 = pos_lis[l]['pos'][1]
    leng = math.sqrt((x1-x2)**2 + (y1-y2)**2)
    pos_lis[k][l] = leng
    pos_lis[l][k] = leng
numbers = list(range(n))
p = list(itertools.permutations(numbers, n))
len_sum = []
for j in range(len(p)):
	len_sum.append(sum([pos_lis[p[j][t]][p[j][t+1]] for t in range(n-1)]))
ans = sum(len_sum) / len(p)
print(ans)



Measured memory_bytes: 9276
def main():
    n = int(input())
    D = map(int, input().split())
    m = int(input())
    T = map(int, input().split())
    dic = dict()
    
    # 辞書はDだけで十分.Counterより速い.
    for d in D:
        if d in dic:
            dic[d] += 1
        else:
            dic[d] = 1
            
    for t in T:
        if t not in dic or dic[t] == 0:
            print('NO')
            return
        else:
            dic[t] -= 1
    print('YES')
main()

Measured memory_bytes: 59108
'use strict';

function Main(INPUT) {
    const input = INPUT.split("\n")[0].split("");
    let min = Number(input[0] + input[1] + input[2]);
    for (let i = 1; i <= input.length - 3; i++) {
        let tmp = Number(input[i] + input[i + 1] + input[i + 2])
        if (Math.abs(753 - min) > Math.abs(753 - tmp)) {
            min = tmp
        }
    }
    console.log(Math.abs(753 - min));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	string s, t; cin >> s >> t;
	int ns = s.size(), nt = t.size();
	vector<int> fs(ns + 1, 0), ft(nt + 1, 0);
	REPU(i, 0, ns) {
		fs[i + 1] = fs[i] + (s[i] == 'A');
	}
	REPU(i, 0, nt) {
		ft[i + 1] = ft[i] + (t[i] == 'A');
	}
	int q; cin >> q;
	REPU(_, 0, q) {
		int a, b, c, d; cin >> a >> b >> c >> d;
		int mod1 = (2 * (fs[b] - fs[a - 1]) - (b - a + 1)) % 3;
		if (mod1 < 0) mod1 += 3;
		int mod2 = (2 * (ft[d] - ft[c - 1]) - (d - c + 1)) % 3;
		if (mod2 < 0) mod2 += 3;
		puts(mod1 == mod2 ? "YES" : "NO");
	}

	return 0;
}


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

int main(){
	char x[10005];
while(scanf("%s",&x)!=EOF){
	int k=0,JOI=0,IOI=0;
	while(x[k+2]!='\0'){
		if(x[k+1]=='O'&&x[k+2]=='I'){
			if(x[k]=='J')JOI++;
			if(x[k]=='I')IOI++;
		}
		k++;
	}
	printf("%d\n%d\n",JOI,IOI);
	for(int i=0;i<10005;i++)x[i]='\0';
}
}

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

int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i,N){
        cin >> X.at(i);
    }
    int64_t A = 0,B = 100000000;
    rep(i,100){
        rep(j,N){
            A += pow(X.at(j) - i,2);
        }
        if (A < B){
            B = A;
        }
        A = 0;
    }
    cout << B << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
A=[int(input()) for i in range(n)]
data=collections.deque()
for i, ai in enumerate(A):
    k=bisect.bisect_left(data,ai)
    if k==0:
        data.appendleft(ai)
    else:
        data[k-1]=ai
print(len(data))

Measured memory_bytes: 46940
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-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(){
    string a,b,c; cin >> a >> b >> c;
    string ans="";
    ans+=toupper(a[0]);
    ans+=toupper(b[0]);
    ans+=toupper(c[0]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
h, w, K = STDIN.gets.split(' ').map(&:to_i)

dp = Array.new(h + 1) { Array.new(w, 0)}
dp[0][0] = 1

MOD = 1000000007

for i in 0..(h - 1) do
  for j in 0..(w - 1) do
    for k in 0..((1 << (w - 1)) - 1) do

      invalid = false

      for l in 0..(w - 3) do
        if (((k >> l) & 1) == 1) && (((k >> l + 1) & 1) == 1)
          invalid = true
          break
        end
      end

      # puts "i:#{i} j:#{j} k:#{k} invalid:#{invalid}"
      next if invalid

      if (j >= 1) && (((k >> j - 1) & 1) == 1)
      # go left
        dp[i + 1][j - 1] += dp[i][j]
        dp[i + 1][j - 1] %= MOD
      elsif (j <= w - 2) && (((k >> j) & 1) == 1)
        # go right
        dp[i + 1][j + 1] += dp[i][j]
        dp[i + 1][j + 1] %= MOD
      else
        # go straight
        dp[i + 1][j] += dp[i][j]
        dp[i + 1][j] %= MOD
      end

    end
  end
end

puts dp[h][K - 1]


Measured memory_bytes: 1788
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [[0]*M]*N
ans = 0
sum = 0
for i in range(N):
  A[i] = list(map(int, input().split()))
for i in range(N):
  sum = 0
  for j in range(M):
    sum += A[i][j] * B[j]
  sum += C
  if sum > 0:
    ans += 1
      
print(ans)

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

using namespace std;

#define all(x) x.begin(), x.end()
#define inf ((int) 1e9)
#define Linf ((long long) 1e18)

typedef long long ll;
typedef long double ld;

const int N = 123456;
const int M = 1234567;
const int P = 400004;
const int A = 256;

ll ncr(int n, int r){

	if(n < r)
		return 0;

	if(n < 0 || r < 0)
		return 0;

	if(n == r)
		return 1;

	return ncr(n - 1, r - 1) + ncr(n - 1, r);
}


void qsort(auto * a, int i, int j){

	if(i >= j) return;

	int l = i;
	int r = j;

	while(r > l){ 

		while(r > l && a[r] >= a[l]) r--;

		if(a[r] < a[l]){
			swap(a[r], a[l]);
		}

	}	

	qsort(a, i, r - 1);
	qsort(a, r + 1, j);

	return;
}


auto bpow(auto base, auto exp, auto MOD){

	ll ans = 1;
	for(; exp; exp>>=1){
		if(exp & 1)
			ans = (ans * base) % MOD;
		base = (base * 1ll * base) % MOD;
	}

	return ans;
}

int main(int argc, char const *argv[])
{
	
	#ifdef Cyborg1o1
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	

	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	string str;
	cin >> str;


	stack<char> ss;

	int l = 0, r = 0;
	for(int i = 0; i < n; ++i){
		if(str[i] == '('){
			ss.push(str[i]);
			r++;
		}
		else if(ss.size() && ss.top() == '('){
			ss.pop();
			r--;
		}
		else{
			ss.push(str[i]);
			l++;
		}
	}

	if(!ss.empty()){

		// int left = 0, right = 0;
		// for(int i = 0; i < n; ++i)
		// {
		// 	if(str[i] == ')') left++;
		// 	if(str[i] == '(') right++;
		// }


		for(int i = 0; i < l; ++i)
			str = '(' + str;

		for(int i = 0; i < r; ++i)
			str += ')';

	}

	cout << str << endl;

	return 0;					
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int gcd(int a,int b)
{
    if(a%b==0)
        return b;
    else
        return gcd(b,a%b);
}
int main()
{
    long long int a,b,c;
    scanf("%lld %lld",&a,&b);
    if(b>a)
    {
        int tem=a;
        a=b;
        b=tem;
    }
    c=gcd(a,b);
    long long int ans;
    ans=a*b/c;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	int n, x;
	while(cin >> n >> x){
		if(n == 0 && x == 0)break;
		int ans = 0; 
		for(int i = 1; i <= n; i++){
			for(int j = i + 1; j <= n; j++){
				for(int k = j + 1; k <= n; k++){
					if(i + j + k == x){
						set<int> s;
						s.insert({i, j, k});
						if((int)s.size() == 3)ans++;
					}
				}
			}
		}
		cout << ans << "\n";
	}
	return 0;
}



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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    ll n, k;
    cin >> n >> k;
    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));

    ll ub = 1e18, lb = -1e18;
    while (ub - lb > 1) {
        ll mid = (ub + lb) / 2;
        auto is_smaller = [&](ll x) {
            ll cnt = 0;
            rep(i, n) {
                if (a[i] >= 0) {
                    ll l = -1, r = n;
                    while (r - l > 1) {
                        ll o = (l + r) / 2;
                        if (a[i] * a[o] < x) {
                            l = o;
                        } else {
                            r = o;
                        }
                        // debug(l);
                        // debug(r);
                        // debug(o);
                    }
                    cnt += r;
                } else {
                    ll l = -1, r = n;
                    while (r - l > 1) {
                        ll o = (l + r) / 2;
                        if (a[i] * a[o] < x) {
                            r = o;
                        } else {
                            l = o;
                        }
                        // debug(l);
                        // debug(r);
                        // debug(o);
                    }
                    cnt += n - r;
                }

                if (a[i] * a[i] < x) cnt--;
            }
            cnt /= 2;
            return cnt < k;
        };

        // debug(mid);
        if (is_smaller(mid)) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    out(lb);
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int no = 1, temp;
        while((temp = sc.nextInt())!=0){
            System.out.printf("Case %d: %d\n",no++, temp);
        }
        }
    }


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int W, a, b; cin >> W >> a >> b;
    int ans;
    if(a+W < b) ans = b - (a+W);
    else if(b+W < a) ans = a - (b+W);
    else ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;


void solution();

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}



void solution(){
    ll n;
    cin >> n;
    bool ans = true;
    from(i, n){
        ll tmp;
        cin >> tmp;
        if(tmp%2 == 0){
            if(tmp%3 != 0 && tmp%5 != 0){
                ans = false;
            }
        }
    }

    if(ans){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
}   

Measured memory_bytes: 256
function Main(input) {
	var r = 0;
	var b = 0;
	input = input.split("\n");
	var arr = input[1].split("");
	for(var i=0;i<arr.length;i++){
		if(arr[i]=="R") r++;
		else b++;
	}
	console.log(r>b?"Yes":"No")
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

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

int main() {
  int H,W;
  cin >> H >> W;
  
  vector<vector<char>> data(H, vector<char>(W));
 
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data.at(i).at(j);
      if (j == W - 1){
        for (int k = 0; k < W; k++) {
          if (k != W - 1){
            cout << data.at(i).at(k);
          }
          else {
            cout << data.at(i).at(k) << endl;
          }
        }
        for (int k = 0; k < W; k++) {
          if (k != W - 1){
            cout << data.at(i).at(k);
          }
          else {
            cout << data.at(i).at(k) << endl;
          }
        }
      }
    }
  }
}
        
 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const long long mod = 1e9 + 7;

ll h, w;
vector<string> s;
vector<vector<bool>> c;
vector<ll> vx = {1, -1, 0, 0};
vector<ll> vy = {0, 0, -1, 1};
ll lb;
ll lw;

void dfs(ll y, ll x, char col)
{
    c[y][x] = 1;
    
    char nextcol;
    if (col == '.')
    {
        nextcol = '#';
    }
    else
    {
        nextcol = '.';
    }
    
    for (int i = 0; i < vx.size(); ++i)
    {
        ll nextx = x + vx[i];
        ll nexty = y + vy[i];
        if (nextx >= 0 && nextx < w && nexty >= 0 && nexty < h && !c[nexty][nextx] && s[nexty][nextx] == nextcol)
        {
            if (nextcol == '#')
            {
                lb++;
            }
            else
            {
                lw++;
            }
            dfs(nexty, nextx, nextcol);
        }
    }
}

int main() {
    
    
    cin >> h >> w;
    s = vector<string>(h);
    c = vector<vector<bool>>(h, vector<bool>(w, 0));
    
    for (int i = 0; i < h; ++i)
    {
        cin >> s[i];
    }
    ll ret = 0;
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            dfs(i, j, s[i][j]);
            if (s[i][j] == '#')
            {
                lb++;
            }
            else
            {
                lw++;
            }
            ret += (lb * lw);
            lb = 0;
            lw = 0;
        }
    }
    
    
    cout << ret << endl;
    
    
    return 0;
}

Measured memory_bytes: 13056
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
typedef long long ll;

ll calc(ll B, ll C, ll D, ll E) {
   ll tmp[] = {B, C, D, E};
   sort(tmp, tmp + 4);
   return abs(tmp[0] - tmp[3]);
}

int main() {
   int N;
   cin >> N;
   int A[N];
   ll S[N + 1];
   S[0] = 0;
   for (int i = 0; i < N; i++) {
      cin >> A[i];
      S[i + 1] = S[i] + A[i];
   }
  
   ll ans = -1;
   ll B = A[0], C = A[1], D = A[2], E = S[N] - S[3];
   int left = 1, right = 3;
   ans = calc(B, C, D, E);
   for (int i = 2; i < N - 1; i++) {
      // cout << "---" << i << endl;
      // cout << B << " " << C << " " << D << " " << E << endl; 
      while (left < i && abs(B + A[left] - C + A[left]) <= abs(B - C)) {
         B += A[left];
         C -= A[left];
         left++;
      }
      // cout << "left: " << left << endl;
      // cout << B << " " << C << " " << D << " " << E << endl; 
      while (right < N && abs(D + A[right] - E + A[right]) <= abs(D - E)) {
         D += A[right];
         E -= A[right];
         right++;
      }
      // cout << "right: " << right << endl;
      // cout << B << " " << C << " " << D << " " << E << endl; 
      if (ans == -1) ans = calc(B, C, D, E);
      else if (ans > calc(B, C, D, E)) ans = calc(B, C, D, E);

      C += A[i];
      D -= A[i];
   }

   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        final int t = fs.nextInt();
        int res = (int) 1e9;
        for (int i = 0; i < n; i++) {
            final int cost = fs.nextInt();
            final int time = fs.nextInt();
            if (time <= t) {
                res = Math.min(res, cost);
            }
        }
        System.out.println(res == (int) 1e9 ? "TLE" : res);
    }

    static final class Utils {
        public static void shuffleSort(int[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffleSort(long[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffle(int[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void shuffle(long[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void swap(int[] arr, int i, int j) {
            final int t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        public static void swap(long[] arr, int i, int j) {
            final long t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        private Utils() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 32788
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n; cin >> n;
	
	LL ans = 0;
	for (int i = 0; i < n+1; i++) {
		if (i % 3 == 0 || i % 5 == 0)continue;
		ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

const int INF = 1e9;

int main(){
    int h,w;
    cin >> h >> w;
    int table[10][10];
    int dp[10][10];
    
    rep(i,10){
        rep(j,10){
            dp[i][j] = INF;
        }
    }

    rep(i,10){
        rep(j,10){
            cin >> table[i][j];
            if(table[i][j] != -1) dp[i][j] = table[i][j];
        }
    }

    rep(k,10){
        rep(i,10){
            rep(j,10){
            
                dp[i][j] = min(dp[i][j],dp[i][k] + dp[k][j]);
            }
        }
    }

    rep(i,10){
        rep(j,10){
            rep(k,10){
                dp[i][j] = min(dp[i][j],dp[i][k] + dp[k][j]);
            }
        }
    }

    int tmp;
    int ans = 0;
    rep(i,h){
        rep(j,w){
            cin >> tmp;
            if(tmp == -1) continue;
            ans += dp[tmp][1];
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];

    sort(ALL(d));
    cout << d[n/2] - d[n/2-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
// ░█████╗░░░░░░░░░░░░░░░
// ██╔══██╗░░██╗░░░░██╗░░
// ██║░░╚═╝██████╗██████╗
// ██║░░██╗╚═██╔═╝╚═██╔═╝
// ╚█████╔╝░░╚═╝░░░░╚═╝░░
// ░╚════╝░░░░░░░░░░░░░░░
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define f(ii,n) for(ii=0;ii<n;ii++)
#define F(ii,a,n) for(ii=a;ii<n;ii++)
#define read(array,n) for(ll i=0;i<n;i++) cin>>array[i];
#define inf 1000000007;
// function to transform string to lowercase --> transform(s.begin(),s.end(),s.begin(),::tolower)
//(a + b ) % m = (a % m + b % m ) %m
//(a - b ) % m = ( (a % m - b % m ) + m ) %m
//(a * b ) % m = (a % m * b % m ) %m
//(a / b ) % m = (a % m * inv(b) ) %m where inv(b) = pow(b,m,m-2)



ll power(ll i,ll j){
	ll prod=1;
	while(j>0){
		if(j&1){
			prod=prod*i;
		}
		j=j>>1;
		i=i*i;
	}
	return prod;
}


void solve(){
	ll i,j,n;
	string s;
	cin>>s;
	if(s=="ABC"){
		cout<<"ARC\n";
	}
	else{
		cout<<"ABC\n";
	}
}
int main(){
	// freopen("filename.txt","r",stdin);
	solve();
	
	// ll t;
	// cin>>t;
	// while(t--){
	// 	solve();
	// }
}

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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

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

    LL n, m;
    cin >> n >> m;

    VVl v;
    v.resize(n + 5);

    for(LL i = 1; i <= m; i++){
        LL a, b;
        cin >> a >> b;

        v[a].Pb(b);
        v[b].Pb(a);
    }

    for(LL i = 1; i <= n; i++)
        cout << v[i].size() << '\n';

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
 
  int time=0,i,head=0,tail,n,k,x[100000];
  char p[100000][10];
 
  scanf("%d %d",&n,&k);
  tail =n;
  for(i =0; i <n; i++) {
    scanf("%s %d",p[i],&x[i]);
  }
 
 
  while(tail != head) {
    if(x[head] > k) {
      time += k;
      x[head] -= k;
 
      strcpy(p[tail],p[head]);
      x[tail] = x[head];
      tail++;
      if(tail == 100000) {
        tail = 0;
      }
    }
    else{
      time += x[head];
      printf("%s %d\n",p[head],time);
    }
    head++;
    if(head == 100000) {
      head = 0;
    }
  }
  return 0;
}



Measured memory_bytes: 3160
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

# import numpy as np
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, L = map(int, readline().split())
F = [L + i for i in range(N)]
F.sort(key=lambda x: abs(x))

print(sum(F[1:]))


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

using namespace std;

int main()
{
	string s;
	cin>>s;
	for(int i=0;i<(int)s.size();i++) {
		if(s[i]=='7') {
			puts("Yes");
			return 0;
		}
	}	
	puts("No");
	return 0;
} 


Measured memory_bytes: 3628
#include<stdio.h>

int main(){
  int i, j, num, n, stc[4][13] = { 0 };
  char rank;

  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    scanf(" %c %d",&rank ,&num);
	switch(rank){
	case 'S': stc[0][num - 1] = 1;
	  break;
	case 'H': stc[1][num - 1] = 1;
	  break;
	case 'C': stc[2][num - 1] = 1;
	  break;
	case 'D': stc[3][num - 1] = 1;
	  break;
	}
  }
  for(i = 0; i < 4; i++){
    for(j = 0; j < 13; j++){
      if(stc[i][j] == 0){
	    if(i == 0) rank = 'S';
		else if(i == 1) rank = 'H';
		else if(i == 2) rank = 'C';
		else if(i == 3) rank = 'D';
		printf("%c %d\n",rank, j + 1);
	  }
	}
  }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

#include <atcoder/convolution>
#include <atcoder/dsu>
#include <atcoder/fenwicktree>
#include <atcoder/lazysegtree>
#include <atcoder/math>
#include <atcoder/maxflow>
#include <atcoder/mincostflow>
#include <atcoder/modint>
#include <atcoder/scc>
#include <atcoder/segtree>
#include <atcoder/string>
#include <atcoder/twosat>

using namespace atcoder;
//typedef modint998244353 mint;

int main(){
  string S;
  cin>>S;
  ll N=S.size();
  VI SA=suffix_array(S);
  VI L=lcp_array(S,SA);
  ll ans=N*(N+1)/2;
  rep(i,N-1) ans-=L[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 15672
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  map<string, int> mp;
  int n;
  cin >> n;
  int m = -1;
  REP(i, n) {
    string s;
    cin >> s;
    mp[s]++;
    m = max(mp[s], m);
  }

  vector<string> ans;
  for (auto i = mp.begin(); i != mp.end(); i++) {
    if (i->second == m) {
      ans.push_back(i->first);
    }
  }
  sort(ALL(ans));
  REP(i, (int)ans.size()) { cout << ans[i] << endl; }
  return 0;
}


Measured memory_bytes: 26868