akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
	
	int n,m;
	string s;
	cin >> n >> m;
	cin >> s;
	
	s[m-1] = tolower(s[m-1]);
	
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
      char[] s = sc.next().toCharArray();
      char ch = s[0];
      boolean flag = false;
      for(int i=1;i<4;i++){
        if(s[i]==ch){
          flag = true;
          break;
        }else{
          ch = s[i];
        }
      }
      if(flag){
        System.out.print("Bad");
      }else{
        System.out.print("Good");
      }
      System.out.flush();
    }
}

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

using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),greater<char>());
	
	if(lexicographical_compare(s.begin(),s.end(),t.begin(),t.end()))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

LL n, p[2][6];

LL f(LL t) {
	LL xmi = min({ p[0][0] + t, p[0][2], p[0][4] - t });
	LL xma = max({ p[0][1] + t, p[0][3], p[0][5] - t });
	LL ymi = min({ p[1][0] + t, p[1][2], p[1][4] - t });
	LL yma = max({ p[1][1] + t, p[1][3], p[1][5] - t });
	return (xma - xmi) * (yma - ymi);
}

int main() {
	inc(i, 2) {
	inc(j, 6) {
		p[i][j] = (j % 2 == 0 ? +1 : -1) * 1e9;
	}
	}
	
	cin >> n;
	inc(i, n) {
		LL x, y; string d;
		cin >> x >> y >> d;
		x *= 2;
		y *= 2;
		
		if(d == "R") { setmin(p[0][0], x); setmax(p[0][1], x); }
		ef(d == "L") { setmin(p[0][4], x); setmax(p[0][5], x); }
		ef(d == "U") { setmin(p[1][0], y); setmax(p[1][1], y); }
		ef(d == "D") { setmin(p[1][4], y); setmax(p[1][5], y); }
		else { UR; }
		
		if(d == "U" || d == "D") { setmin(p[0][2], x); setmax(p[0][3], x); }
		ef(d == "R" || d == "L") { setmin(p[1][2], y); setmax(p[1][3], y); }
		else { UR; }
	}
	
	vector<LL> T = { 0 };
	inc(i, 2) {
		inc(j, 6) {
		inc(k, j) {
			if(j/2 == k/2) { continue; }
			
			LL t = - (p[i][j] - p[i][k]) / ((1 - j/2) - (1 - k/2));
			if(t > 0) { T.PB(t); }
		}
		}
	}
	
	LL ans = 1e18;
	RF(t, T) { setmin(ans, f(t)); }
	
	printf("%.2Lf\n", ans / 4.0L);
	
	return 0;
}


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

#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

vector<ll> divisor(ll n)
{
  vector<ll> res;
  for (ll i=1; i*i<=n; i++) {
    if (n%i == 0) {
      res.push_back(i);
      if (i != n/i) res.push_back(n/i);
    }
  }
  return res;
}

void solve()
{
  ll n; cin>>n;
  ll ans=0;

  vector<ll> d = divisor(n);
  SORT(d);
  for (int i=1; i<SZ(d); i++) {
    ll p = d[i]-1;
    if (n/p == n%p) ans+=p;
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  string s;
  cin >> s;
  for(int i=1;i<s.size();i++){
    if(s[i-1]==s[i]){
      cout <<"Bad\n";
      return 0;
    }
  }
  cout << "Good\n";
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int H, W;
	int i, j;
	
	while( scanf("%d %d", &H, &W) != EOF )

	if (H == 0 && W == 0) {
		break; 
	} else {
		for(i=0; i<H; i++) {
			for(j=0; j<W; j++) {
				if(i==0 || i==H-1 || j==0 || j==W-1) {
					printf("#");
				} else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define ALL(x) x.begin(),x.end()

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;

int main() {
	int n, z, w;
	scanf("%d %d %d", &n, &z, &w);
	vint a(n);
	rep(i, 0, n)
		scanf("%d", &a[i]);
	int ans;
	if (n > 1) {
		ans = max(abs(a[n - 2] - a[n - 1]), abs(a[n - 1] - w));
	}
	else {
		ans = abs(a[n - 1] - w);
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
def num_of_days(string)
	days = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
	days.each_with_index do |day, index|
		if string == day
			return (7 - index)
		end
	end
	-1
end

line = gets.chomp
puts num_of_days(line)


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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

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

struct edge{int from, to,cost;};

// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));

int n,m,x;
vec<int> c(12,0);
vec<vec<int>> a(12,vec<int>(12,0));


int main()
{
    cin>>n>>m>>x;

    rep(i,n){
        cin>>c[i];
        rep(j,m){
            cin>>a[i][j];
        }
    }

    vec<int> learn(m,0);
    int Min=10000000;
    int cost=0;

    for(int bit=0;bit<(1<<n);++bit){ // bit全探索による部分組み合わせ全列挙 2^n パターン
        
        cost=0;
        rep(i,m) learn[i]=0;

        rep(i,n){
            if(bit & (1<<i)){// i番目が1(存在)する場合
                rep(j,m){
                    learn[j]+=a[i][j];
                    
                }
               cost+=c[i];
            }
        }


        bool flag=true;
        rep(i,m){
            //cout<<learn[i]<<endl;
            if(learn[i]<x) flag=false;
        }
         //cout<<endl;
        if(flag){
            Min=min(cost,Min);
        }
    }

    if(Min==10000000) Min=-1;


    cout<<Min<<endl;


    

    return 0;

}






Measured memory_bytes: 3636
require 'set'
n = gets.to_i
a = gets.split.map(&:to_i)
q = gets.to_i
b = gets.split.map(&:to_i)
max = b.max
set = Set.new
a.each do |x|
  new_set = Set.new
  new_set << x
  set.each do |y|
    new_set << y
    new_set << x + y if x + y <= max
  end
  set = new_set
end
b.each do |x|
  puts set.include?(x) ? 'yes' : 'no'
end


Measured memory_bytes: 7192
#include <stdio.h>
int main(void){
    int a,b,c;
    
    scanf("%d %d %d\n",&a,&b,&c);
    
   if(a<b&&b<c){
       printf("Yes\n");
   }else{
       printf("No\n");
   }
    
    return(0);
    
}



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

const MOD: usize = 1000000007;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut csum = vec![0; n + 1];
    for i in 0..n {
        csum[i + 1] = csum[i] + a[i];
    }
    let mut res = 0;
    for i in 0..n {
        let sum = (csum[n] - csum[i + 1]) % MOD;
        res += a[i] * sum;
        res %= MOD;
    }
    println!("{}", res);
}


Measured memory_bytes: 7224
while True:
  n =int(input())
  if n==0:
    break
  A=[0]*10
  for i in range(n):
    A[int(input())]+=1
  #print(A)

  for i in range(10):
    if A[i]==0:
      print("-")
    else:
      print("*"*A[i])



Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    ll ans=0;
    map<ll,int> MA;
    for(int i=N-1;i>=0;i--){
        ans+=MA[i+A[i]];
        MA[i-A[i]]++;
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 27312
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

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

struct point {
  double x, y, z;
  point(double x, double y, double z) :x(x),y(y),z(z) {}
  point() {}
};

double dot(const point& a, const point& b) {
  return a.x*b.x+a.y*b.y+a.z*b.z;
}
double abs(const point &a) {
  return sqrt(dot(a,a));
}
double angle(const point &a, const point &b) {
  return acos( dot(a,b)/abs(a)/abs(b) );
}


int main() {
  int n;
  while(cin >> n, n) {
    point p[n];
    REP(i, n) {
      double x,y,z;
      cin >> x >> y >> z;
      p[i] = point(x,y,z);
    }
    int m;
    cin >> m;
    point d[m];
    double phi[m];
    REP(i, m) {
      double x, y, z;
      cin >> x >> y >> z;
      d[i] = point(x,y,z);
      cin >> phi[i];
    }
    int ans = 0;
    REP(i, n) {
      REP(j, m) {
        if (angle(p[i], d[j]) < phi[j]) {
          ans++;
          break;
        }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
x,n = map(int, input().split())
line = list(map(int, input().split()))

plus = x
minus = x

if not x in line:
    print(x)
    exit()

while True:

    if plus <= 100:
        plus += 1

    if minus >= 0:
        minus -=1


    if not minus in line:
        print(minus)
        exit()

    if not plus in line:
        print(plus)
        exit()

    if plus > 100 and minus < 0:
      exit()


Measured memory_bytes: 9128
#include<iostream>
using namespace std; // 575
 
int main() {
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0, j = 0;i < S.size();++ i) {
		if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') ans = max(ans, ++j);
		else j = 0;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*b);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}

template <typename T>
class Seg_Tree{
public: // 0-index
	vector<T> dat;
	T initial,M;
	int n;
	T unite(T a,T b){//
		return a + b;
	}
	Seg_Tree(int n0_=1,T initial_=1,T M_=1){
		initsize(n0_,initial_,M_);
	}
	void initsize(int n0,T initial_,T M_){
		M = M_;
		initial = initial_;
		int k=1;
		while(1){
			if(n0<=k){
				n=k;
				dat.resize(2*n-1);
				for(int i=0;i<2*n-1;i++)dat[i]=initial;
				break;
			}
			k*=2;
		}
	}
 
	//i banme wo x nisuru
	void update(int i,T x){
		i += n-1;
		dat[i] = x;
		while(i>0){
			i = (i-1) / 2;
			dat[i] = unite(dat[i*2+1],dat[i*2+2]);
		}
	}
 
	//[a,b)
	T query0(int a,int b,int k,int l,int r){
		if(r<=a || b<=l)return initial;
		if(a<=l && r<=b)return dat[k];
		else{
			T vl = query0(a,b,k*2+1,l,(l+r)/2);
			T vr = query0(a,b,k*2+2,(l+r)/2,r);
			return unite(vl,vr);
		}
	}
 
	//return [a,b)
	T query(int a,int b){
		return query0(a,b,0,0,n);
	}
};

int main(){


	ll N;
	cin >> N;

	bool ans = false;
	ll cnt = 0;

	FOR(i,0,N){
		ll a,b;
		cin >> a >> b;
		if(a==b){
			cnt++;
			if(cnt >= 3)ans = true;
		}else{
			cnt = 0;
		}
	}
	if(ans){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}


}


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

int main(){
    int N;
    cin >> N;
    vector<int> h(N);
    rep(i,N)cin >> h[i];
    vector<int> dp(N,0);
    dp[0] = h[0];
    for(int i = 1; i < N ; i++){
        dp[i] = max(h[i]-h[i-1],dp[i]);
    }
    int ans = 0;
    for(auto e : dp){
        ans += e;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
L=[]
for i in range(N) :
   A=list(map(int,input().split()))
   L.append(A)
L.sort()
X=Y=P=0
for i in range(N) :
  X=Y+L[i][1]
  if X<M :
    P=P+L[i][0]*L[i][1]
    Y=Y+L[i][1]
  else :
    P=P+L[i][0]*(M-Y)
    break
print(P)


Measured memory_bytes: 27760
/**
 * ??°???????????¢

?????????????????°???????????????????????????????????°?????????????????????????????????

Input
??\????????\????????¢?????§?????????????????????

n
a1 a2 . . . an
n ?????°????????????????????????ai ??? i ???????????°?????¨????????????

Output
???????????°?????????????????????????????????????????°??????????´??????????????????????????????\?????????????????????????????°????????????????????\??????????????¨?????¨????????????????????????

Constraints
n ??? 100
0 ??? ai < 1000
Sample Input 1
5
1 2 3 4 5
Sample Output 1
5 4 3 2 1
Sample Input 2
8
3 3 4 4 5 8 7 9
Sample Output 2
9 7 8 5 4 4 3 3
 */

#include <iostream>
#include <sstream>
#include <vector>

int main(int argc, char const *argv[]) {
  unsigned int n = 1;
  std::string Param;

  while (true) {

    getline(std::cin, Param);
    std::istringstream iss(Param);
    iss >> n;

    if (n < 1 || n > 100) {
      std::cout << "Error: 1 <= n <= 100" << std::endl;
    } else {
      break;
    }
  }

  // unsigned int Ai[n];
  std::vector<unsigned int> Ai(n, 0);
  while (true) {
    bool isValid = true;

    getline(std::cin, Param);
    std::istringstream iss(Param);
    for (size_t i = 0; i < n; i++) {
      iss >> Ai[i];
      if (Ai[i] > 1000) {
        std::cout << "Error: 0 <= Ai <= 1000" << std::endl;
        isValid = false;
        break;
      } else {
        isValid = true;
      }
    }
    if (isValid == true) {
      break;
    }
  }
  for (size_t i = n - 1; i > 0; i--) {
    std::cout << Ai[i] << " ";
  }
  std::cout << Ai[0] << std::endl;
  
  return 0;
}

Measured memory_bytes: 3128
/*
 ____________________________________________________________
|                                                            |
|                   Author: ay2306                           |
|____________________________________________________________|

*/
#include <bits/stdc++.h>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
using namespace std;

const ll maxn = 1e5;


int main(){
	ll n;
  cin >> n;
  ll i = 1;
  ll ans = 0;
  while(i*i < n){
  	if(n%i != 0){i++;continue;}
    ll m = n/i - 1;
    if(n%m == n/m)ans += (n/i - 1);
    ++i;
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
class Sight{
    public:
        Sight();
        void setData(double left, double right);
        void getData(int ret[4][2]);

    private:
        int data[4][2];
        int jug(double eye_sight);
};
Sight::Sight(){
    for(int i = 0; i < 4; ++i){
        for (int j = 0; j < 2; j++) {
            data[i][j] = 0;
        }
    }
}
int Sight::jug(double eye_sight){
    if (eye_sight >= 1.1) {
        return 0;
    }
    else if (eye_sight >= 0.6) {
        return 1;
    }
    else if (eye_sight >= 0.2) {
        return 2;
    }
    else {
        return 3;
    }
}
void Sight::setData(double left, double right){
    ++data[jug(left)][0];
    ++data[jug(right)][1];
}
void Sight::getData(int ret[4][2]){
    for(int i = 0; i < 4; ++i){
        for(int j = 0; j < 2; ++j){
            ret[i][j] = data[i][j];
        }
    }
}
int main(){
    double right, left;
    Sight sight;
    while (cin >> left >> right) {
        sight.setData(left, right);
    }
    int ret[4][2];
    sight.getData(ret);

    for(int i = 0; i < 4; ++i){
        cout << ret[i][0] << " " << ret[i][1] << endl;
    }
}

Measured memory_bytes: 1224
# 解説読んだ
# 大きい順に並べて、最初のが1回、それ以降は2回ずつ足されてN-1回で終了
# 構造まではなんとなく理解してたけど個数から頭が離れなかったなあ

N = int(input())
A = list(map(int, input().split()))

A.sort()
ans=0

for i in range(1,N):
    ans += A[-(i//2)-1]
print(ans)

Measured memory_bytes: 94212
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int l[200005],r[200005],la[200005],ra[200005],n,k,c;
char s[200005];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>k>>c;
	c++;
	FOR(i,1,n)cin>>s[i];
	FOR(i,1,n){
		if(s[i-1]=='o')l[i]=i-1;
		else l[i]=l[i-1];
		if(s[i]=='o'){
			if(i>c)la[i]=la[i-c]+1;
			else la[i]=1;
		}else la[i]=la[i-1];
	}
	for(int i=n;i>=1;i--){
		if(s[i+1]=='o')r[i]=i+1;
		else r[i]=r[i+1];
		if(s[i]=='o'){
			if(n-i>=c)ra[i]=ra[i+c]+1;
			else ra[i]=1;
		}else ra[i]=ra[i+1];
	}
	FOR(i,1,n){
		if(la[l[i]]+ra[r[i]]==k-1)cout<<i<<'\n';
	}
	RE 0;
}




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

int main()
{
	int n;
	cin >> n;

	vector<int> v;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		tmp--;
		v.push_back(tmp);
	}

	int i = 0;
	int status = 0;
	int count = 0;
	while (true)
	{
		if (status == 1)
		{
			cout << count << endl;
			break;
		}
		if (n <= count)
		{
			cout << -1 << endl;
			break;
		}
		count++;
		status = v[status];
	}
}


Measured memory_bytes: 892
#include "bits/stdc++.h"
using namespace std;
int main() {
	cin.tie(0);ios::sync_with_stdio(false);
	int D, E;
	while (true) {
		cin >> D >> E;
		if (D == 0 && E == 0) break;
		double Ans = 200;
		for (int x = 0; x <= D / 2; x++) {
			int y = D - x;
			Ans = min(Ans, abs(sqrt(x*x + y*y) - E));
		}
		cout << fixed << Ans << endl;
	}
}

Measured memory_bytes: 3180
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>

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

int main() {
  string s;
  cin >> s;
  int ans = 700;

  for(char c: s){
    if(c=='o') ans+=100;
  }
  
  cout << ans << endl;

}


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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

const long long mod = 1e9+7;

template <class T> T modpow(T a, T b) {
    if (b == 0) return T(1);
    if (b % 2 == 0) {
        long long d = modpow(a, b / T(2));
        return (d * d) % mod;
    } else {
        return (a * modpow(a, b - 1) % mod );
    }
}
template<class T> T mod_nCr(T n, T r, T mod ) {
    T denom = 1;
    T numer = 1;
    for (T i = 1; i <= r; i++) numer = (numer * i) % mod;
    for (T i = n - r + 1; i <= n; i++) denom = (denom * i) % mod;
    return (denom * modpow(numer, mod - 2) % mod);
}

int X, Y;
long long n, m;

inline void Main() {
  // code
	cin >> X >> Y;
	
	if((X + Y) % 3 != 0) {
		cout << 0 << endl;
		return;
	}

	n = (2*Y - X) / 3;
	m = Y - 2*n;

	if(n<0 || m<0) {
		cout << 0 << endl;
		return;
	}
	
	cout << mod_nCr(m+n, n, mod) << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;

int main(){
    while (1){
        int n;
        cin >> n;
        if (n == 0){
            break;
        }

        vector<pair<int, int> > gems(n);

        for (auto itr = gems.begin(); itr != gems.end(); ++itr){
            int x, y;
            cin >> x >> y;
            *itr = make_pair(x, y);
        }

        int m;
        cin >> m;

        pair<int, int> pos(10, 10);
        int cnt = 0;

        for (int i = 0; i < m; i++){
            char dir;
            int step;
            cin >> dir >> step;
            if (dir == 'N'){
                for (int j = 0; j < step; j++){
                    pos.second++;
                    auto isGems = find(gems.begin(), gems.end(), pos);
                    if (isGems != gems.cend()){
                        gems.erase(isGems);
                        cnt++;
                    }
                }
            }
            else if (dir == 'E'){
                for (int j = 0; j < step; j++){
                    pos.first++;
                    auto isGems = find(gems.begin(), gems.end(), pos);
                    if (isGems != gems.cend()){
                        gems.erase(isGems);
                        cnt++;
                    }
                }
            }
            else if (dir == 'S'){
                for (int j = 0; j < step; j++){
                    pos.second--;
                    auto isGems = find(gems.begin(), gems.end(), pos);
                    if (isGems != gems.cend()){
                        gems.erase(isGems);
                        cnt++;
                    }
                }
            }
            else{
                for (int j = 0; j < step; j++){
                    pos.first--;
                    auto isGems = find(gems.begin(), gems.end(), pos);
                    if (isGems != gems.cend()){
                        gems.erase(isGems);
                        cnt++;
                    }
                }
            }
        }
        if (cnt == n){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }

    
    return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d);
	
	printf("%d\n", std::max(a * b, c * d));
	return 0;
}


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>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng (chrono::steady_clock::now().time_since_epoch().count() );

const int MOD = 998244353;
const ll INF = 1e18;
const int N = 2e5 + 12; //check the limits, dummy


int main() {

    ios_base::sync_with_stdio (0);
    cin.tie (0);

    ll n;
    cin >> n;
    string s;
    cin >> s;
    if (n & 1) {
        cout << "No\n";
        return 0;
    }
    FOR (i, 0, n / 2) {
        if (s[i] != s[i + n / 2]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";

    return 0;
}


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int X,Y;
signed main() {
    cin>>X>>Y;
    cout<<X+Y/2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <list>

int n, a, b;
std::string str;

int main() {
    std::cin >> n >> a >> b;

    std::cin >> str;

    int pass = 0;
    int b_rank = 0;
    for(int i = 0; i < n; ++i) {
        if(str[i] == 'a') {
            std::cout << (pass < a + b ? (++pass, "Yes") : "No") << std::endl;
        }else if(str[i] == 'b'){
            std::cout << ((pass < a + b && (++b_rank <= b)) ? (++pass, "Yes") : "No") << std::endl;
        }else {
            std::cout << "No" << std::endl;
        }
    }
}

Measured memory_bytes: 896
#include <iostream>
using namespace std;
int N;
char str[11];
void dfs(int idx, char to){
	if(idx == N)
		cout << str << endl;
	else
		for(char c='a'; c<=to; c++){
			str[idx] = c;
			dfs(idx+1, max((int)to, c+1));
		}
}
int main(){
	cin >> N;
	dfs(0, 'a');
}


Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i = 1;
		int x;
		//CHECK_NUM
		do {
			x = i;
			if (x % 3 == 0) {
				System.out.print(" "+i);
			} else while (true) { //INCLUDE3
				if (x % 10 ==3) {
					System.out.print(" "+i);
					break;
				} else {
					x /= 10;
					if (x != 0) continue;
					else break;
				}
			}
		} while (++i <= n);
		// END_CHECK_NUM
		System.out.println();
	}
}

Measured memory_bytes: 28968
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine().toLowerCase();
		int cnt=0;
		while(true){
			String[] str2 = br.readLine().split(" ");
			if(str2[0].equals("END_OF_TEXT")) break;
			for(int i=0; i<str2.length; i++){
				if(str2[i].toLowerCase().equals(str)) cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 16980
#include <stdio.h>
int main(void){
  int n,b,ans=0;
  scanf("%d",&n);
  int a[n],c[n-1];
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(int i=0;i<n;i++){
    scanf("%d",&b);
    ans=ans+b;
  }
  for(int i=0;i<n-1;i++){
    scanf("%d",&c[i]);
  }
  for(int i=0;i<n-1;i++){
    if(a[i]+1==a[i+1]){
      ans=ans+c[a[i]-1];
    }
  }
  printf("%d",ans);
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n, k;
string s;

vector<int> block;
int num[MAX_N];
int acc[MAX_N];

int ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);

  cin >> s;
  if (s[n - 1] == '0') {
    s.push_back('1');
  }

  int cnt = 0;

  for (int i = 0; i < n; ++i) {
    if (s[i] == '1') continue;
    if (s[i] == '0' && s[i + 1] == '1') {
      cnt += 1;
    }
  }

  if (k >= cnt) {
    printf("%d\n", n);
    return 0;
  }

  for (int i = 0; i < n; ++i) {
    if (s[i] == '0') {
      if (i == 0 || s[i - 1] == '1') {
        num[i] = 1;
      }
    }
  }

  for (int i = 1; i < n; ++i) {
    num[i] += num[i - 1];
  }

  num[n] = num[n - 1] + 1;

  // for (int i = 0; i < n; ++i) {
  //   printf("%d %d\n", i, num[i]);
  // }

  ans = -1;

  for (int i = 0; i < n; ++i) {
    int add = (s[i] == '0') ? k - 1 : k;

    auto itr = upper_bound(num + i, num + n + 1, num[i] + add);

    int ind = (itr - num) - 1;

    // printf(":%d %d %d\n", i, ind, num[i] + k);

    int tmp = num[ind];
    if (tmp - num[i] != add) break;

    int score = ind - i + 1;

    ans = max(ans, score);
  }

  // cnt = 0;
  //
  // int l = 0;
  //
  // for (int i = 0; i < n; ++i) {
  //   if (s[i] == '0') {
  //     if (i == 0 || s[i - 1] == '1') cnt += 1;
  //   }
  //
  //   if (cnt > k) {
  //     while (s[l] == '1') l += 1;
  //     while (s[l] == '0') l += 1;
  //     cnt -= 1;
  //   }
  //
  //   ans = max(ans, i - l + 1);
  // }

  printf("%d\n", ans);

  return 0;
}


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

int main()
{
  int k, t;
  cin >> k >> t;
  vector<int> a(t);
  int i;
  int maxn = 0;
  int sum = 0;
  for(i = 0; i < t; i++)
  {
    cin >> a.at(i);
    if(a.at(i) > maxn) maxn = a.at(i);
    sum += a.at(i);
  }
  cout << max(maxn-(sum-maxn+1), 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    
    int cnt = 0;
    rep(i, n) { // iとj,kの2重ループのイメージ
        // abs(a[i] - a[j]) < a[i], a[j] < a[k]
        // よりこっちの条件は満たせてる
        int k = i + 2;
        rep3(j, i + 1, n) {
            while (k < n && a[k] < a[i] + a[j]) k++; // while ok
            // cout << i << " " << j << " " << k << endl;
            // kは1個先にいるから個数求める+1はいらない
            // j+1は, 3数目の最初の位置
            cnt += k - (j + 1);
        }
    }
    cout << cnt << endl;
    
}



Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int X,Y,Z,temp;
  scanf("%d %d %d",&X,&Y,&Z);
  temp = X;
  X = Y;
  Y = temp;
  temp = X;
  X = Z;
  Z = temp;
  printf("%d %d %d",X,Y,Z);
  return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
int H, W, h, w;

int main() {
  scanf("%d %d", &H, &W);
  scanf("%d %d", &h, &w);

  printf("%d\n", (H - h) * (W - w));
  
  return 0;
}


Measured memory_bytes: 256
n,q=gets.split.map &:to_i
A=n.times.map{[]}
q.times{
a=gets.split.map &:to_i
if a[0]==0
A[a[1]]<<a[2]
elsif a[0]==1
puts A[a[1]][-1] if A[a[1]][-1]
else
A[a[1]].pop
end
}


Measured memory_bytes: 9364
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

"""
・reversed LCS = 最大長の回文
・(長さ、始点、変更コスト) -> opt value
"""

S = np.frombuffer(readline().rstrip(),'S1')
N = len(S)
K = int(readline())

dp = [None] * (N+1) # 長さ -> array
dp[0] = None # 自身ないので使わない
dp[1] = np.zeros((N,K+10),np.int32); dp[1][:,0] = 1
if N >= 2:
    dp[2] = np.zeros((N-1,K+10),np.int32)
    dp[2][:,0] = 1+(S[:-1]==S[1:])
    dp[2][:,1] = 2

for n in range(3,N+1):
    arr = np.zeros((N-n+1,K+10),np.int32)
    # 両端をマッチしない場合
    np.maximum(arr,dp[n-1][:-1],out=arr)
    np.maximum(arr,dp[n-1][1:],out=arr)
    # 両端をコストなしでマッチさせる場合
    match = (S[:-n+1]==S[n-1:])
    np.maximum(arr,match[:,None]*(dp[n-2][1:-1]+2),out=arr)
    # 両端をコストありでマッチさせる場合
    np.maximum(arr[:,1:],dp[n-2][1:-1,:-1]+2,out=arr[:,1:])
    
    dp[n] = arr

answer = dp[-1][0][:K+1].max()
print(answer)

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

int main(){
  int n,m;
  cin >> n >> m;
  int flag[n],ans[n];
  rep(i,n) flag[i]=0;
  int a[m],b[m];
  rep(i,m){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  vector<vector<int>> nd(n);

  rep(i,m){
    nd[a[i]].push_back(b[i]);
    nd[b[i]].push_back(a[i]);
  }

  queue<int> que;
  que.push(0);
  flag[0]=1;
  while(que.empty()==0){
    int now=que.front();
    que.pop();
    rep(j,(int)nd[now].size()){
      if(flag[nd[now][j]]==0){
        que.push(nd[now][j]);
        ans[nd[now][j]]=now+1;
        flag[nd[now][j]]=1;
      }
    }
  }

  cout << "Yes\n";
  rep(k,n-1){
    cout << ans[k+1] << endl;
  }
  return 0;
}

Measured memory_bytes: 11960
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define pb push_back
#define mod 1000000007
#define N 1000007
ll power(ll a,ll b){
    ll res=1ll;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res%mod;
}
ll ncr(ll n,ll k){
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro)%mod;
}

void swap(ll *a,ll *b) {
    ll temp=*a;
    *a=*b;
    *b=temp;
}
vector<ll> prime;
void seive(){
    vector<bool > isprime(1000001,true);
    for(int i=2;i*i<=1000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
vector<ll> parent;
ll find(ll p) {
    if(parent[p]==p) return parent[p];
    return parent[p]=find(parent[p]); 
}
void unun(ll a,ll b) {
    ll r1=find(a);
    ll r2=find(b);
    if(r1!=r2) parent[r2]=r1;
}
void solve() {   
    ld n;
    cin>>n;
    if(n==100) {
        cout<<"0";
        return ;
    }
    ll p=100;
    for(ll i=1;i<=1e6;i++) {
        p=p*(1.01);
        if(p>=n) {
            cout<<i;
            return ;
        }
    }
    return ;
}   


int main(void){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        // cout<<endl;
    }
    return 0; 

}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define int long long
int sod(int val)
{
    int ans = 0;
    while(val)
    {
        ans += val%10;
        val/=10;
    }
    return ans;
}
int32_t main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    int ans = sod(1)+sod(n-1);
    for(int a=1;a<n;a++)
    {
        int b = n-a;
        ans = min(ans,sod(a)+sod(b));
    }
    cout<<ans;
    return 0;
}

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

public static class Program
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        for (int i = 1; i < 10; i++)
            for (int j = 1; j < 10; j++)
                if (i * j == n)
                {
                    Console.WriteLine("Yes");
                    return;
                }
        Console.WriteLine("No");
    }
}

Measured memory_bytes: 11092
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Long[] a = new Long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        Arrays.sort(a, (x,y) -> Long.compare(y, x));
        long ans = a[0];
        int cnt = 2;
        for (int i = 1; i < n; i++) {
            if(cnt == n)break;
            ans += a[i];
            if(n == ++cnt) break;
            ans += a[i];
            if(n == ++cnt) break;
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 64700
#include <iostream>
#include <vector>
#include <array>
#include <stack>

int main()
{
	std::vector<int> a;
	std::vector<int> b;

	int n = 0;
	std::cin >> n;

	while (n--)
	{
		bool is_failure = false;

		int datas[10] = { 0 };
		std::cin >> datas[0] >> datas[1] >> datas[2] >> datas[3] >> datas[4] >> datas[5] >> datas[6] >> datas[7] >> datas[8] >> datas[9];

		std::stack<int> stack_a{};
		std::stack<int> stack_b{};

		for (auto data : datas)
		{
			if (stack_a.empty())
			{
				stack_a.push(data);
				continue;
			}

			if (stack_a.top() < data)
			{
				stack_a.push(data);
				continue;
			}

			if (stack_b.empty())
			{
				stack_b.push(data);
				continue;
			}

			if (stack_b.top() < data)
			{
				stack_b.push(data);
				continue;
			}

			is_failure = true;
			break;
		}

		if (false == is_failure)
		{
			std::cout << "YES" << std::endl;
		}
		else
		{
			std::cout << "NO" << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3020
#include<bits/stdc++.h>
#define int long long
using namespace std;
int x;
signed main()
{
	scanf("%lld",&x);
	for(int i=0;i<=1000;i++)for(int j=i;j<=1000;j++)
	{
		int i5=i*i*i*i*i,j5=j*j*j*j*j;
		if(i5+j5==x)
		{
			printf("%lld %lld",i,-j);
			return 0;
		}
		if(i5-j5==x)
		{
			printf("%lld %lld",i,j);
			return 0;
		}
		if(-i5+j5==x)
		{
			printf("%lld %lld",j,i);
			return 0;
		}
		if(-i5-j5==x)
		{
			printf("%lld %lld",-i,j);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3828
import numpy as np
n,m,c=map(int,input().split())
b=np.array(list(map(int,input().split())))
a=np.array([list(map(int,list(input().split()))) for i in range(n)])
ans=0
for i in range(n):
    if sum(a[i][:]*b)+c>0:
        ans+=1
print(ans)

Measured memory_bytes: 12512
def find(i, m):
    if m[i] < 0:
        return i
    return find(m[i], m)


def count(i, m):
    if m[i] < 0:
        return abs(m[i])
    return count(m[i], m)


def main():
    n, m, *ab = map(int, open(0).read().split())
    ab = ab[::-1]
    tmp = n * (n - 1) // 2
    utl = []
    par = [-1] * (n + 1)

    for u, v in zip(ab[::2], ab[1::2]):
        if find(u, par) == find(v, par):
            utl.append(tmp)
        else:
            i, j = find(u, par), find(v, par)
            utl.append(tmp)
            tmp -= par[i] * par[j]
            if par[i] > par[j]:
                i, j = j, i
            par[i] += par[j]
            par[j] = i

    ans = '\n'.join(map(str, utl[::-1]))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25076
#include <bits/stdc++.h>
using namespace std;
int main(){
  int T;
  cin >> T;
  for (int i = 0; i < T; i++){
    int m, n;
    cin >> m >> n;
    int s = m * m + n * n;
    bool prime = true;
    int a = sqrt(s - 1);
    for (int j = - a; j <= a; j++){
      int b = sqrt(s - j * j - 1);
      for (int k = - b; k <= b; k++){
        int t = j * j + k * k;
        if (abs(t) > 1){
          if ((j * m + k * n) % (j * j + k * k) == 0 && (j * n - k * m) % (j * j + k * k) == 0){
            prime = false;
          }
        }
      }
    }
    if (prime){
      cout << 'P' << endl;
    } else {
      cout << 'C' << endl;
    }
  }
}


Measured memory_bytes: 2988
N,X=list(map(int,input().split()))
p=[]
a=[]
def search(N):
    if N==0:
        p.append(1)
        a.append(1)
        return 1,1
    else:
        search(N-1)
        p.append(2*p[N-1]+1)
        a.append(2*a[N-1]+3)
search(N)
def bug(N,X):#p,a
    if N==0 and X>=1:return 1
    if X==1:return 0
    if 1<X<=1+a[N-1]:
        return bug(N-1,X-1)
    elif X==a[N-1]+2:
        return p[N-1]+1
    elif a[N-1]+2<X<=2+2*a[N-1]:
        return p[N-1]+1+bug(N-1,X-2-a[N-1])
    elif X==3+2*a[N-1]:
        return 2*p[N-1]+1
print(bug(N,X))

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

int main() {
    int K;
    cin >> K;
    string S;
    cin >> S;
    if(S.size()<=K){
        cout << S << endl;
    }
    else{
        cout << S.substr(0,K) << "..." << endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#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)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")
 
bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}
 
int main(){
  int a,b,c;
  cin >> a >> b;
  if (b<10) {
    c = a*10+b;
  } else if (b==100) {
    c = a*1000+b;
  } else {
    c = a*100+b;
  }
  REP(i,1000){
    if (i*i==c){
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int IsPrimeCheck(int n) {
  int i;
  int m = n;

  for (i = 2; i < m; i++) {
    if (n%i == 0) return 0;
    m = n/i;
  }
  return 1;
}

int main() {
  int n;
  int buf;
  int i;
  int cnt = 0;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%d", &buf);
    if (IsPrimeCheck(buf)) {
      cnt++;
    }
  }

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


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int A, B;
    cin >> A >> B;
    if(A * B % 2 == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
  char a[4],b[4];
  scanf("%s%s",&a,&b);
  char c[7];
  int i;
  int k;
  i = 0;
  while (a[i])
  {
    c[i] = a[i];
    i++;
  }
  while (b[k])
  {
    c[i] = b[k];
    i++;
    k++;
  }
  c[i] = '\0';
  int d;
  i = 0;
  d = 0;
  while (c[i + 1])
  {
    d += c[i] - '0';
    d *= 10;
    i++;
  }
  d += c[i] - '0';
  i = 0;
  while (i * i < d)
  {
    i++;
  }
  if (i*i == d)
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }
}

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

int main(){

  int a,b,c,d,e,f;

  while(cin >> a >> b >> c >> d >> e >> f){

    a = (a*3600) + (b*60) + c;

    d = (d*3600) + (e*60) + f;

    d = d - a;

    cout << d/3600 << " " << (d%3600)/60 << " " << (d%3600)%60 << endl;

  }

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 200005

// it's swapnil07 ;)

signed main(){
    fast    
    #ifdef SWAPNIL07
        freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
        freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    #endif
    string s, t; cin>>s>>t;
    s = '0'+s;
    t = '0'+t;
    int n = s.length(), m = t.length();
    pii rev[n][m]; int dp[n][m];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(i==0 || j==0){
                dp[i][j]=0;
                rev[i][j]={0, 0};
            }
            else if(s[i]==t[j]){
                dp[i][j]=dp[i-1][j-1]+1LL;
                rev[i][j]={i-1, j-1};
            }
            else if(dp[i-1][j]>dp[i][j-1]){
                dp[i][j]=dp[i-1][j];
                rev[i][j]={i-1, j};
            }
            else{
                dp[i][j]=dp[i][j-1];
                rev[i][j]={i, j-1};
            }
        }
    }
    int i=n-1, j=m-1;
    string ans = "";
    while(i!=0 && j!=0){
        if(s[i]==t[j]){
            ans += s[i];
        }
        int ni = rev[i][j].F;
        int nj = rev[i][j].S;
        i = ni;
        j = nj;
    }
    reverse(all(ans));
    cout<<ans;
    return 0;
}

Measured memory_bytes: 211328
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(n):
    if a[i]>b[i]:
        ans+=b[i]
    else:
        ans+=a[i]
        if  a[i+1]>(b[i]-a[i]):
            ans+=b[i]-a[i]
            a[i+1]-=(b[i]-a[i])
        else:
            ans+=a[i+1]
            a[i+1]=0
print(ans)

Measured memory_bytes: 18624
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	k=k*2+1;
	if(n%k==0)
	{
		cout<<n/k<<endl;
		return 0;
	} else
	{
		cout<<n/k+1<<endl;
	}
}

Measured memory_bytes: 256
x,y=map(int,input().split())
a=y-x
if y-x<0:
	a=10**30
b=y+x+1
if y+x<0:
	b=10**30
c=-y-x+1
if -y-x<0:
	c=10**30
d=-y+x+2
if -y+x<0:
	d=10**30
print(min(a,b,c,d))

Measured memory_bytes: 3064