akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in();
  vector<int> a(n);
  cin >> a;

  int ans = inf;
  for (int x = -100; x <= 100; ++x) {
    int sum = 0;
    for (int i = 0; i < n; ++i) {
      sum += (x - a[i]) * (x - a[i]);
    }

    chmin(ans, sum);
  }
  cout << ans << endl;
}


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

class Program
{
    static void Main()
    {
        string[] cin = Console.ReadLine().Split();
        long n = long.Parse(cin[0]);
        long x = long.Parse(cin[1]);
        long[] a = Console.ReadLine().Split().Select(i => long.Parse(i)).ToArray();

        long ans = 0;
        if (a[0] > x)
        {
            ans = a[0] - x;
            a[0] = x;
        }

        for (long i = 0; i < n - 1; i++)
        {
            if (a[i] + a[i + 1] > x)
            {
                long gap = a[i] + a[i + 1] - x;
                ans += gap;
                if (a[i + 1] >= gap) a[i + 1] -= gap;
                else
                {
                    a[i] -= (gap - a[i + 1]);
                    a[i + 1] = 0;
                }
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 33500
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
const char newl = '\n';
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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 (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL<<60;

int main(){
    int n;cin >> n;
    vector<P> x(n);
    rep(i,n) cin >> x[i].first >> x[i].second;
    vector<P> y(n);
    rep(i,n) cin >> y[i].first >> y[i].second;

    sort(ALL(x));
    sort(ALL(y));
    multiset<int> ms;
    int cur = 0;
    int ans = 0;
    rep(i,n){
        while(cur<n&&x[cur].first<y[i].first){
            ms.insert(x[cur].second);
            cur++;
        }
        auto it = ms.lower_bound(y[i].second);
        if(it!=ms.begin()){
            it--;
            ms.erase(it);
            ans++;
        }
    }
    cout << ans << endl;
}


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

int N, M;
const int MAX_NM = 1.0e5;
int L[MAX_NM], R[MAX_NM];

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) cin >> L[i] >> R[i];

    int max_L = -1;
    int min_R = 1.0e9;
    for (int i = 0; i < M; i++) {
        max_L = max(L[i], max_L);
        min_R = min(R[i], min_R);
    }
    
    int ans = 0;
    if (max_L <= min_R) ans = min_R - max_L + 1;

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

Measured memory_bytes: 1024
#include <cstdio>
#include <string>
#include <queue>
#include <map>

using namespace std;

int main()
{
	char str[256];
	char col[4] = "rgb";
	
	while (scanf("%s", str) && str[0] !='0'){
		map<string, int> minTime;
		queue<string> q;
		string s = str;
		
		minTime[s] = 0;
		
		bool ng = true;
		for (q.push(s); !q.empty(); q.pop()){
			string look = q.front();
			
			bool flag = true;
			for (int i = 0; i < look.size() - 1; i++){
				if (look[i + 1] != look[i]) flag = false;
			}
			
			if (flag){
				printf("%d\n", minTime[look]);
				ng = false;
				break;
			}
			
			for (int c = 0; c < 3; c++){
				for (int i = 0; i < look.size() - 1; i++){
					if (look[i + 1] != col[c] && look[i] != col[c] && look[i + 1] != look[i]){
						string next = look;
						next[i + 1] = next[i] = col[c];
						if (minTime.count(next) > 0) continue;
						minTime[next] = minTime[look] + 1;
						q.push(next);
					}
				}
			}
		}
		if (ng) printf("NA\n");
	}
	
	return (0);
}

Measured memory_bytes: 2788
import math
A,B = map(int,input().split())

x1=math.ceil(A/0.08)
x2=math.ceil(B/0.1)
ans=-1
if math.floor(x1*0.08)==A and math.floor(x1*0.10)==B:
	ans=x1
if math.floor(x2*0.08)==A and math.floor(x2*0.10)==B:
	if ans==-1 or x2<ans:
		ans=x2
print(int(ans))



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n,i;
 long long int s;
 cin>>n;
 vector<long long>v(n);
 for(i=0;i<n;i++)cin>>v[i];
 sort(v.begin(),v.end());
 s=0;
 for(i=1;i<n;i++)
 {
     int l=n-1-i/2;
     s +=v[l];
 }
 cout<<s;
 return 0;
}



Measured memory_bytes: 4860
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

class Edge{
public:
    int from, to;
    long long cost;
    Edge(): from(0), to(0), cost(0){};
    Edge(int u, int v, long long w): from(u), to(v), cost(w){};
    ~Edge(){};
};

void Warshall_Floyd(std::vector<Edge> &edge, int V,
    std::vector<std::vector<long long> > &d)
{
    int E = edge.size();
    // const long long infty = 1e+16;
    // d.clear(); d.resize(V);
    // for(int i=0; i<V; i++){
    //     for(int j=0; j<V; j++) d[i].push_back(infty);
    // }

    // initialize
    for(int i=0; i<E; i++){
        d[edge[i].from][edge[i].to] = edge[i].cost;
    }
    for(int i=0; i<V; i++) d[i][i] = 0;

    // dp
    for(int k=0; k<V; k++){
        for(int i=0; i<V; i++){
            for(int j=0; j<V; j++) d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
        }
    }
}

int main()
{
    ll N, M, L, Q;
    scanf(" %lld %lld %lld", &N, &M, &L);
    vector<Edge> edges;
    for(int i=0; i<M; i++){
        int u, v; ll w;
        scanf(" %d %d %lld", &u, &v, &w); u--; v--;
        edges.emplace_back(u, v, w);
        edges.emplace_back(v, u, w);
    }
    scanf(" %lld", &Q);
    vector<int> s(Q), t(Q);
    for(int i=0; i<Q; i++){
        scanf(" %d %d", &s[i], &t[i]);
        s[i]--; t[i]--;
    }

    Vvec<ll> d(N, vector<ll>(N, 1e18));
    Warshall_Floyd(edges, N, d);

    vector<Edge> edges2;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            if(d[i][j] <= L){
                edges2.emplace_back(i, j, 1);
                edges2.emplace_back(j, i, 1);
            }
        }
    }

    Vvec<ll> d2(N, vector<ll>(N, 1e18));
    Warshall_Floyd(edges2, N, d2);

    for(int i=0; i<Q; i++){
        if(d2[s[i]][t[i]] > 1e5) cout << -1 << endl;
        else cout << d2[s[i]][t[i]]-1 << endl;
    }
}

Measured memory_bytes: 6128
#include <iostream>
#include <vector>
#include <stack>


void insert_stack(std::vector<std::vector<char> > &map, std::stack<std::pair<int, int> > &st, char self_color, char other_color, int &count, bool &check_surrounded, bool &check_only_wall) {
    int dx[] = {0, 0, 1, -1};
    int dy[] = {1, -1, 0, 0};
    int first;
    int second;

    first = st.top().first;
    second = st.top().second;
    st.pop();
    ++count;

    for (int k = 0; k < 4; k++) {
        if (map[first + dx[k]][second + dy[k]] == '.') {
            st.push(std::make_pair(first + dx[k], second + dy[k])); 
            map[first + dx[k]][second + dy[k]] = '$';
        } else if (map[first + dx[k]][second + dy[k]] == other_color) {
            check_surrounded = false; 
        } else if (map[first + dx[k]][second + dy[k]] == self_color) {
            check_only_wall = true;
        }
    }
    return;
}

void dfs(std::vector<std::vector<char> > &map, int i, int j, char self_color, char other_color, int &total) {
    int count = 0;
    bool check_surrounded = true;
    bool check_only_wall = false;

    std::stack<std::pair<int, int> > st;
    st.push(std::make_pair(i, j));
    map[i][j] = '$';

    while (1) {
        if (st.empty() == 1) {
            break; 
        }
        insert_stack(map, st, self_color, other_color, count, check_surrounded, check_only_wall);
    }

    if (check_surrounded == true && check_only_wall == true) {
        total += count;
    } else {
        check_surrounded = true;
        check_only_wall = false;
    }
    return;
}

int whole_search(std::vector<std::vector<char> > map, int w, int h, char self_color, char other_color) {
    int total = 0;

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (map[i][j] == '.') {
                dfs(map, i, j, self_color, other_color, total);
            }
        }
    }
    return total; 
}

int main(void) {
    int w;
    int h;

    while (1) {
        std::cin >> w >> h;
        if (w == 0 && h == 0) {
            break;
        }

        std::vector<std::vector<char> > map_b(h+2, std::vector<char>(w+2, '#'));
        std::vector<std::vector<char> > map_w(h+2, std::vector<char>(w+2, '#'));

        for (int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                std::cin >> map_b[i][j];
                map_w[i][j] = map_b[i][j];
            }
        }
        std::cout << whole_search(map_b, w, h, 'B', 'W') << " " << whole_search(map_w, w, h, 'W', 'B') << std::endl;
    }


    return 0;
}

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

int main() {
  int n, N, x;
  x = 0;
  
  cin >> n;
  N = n;
  while (N != 0) {
    x += N % 10;
    N /= 10;
  }
  
  if (n % x == 0) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}
      

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		String ans = "Yes";
		
		if (S.length()+1!=T.length()) {
			ans = "No";	
		}
		if (S.equals(T.substring(0, T.length()-1))) {	
		}
		else{
		ans = "No";}
		System.out.println(ans);
		

    }
}

Measured memory_bytes: 35600
import Data.List

splitBy :: Char -> String -> [String]
splitBy _ [] = []
splitBy a x =
  let s = takeWhile (/= a) x
      x'= dropWhile (/= a) x
  in
    if x' == []
    then [s]
    else s:(splitBy a $ drop 1 x')

-- a*x + b*y + c = 0 と d*x + e*y + f = 0の交点
cpl [a,b,c,d,e,f] =
  let x = (b*f - c*e) / (a*e - b*d) -- aex + bey + ce = 0, bdx + bey + bf = 0
      y = (a*f - c*d) / (b*d - a*e) -- adx + bdy + cd = 0, adx + aey + af = 0
  in
    if (a*e == b*d) || (b*d == a*e)
    then Nothing
    else Just (x,y)

-- 2点 (xa,ya) (xb,yb)を通る直線 ax+by+c=0
ln [xa,ya,xb,yb] =
  let a =  ya - yb
      b = -xa + xb
      c = (-ya+yb)*xa + (xa-xb)*ya
  in
    [a,b,c]
  
cp4 [xa,ya,xb,yb,xc,yc,xd,yd] =
  let lab = ln [xa,ya,xb,yb]
      lcd = ln [xc,yc,xd,yd]
  in
    cpl (lab ++ lcd)

ans [xa,ya,xb,yb,xc,yc,xd,yd] =
  let cross = cp4 [xa,ya,xc,yc,xb,yb,xd,yd] 
      [xo,xp] = sort [xa,xc]
      [xq,xr] = sort [xb,xd]
      [yo,yp] = sort [ya,yc]
      [yq,yr] = sort [yb,yd]
  in
    case cross of
      Nothing      -> "NO"
      Just (xx,yx) -> if (xo <= xx ) && (xx <= xp) && (xq <= xx) && (xx <= xr) &&
                         (yo <= yx ) && (yx <= yp) && (yq <= yx) && (yx <= yr)
                      then "YES"
                      else "NO"

main = do
  c <- getContents
  let i = map (map read) $ map (splitBy ',') $ lines c :: [[Float]]
      o = map ans i
  mapM_ putStrLn o




Measured memory_bytes: 4284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n,MIN=INF;
	cin>>n;
	for(int i=0;i<5;i++){
		ll z;
		cin>>z;
		MIN=min(MIN,z);
	}
	cout << (n-1)/MIN+5;
}


Measured memory_bytes: 256
N,H=map(int,raw_input().split())
c=[]
for i in range(N):
	a,b=map(int,raw_input().split())
	c.append((a,0))
	c.append((b,1))

c.sort(key=lambda x:x[0],reverse=True)

cnt=0
for i,j in c:
	if j==1:
		H-=i
		cnt+=1
		if H<=0:
			break
	else:
		if H%i==0:
			cnt+=H/i
			break
		else:
			cnt+=H/i+1
			break
print cnt




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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
    if(b==0) return a;
    return gcd(b, a%b);
}


////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
    vector<bool> prime(n+1, true);
    for(int i = 2; i <= sqrt(n); i++)
    {
        if(prime[i])
        {
            for(int j = i*i; j<=n; j+=i)
            {
                prime[j]=false;
            }
        }
    }
    vector<int> all_primes;
    for(int i = 2; i <=n; i++)
    {
        if(prime[i]) all_primes.pb(i);
    }
    return all_primes;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int> arr(n), sum(n), diff(n);
    map<int, int> ct;
    for(int i = 0; i < n; i++)
        {cin>>arr[i];}
    for(int i = 0; i < n; i++)
        sum[i]=i+arr[i];
    for(int j = 0; j < n; j++)
    {
        diff[j] = j - arr[j];
        ct[diff[j]]++;
    }
    sort(diff.begin(), diff.end());
    sort(sum.begin(), sum.end());
    ll ans = 0;
    for(int i = 0; i < n; i++)
        if(binary_search(diff.begin(), diff.end(), sum[i]))
            ans+=ct[sum[i]];
    cout<<ans<<endl;
    return 0; 
} 

Measured memory_bytes: 14136
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) a[i] = scan.nextInt();
		
		for (int i = 0; i < n/2; i++) {
			int temp = a[i];
			a[i] = a[n-i-1];
			a[n-i-1] = temp;
		}
		
		for (int i = 0; i < n; i++) {
			System.out.printf("%d", a[i]);
			if (i != n-1) System.out.print(" ");
		}
		System.out.println();
	}
}



Measured memory_bytes: 26780
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, M, K, Q;
string S;

int main() {
    cin >> N;

    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            if (i * 4 + j * 7 == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

string sa;

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>sa;
	a=0;
	for(i=0;i<sa.size()-1;i++){
		if(sa[i]!=sa[i+1])a++;
	}
	cout<<a<<endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		 int n=scn.nextInt();
		 int m=scn.nextInt();
		 int [] arr = new int[m];
		 for(int i=0;i<m;i++){
			 arr[i]=scn.nextInt();
			 
		 }
		 for(int i=0;i<m;i++){
			 n-=arr[i];
			 if(n<0){
				 System.out.println(-1);
				 return;
			 }
		 }
		 System.out.println(n);

	}

}

Measured memory_bytes: 46220
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;

int n;
LL a, b;

LL Get_sqrt(LL x) 
{
	LL l = 1, r = 1e9 + 10;
	while(l < r - 1) {
		LL mid = (l + r) >> 1;
		if(mid * mid <= x) l = mid;
		else r = mid;
	}
	return l;
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%lld%lld", &a, &b);
		LL x = Get_sqrt(a * b - 1LL);
		LL ans;
		if(x * (x + 1LL) <= a * b - 1LL) {
			ans = x * 2LL;
			if(x >= min(a, b)) ans--;
		}
		else {
			ans = 2LL * x - 1LL;
			if(x >= min(a, b)) ans--;
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;

int main(){
    int len; cin>>len;
    int k; cin>>k;
    vector<int> arr(len);
    for(int& i:arr) cin>>i;
    
    vector<int> dp(len, INF);

    dp[0] = 0;
    
    for(int i=0;i<len;i++){
        for( int j = i+1; j<=i+k;j++){
            if( j<len ) dp[j] = min(dp[j],dp[i] + abs(arr[j]-arr[i]));
        }
    }
    
    cout<<dp[len-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT32 N = 0;
	cin >> N;

	vector<SINT32> ADATA(N);
	vector<SINT32> BDATA(N);
	vector<SINT32> CDATA(N);

	vector<vector<SINT32>> DP(N,vector<SINT32>(3));
	
	for (SINT32 i = 0; i < N; i++) {
		cin >> ADATA[i];
		cin >> BDATA[i];
		cin >> CDATA[i];
	}

	DP[0][0] = ADATA[0];
	DP[0][1] = BDATA[0];
	DP[0][2] = CDATA[0];

	for (SINT32 i = 1; i < N; i++) {
		DP[i][0] = MAX(DP[i-1][1],DP[i-1][2]) + ADATA[i];
		DP[i][1] = MAX(DP[i-1][0],DP[i-1][2]) + BDATA[i];
		DP[i][2] = MAX(DP[i-1][0],DP[i-1][1]) + CDATA[i];
	}

	SINT32 ANS = MAX(MAX(DP[N-1][0],DP[N-1][1]),DP[N-1][2]);

	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

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

using namespace std;
using ll = long long;

int main() {
    int n, k;
    cin >> n >> k;
    int h[n];
    for (int &x : h) cin >> x;
    sort(h, h + n);
    ll sum = 0;
    for (int i = 0; i < (n - k); ++i) {
        sum += h[i];
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		sc.close();

		int x3 = 0;
		int y3 = 0;
		int x4 = 0;
		int y4 = 0;

		x3 = x2 + y1 - y2;
		y3 = y2 - x1 + x2;
		x4 = x1 + y1 - y2;
		y4 = x2 - x1 + y1;

		System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);

	}
}

Measured memory_bytes: 21844
N,M = gets.split.map(&:to_i)
AB = readlines.map {|a| a.split.map(&:to_i) }.sort

ans = 0
cnt = 0
AB.each do |a,b|
  n = [M-cnt,b].min
  ans += a * n
  cnt += n
  break if cnt == M
end
puts ans


Measured memory_bytes: 19704
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    string s;
    cin >> s;
    int ans = s.size(), cnt = 0;
    rep(i, s.size()){
        if(s[i] == 'S'){
            cnt++;
        }else if(cnt > 0){
            cnt--;
            ans -= 2;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define lowbit(x) (x&(-x))
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) ((a)<(b)?(a):(b))
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 1e7;
const int maxn = 2e5 + 5;
ll mod = 1e9 + 7;

int n, a[maxn], p[maxn];

int t[maxn];
void add(int x)
{
	while (x <= n)
	{
		++t[x];
		x += lowbit(x);
	}
}
int sum(int x)
{
	int cnt = 0;
	while (x)
	{
		cnt += t[x];
		x -= lowbit(x);
	}
	return cnt;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", a + i);
		p[a[i]] = i;
	}

	ll ans = 0;
	for (int i = 1; i <= n; i++)
	{
		int L, R, l, r, mid;

		l = 1; r = p[i];
		while (l < r)
		{
			mid = (l + r) / 2;
			if (sum(p[i]) - sum(mid - 1))
				l = mid + 1;
			else
				r = mid;
		}
		L = r;

		l = p[i]; r = n;
		while (l < r)
		{
			mid = (l + r) / 2 + 1;
			if (sum(mid) - sum(p[i]))
				r = mid - 1;
			else
				l = mid;
		}
		R = r;

		ans += (ll)(p[i] - L + 1)*(R - p[i] + 1)*i;
		add(p[i]);
	}
	printf("%lld", ans);
}

Measured memory_bytes: 3196
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
	long long n, k;
	cin >> n >> k;
	n = n % k;
	while (n > abs(n - k)) {
		n = abs(n - k);
	}
	cout << n << endl;
}

Measured memory_bytes: 888
#include<stdio.h>
main(){for(;;){
		int i,n,m,hito = 0,temp;
		int me[1000];
		int ban[1000];
		
		scanf("%d%d",&n,&m);
		if(n == 0){break;}
		for(i = 0; i < n; i++){scanf("%d",&ban[i]);}
		for(i = 0; i < m; i++){scanf("%d",&me[i]);}
		for(i = 0; i < m; i++){hito += me[i];
		if(hito >= n){i++;break;}temp = hito;hito += ban[temp];
		if(hito >= n){i++;break;}}
		printf("%d\n",i);}}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define Z 10100
using namespace std;
int d[Z+1];
int main(){
	int n,m,k,r,l;
	while(true){
		cin>>n>>k>>m>>r;
		if(!(n+m+k+r))break;
		rep(i,0,Z)d[i]=0;
		k=1,l=n;
		rep(i,0,Z)d[i]+=k/l,k%=l,k*=10;
		if(m)rep(i,1,n){k=1,l=i*n;rep(j,0,Z)d[j]+=k/l,k%=l,k*=10;}
		for(int i=Z;i>0;i--)d[i-1]+=d[i]/10,d[i]%=10;
		cout<<d[0]<<".";
		rep(i,1,r+1)cout<<d[i];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3016
#include <iostream>

int main(){
    uint a, b, sum = 0;
    std::cin >> a >> b;
    
    switch(a){
        case 1: sum += 300000; break;
        case 2: sum += 200000; break;
        case 3: sum += 100000; break;
    }
    switch(b){
        case 1: sum += 300000; break;
        case 2: sum += 200000; break;
        case 3: sum += 100000; break;
    }
    if (a == 1 && b == 1){
        sum += 400000;
    }
    std::cout << sum << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	int N,K;
	cin>>N>>K;
	vector<double>P(N);
	rep(i,0,N){
		cin>>P[i];
		P[i]=(P[i]+1)/2;
	}
	vector<double>T(N);
	rep(i,0,K){
		T[0]+=P[i];
	}
	rep(i,1,N-K+1){
		T[i]=T[i-1]-P[i-1]+P[i+K-1];
	}
	sort(all(T));
	reverse(all(T));
	cout<<fixed << setprecision(14)<<T[0]<<endl;
	return 0;
}


Measured memory_bytes: 3456
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B = il()
    print(max(0, A - B*2))


if __name__ == '__main__':
    main()


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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N = 2000005;
const LL MOD = 1e9 + 7;
LL fac[N];
inline LL BigMod(LL B,LL P,LL M){LL R=1;while(P>0){if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;}return R;}

LL COM(LL a,LL b){return ((fac[a]*BigMod((fac[b]*fac[a-b])%MOD,MOD-2,MOD))%MOD+MOD)%MOD;}

LL solve(LL x,LL y)
{
    LL ans = 0;

    for(int i = 0;i <= x;i++){
        LL temp = COM(i + y + 1,y);
        ans = (ans + temp) % MOD;
    }
    return ans;
}
int main()
{
    fac[0] = 1;
    for(int i = 1;i < N;i++)fac[i] = (fac[i - 1] * i) % MOD;

    LL r1,r2,c1,c2;
    cin >> r1 >> c1 >> r2 >> c2;
//    cout << solve(r2,c2) << endl;
    LL ans = solve(r2,c2) - solve(r2,c1 - 1) - solve(r1 - 1,c2) + solve(r1 - 1,c1 - 1);

    ans = (ans % MOD + MOD) % MOD;
    cout << ans << "\n";

}




Measured memory_bytes: 15872
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  long long int N, C;
  cin >> N >> C;
  
  vector<long long int> x(N), v(N);
  for(long long int i = 0; i < N; ++i) cin >> x[i] >> v[i];

  vector<long long int> sxv(N);
  sxv[0] = v[0]-x[0];
  for(int i = 1; i < N; ++i) sxv[i] = sxv[i-1]+v[i]-x[i]+x[i-1];
  
  vector<long long int> mxv(N);
  mxv[0] = sxv[0];
  for(long long int i = 1; i < N; ++i) mxv[i] = max(mxv[i-1],sxv[i]);
  
  vector<long long int> y(N);
  for(int i = 0; i < N; ++i) y[i] = C-x[N-i-1];

  vector<long long int> syv(N);
  syv[0] = v[N-1]-y[0];
  for(int i = 1; i < N; ++i) syv[i] = syv[i-1]+v[N-i-1]-y[i]+y[i-1];
  
  vector<long long int> myv(N);
  myv[0] = syv[0];
  for(long long int i = 1; i < N; ++i) myv[i] = max(myv[i-1],syv[i]);
  
  long long int ans {0};
  ans = max(ans, mxv[N-1]);
  ans = max(ans, myv[N-1]);

  for(long long int i = 0; i < N-1; ++i) ans = max(ans, myv[i]+mxv[N-i-2]-y[i]);
  for(long long int i = 0; i < N-1; ++i) ans = max(ans, mxv[i]+myv[N-i-2]-x[i]);

  cout << ans << endl;
}

Measured memory_bytes: 5760
n,k=(int(i) for i in input().split())
l=[int(i) for i in input().split()]
d={}
town=1
telep=0
ls=0
lc=0
d[town]=0
for i in range(n):
    telep=l[town-1]
    town=telep
    if(ls==0):
        lc+=1
    if(town not in d):
        d[town]=lc
    elif(ls==0):
        ls=town
lc=d[ls]
if(k<=lc):
    town=1
    telep=0
    for i in range(k):
        telep=l[town-1]
        town=telep
    print(town)
else:
    k-=lc
    town=ls
    telep=0
    k=k%(max(d.values())-lc+1)
    for i in range(k):
        telep=l[town-1]
        town=telep
    print(town)

Measured memory_bytes: 39240
import collections
n = (int)(input())
l = list(map(int,input().split()))
a = l[::2]
b=l[1::2]

a_c=collections.Counter(a).most_common()
b_c=collections.Counter(b).most_common()
if a_c[0][0]==b_c[0][0]:
    if a_c[0][1]==b_c[0][1]:
        if a_c[0][1]==n/2:
            print(n//2)
        else:
            print(n-a_c[0][1]-max(a_c[1][1],b_c[1][1]))
    elif a_c[0][1]>b_c[0][1]:
        if len(b_c)>1:
            print(n-a_c[0][1]-b_c[1][1])
        else:
            print(n-a_c[0][1])
    else:
        if len(a_c)>1:
            print(n-a_c[1][1]-b_c[0][1])
        else:
            print(n-b_c[0][1])
else:
    print(n-a_c[0][1]-b_c[0][1])


Measured memory_bytes: 21084
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

int main(){
  int n, m;
  map<int, int> cnt;

  scanf("%d%d", &n, &m);
  for(int i = 0;i < m;++i){
    int a, b;
    scanf("%d%d", &a, &b);
    ++cnt[a];
    ++cnt[b];
  }

  bool ok = true;
  for(const auto& p : cnt)
    if(p.se & 1) ok = false;

  printf(ok ? "YES\n" : "NO\n");

  return 0;
}


Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	a := float64(nextInt())
	b := float64(nextInt())
	x := float64(nextInt())

	z := x / (a * a)
	deg := float64(180.0) / math.Pi

	if z >= b/2 {
		deg *= math.Atan2(b-z, a/2.0)
	} else {
		deg *= math.Atan2(b, (2.0*x)/(a*b))
	}
	fmt.Printf("%.10f\n", deg)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli t;
    // cin >> t;
    vector<lli> v;
    string s;
    cin >> s;
    lli x = 0;
    for1(i, 0, s.length())
    {
        x += (s[i] - '0');
        x %= 9;
    }
    if (!x)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define range(c) c.begin() , c.end()
#define forn(i,n) for(ll i=0; i<n; ++i)
#define endl '\n'
#define MOD 1000000007
#define test ll t;cin >> (t);while(t--)
using namespace std;
//////////////////////////////////////////////////////////////


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    ll a[n][3];
    forn(i,n)
    {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    ll dp[n][3];
    memset(dp,-1,sizeof(dp));
    
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    
    
    
    for(ll i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
    }
    
    
    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 4992
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int lli;
typedef vector<vector<lli> > vlli;
lli N, K, W;
vector<lli> Weight(100);
vector<lli> Value(100);
vector<vector<lli> > M(101, vector<lli> (1e5 +5, -2));
lli dfs(int i, int S){
	if(S<=0) return 0;
	if(i==-1){
		if(S>0) return 1e15;
			return 0;}	
	if(M[i][S]!=-2) return M[i][S];
	lli x=	Weight[i]+dfs(i-1, S-Value[i]);
	lli y=	dfs(i-1, S);
	// cout<<"i:"<<i<<" S:"<<S<<" x:"<<x<<" y:"<<y<<endl;
	return M[i][S]=min(
	x, 
	y
	);
}
int main() 
{ 
    cin>>N>>W;
    for (int i = 0; i < N; ++i)
    {
    	cin>>Weight[i]>>Value[i];
    }
    lli SUM=0;
    for (int i = 0; i < N; ++i)
    {
    	SUM+=Value[i];
    }
    for (int i =SUM; i >=0 ; i--)
    {
		dfs(N-1, i);
    }
    for (int i = SUM; i >=0; i--)
    {
    	if(M[N-1][i]>W) continue;
    	cout<<i;
    	return 0;
    }
    cout<<0;
    return 0; 
}

Measured memory_bytes: 81520
def resolve():
    N = int(input())
    ABs = [list(map(int, input().split(" "))) for i in range(N)]
    ABs = sorted(ABs, key=lambda x: x[1])
    time = 0
    for ab in ABs:
        if time + ab[0] > ab[1]:
            print("No")
            return
        time += ab[0]
    print("Yes")

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 89768
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	lint N, Q;
	cin >> N >> Q;
	vector<deque<int>>A(N);
	rep(i, Q) {
		lint a;
		cin >> a;
		if (a == 0) {
			lint t, x;
			cin >> t >> x;
			A[t].push_front(x);
		}
		else if (a == 1) {
			lint t;
			cin >> t;
			if (!A[t].empty()) {
				cout << A[t].back() << endl;
			}
		}
		else if (a == 2) {
			lint t;
			cin >> t;
			if (!A[t].empty()) {
				A[t].pop_back();
			}
		}
	}
}




Measured memory_bytes: 4468
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))
x = 0
y = 0
z = 0
for i in range(N):
  if(P[i]<=A):
    x+=1
  elif P[i]<=B:
    y+=1
  else:
    z+=1
print(min(x,y,z))

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

//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここからコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////
// Ford-Fulkerson //
////////////////////

class MaxFlow {
private:
	using vi64 = std::vector<int64_t>;
	using Matrix = std::vector<vi64>;
	std::vector<bool> visited_;

	Matrix graph_;

	int64_t findPath(const int source, const int sink, const int node_i, const int64_t flow)
	{
		if (node_i == sink) return flow;
		visited_[node_i] = true;
		for (int next_i{}; next_i < (int)graph_.size(); next_i++)
		{
			if (!graph_[node_i][next_i] || visited_[next_i]) continue;
			const int64_t additional_flow{findPath(source, sink, next_i, std::min(flow, graph_[node_i][next_i]))};
			if (!additional_flow) continue;

			graph_[node_i][next_i] -= additional_flow;
			graph_[next_i][node_i] += additional_flow;
			return additional_flow;
		}
		return 0;
	}
public:
	MaxFlow(const int node_num)
		: graph_(node_num, vi64(node_num)), visited_(node_num){}
	void add_edge(const int from, const int to, const int64_t flow)
	{
		graph_[from][to] += flow;
	}
	int64_t operator()(const int source, const int sink)
	{
		int64_t flow_sum{};
		while (true)
		{
			std::fill(visited_.begin(),visited_.end(), false);
			int64_t additional_flow{findPath(source, sink, source, LLONG_MAX)};
			if (!additional_flow) break;
			flow_sum += additional_flow;
		}
		return flow_sum;
	}
};


//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここまでコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=jp
int main()
{
	int V, E;
	scanf("%d%d", &V, &E);
	MaxFlow max_flow(V);

	for (int e_i{}; e_i < E; e_i++)
	{
		int u, v, c;
		scanf("%d%d%d", &u, &v, &c);
		max_flow.add_edge(u, v, c);
	}
	printf("%lld\n", max_flow(0, V - 1));
	return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

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

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

int main() {
  int N;
  cin >> N;
  set<int> s;
  int m;
  rep(i, 0, N) {
    cin >> m;
    s.insert(m);
  }

  cout << s.size() << endl;
};


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

int main(){
	int h, w, count = 0;
	cin >> h >> w;
	string s[h];
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	for(int i=0; i < h; i++) {
		for(int j=0; j < w; j++) {
			if(s[i].at(j) == '#') {
				cout << '#';
				continue;
			}
			for(int k=-1; k <= 1; k++) {
				for(int l=-1; l <= 1; l++) {
					if(i+k < 0 || i+k >= h || j+l < 0 || j+l >= w)
						continue;
					if(s[i+k].at(j+l) == '#')
						count++;
				}
			}
			cout << count;
			count = 0;
		}
		cout << endl;
	}
}


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

int main(){
  int N;
  std::cin >> N;

  std::vector<int> b(N);

  for(int i=0; i < N; i++){
    std::cin >> b[i];

  }

  std::vector<int> res(N);

  bool feasible = true;


  for(int n=N-1; n >= 0; n--){
    bool found = false;

    for(int j=n; j >= 0; j--){
      if(b[j] == j+1){
        found = true;
        res[n] = j+1;

        b.erase(b.begin()+j);
        break;
      }
    }
    
    if(!found){ 
      feasible = false;
      break;
    }
  }

  if(!feasible){
    std::cout << -1 << std::endl;
  } else{
    for(int i=0; i < N; i++){
      std::cout << res[i] << std::endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int N, T, c, t, ans = 10000;
    cin >> N >> T;
    int mincost = (1 << 21);
    rep(i, N){
        cin >> c >> t;
        if(t <= T && mincost > c) {
            mincost = c;
            ans = i + 1;
        }
    }
    if(ans != 10000 ) cout << mincost << endl;
    else cout << "TLE\n";
    return 0;
}

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

using namespace std;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back

typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const ll mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//


int main(){
        int a,b;
        cin >> a >> b;
        if(a <= 0 && b >= 0) cout << "Zero" << endl;

        else if(a >= 1 && b >= 1) cout << "Positive" << endl;

        else if(a < 0 && b < 0){
                if((a-b+1)%2 == 0) cout << "Positive" << endl;
                else cout << "Negative" << endl;
        }

        else if(a < 0){
                if(a%2 == 0) cout << "Positive" << endl;
                else cout << "Negative" << endl;
        }
        return 0;
}





























Measured memory_bytes: 256
def main():
    s = input()
    iti = int(s[-1])
    ans = {"hon":[2,4,5,7,9],
           "pon":[0,1,6,8],
           "bon":[3]}
    for key in ans:
        if iti in ans[key]:
            print(key)

if __name__ == '__main__':
    main()

Measured memory_bytes: 61652
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; cout << "i=  ";for(ll i=0; i<num; i++) cout << i << "   ";cout << endl;  
  cout << "    ";
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<"   ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<"   ";}
  cout << endl;
}

// template <typename T>
// void print_pairvec(const vector<T> &v, ll num=0){
//   if(num == 0) num = (ll)v.size();
//   cout << endl; for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
// }
template <typename T>
void print_pairvec(const T &_pair, ll num=0){
  cout << endl; for(pair<ll, int> x: _pair){ cout << x.first << " " << x.second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

struct Eratosthenes{
  vector<ll> sieve;// sieve[i]: 数字iがエラトステネスで篩落とされた時の素数

  Eratosthenes(ll n): sieve(n+1){
    for(int i=0; i<=n; i++) sieve[i] = i;
    for(ll i=2; i*i<=n; i++){
      if(sieve[i] < i) continue;
      for(ll j=i*i; j<=n; j+=i) sieve[j] = min(sieve[j], i);
    } 
  }

  vector<ll> prime_divisors(ll x, bool tmp=false){
    vector<ll> res(1,1);//back()のところで ひっかかるので1を入れとかないとダメ
    while(x > 1){
      if(res.back() != sieve[x]) res.push_back(sieve[x]);
      x /= sieve[x];
    }
    return res;
  }

  map<ll, int> prime_divisors(ll x, int tmp=0){
    map<ll, int> mp;
    while(x > 1){
      mp[sieve[x]]++;
      x /= sieve[x];
    }
    return mp;
  }
};

int main(){
  int N;
  cin >> N;
  
  const int INF = 1e7;
  Eratosthenes era(INF);
  ll ans = 0;
  for(int k=1; k<=N; k++){
    map<ll, int> mp = era.prime_divisors(k, 0);
    int num = 1;//約数の個数を数える
    for(pair<ll, int> x : mp) num *= x.second+1;
    ans += (ll)k * num;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 81400