akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  int x, y, z;
  ;
  cin >> N;
}
void solve() {
  int x = 800 * N;
  int y = 200 * (N / 15);
  cout << x - y << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
import math
A, B = list(map(int,input().split()))
if math.ceil(A*12.5)>B*10:
    print(math.ceil(A*12.5) if math.ceil(A*12.5)<(B+1)*10 else -1)
else:
    print(B*10 if B*10<math.floor((A+1)*12.5) else -1)

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

int main(){
    int n;
    cin >> n;
    vector<int>a(100,0);
    for(int i=0; i < n;i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int suma = 0,sumb =  0;
    for(int i=0; i<n;i += 2){
        suma += a.at(i);
        sumb += a.at(i+1);
    }
    cout << suma - sumb << endl;
    return 0;
}

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

int main(void){

  int n,B[25],T[25],cnt,cnt2;

  while(1){
    
    cin >>n;

    if(n ==0)break;

    cnt=0;
    cnt2=0;

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

    for(int i=0 ; i < n ; i++){
      for(int j=1 ; j < n-i ; j++){
	if(B[j] > B[j-1]){
	  swap(B[j],B[j-1]);
	  swap(T[j],T[j-1]);
	}
      }
    }

   

    for(int i=n-1 ; 0 <= i ; i--){
      if(B[i] >= T[i]+cnt){
	cnt+=T[i];
	cnt2++;
      }else{
	cnt2=0;
	break;
      }
    }
    
    if(cnt2 == 0){
      cout <<"No"<<endl;
    }else{ 
      cout <<"Yes"<<endl;
    }   
  } 
  
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*
10^12=2^40
論理和とって0になればOK
01011
0だったら、11か00
A[0]+[1]=32とかだったら、1<<4がどちらも1でないと満たせない
1だったら、01か10
*/
int main(){
  ll N,oo=1e12; cin>>N;
  vector<ll> A(N,0),B(0,0),C(0,0);
  ll x=0;
  for(ll i=0; i<N; i++) cin>>A[i];
  for(ll i=0; i<N; i++) x^=A[i];
  if(x==0){
    cout<<0<<endl;
    return 0;
  }
  x^=A[0];
  x^=A[1];
  ll tmp=A[0]+A[1];
  ll res=0;
  for(ll i=40; i>=0; i--){
    ll n=(1LL<<i);    
    if((x&n)==0){
      if(tmp>=n*2){
        res+=n*2;
        tmp-=n*2;
      }
    }
    else{//01の際1をどちらに入れるか選択
      B.push_back(n);
      tmp-=n;
    }
  }
  if(tmp!=0){
    cout<<-1<<endl;
    return 0;
  }
  res/=2;
  for(auto v:B){
    if(res+v > A[0]) C.emplace_back(res+v);//A[0]を上回ったら候補。
    else res+=v;//下回ってるなら和をとっちゃう
  }
  C.emplace_back(res);
  sort(C.begin(),C.end());
  ll ans=1e12;
  for(auto v: C){
    if(v>A[0] || v==0) continue;
    ans=min(ans,A[0]-v);
  }
  if (ans==oo) cout<<-1<<endl;
  else cout<<ans<<endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define double long double
using namespace std;
const ll inf = 1000000000000000000;

typedef pair<ll, ll> para;
vector<para> edges[1000005];
ll n, m, stx, sty, fix, fiy, start, finish, top;
char a[1005][1005];
ll dist[1000005];
bool used[1000005];
bool check(ll x, ll y) {
    return (x >= 0 && x < n && y >= 0 && y < m);
}
void dijkstra() {
    dist[start] = 0;
    set<para> myset;
    myset.clear();
    myset.insert(make_pair((ll)0, start));
    while (!myset.empty()) {
        para p = *myset.begin();
        myset.erase(myset.begin());
        for (ll i = 0; i < (ll)edges[p.second].size(); ++i) {
            ll to = edges[p.second][i].first;
            ll new_min = dist[p.second] + edges[p.second][i].second;
            if (new_min < dist[to]) {
                dist[to] = new_min;
                myset.insert(make_pair(dist[to], to));
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    cin >> stx >> sty;
    cin >> fix >> fiy;
    --stx;
    --sty;
    --fix;
    --fiy;
    start = stx * 1000 + sty;
    finish = fix * 1000 + fiy;
    for (ll i = 0; i < n; ++i)
        for (ll j = 0; j < m; ++j)
            cin >> a[i][j];
    for (ll i = 0; i < n; ++i)
        for (ll j = 0; j < m; ++j)
            if (a[i][j] == '.') {
                top = i * 1000 + j;
                if (check(i + 1, j) && a[i + 1][j] == '.')
                    edges[top].push_back(make_pair((i + 1) * 1000 + j, (ll)0));
                if (check(i - 1, j) && a[i - 1][j] == '.')
                    edges[top].push_back(make_pair((i - 1) * 1000 + j, (ll)0));
                if (check(i, j + 1) && a[i][j + 1] == '.')
                    edges[top].push_back(make_pair(i * 1000 + j + 1, (ll)0));
                if (check(i, j - 1) && a[i][j - 1] == '.')
                    edges[top].push_back(make_pair(i * 1000 + j - 1, (ll)0));
                for (ll i2 = i - 2; i2 <= i + 2; ++i2)
                    for (ll j2 = j - 2; j2 <= j + 2; ++j2)
                        if (check(i2, j2) && a[i2][j2] == '.' && (abs(i2 - i) + abs(j2 - j) > 1))
                            edges[top].push_back(make_pair(i2 * 1000 + j2, (ll)1));
            }
    for (ll i = 0; i < n; ++i)
        for (ll j = 0; j < m; ++j)
            dist[i * 1000 + j] = inf;
    dijkstra();
    if (dist[finish] == inf)
        cout << -1;
    else
        cout << dist[finish];
    return 0;
}


Measured memory_bytes: 168168
io = STDIN
n=io.gets.to_i
a=io.gets.split.map(&:to_i)
b=Array.new(n)
even=(1..n).select(&:even?)
odd=(1..n).select(&:odd?)
if n.even?
  ar=even.reverse+odd
else
  ar=odd.reverse+even
end
puts ar.map{|i|a[i-1]}.join(" ")


Measured memory_bytes: 30980
#include <bits/stdc++.h>
using namespace std;
int n,d[100005],l,a[100005];
int main(){
	scanf("%d",&n);
	for (int i=1; i<=n; i++){
		scanf("%d",&a[i]);
	}
	l=1;
	d[1]=a[n];
	for (int i=n-1; i>=1; i--){
		int tt=upper_bound(d+1,d+1+l,a[i])-d;
		if (tt>l){
			d[++l]=a[i];
		} 
		if (d[tt]>a[i]){
			d[tt]=a[i];
		} 
	}
	printf("%d",l);
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }


int main() {
	int n;
	cin >> n;
	put(180 * (n - 2));
	return 0;
}



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

int main() {
    int cnt=0;
    bool f;
    string w;
    cin >> w;
    for (int i=0; i<w.size(); i++) {
        for (int j=0; w[j] != '\0'; j++) {
            if (w[i] == w[j]) {
                cnt++;
            }
        }
        if (cnt % 2 == 0)
            f = true;
        else {
            f = false;
            break;
        }
    }
    if (f)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



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

using namespace std;
string s;


int main(){
  string ans = "YES";
  cin >> s;
  while(s.size()>0){
    if(s[0]=='e'){
      if(s.size()<5){
        ans = "NO";
        break;
      }
      if(s.substr(0,5)=="erase"){
        s = s.substr(5,s.size()-5);
        if(s.size()>0&&s[0]=='r') s = s.substr(1,s.size()-1);
      }
      else{
        ans = "NO";
        break;
      }
    }
    else if(s[0]=='d'){
      if(s.size()<5||s.substr(0,5)!="dream"){
        ans = "NO";
        break;
      }
      s = s.substr(5,s.size()-5);
      if(s.size()==2&&s=="er") s = "";
      if(s.size()>2&&s[0]=='e'&&s[1]=='r'&&(s[2]=='d'||s[2]=='e')){
        s = s.substr(2,s.size()-2);
      }
    }
    else{
      ans = "NO";
      break;
    }
  }
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<(int)N;i++)
int main(void)
{
  int A,B,N,M,x;
  queue<int> q;
  x=scanf("%d %d",&N,&M);
  vector<int> room(N,-1);vector<vector<int>> cave(N);
  rep(i,M)x=scanf("%d %d",&A,&B),A--,B--,cave[A].push_back(B),cave[B].push_back(A);
  room[0]=0;q.push(0);
  while(!q.empty())
  {
    x=q.front();q.pop();
    for(int y:cave[x]){if(room[y]!=-1)continue;room[y]=x,q.push(y);}
  }
  puts("Yes"),puts("");
  rep(i,N-1)printf("%d\n",room[i+1]+1);
}

Measured memory_bytes: 10264
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef long long LL;
const int INF = 999999999;

int dp[101010];
int p[20][20];

int main(){
    int n, d, x;
    cin >> n >> d >> x;
    rep(i,d)rep(j,n) cin >> p[i][j];
    int have = x;
    rep(now, d-1){
        memset(dp, 0, sizeof(dp));
        rep(j, have+1) dp[j] = j;
        rep(i, n)rep(j, have+1){
            if(j-p[now][i] >= 0) dp[j] = max(dp[j], dp[j-p[now][i]] + p[now+1][i]);
        }
        have = max(have, dp[have]);
    }
    cout << have << endl;
}




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

using namespace std;

const int n = 3;

void findAndMark(int a[][n], int b)
{
	for(int i = 0 ; i < n ; i++)
		for(int j = 0 ; j < n ; j++)
			if(a[i][j] == b)
				a[i][j] = 0;
}

bool checkRows(int a[][n])
{
	for(int i = 0 ; i < n ; i++)
	{
		int j;
		for(j = 0 ; j < n ; j++)
			if(a[i][j] != 0)
				break;
		if(j == n)
			return true;
	}
	return false;
}

bool checkColumns(int a[][n])
{
	for(int i = 0 ; i < n ; i++)
	{
		int j;
		for(j = 0 ;  j < n ; j++)
			if(a[j][i] != 0)
				break;
		if(j == n)
			return true;
	}
	return false;
}

bool checkDiagonals(int a[][n])
{
	int i, j;
	for(i = 0, j = 0 ; i < n ; i++, j++)
		if(a[i][j] != 0)
			break;
	if(i == n)
		return true;
	for(i = n - 1, j = 0 ; j < n ; i--, j++)
		if(a[i][j] != 0)
			return false;
	return true;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int m;
	int a[n][n];
	for(int i = 0 ; i < n ; i++)
		for(int j = 0 ; j < n ; j++)
			cin >> a[i][j];
	cin >> m;
	for(int i = 0 , b; i < m ; i++)
	{
		cin >> b;
		findAndMark(a, b);
	}
	if(checkRows(a) || checkColumns(a) || checkDiagonals(a))
		cout << "Yes\n";
	else
		cout << "No\n";
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
  ll n;
  cin >> n;
  ll a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  ll nax = a[0], ans = 0;
  for(int i = 1; i < n; i++){
    if(a[i] >= nax){
      nax = a[i];
    }
    else{
      ans += nax - a[i];
    }
  }
  cout << ans;
}

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

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

    vector<int> p;
    int tmp;
    for(int i=0; i<N; i++){
        cin >> tmp;
        p.push_back(tmp);
    }

    sort(p.rbegin(), p.rend());

    int sum = 0;
    for(int i=0; i<K; i++){
        sum += p.back();
        p.pop_back();
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3608
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		System.out.println(H*W - (h*W+H*w-h*w));
	}
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e3+10;
int arr[N][N];
ll memo[N][N][4];
int r,c;
ll dp(int x, int y, int rctr){
	if (x == r && y == c){
		if (rctr < 3)
			return arr[x][y];
	}
	ll &ret = memo[x][y][rctr];
	if (ret != -1)
		return ret;
	ret = 0;
	// stay in same row if possible
	if (y+1 <= c) {
		// sel if poss
		ll sel = arr[x][y];
		if (rctr < 3 && sel) 
			ret = max(ret, sel + dp(x,y+1,rctr+1));
		// don't sel
		ret = max(ret, dp(x,y+1,rctr));
	}
	// shift to new row
	if (x+1 <= r) {
		//sel if poss
		ll sel = arr[x][y];
		if (rctr < 3 && sel)
			ret = max(ret, sel + dp(x+1,y,0));
		// don't sel
		ret = max(ret, dp(x+1,y,0));
	}
	return ret;
}
int main(){
	int k,x,y;
	cin >> r >> c >> k;
	while (k--){
		cin >> x >> y;
		cin >> arr[x][y];
	}
	memset(memo,-1,sizeof(memo));
	cout << dp(1,1,0);
	return 0;
}

Measured memory_bytes: 322508
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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


    int N;
    cin >> N;
    vector<ll> t(N+1), x(N+1), y(N+1);
    rep(i, 0, N) {
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    }
    rep(i, 1, N+1) {
        ll dt = t[i] - t[i - 1];
        ll dd = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);

        if(dt % 2 != dd % 2){
            cout << "No" << endl;
            return 0;
        }
        if(dt < dd){
            cout << "No" << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,T;
  cin >> n >> T;
  while(T--) {
    ll x,y;
    cin >> x >> y;
    if(n==1) {
      pr(min(x,y));
      continue;
    }
    x--,y--;
    set<ll> s;
    s.in(x);
    s.in(y);
    while(x!=y) {
      if(x<y) swap(x,y);
      x=(x-1)/n;
      if(s.count(x)) {
        pr(x+1);
        goto end;
      }
      s.in(x);
    }
    pr(x+1);
  end:;
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

Measured memory_bytes: 1280
#include <cstdio>
#include <cmath>
#define N 100010
#define ll long long
#define mem(x, a) memset(x, a, sizeof x)
#define mpy(x, y) memcpy(x, y, sizeof y)
#define fo(x, a, b) for (int x = (a); x <= (b); x++)
#define fd(x, a, b) for (int x = (a); x >= (b); x--)
using namespace std;
int n, st, coo[N], go_[N], tot = 0;
ll ans = 0, hav[N];

inline int read() {
	int x = 0, f = 0; char c = getchar();
	while (c < '0' || c > '9') f = (c == '-') ? 1 : f, c = getchar();
	while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return f ? -x : x;
}

void dfs(int l, int r) {
	if (l > r) return;
	if (st < coo[l]) dfs(l, r - 1), go_[++tot] = r;
	else if (st > coo[r]) dfs(l + 1, r), go_[++tot] = l;
	else if (hav[l] >= hav[r]) hav[l] += hav[r], dfs(l, r - 1), go_[++tot] = r;
	else hav[r] += hav[l], dfs(l + 1, r), go_[++tot] = l;
}

int main()
{
//	freopen("home.in", "r", stdin);
//	freopen("home.out", "w", stdout);
	n = read(), st = read();
	fo(i, 1, n) coo[i] = read(), hav[i] = read();
	dfs(1, n);
	ans = abs(coo[go_[1]] - st);
	fo(i, 2, n) ans += abs(coo[go_[i]] - coo[go_[i - 1]]);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 6268
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#include <bits/stdc++.h>
#define f first
#define s second
#define ms(a, b) memset(a,b,sizeof(a))
typedef long long ll;

using namespace std;

char _;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);

    int A,B,C,K,sum=0;

    scan(A);scan(B);scan(C);scan(K);

    if(K<=A)
        sum+=K;
    if(K>A){
        sum+=A;
        K-=A;
    }
    if(K!=0){
        K-=B;
    }

    if(K>0){
        if(K<=C){
            for(int i=0;i<K;i++) sum--;
            K-=C;
        }
        if(K>C) for(int i=0;i<C;i++) sum--;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;

void solve(){
  ll n; cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ll maxa = a[n - 1];
  ll x = maxa / 2, y = a[0];
  for(int i = 1; i < n - 1; i++){
    if(a[i] > x){
      if(a[i] - x <= x - a[i - 1]) y = a[i];
      else y = a[i - 1];
      break;
    }
  }
  cout << maxa << " " << y << endl;
  return;
}

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


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// ??? p ????????? x ????????\????????\???
vector<P> tangentPoints(P p, C x) {
    vector<P> ps;
    P a = x.first; double ar = x.second;
    double sin = ar / abs(p-a);
    if(!LE(sin, 1)) return ps; // ????????§ NaN ??????????????????

    double t = M_PI_2 - asin(min(sin, 1.0));
    ps.push_back(a + (p-a) * polar(sin, t));
    if(!EQ(sin, 1)) ps.push_back(a + (p-a)*polar(sin, -t));
    return ps;
}

int main() {
    P a; cin >> a.X >> a.Y;
    C c; cin >> c.fr.X >> c.fr.Y >> c.sc;

    vector<P> ans = tangentPoints(a, c);
    sort(ans.begin(), ans.end());
    printf("%.10f %.10f\n%.10f %.10f\n", ans[0].X, ans[0].Y, ans[1].X, ans[1].Y);
    return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N;
	cin >> N;
	map<int, int> m;
	rep(i, 0, N) {
		int a;
		cin >> a;
		m[a]++;
	}

	ll res = 0;
	for(map<int, int>::iterator itr = m.begin(); itr != m.end(); itr++) {
		if(itr->first == itr->second) continue;
		else if(itr->first < itr->second) res += (itr->second - itr->first);
		else res += itr->second;
	}

	cout << res << endl;

}


Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    int ans = 0;
    int inv = S.size()-1;
    for(int i = 0; i < S.size()/2; ++i){
        if(S[i] != S[inv]){
            ans++;
        }
        inv--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
def yks(n):
    yakusu = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            yakusu.append(i)
            if i != n // i:
                yakusu.append(n//i)
    yakusu.sort()
    return yakusu
g=yks(n)
p=len(yks(n))//2
if g[p]*g[p-1]==n:
    print(g[p]+g[p-1]-2)
else:
    print(2*g[p]-2)

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

bool solve() {
  int H, W; cin >> H >> W;
  int g1 = H & W & 1;
  int g2 = H % 2 * W / 2 + W % 2 * H / 2;
  vector<int> cnt(26);
  for (int i = 0; i < H*W; i++) {
    char c; cin >> c;
    ++cnt[c-'a'] &= 3;
  }
  int c1 = 0, c2 = 0;
  for (int i = 0; i < 26; i++) {
    c1 += cnt[i] & 1;
    c2 += cnt[i] >> 1 & 1;
  }
  return c1 <= g1 && c2 <= g2;
}

int main() {
  if (solve()) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int d, g;
vi p, c;
vi complete;
int main() {
  scanf("%d %d", &d, &g);
  p.assign(d+0, 0);
  c.assign(d+0, 0);
  rep (i, d) {
    scanf("%d %d", &p[i], &c[i]);
  }
  complete.assign(d, 0);
  rep (i, d) {
    complete[i] = (i+1)*100 * p[i] + c[i];
  }

  int n = (1 << d);
  int ans = INT_MAX;
  rep (i, n) {
    int score = 0;
    int cnt = 0;
    rep (j, d) {
      if (((i>>j)&1) == 1) {
        score += complete[j];
        cnt += p[j];
      }
    }
    int rest = g - score;
    if (rest <= 0) {
      ans = min(ans, cnt);
      continue;
    }
    for (int j = d-1; j >= 0; --j) {
      if (((i>>j)&1) == 0) {
        if (rest <= (j+1)*100 * (p[j] - 1)) {
          cnt += ((rest + (j+1)*100 - 1) / ((j+1)*100));
          ans = min(ans, cnt);
        }
        break;
      }
    }
  }
  printf("%d\n", ans);

  return 0;
}


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

int main(){
    
    int A , B;
    cin >> A >> B;
    
    
    int difference;
    
    
    //値の差を２以上か以下かを判断
    if(A >= B){
        difference = A - B;
    }else if(A < B){
        difference = B - A;
    }
    
    
    //differenceの値で場合分け
    if(difference >= 2) {
        if(A > B){
            cout << A + A - 1 << endl;
        }else if(A < B){
            cout <<  B + B - 1 << endl;
        }
    
    }else if(difference < 2) {
        cout << A + B << endl;
    }
    
    
    return 0;
}

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


int main(){
    int X; cin >> X;
    int cnt = X / 100;
    int rem = X % 100;
    if(cnt == 0){
        cout << 0 << endl;
        return 0;
    }
    else{
        if(rem == 0){
            cout << 1 << endl;
            return 0;
        }
        else{
            for(int i = 0; i <= rem/5; ++i){
                for(int j = 0; j <= rem/4; ++j){
                    for(int k = 0; k <= rem/3; ++k){
                        for(int l = 0; l <= rem/2; ++l){
                            for(int m= 0; m <= rem; ++m){
                                if(5*i + 4*j + 3*k + 2*l + m == rem && i+j+k+l+m <= cnt){
                                    cout << 1 << endl;
                                    return 0;
                                }
                            }
                        }
                    }
                }
            }
        }
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int A, B, C;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> A >> B >> C;
  if(A+B >= C) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define  ll  long long int
#define  sz  200010

using namespace std;

//ll num[sz];
ll mn=LONG_LONG_MAX;

//set<ll>st;


int main()
{

    ll n,a,d,b,c,x,t,i,j,k;

    cin>>t>>n;
    ll f=0;

    for(i=0; i<=2010; i++)
    {
        x=n-(i*10000);
        a=i;


        x=x/1000;

        for(j=0; j<=x; j++)
        {
            b=j;
            if(a+b<=t)
            {
                c=t-(a+b);

                ll s=a*10000+b*1000+c*5000;
                if(s==n && (a+b+c)==t)
                {
                    cout<<a<<" "<<c<<" "<<b<<endl;
                    return 0;
                }
            }
        }


    }

    string xx="-1 -1 -1";


    cout<<xx<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <fstream>
#include <algorithm>
#include <queue>
#include <cassert>
#include <stack>

using namespace std;



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


    string r;
    cin >> r;
    set<char > a;
    for (char c : r){
        a.insert(c);
    }
    cout << (a.size() == 2 ? "Yes" :"No");
    return 0;
}




void print(vector<int> &b) {
    for (auto i : b) {
        cout << i << " ";
    }
}


Measured memory_bytes: 256
[A, B, C, K] = list(map(int, input().split()))
total = 0
if K - A >= 0:
    total += A
    K -= A
else:
    total += K
    K = 0
if K - B >= 0:
    K -= B
else:
    K = 0
if K - C >= 0:
    total -= C
    K -= C
else:
    total -= K

print(total)


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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> a(n, -1);

  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (a[s] < 0 || a[s] == c) {
      a[s] = c;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }

  if (n == 1) {
    cout << max(a[0], 0) << endl;
    return 0;
  }

  if (a[0] == 0) {
    cout << -1 << endl;
    return 0;
  }

  int ans = max(a[0], 1);
  for (int i = 1; i < n; i++) {
    ans = ans * 10 + max(a[i], 0);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
p=lambda x:print(x,end=' ')
n=input();p(n+':')
m=n=int(n)
while n%2==0 and n>3:p(2);n//=2
d=3
while d*d<m and n>d:
 if n%d>0:d+=2
 else:p(d);n//=d
print(n)


Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class T> class Matrix
{
public:
    vector<vector<T>> A;
    Matrix(int n):A(n,vector<T>(n)){}
    Matrix(int n,int m):A(n,vector<T>(m)){}

    vector<T>& operator[](int i){ return A[i]; }
    int height(){ return A.size(); }
    int width(){ return A[0].size(); }
    static Matrix I(int n){
        Matrix mat(n);
        for(int i=0;i<n;i++) mat[i][i]=1;
        return mat;
    }

    Matrix& operator+=(Matrix& B){
        int H=height(), W=width();
        for(int i=0;i<H;i++) for(int j=0;j<W;j++)
            A[i][j]+=B[i][j];
        return *this;
    }
    Matrix& operator-=(Matrix& B){
        int H=height(), W=width();
        for(int i=0;i<H;i++) for(int j=0;j<W;j++)
            A[i][j]-=B[i][j];
        return *this;
    }
    Matrix& operator*=(Matrix& B){
        int H=height(), W=B.width(), K=width();
        vector<vector<T>> C(H,vector<T>(W));
        for(int i=0;i<H;i++) for(int j=0;j<W;j++)
            for(int k=0;k<K;k++) C[i][j]+=A[i][k]*B[k][j];
        A.swap(C);
        return *this;
    }
    Matrix operator+(Matrix& B){ return Matrix(*this)+=B; }
    Matrix operator-(Matrix& B){ return Matrix(*this)-=B; }
    Matrix operator*(Matrix& B){ return Matrix(*this)*=B; }
    Matrix pow(int K){
        Matrix res=Matrix::I(height());
        Matrix B=*this;
        while(K>0){
            if(K&1) res*=B; B*=B; K>>=1;
        }
        return res;
    }
};

template<int mod> class modint
{   
public:
    int val;
    modint(int x=0){ val=x%mod; }
    int value(){ return val; }

    modint pow(int n){
        modint res(1),x(val);
        while(n>0){ if(n&1) res*=x; x*=x; n>>=1; }
        return res;
    }
    modint inv(){ return pow(mod-2); }
    modint& operator+=(modint rhs){ val+=rhs.val; if(val>=mod) val-=mod; return *this; }
    modint& operator-=(modint rhs){ val+=mod-rhs.val; if(val>=mod) val-=mod; return *this; }
    modint& operator*=(modint rhs){ val=val*rhs.val%mod; return *this; }
    modint& operator/=(modint rhs){ *this*=rhs.inv(); return *this; }
    modint operator+(modint rhs){ return modint(val)+=rhs; }
    modint operator-(modint rhs){ return modint(val)-=rhs; }
    modint operator*(modint rhs){ return modint(val)*=rhs; }
    modint operator/(modint rhs){ return modint(val)/=rhs; }
};


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

    using mint=modint<1000000007>;
    int N,K; cin>>N>>K;
    Matrix<mint> A(N);
    for(int i=0;i<N;i++) for(int j=0;j<N;j++){
        int t; cin>>t; A[i][j]=t;
    }
    A=A.pow(K);
    mint ans=0;
    for(int i=0;i<N;i++) for(int j=0;j<N;j++){
        ans+=A[i][j];
    }
    cout<<ans.value()<<endl;
    return 0;
}

Measured memory_bytes: 384
/************************Code by Hardik Aggarwal!!!!***********************************/

#include<bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % mod; 
    p = (p * p) % mod; 
  
    return (y%2 == 0)? p : (x * p) % mod; 
}

int main()
{	

	IOS
	ll n,ans=0;
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		ll c=0,temp=i;
		while(temp)
		{
			c++;
			temp/=10;
		}

		if(c%2)
			ans++;
	}

	cout<<ans;


}
    
 
    
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll n;
	cin >> n;
	string a;
	cin >> a;
	ll k;
	cin >> k;
	for (int z=0;z<n;z++){
		if (a[z] != a[k-1]){
			cout << "*";
		} else {
			cout << a[k-1];
		}
	}
	cout << endl;
	cin >> n;
}

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

#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)


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

typedef long long ll;


//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}
//---------------//

int divnum2(int n){
    int ans = 0;
    while(n % 2 == 0){
        ans += 1;
        n /= 2;
    }
    return ans;
}
ll N;
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    int a[N];
    REP(i, 0, N) cin >> a[i];

    int ans = 0;
    REP(i, 0, N){
        ans += divnum2(a[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i,j,k,m;
    cin>>n;
    int x[n],y[n];
    ll h[n],ex;
    for (i=0;i<n;i++)
    {
        cin>>x[i]>>y[i]>>h[i];
        if (h[i])
            m=i;
    }
    int cx,cy,f;
    ll H,th;
    for (i=0;i<=100;i++)
    {
        for (j=0;j<=100;j++)
        {
            f=0;
            th=h[m]+abs(x[m]-i)+abs(y[m]-j);
            for (k=0;k<n;k++)
            {
                if (h[k]!=max(th-abs(x[k]-i)-abs(y[k]-j),0LL))
                {
                    f=1;
                    break;
                }
            }
            if (!f)
            {
                cx=i;
                cy=j;
                H=th;
                break;
            }
        }
        if (!f)
            break;
    }
    cout<<cx<<" "<<cy<<" "<<H<<endl;
}

Measured memory_bytes: 256
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/rope>
// #include <type_traits>
using namespace std;
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)

#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(xs) ((int)(xs).size())
#define all(xs) xs.begin(),xs.end()
#define lla(xs) xs.rbegin(),xs.rend()
#define sum(xs) accumulate(all(xs), 0)
#define sortup(xs) sort(all(xs))
#define sortdown(xs) sort(lla(xs))
#define reverse(xs) reverse(all(xs))
#define contain(xs,n) (find(all(xs),n)!=xs.end())
#define unique(xs) xs.erase(unique(all(xs)),xs.end())
#define search(xs,n) distance(xs.begin(),find(all(xs),n))
#define count(xs,n) count(all(xs),n)
#define vecmin(xs) *min_element(all(xs))
#define vecmax(xs) *max_element(all(xs))

template<class C>void mini(C &a,C b){a=min(a,b);}
template<class C>void maxi(C &a,C b){a=max(a,b);}

// 複数，シフト，演算
// #define newvec(T,n,xs) vector<T> xs(n)

#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__)
#define invec(T,n,...) vector<T> __VA_ARGS__;T t;_cinvec(t,n,__VA_ARGS__)
#define invec2(T,n,xs,ys) vector<T> xs(n),ys(n);fou(i,0,n)cin>>xs.at(i)>>ys.at(i)
#define invec3(T,n,xs,ys,zs) vector<T> xs(n),ys(n),zs(n);fou(i,0,n)cin>>xs.at(i)>>ys.at(i)>>zs[i]
// #define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
// #define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define out(...) _cout(__VA_ARGS__)
#define outvec(xs) tra(x,xs) cout << x << " ";cout << endl
void _cin(){}template<class Head,class...Tail>void _cin(Head&&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
void _cout(){}template<class Head,class...Tail>void _cout(Head&&head,Tail&&...tail){cout<<head<<endl;_cout(forward<Tail>(tail)...);}
template<class Type>void _cinvec(Type t,int n){}template<class Type,class Head,class...Tail>void _cinvec(Type t,int n,Head&&head,Tail&&...tail){rep(n){cin>>t;head.eb(t);}_cinvec(t,n,forward<Tail>(tail)...);}


// #define int int64_t
// #define double long double

// map,文字列処理


signed main(){
  invec(int,5,a);
  in(int,k);
  out((a.at(4)-a.at(0))<=k?"Yay!":":(");
}

Measured memory_bytes: 256
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()
    L = LIST()

    one = max(L)
    print("Yes" if one < sum(L)-one else "No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define st first
#define nd second
using namespace std;
using pii = pair<int,int>;
int bz = 2e5;
pii p[(int)2e5 + 10];
long long bit[(int)2e5 + 10];
void update(int pos, long long val){
    for(;pos <= bz; pos += pos & -pos){
        bit[pos]+=val;
    }
    return;
}
long long query(int pos){
    long long sum = 0LL;
    for(;pos > 0;pos-=pos&-pos){
        sum+=bit[pos];
    }
    return sum;
}
int main(){
    int n,d,a;
    scanf("%d%d%d",&n,&d,&a);
    bz = n;
    for(int i =1;i<=n;i++){
        scanf("%d%d",&p[i].st,&p[i].nd);
    }
    sort(p+1,p+n+1);
    int ti = 0,to = -1,it = 1;
    long long ans = 0LL;
    p[0] ={0,0};
    for(int i =1;i<=n;i++){
        update(i, 1LL *( p[i].nd - p[i-1].nd));
        long long x = query(i);
        if(x <= 0LL) continue;
        int dis = p[i].st + 2 * d;
        for(it = max(it,i);it <= n && p[it].st <= dis;it++);
        ti = x/a + (x % a > 0);
        update(i,1LL * -1 * ti * a);
        if(it <= n) update(it,1LL * ti * a);
        ans += 1LL * ti;
    }
    printf("%lld",ans);

}


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

using namespace std;

const int INF = 1 << 29;

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

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<vector<int>> dp(N + 1, vector<int>(3, 0));
  for (int i = 0; i < N; i++) {
    for (int a = 0; a < 3; a++) {
      int x;
      cin >> x;
      for (int b = 0; b < 3; b++) {
        if (a == b) continue;
        chmax(dp[i + 1][a], dp[i][b] + x);
      }
    }
  }

  int res = 0;
  for (int i = 0; i < 3; i++) {
    res = max(res, dp[N][i]);
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-9
#define MOD 1000000007
#define int long long
using namespace __gnu_pbds;
using namespace std;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ost;
#define INF 10000000000


int32_t main(){
	int n, w;
	cin >> n >> w;
	int dp[w+1] = {0};
	for(int i = 0; i < n; i++){
		int wt, val;
		cin >> wt >> val;
		for(int j = w-wt; j >= 0; j--){
			dp[j+wt] = max(dp[j+wt], dp[j]+val);
		}
	}
	int ans = 0;
	for(int i = 0; i <= w; i++)
		ans = max(ans,dp[i]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
n=int(input())
tree={}
root=None

def insert(tree,number):
    parent=None
    children=root
    while children!=None:
        parent=children
        if children>number:
            children=tree[parent][0]
        else:
            children=tree[parent][1]
    
    if parent>number:
        tree[parent][0]=number
    else:
        tree[parent][1]=number

def preorder(tree,i):
    if i==None:
        return
    print(" {}".format(str(i)),end="")
    preorder(tree,tree[i][0])
    preorder(tree,tree[i][1])

def inorder(tree,i):
    if i==None:
        return
    inorder(tree,tree[i][0])
    print(" {}".format(str(i)),end="")
    inorder(tree,tree[i][1])

def find(x,key):
    while x is not None and key!=x:
        if key<x:x=tree[x][0]
        else:x=tree[x][1]
    return x

for i in range(n):
    tmp=list(input().split())
    if tmp[0]=="print":
        inorder(tree,root)
        print()
        preorder(tree,root)
        print()
    else:
        number=int(tmp[1])
        if tmp[0]=="insert":
            if root is None:
                root=number
                tree[number]=[None,None]
            else:
                tree[number]=[None,None]
                insert(tree,number)
        else:
            if find(root,int(tmp[1])) is not None:print("yes")
            else:print("no")


Measured memory_bytes: 75124
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int N_MAX = 2001;
int p=1e9+7;
int main()
{
  int n,i;
  ll s[N_MAX];
  cin >> n;
  s[1]=0;
  s[2]=0;
  s[3]=1;
  for(i=4;i<=n;i++){
    s[i]=s[i-1]+s[i-3];
    s[i]%=p;
  }
  cout << s[n] << endl;
  return 0;
}

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

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int N, M;

int gcd(int a, int b) {
    if(a < b) std::swap(a,b);
    if(a == 1) return 1;
    if(a%b == 0) return b;
    return gcd(b,a%b);
}

int main(){
    INIT;
    cin >> N; cin >> M;
    if(N == 1) {
        cout << M << "\n";
        return 0;
    }

    int ans = 1;
    for(int i = 1; i <= sqrt(M) && i <= (M/N); i++) {
        if(M % i != 0) continue;
        if(ans < i) ans = i;
        if(N <= i && ans < (M/i)) ans = M/i;
    }

    cout << ans << "\n";
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



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

	ll s = 0;
	for (int i = 0; i < n; i++) {
		s = (s + a[i]) % MOD;
	}

	ll ans = (s * s) % MOD;

	for (int i = 0; i < n; i++) {
		ll p = a[i];
		p = (p * p) % MOD;
		ans = (ans + MOD - p) % MOD;
	}

	ll inv2 = MOD - MOD / 2;
	
	ans = (ans * inv2) % MOD;
	cout << ans << endl;

}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define DBG(x) ;//cerr<<#x<<" = "<<x<<endl
using LL = long long;

LL N,M,T;

LL INF = 123456789012345678;

struct node{
	vector<LL>vec;
	node(){
		vec.resize(T);
	}
	node operator + (const node&o){
		node x = *this;
		for(int i = 0;i < T;++i){
			for(int j = 0;j < T;++j){
				x.vec[(i+j)%T] = max(x.vec[(i+j)%T],
				vec[i]+o.vec[j]);
			}
		}
		return x;
	}
};

node m_pow(const node&e,LL x){
	if(x == 1)return e;
	node half = m_pow(e,x/2);
	half = half + half;
	if(x % 2)half = half + e;
	return half;
}

int main(){
	cin>>N>>M>>T;
	node e;
	fill(e.vec.begin(),e.vec.end(),-INF);
	e.vec[0] = 0;
	for(int i=0;i<N;++i){
		LL a;cin>>a;
		e.vec[a%T]=max(a,e.vec[a%T]);
	}
	auto res = m_pow(e,M);
	vector<LL>ans(T+1,-INF);
	for(int i=0;i<T;++i){
		ans[i]=res.vec[i];
	}
	for(int i=T-1;i>=0;--i){
		ans[i]=max(ans[i],ans[i+1]);
	}
	for(int i=0;i<T;++i){
		ans[i]/=T;
		//ans[i]++;
		DBG(ans[i]);
	}
	int Q;
	cin>>Q;
	for(int q=0;q<Q;++q){
		LL A,B;
		cin>>A>>B;
		if(ans[A]>=B){
			cout<<"yes"<<endl;
		}else{
			cout<<"no"<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d) cout<<"Yes"<<endl;
  else if(abs(a-b)<=d && abs(b-c)<=d) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	string s;
	cin >> s;

	int ans = 0;
	for(int i = 1; i < (int)s.size()/2; i++){
		if(s.substr(0,i) == s.substr(i,i))
			ans = i;
	}

	cout << ans*2 << endl;

	return 0;
}

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

int main() {
  int N, K, x, a=0;
  cin >> N >> K;
  
  for(int i=0; i<N; i++){
    cin >> x;
    if(K-x > x){
      a+=x*2;
    }
    else{
      a+=(K-x)*2;
    }
  }
  
  cout << a << endl;
}

Measured memory_bytes: 256