akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



n = I()
L = LI()
A = sorted(list(set(L)))
if len(A) == 1:
    if 1 <= A[0] <= n // 2 or A[0] == n - 1:
        print('Yes')
    else:
        print('No')
elif len(A) == 2 and A[0] + 1 == A[1]:
    cnt = Counter(L)
    min_type_num = cnt[min(L)]  + 1
    max_type_num = cnt[min(L)] + cnt[max(L)] // 2
    if min_type_num <= max(L) <= max_type_num:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 60324
n, m, x = map(int, input().split())
A = [[] for i in range(m)]
eff = [[] for i in range(m)]
price = []
for a in range(n):
    a = list(map(int, input().split()))
    price.append(a[0])
    for j in range(m):
        A[j].append(a[j+1])


for a in A:
    if sum(a) < x:
        print(-1)
        exit()


min_money = 1<<30
for bits in range(1<<n):
    sum_temp = [0] * m
    sum_money = 0
    for j in range(n):
        if bits>>j & 1:
            sum_money += price[j]
            for i in range(m):
                sum_temp[i] += A[i][j]
    else:
        ok = True
        for i in sum_temp:
            if i < x:
                ok = False
                break
        if ok:
            min_money = min(min_money, sum_money)



print(min_money)
        

Measured memory_bytes: 9192
#include<iostream>
#include<complex>
#include<cmath>
using namespace std;
#define EPS 1e-10

int main(void){
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		double x1, y1, x2, y2, x3, y3, x4, y4;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		if( abs((x2-x1)*(y4-y3) - (x4-x3)*(y2-y1))<EPS )
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys
from itertools import product
H, W, M = map(int, input().split())
hsum = [0 for i in range(H)]
wsum = [0 for i in range(W)]
s = set()
for i in range(M):
    h, w = map(int, input().split())
    h, w = h-1, w-1
    s.add((h, w))
    hsum[h] += 1
    wsum[w] += 1

hmax = max(hsum)
wmax = max(wsum)

hmax_index = []
for i in range(H):
    if hsum[i] == hmax:
        hmax_index.append(i)
wmax_index = []
for i in range(W):
    if wsum[i] == wmax:
        wmax_index.append(i)

for x in hmax_index:
    for y in wmax_index:
        if (x, y) not in s:
            print(hmax+wmax)
            sys.exit()
print(hmax+wmax-1)

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int n, x;
    cin >> n >> x;

    vector<int> m(n);
    int sum = 0;
    for(int in=0;in<n;in++) {
        cin >> m.at(in);
        sum += m.at(in);
    }

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

    cout << n + (x-sum)/m.at(0) << endl;
    
    return 0;
}


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

int main() {
  int h, w, m;
  cin >> h >> w >> m;
  vector<int> vh(h), vw(w);
  set<pair<int, int>> s;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    vh[a]++;
    vw[b]++;
    s.insert({a, b});
  }
  int maxh = 0, maxw = 0;
  for (int i : vh) maxh = max(maxh, i);
  for (int i : vw) maxw = max(maxw, i);
  vector<int> maxvh, maxvw;
  for (int i = 0; i < h; i++) if (maxh == vh[i]) maxvh.push_back(i);
  for (int i = 0; i < w; i++) if (maxw == vw[i]) maxvw.push_back(i);
  int ans = maxh + maxw;
  for (int i : maxvh) for (int j : maxvw) {
    if (s.count(pair<int, int>(i, j))) continue;
    cout << ans << endl;
    return 0;
  }
  cout << ans - 1 << endl;
  return 0;
}

Measured memory_bytes: 23852
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N;
ll A[SIZE];
ll S[SIZE];

int main(){
  cin >> N;
  rep(i,0,N){
    cin >> A[i];
    S[i] = A[i];
  }
  rep(i,0,N-1){
    S[i+1] += S[i];
  }

  ll ans = INF;

  int l=0,r=2;
  rep(t,1,N-2){
    while(abs(S[t]-2*S[l]) > abs(S[t]-2*S[l+1]))l++;
    while(abs(S[N-1]-2*S[r]+S[t]) > abs(S[N-1]-2*S[r+1]+S[t]))r++;
    ans = min(ans, max({S[l],S[t]-S[l],S[N-1]-S[r],S[r]-S[t]})
      - min({S[l],S[t]-S[l],S[N-1]-S[r],S[r]-S[t]}));
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3328
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<string>

typedef long long ll;
using namespace std;

char a[100000];
int main()
{
	int x = 0, max = 0;
	int N,i;
	scanf("%d",&N);
	scanf("%s",a);
	N = strlen(a);
	for(i = 0; i < N; i++)
	{
		if(a[i] == 'I')
		{
			x++;
			max = max > x ? max : x;
		}
		if(a[i] == 'D')
		{
			x--;
		}
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


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


int main(){
  int n;
  int d, x;
  cin >>n >> d >> x;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = x;
  for(int i = 0; i < n; ++i){
    ans += ((d - 1) / a[i]) + 1;
  }

  cout << ans << endl;
}


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

int main(){
    int m,f,b;
    cin >> m >> f >> b;
    if(m>=b)cout << "0" << endl;
    else{
        if(b-m<=f){
            int n=b-m;
            cout << n << endl;
        }else{
            cout << "NA" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3080
#include<cstdio>
bool a[400000];
int main(void)
{
    int n,k,t,cnt=0,num=0;
    scanf("%d %d" ,&n,&k);
    for(int i=0;i<n;i++)
        scanf("%d" ,&t);
    while(a[n-1]==false){
        for(int i=cnt;i<cnt+k;i++)
            a[i]=true;
        cnt+=k-1;
        num++;
    }
    printf("%d" ,num);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))[::-1]

def f():
    if N == 1:
        return True

    for i in range(N - 1):
        if H[i] >= H[i + 1]:
            continue

        d = H[i + 1] - H[i]
        if d == 1:
            H[i + 1] -= 1
            continue

        return False

    return True


print("Yes" if f() else "No")

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

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

string s;

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

	cin>>s;
	cout<<"2018";
	FOR(i,4,s.size()) cout<<s[i];
	cout<<endl;

	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int n,m,x,y;
	vector<int> X,Y;
	cin>>n>>m>>x>>y;
	X.push_back(x);Y.push_back(y);
	rep(i,n){
		cin>>x;
		X.push_back(x);
	}
	rep(i,n){
		cin>>y;
		Y.push_back(y);
	}
	sort(all(X));
	sort(all(Y));
	if(X[X.size()-1] < Y[0]){
		cout<<"No War"<<endl;
	}else{
		cout<<"War"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c, s, e) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define PI acos(-1l)
const int M = 1000000007;
const int N = 3e5 + 5;
const long long INF = 1e18 + 37;

#ifdef rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif


void solve(){
    int n;
    cin >> n;
    int k = n/1000;
    int k1 = (n+1000-1)/1000;
    cout << abs(k1*1000 - n);
}


signed main() {
    FAST
    int tc = 1;
//    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
}

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
  string s;
  int in,iw,is,ie;
  in=iw=is=ie=0;
  std::cin >> s;
  rep(i,s.size()){
    if(s[i]=='N') in++;
    if(s[i]=='S') is++;
    if(s[i]=='W') iw++;
    if(s[i]=='E') ie++;
  }
  if(in==0&&is==0&&iw==0&&ie==0){
    std::cout << "Yes" << std::endl;
  }else if(in>0&&is>0&&iw==0&&ie==0){
    std::cout << "Yes" << std::endl;
  }else if(iw>0&&ie>0&&in==0&&is==0){
    std::cout << "Yes" << std::endl;
  }else if(iw>0&&ie>0&&in>0&&is>0){
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cout << "No" << std::endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  map<string ,int>mp;
  set<string>st;
  string a;
  int mx=-1,n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
            mp[a]++;
            st.insert(a);
  }
  for(string chos: st){
        if(mp[chos]>mx)mx = mp[chos];
       }
  for(string it:st){
    if(mp[it]==mx)cout<<it<<endl;
  }
return 0;
}


Measured memory_bytes: 34560
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
#define MOD 1000000007
//scanf("%d", &a) '\n'

int main() {
	int x;
	cin >> x;
	int key;
	key=x/100;
	x = x - key * 100;
	if (5 * key < x) cout << 0 << endl;
	else cout << 1 << endl;

}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s;

    cin>>s;
    int counter=0,len = s.length();

    for(int i=0;i<len/2;i++){
        if(s[i]!=s[len-1-i]){
            counter++;
        }
    }

    cout<<counter<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    char S[5];
    cin>>(S+1);
    if((S[1]==S[2]&&S[3]==S[4]&&S[2]!=S[3])||(S[1]==S[3]&&S[2]==S[4]&&S[1]!=S[2])||(S[1]==S[4]&&S[2]==S[3]&&S[1]!=S[2]))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    //std::cout << "Hello, World!" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,i,j,n,m[301],d[1001][3];
	while(scanf("%d%d%d",&a,&b,&c),a!=0){
		for(i=0;i<=a+b+c;i++)m[i]=2;
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d%d%d%d",&d[i][0],&d[i][1],&d[i][2],&d[i][3]);
			if(d[i][3]==1)m[d[i][0]]=1,m[d[i][1]]=1,m[d[i][2]]=1;
		}
		for(i=0;i<n;i++){
			if(m[d[i][0]]==1 && m[d[i][1]]==1 && m[d[i][2]]==2)m[d[i][0]]=1,m[d[i][1]]=1,m[d[i][2]]=0;
			if(m[d[i][0]]==1 && m[d[i][1]]==2 && m[d[i][2]]==1)m[d[i][0]]=1,m[d[i][1]]=0,m[d[i][2]]=1;
			if(m[d[i][0]]==2 && m[d[i][1]]==1 && m[d[i][2]]==1)m[d[i][0]]=0,m[d[i][1]]=1,m[d[i][2]]=1;
		}
		for(i=1;i<=a+b+c;i++)printf("%d\n",m[i]);
	}
	return 0;
}


Measured memory_bytes: 2016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    double N;
    cin >> N;

    int m = 3501;
    for(int i = 1; i < m; i++){
        for(int j = 1; j < m; j++){
            double w = N*i*j/(4.0*i*j-N*(i+j));
            if(w<1){continue;}
            ll w2 = (ll)w;
            if((double)w2 == w){
                cout << i << " " << j << " " << (ll)w;
                return 0;
            }
        }
    }


}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int dy[2] = {1,0};
int dx[2] = {0,1};
int h,w;
vector<string>s(10);

int main(){
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    map<string, int>mp;
    mp[s] = a;
    mp[t] = b;
    mp[u]--;
    cout << mp[s] << " " << mp[t] << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
using namespace std;

bool IsInside(double x1,double y1,double r1, double x2,double y2) {
    return ((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2) <= r1*r1);
}

double Distance(double x1,double y1,double x2,double y2) {
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

double ComputeDist(double x1, double y1, double r1,
                   double x2, double y2, double r2) {
    
    if (IsInside(x1,y1,r1,x2,y2))
        return 0;
    
    if (IsInside(x2,y2,r2,x1,y1))
        return 0;
    
    
    double d = Distance(x1,y1,x2,y2);
    if (d <= r1+r2)
        return 0;
    else
        return d-r1-r2;
        
    
    
}

bool done[1002];
double min_dist[1002];

double D[1002][1002];
double X[1002];
double Y[1002];
double R[1002];

int main(){
    double xs,ys,xt,yt;
    cin>>xs>>ys>>xt>>yt;
    
    
    int N;
    cin>>N;
    for(int i=1;i<=N;i++) {
        cin>>X[i]>>Y[i]>>R[i];
    }
    
    X[N+1]=xs;
    Y[N+1]=ys;
    X[N+2]=xt;
    Y[N+2]=yt;
    
    
    for(int i=1;i<=N+2;i++) {
        for(int j=1;j<=N+2;j++) {
            D[i][j]=ComputeDist(X[i],Y[i],R[i],X[j],Y[j],R[j]);
        }
    }
    
    for(int i=1;i<=N+2;i++) {
        done[i]=false;
        min_dist[i]=-1;
    }
    
    
    set<pair<double, int> > verts;
    verts.insert(make_pair(0,N+1));
    
    while(!verts.empty()) {
        
        set<pair<double,int> >::iterator it = verts.begin();
        
        int u = it->second;
        double dist = it->first;
        
        verts.erase(it);
        
        if (done[u])
            continue;
        
        done[u]=true;
        min_dist[u] = dist;
        
        if (u==N+2)
            break;
        
        for(int v=1;v<=N+2;v++) {
            // D[u][v].
            
            if (done[v])
                continue;
            double next_dist = dist + D[u][v];
            verts.insert(make_pair(next_dist, v));
        }
    }
    
    
    printf("%1.11f\n",min_dist[N+2]);
    
    
    
    
    
    
}

Measured memory_bytes: 39168
/*
 * Created by SharpDevelop.
 * User: Administrator
 * Date: 12/08/2017
 * Time: 21:24
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;

namespace Two_Switches_AtCoder
{
	class Program
	{
		public static void Main(string[] args)
		{
			String[] s = Console.ReadLine().Split(' ');
			int a = int.Parse(s[0]);
			int b = int.Parse(s[1]);
			int c = int.Parse(s[2]);
			int d = int.Parse(s[3]);
			
			if (c>=b || a>=d) Console.WriteLine(0);
			else{
				if (c>=a && c<=b && d>b) Console.WriteLine(b-c);
				else{
					if (a>=c && a<=d && b>d) Console.WriteLine(d-a);
					else{
						if (a<=c && d<=b) Console.WriteLine(d-c);
						else if (c<=a && b<=d) Console.WriteLine(b-a);
					}
				}
			}
		}
	}
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 1e8;
    int tmp = 0;
    rep(j, 2) {
        tmp += abs(a[j] - a[j+1]);
    }
    cout << tmp << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n), comp(n);
  REP(i, n) {
    cin >> a[i];
    comp[i] = a[i];
  }
  sort(ALL(comp));
  REP(i, n) a[i] = lower_bound(ALL(comp), a[i]) - a.begin();
  int ans = 0;
  REP(i, n) {
    if (abs(a[i] - i) & 1) ++ans;
  }
  cout << ans / 2 << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
ll X, Y;

/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>X>>Y;

    int ans = 1;
    ll x=X;
    while( 1){
        x = x*2;
        if(x > Y){
            break;
        }else{
            ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define inf 1000000007 //10^9+
#define sort(vec) sort((vec).begin(),(vec).end());
#define rever(vec) reverse((vec).begin(),(vec).end());
#define unsort(vec) sort((vec)); rever((vec));
#define gcd __gcd
using namespace std;

int main() {
  ll a,b,k;
  cin>>a>>b>>k;
  ll s=1;
  ll l=b-a+1;
  for(ll i=a;i<=b;i++) {
    if(s<=k||l<=k) {
      cout<<i<<endl;
    }
    s++;
    l--;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
string fi[8];
bool range88(int x,int y){
  return 0<=x && x<8 && 0<=y && y<8;
}
int mov(int x,int y,bool d,char t){
  if(!range88(x,y)||fi[x][y]!='.') return 0;
  int answer=0;
  FOR(dx,-1,2) FOR(dy,-1,2){
    if(!dx&&!dy) continue;
    FOR(st,1,10){
      int tx=x+dx*st,ty=y+dy*st;
      if(!range88(tx,ty)||fi[tx][ty]=='.') break;
      if(fi[tx][ty]==t){
	if(d) FOR(tst,1,st) fi[x+dx*tst][y+dy*tst]=t;
	answer+=st-1;
	break;
      }
    }
  }
  if(answer){
    if(d) fi[x][y]=t;
    return answer+1;
  }
  return 0;
}

int main(void)
{
  REP(i,8) cin >> fi[i];
  char turn[2]={'o','x'};
  REP(i,128){
    int tmpm=0,tmpx=-1,tmpy=-1;
    REP(j,8) REP(k,8){
      int tx=j,ty=k;
      if(i%2){
	tx=7-tx,ty=7-ty;
      }
      if(fi[tx][ty]!='.') continue;
      int tmp=mov(tx,ty,false,turn[i%2]);
      if(tmp>tmpm){
	tmpm=tmp;
	tmpx=tx;
	tmpy=ty;
      }
    }
    mov(tmpx,tmpy,true,turn[i%2]);
    if(false && i<10 && tmpm){
      cout << tmpx << ' ' << tmpy << endl;
      REP(i,8) cout << fi[i] << endl;
      cout << endl;
    }
  }
  REP(i,8) cout << fi[i] << endl;
  return 0;

}

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

using namespace std;
const long long MOD = 1e9+7;
const long long MAXN = 2e3+5;
long long dp[MAXN][MAXN];
long long suff[MAXN];
int main(){
    long long n,k;
    cin>>n>>k;
    dp[0][n] = 1;
    if(n==1 && k==1){
        cout<<1<<endl;
        return 0;
    }
    for(long long i=1;i<=k;i++){
        for(long long j=n;j>=1;j--){
            suff[j] = suff[j+1]+dp[i-1][j];
            suff[j]%=MOD;
            if(j<=(n-i+1)){
                dp[i][j] =suff[j];
                dp[i][j]%=MOD;
            }
            //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
        }
        
    }
    
    long long ans = (dp[k][1] - dp[k-1][1] + MOD)%MOD;
    //cout<<ans<<endl;
    for(long long i=1;i<=n-k-1;i++){
        ans*=2;
        ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 31104
package main

import (
        "fmt"
)

func main() {
        var n int
        fmt.Scanf("%d", &n)

        // --- all ---
        for i := 1; i < 50000; i++ {
                if int(float64(i)*1.08) == n {
                        fmt.Println(i)
                        return
                }
        }
        fmt.Println(":(")
}

Measured memory_bytes: 512
n, m = map(int, input().split())
g=[[] for i in range(n)]
x=[[] for i in range(m)]

count=0
for i in range(m):
    u,v=map(int,input().split())
    u-=1
    v-=1
    g[u].append(v)
    g[v].append(u)
    x[i]=[u,v]
memo=[False for i in range(n)]
memo[0]=True


def dfs(now,prev):
    for next in g[now]:        
        if next!=prev:
            if memo[next]==True:
                continue
            else:
                memo[next]=True
                dfs(next,now)


for i in range(m):
    g[x[i][0]].remove(x[i][1])
    g[x[i][1]].remove(x[i][0])
    dfs(0,0)
    if memo.count(False)>=1:
        count+=1
    g[x[i][0]].append(x[i][1])
    g[x[i][1]].append(x[i][0])
    memo=[False for i in range(n)]
    memo[0]=True
    
print(count)
    
    
    
    
    
    


Measured memory_bytes: 3444
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int num[5]={0},i;
	for(i=0;i<5;i++){
		cin>>num[i];
	}
	sort(num,num+5);
	for(i=0;i<5;i++){
		cout<<num[4-i];
		if(i!=4){
			cout<<' '; 
		}
	}
	cout<<endl;
	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    string S;
    cin >> N;
    cin >> S;
    char c = '#';
    ll cnt = 0;
    for (int i = 0; i < N; i++) {
        if(S[i] != c){
            c = S[i];
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int maxn =2e5+10;
struct po
{
	int a,b,id;
	bool operator < (const po & A) const 
	{
		return a*A.b<A.a*b;
	}
};
priority_queue<po> q;
int fa[maxn],n,a,u,v,ans,cnt[maxn][2],f[maxn];
int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
void merge(int a, int b){fa[find(a)]=find(b);}
signed main() 
{
	scanf("%d", &n);
	for(int i=2;i<=n;i++)cin>>f[i];
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a),cnt[i][a]=1;
		fa[i]=i;
	}
	for(int i=2;i<=n;i++)q.push((po){cnt[i][0],cnt[i][1],i});
	while(!q.empty())
	{
		po now=q.top();q.pop();
		u=find(now.id);
		if(cnt[u][0]==now.a&&cnt[u][1]==now.b) 
		{
			v=find(f[u]);
			ans+=cnt[v][1]*cnt[u][0];
			cnt[v][1]+=cnt[u][1];cnt[v][0]+=cnt[u][0];
			merge(u,v);
			if(v!=1)q.push((po){cnt[v][0],cnt[v][1],v});
		}
	}
	printf("%lld", ans);
	return 0;
}
/*
问题换到序列上 
显然可以冒泡去做，挪动条件这样 A.1* B.0 < A.0 * B.1
改一下方向！A.1 / A.0 < B.1 / B.0
这不就可以排序了吗 
这个题的道理是一样的  用堆做一下就好。 
*/

Measured memory_bytes: 17196
#include<string>
#include<list>
#include<iostream>
using namespace std;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  string str;
  list<int> data;
  list<int>::iterator it,l;
  int n,x;
  cin >> n;
  while(n--){
    cin >> str;
    if(str == "insert"){
      cin >> x;
      data.push_front(x);
    }else if(str == "delete"){
      cin >> x;
      for(it=data.begin(),l=data.end();it!=l;++it){
	if(*it == x){
	  data.erase(it);
	  break;
	}
      }
    }else if(str == "deleteFirst") data.pop_front();
    else data.pop_back();
  }
  for(it=data.begin(),l=--data.end();it!=l;++it) cout << *it << " ";
  cout << *it << endl;
}


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

int n, m = 0;
string s;

int main() {
	cin >> n >> s;
	for (int i = 1, l, r; i < n; i++) { //[0,i-1].[i,n-1]
		l = 0, r = 0;
		for (int j = 0; j < n; j++) {
			if (j < i)
				l |= 1 << s[j] - 'a';
			else
				r |= 1 << s[j] - 'a';
		}
		m = max(m, __builtin_popcount(l & r));
	}
	cout << m << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

signed main(){
    int n;
    while(cin >> n){
        int ans = 0;
        int memo[31] = {0};
        memo[0] = 0;
        rep(i, 1, n + 1){
            int t = min(i - 1, n - i);
            ans += 2*memo[t] + 1;
            memo[i] = ans;
            //cout << i << ' ' << memo[i] << endl;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int gcd(int a,int b){
  if(b==0){
    return a;
  }
  else{
    return gcd(b,a%b);
  }
}
int main(){
  int n,b[1000010],a[1000010],i,j;
  cin >> n;
  int res=0;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    b[i]=a[i];
  }
  vector<int> c(1000010,0);
  for(i=0;i<n;i++){
    for(j=2;j*j<=a[i];j++){
      if(a[i]%j==0){
        if(c[j]==0){
          c[j]=1;
          while(a[i]%j==0){
            a[i]=a[i]/j;
          }
        }
        else{
          res=1;
          break;
        }
      }
    }
    if(a[i]!=1){
      if(c[a[i]]==0){
        c[a[i]]=1;
      }
      else{
        res=1;
        break;
      }
    }
    if(res==1){
      break;
    }
  }
  if(res==0){
    cout << "pairwise coprime" << endl;
    return 0;
  }
  for(i=0;i<n;i++){
    a[i]=b[i];
  }
  int q=gcd(a[0],a[1]);
  for(i=2;i<n;i++){
    q=gcd(q,a[i]);
  }
  if(q==1){
    cout << "setwise coprime" << endl;
  }
  else{
    cout << "not coprime" << endl;
  }
}

Measured memory_bytes: 14928
#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>
#include <map>

class union_find {
private:
  size_t component;
  std::vector<int32_t> parent;

public:
  union_find() = default;
  union_find(size_t size_) { init(size_); }

  void init(size_t size_) {
    component = size_;
    parent.assign(size_, -1);
  }

  size_t count_components() const { 
    return component; 
  }
  size_t component_size(size_t i) { 
    return -parent[find_parent(i)]; 
  }
  bool same_component(size_t i, size_t j) { 
    return find_parent(i) == find_parent(j); 
  }

  size_t find_parent(size_t i) {
    if (parent[i] < 0) {
      return i;
    }
    else {
      return parent[i] = find_parent(parent[i]);
    }
  }

  bool unite(size_t i, size_t j) {
    i = find_parent(i);
    j = find_parent(j);
    if (i == j) {
      return false;
    }
    if (parent[i] > parent[j]) {
      std::swap(i, j);
    }
    parent[i] += parent[j];
    parent[j] = i;
    --component;
    return true;
  }

};

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

int main() {
  size_t N;
  u32 X = 0;
  std::vector<u32> A, B;
  {
    std::cin >> N;
    std::vector<u32> A_(N + 1), B_(N + 1);
    for (size_t i = 0; i < N; ++i) {
      std::cin >> A_[i];
      A_.back() ^= A_[i];
    }
    for (size_t i = 0; i < N; ++i) {
      std::cin >> B_[i];
      B_.back() ^= B_[i];
    }
    X = A_.back();
    for (size_t i = 0; i < N; ++i) {
      if (A_[i] != B_[i]) {
        A.push_back(A_[i]);
        B.push_back(B_[i]);
      }
    }
    N = A.size();
    std::sort(A_.begin(), A_.end());
    std::sort(B_.begin(), B_.end());
    if (A_ != B_) {
      std::cout << "-1\n";
      return 0;
    }
  }
  u32 ans = N, subtract = 0;
  std::map<u32, std::vector<u32>> idx;
  union_find uni(N);
  for (size_t i = 0; i < N; ++i) {
    idx[B[i]].push_back(i);
  }
  for (const auto &p: idx) {
    for (size_t i = 1; i < p.second.size(); ++i) {
      uni.unite(p.second[i - 1], p.second[i]);
    }
  }
  for (size_t i = 0; i < N; ++i) {
    if (B[i] == X) {
      subtract = 1;
    }
    if (!idx[A[i]].empty()) {
      uni.unite(i, idx[A[i]].back());
      idx[A[i]].pop_back();
    }
  }
  std::cout << ans + uni.count_components() - subtract << '\n';
  return 0;
}


Measured memory_bytes: 12388
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

#define INF 1000000007

int main()
{
	int a,b,m;
	cin >> a >> b >> m;
	vector<int> aa(a);
	vector<int> bb(b);
	int amn=INF;
	int bmn=INF;
	for(int i=0;i<a;i++)
	{
		cin >> aa[i];
		if(amn>aa[i])amn=aa[i];
	}
	for(int i=0;i<b;i++)
	{
		cin >> bb[i];
		if(bmn>bb[i])bmn=bb[i];
	}
	int mn=amn+bmn;
	for(int i=0;i<m;i++)
	{
		int x,y,c;
		cin >> x >> y >> c;
		x--;y--;
		int tmp=aa[x]+bb[y]-c;
		if(tmp<mn)mn=tmp;
	}
	cout << mn << endl;
	
	




}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
    int n;  cin >> n;
    int m = n, sum = 0;
    while (m) {
        sum += m % 10;
        m /= 10;
    }

    if (n % sum == 0)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
n,m = map(int,input().split())

edges = [[] for _ in range(n)]

for _ in range(m):
    a,b = map(int,input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

q = [0]

ans = [-1]*n
ans[0] = 0
count = 1

while q:
    l = q.pop(0)
    for i in edges[l]:
        if ans[i] == -1:
            ans[i] = l
            count += 1
            q.append(i)
    if count == n:
        break

if count == n:
    print('Yes')
    for i in ans[1:]:
        print(i+1)
else:
    print('No')


Measured memory_bytes: 34696
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  int n;
  int R,L,D,c;
  string s;
  while(cin>>n){
    if(!n)break;
    R=0;
    L=0;
    D=1;
    c=0;
    while(n--){
      cin >> s;
      if(s=="lu")L++;
      if(s=="ld")L--;
      if(s=="ru")R++;
      if(s=="rd")R--;
      if(L&&R&&D){
	c++;
	D--;
      }else if(!L&&!R&&!D){
	c++;
	D++;
      }
    }
    cout << c << endl;
  }

  return 0;
}

Measured memory_bytes: 3084
use std::io::{stdout, Write, BufWriter};

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        cards: [i32; n],
    }

    cards.sort();
    cards.reverse();

    let alice: i32 = cards.iter().enumerate().filter(|&(i, _)| i % 2 == 0).map(|(_, &x)| x).sum();
    let sum: i32 = cards.iter().sum();
    println!("{}", 2 * alice - sum);
}


Measured memory_bytes: 4352
class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = self.right = None
    def preorder(self):
        L = [self.key]
        if self.left: L += self.left.preorder()
        if self.right: L += self.right.preorder()
        return L
    def inorder(self):
        L = []
        if self.left: L += self.left.inorder()
        L.append(self.key)
        if self.right: L += self.right.inorder()
        return L

def insert(t, z):
    y = None
    x = t
    while x:
        y = x # 親を設定
        x = x.left if z.key < x.key else x.right
    z.parent = y
    if not y: # t が空の場合
        return z
    if z.key < y.key:
        y.left = z # z を y の左の子にする
    else:
        y.right = z # z を y の右の子にする
    return t

t = None
m = int(input())
for _ in range(m):
    cmd = list(input().split())
    if cmd[0] == 'insert':
        t = insert(t, Node(int(cmd[1])))
    if cmd[0] == 'print':
        print('', *t.inorder())
        print('', *t.preorder())



Measured memory_bytes: 120112
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut c: [usize; n],
    }

    c.sort();
    c.reverse();

    let mut ans = 0;
    for i in 1..n {
        ans += c[i / 2]
    }

    println!("{}", ans);
}


Measured memory_bytes: 6196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;

int main() {
	cin >> n;
	if (n == 0 || n == 2)cout << 1 << endl;
	else if (n == 1)cout << 2 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 3072
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N = ni()
    val L = na(N).sorted
    val mx = L(N - 1)
    val ok = mx < L.dropRight(1).sum
    if (ok) out.println("Yes")
    else out.println("No")
  }


  def debug(as: Array[Boolean]): Unit = {
    System.err.println(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(s: String): Unit = {
    System.err.println(s)
  }

  def debug(num: Long): Unit = {
    System.err.println(num)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

Measured memory_bytes: 25552
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<vc> vcc;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 7;
void solve(){
    int n,q; cin>>n>>q;
    string s; cin>>s;
    vi v(n+1,0);
    int cnt=0;
    for(int i = 1; i < n; i++){
        if(s[i-1]=='A' && s[i]=='C') cnt++;
        v[i+1]=cnt;
    }
    //for(auto i: v) cout<<i<<" ";
    //cout<<endl;
    for(int i = 0; i < q; i++){
        int l,r; cin>>l>>r;
        cout<<v[r]-v[l]<<endl;
    }
}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

Measured memory_bytes: 1536
#include<stdio.h>

int main(){
   int X,Y;

   scanf("%d %d",&X,&Y);
   
   if(Y<2*X||X*4<Y){
      printf("No");
   }else if(Y%2==1){
      printf("No");
   }else{
      printf("Yes");
   }
   return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))

using namespace std;

long N, M;
long *a, *b;
long *ans;

/////////////         UnionFind

class UnionFindClass {
public:
	UnionFindClass() {
		N = 0;
		parent = NULL;
		size = NULL;
	}
	~UnionFindClass() {
		if (parent != NULL) {
			delete[] parent;
		}
		if (size != NULL) {
			delete[] size;
		}
	}

	void activate(int n) {// 要素の数N
		N = n;
		parent = new int[N];
		size = new int[N];
		for (int i = 0; i < N; i++) {
			parent[i] = -1;
			size[i] = 1;
		}
	}

	int getParent(int x) {
		if (parent[x] == -1) {
			return x;
		}
		else {
			int y = getParent(parent[x]);
			parent[x] = y;
			return y;
		}
	}
	int getSize(int x) {
		x = getParent(x);
		return size[x];
	}
	bool connect(int x, int y) {
		x = getParent(x);
		y = getParent(y);
		if (x == y) { return false; }
		int xsize = getSize(x), ysize = getSize(y);
		if (xsize < ysize) {
			parent[x] = y;
			size[y] += size[x];
			size[x] = 0;
		}
		else {
			parent[y] = x;
			size[x] += size[y];
			size[y] = 0;
		}
		return true;
	}

	//データ
	int N;// 個数
	int *parent;// 親の番号。自分自身が親なら-1。
	int *size;// 親のみ有効。自分のグループのサイズ。
};

int main() {
	cin >> N >> M;
	a = new long[M];
	b = new long[M];
	ans = new long[M];
	UnionFindClass U;

	ans[M - 1] = (N * (N - 1)) / 2;

	U.activate(N);

	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}

	for (int k = M - 1; k > 0; k--) {
		int x = a[k], y = b[k];
		long xSize = U.getSize(x);
		long ySize = U.getSize(y);
		if (U.connect(x, y)) {// 違うグループ同士でつなげられたら
			ans[k - 1] = ans[k] - xSize * ySize;
		}
		else {
			ans[k - 1] = ans[k];
		}
		
	}

	for (int i = 0; i < M; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);
  string s; cin >> s;
  int n = s.size();
  vector<string> token;
  for(int i=0;i<n;++i) {
    if(s[i] == 'A') {
      token.push_back("A");
    } else if(s[i] == 'B') {
      token.push_back("B");
    } else if(!token.empty() && token[(int)(token.size())-1] == "B") {
      token[(int)(token.size()-1)] = "BC";
    } else {
      token.push_back("C");
    }
  }

  int sz = token.size();
  ll a = 0;
  ll ans = 0;
  for(int i=0;i<sz;++i) {
    if(token[i] == "A") {
      a++;
    } else if(token[i] == "BC") {
      ans += a;
    } else {
      a = 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 11380
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#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 <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    int k;
    cin >> k;
    char t = s[k - 1];
    for( int i = 0; i < n; ++i ) {
        if( s[i] != t ) cout << '*';
        else cout << s[i];

    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 256