akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

void Main() {
	int n,sum=0; cin >> n;
	string s; cin >> s;
	repi(i,1, n) {
		if (s[i] == s[i - 1])sum++;
	}
	cout << n - sum;
}


int main() {
	Main();

	return 0;
}

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

long long gcd (long long a, long long b) {
  long long d=a;
  if (b!=0) {
    d=gcd(b, a%b);
  }
  return d;
}

int main() {
  long long A, B;
  cin >> A >> B;
  long long d=gcd(A,B);
  cout << A/d*B << endl;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	
	int n,k;
	cin >> n >> k;

	int ans = k;
	
	rep(i,n-1)ans *= k-1;
	cout << ans << endl;


	


	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://abc046.contest.atcoder.jp/tasks/abc046_b

Measured memory_bytes: 3596
//Code By CXY07
#include<bits/stdc++.h>
using namespace std;

//#define int long long

const int MAXN = 5;
const int INF = 2e9;
const int mod = 1e9 + 7;

int n;
char s[MAXN];

signed main () {
	cin >> s + 1;
	n = strlen(s + 1);
	for(register int i = 1;i <= n; ++i)
		if(s[i] == '7') {puts("Yes"); return 0;}
	puts("No");
	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int main(){
    char str[21];
    char res[21];

    while(gets(str) != NULL)
    {
        unsigned int i = strlen(str);
        unsigned int j = 0;
        while(i > 0)
        {
            res[j++] = str[i-1];
            i = i - 1;
        }
        res[j] = '\0';

        puts(res);
    }
    return 0;
}

Measured memory_bytes: 520
# 必ずN回以下でループする
N, K = map(int, input().split())
towns = [int(i) for i in input().split()]
arrivedList = [1]
for i in range(N * 2):
    arrivedList.append(towns[arrivedList[-1] - 1])
if K <= N:
    print(arrivedList[K])
    exit()

loop_end = N
loop_start = N - 1
while (arrivedList[loop_end] != arrivedList[loop_start]):
    loop_start -= 1

loop_len = loop_end - loop_start

# Kの値をloop_lenを使って調整する
K = K % loop_len
while K < N:
    K += loop_len

print(arrivedList[K])


Measured memory_bytes: 32360
#include<bits/stdc++.h>
using namespace std;
long long x[1000010],y[1000010];
#define int long long
signed main(){
  
  cin.tie(0);
  ios::sync_with_stdio(false);

  int a,b;
  string s;
  cin>>a>>s>>b;

  if(s=="+") cout<<a+b<<'\n';
  else cout<<a-b<<'\n';
}


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

void insertion_sort(vector<int> &a, int g, int &cnt) {
  int N = a.size();
  for (int i = g; i < N; ++i) {
    int v = a[i];
    int j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j + g] = a[j];
      j = j - g;
      ++cnt;
    }
    a[j + g] = v;
  }
}

void shell_sort(vector<int> &a) {
  int n = a.size();
  vector<int> g;
  while (n) {
    g.push_back(n);
    n /= 2;
  }

  int cnt = 0;
  int m = g.size();
  for (int i = 0; i < m; ++i) {
    insertion_sort(a, g[i], cnt);
  }

  cout << m << endl;
  for (int i = 0; i < m; ++i) {
    if (i) cout << " ";
    cout << g[i];
  }
  cout << endl;
  cout << cnt << endl;
  for (auto t : a) {
    cout << t << endl;
  }
}

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

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

  shell_sort(a);
}

Measured memory_bytes: 6956
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
map<LL,LL>u;
int main()
{
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
  cin>>n>>m>>o;
  u[n]++;
  u[m]++;
  u[o]++;
  cout<<u.SZ<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

#define M 100
#define I 10000000
#define W 0
#define G 1
#define B 2

int n,m[M][M];

int prim(){
  int i,u,min,v,sum = 0;
  int a[M],b[M],c[M];

  for(i = 0;i < n;i++){
    a[i] = I;
    b[i] = -1;
    c[i] = W;
  }

  a[0] = 0;

  while(1){
    min = I;
    u = -1;
    for(i = 0;i < n;i++){
      if(c[i] != B && min > a[i]){
	min = a[i];
	u = i;
      }
    }
    if(u == -1){
      break;
    }

    c[u] = B;

    for(v = 0;v < n ;v++){
      if(c[v] != B && m[u][v] != I){
	if(a[v] > m[u][v]){
	  a[v] = m[u][v];
	  b[v] = u;
	  c[v] = G;
	}
	
      }
    }
  }
  for(i = 0;i < n;i++){
    if(b[i] != -1) sum += m[i][b[i]];
  }

  return sum;
}


int main(){
  int k,i,j;
  scanf("%d",&n);

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      scanf("%d",&k);
      if(k == -1){
	m[i][j] = I;
      }
      else m[i][j] = k;
    }
  }
  printf("%d",prim());
  printf("\n");

  return 0;
}



Measured memory_bytes: 2108
//
// Created by aarav on 9/11/2020.
//

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const string nl = "\n";

bool prime(int n) {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}

vector<bool> sieve(int n) {
    vector<bool> prime(n + 1, true);

    for (int p = 2; p * p <= n; p++) {
        if (prime[p] == true) {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
    return prime;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll N;
    cin >> N;
    if (N == 1) {
        cout << 0 << nl;
        exit(0);
    }
    vector<bool> isprime = sieve(1000001);
    long long ans = 0;
    vector<ll> primes;
    ll mx = (ll) sqrt(N);
    for (long long i = 2; i <= mx; i++) {
        if (isprime[i] && ((N % i) == 0)) {
            long long cnt = 0;
            while (N % i == 0) {
                cnt++;
                N /= i;
            }
            long long c = 1;
            while (((c + 2) * (c + 1) / 2) <= cnt)
                c++;
            ans += c;
        }
    }
    if (N > 1)
        ans++;
    if (ans == 0)
        cout << 1 << nl;
    else
        cout << ans << nl;

}


Measured memory_bytes: 3776
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main() {
  int n, ans;
  cin >> n;
  int  a[n];
  int b[n];
  int c[n];

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

  for(int i=0; i < n; i++){
      ans = ans + b[a[i]-1];
      if(i <= n-1){
      if(a[i]+1 == a[i+1]){
        ans += c[a[i]-1];
      }
    }
  }

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

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

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var A = items[0];
            var B = items[1];
            var kuchi = 1;
            var count = 0;
            while (kuchi < B)
            {
                count++;
                kuchi += A - 1;
            }

            Console.WriteLine(count);
        }
    }
}


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

int main() {
  string s; cin>>s;
  if(s=="Sunny")cout<<"Cloudy";
  if(s=="Cloudy")cout<<"Rainy";
  if(s=="Rainy")cout<<"Sunny";
}
      



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

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


int32_t main(){
	int n;
	cin >>n;
	if(n&1){
		cout << 0;
	}
	else{
		int k=n/2;
		int cnt=0;
		while(k){
			cnt+=(k/5);
			k/=5;
		}
		cout << cnt;
	}
}

Measured memory_bytes: 256
st = input().split()
n = int(st[0])
d = int(st[1])

c = 0

for i in range(n):
    middle = input().split()
    x = int(middle[0])
    y = int(middle[1])
    if x**2 + y**2 <= d**2:
        c+=1

print(c)
        
        
    

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    int n; cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    int EVEN = (n+1) / 2; // 0-index
    int ODD = n / 2;

    int const inf = 1<<29;
    int ans = inf;
    // 各カードについて、どちらの数値を表にするかの状態を全探索
    // bit が立っていたら b[i] 
    rep(bit, 1<<n) {
        vector<pair<int, int>> even, odd;
        rep(i, n) {
            if (bit&1<<i) {
                if(i&1) even.emplace_back(b[i], i);
                else odd.emplace_back(b[i], i);
            } else {
                if(i&1) odd.emplace_back(a[i], i);
                else even.emplace_back(a[i], i);
            }
        }

        if (ODD!=(int)odd.size() || EVEN!=(int)even.size()) continue;
        sort(even.begin(), even.end());
        sort(odd.begin(), odd.end());
        vector<pair<int, int>> v;
        rep(i, ODD) {
            v.push_back(even[i]);
            v.push_back(odd[i]);
        }
        if(n%2) v.push_back(even.back());

        
        bool ok = true;
        repr(i, 1, n) if (v[i].first < v[i-1].first) { ok = false; break; }
        if (!ok) continue;
        int cnt = 0;
        rep(i, n) repr(j, i+1, n) if (v[i].second > v[j].second) ++cnt;
        chmin(ans, cnt);
    }
    cout << (ans==inf? -1:ans) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#define N 1000000+5 
#define ull unsigned long long
using namespace std;
ull n,T[N];
ull gcd(ull a,ull b) {
	if(b == 0) return a;
	return gcd(b,a%b);
}
int main()
{
	scanf("%llu",&n);
	for(ull i=0;i<n;i++) scanf("%llu",&T[i]);
	for(ull i=1;i<n;i++)
		T[i]=T[i]/gcd(T[i],T[i-1])*T[i-1];
	printf("%llu\n",T[n-1]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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...));
}

int main() {
    int n, d; cin >> n >> d;
    auto x = make_v(n, d, 0);
    REP(i, n)REP(j, d) cin >> x[i][j];

    int cnt = 0;
    FOR(i, 0, n)FOR(j, i+1, n) {
        int d2 = 0;
        REP(k, d) {
            int dis = x[i][k] - x[j][k];
            d2 += dis * dis;
        }

        int s = static_cast<int>(sqrt(d2));

        if(s * s == d2) cnt++;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import itertools
N, M, Q = map(int, input().split())
A = []
for i in range(0, Q):
        a, b, c, d = map(int,input().split())
        A.append([a,b,c,d])

nums = []
for i in range(1, M+1):
        nums.append(i)

ans_l = [0]
for A_n in itertools.combinations_with_replacement(nums, N):
        # print(A_n)
        ans = 0
        for i in range(0, Q):
                if A_n[(A[i][1] - 1)] - A_n[(A[i][0] - 1)] == A[i][2]:
                        # print(A_n[(A[i][1] - 1)], A_n[(A[i][0] - 1)], A[i][2], A[i][3])
                        ans += A[i][3]
        ans_l.append(ans)

# print(ans_l)
print(max(ans_l))

Measured memory_bytes: 12524
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    AB=LLIN_(M)
    AB.sort(key=lambda x: x[1])
    before = -1
    ans=0
    for a,b in AB:
        if before<=a:
            before=b
            ans+=1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 60636
#include<stdio.h>

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

int main()
{
    int n,m=0,a[200001],b[200001];
    int i,j,tmp,count;
    
    scanf("%d",&n);
    
    for(i=1;i<n+1;i++)
    {
        a[i] = 0;
        b[i] = 0;
        scanf("%d",&a[i]);
        if(a[i] == 1)
        {
            if(i > n/2)
            {
                b[i] = 1;
                m++;
            }
        }
    }
    
    for(i=n/2;i>0;i--)
    {
//        printf("deb:%d\n",i);
        j=1;
        tmp = i;
        count = 0;
        while(tmp <= n)
        {
            count = count + b[tmp];
            j++;
            tmp = i * j;
        }
        if(count % 2 != a[i])
        {
            b[i] = 1;
            m++;
        }
    }
    
    printf("%d\n",m);
    for(i=1;i<n+1;i++)
    {
        if(b[i] == 1)
        {
            printf("%d\n",i);
        }
    }
    
    return 0;
}


Measured memory_bytes: 2432
#include <stdio.h>

int main(){
  char s[100100];
  for(int i=0;i<=100010;i++){
    s[i]='A';
  }
  scanf("%s",s);
  
  int a['z'-'a'][100010],b['z'-'a'];
  for(int i=0;i<='z'-'a';i++){
    b[i]=0;
  }
  
  for(int i=0;i<=100001;i++){
    if(s[i]-'a' < 0){
      break;
    }
    b[s[i]-'a']+=1;
    a[s[i]-'a'][b[s[i]-'a']]=i;
  }
  
  int flag=0;
  
  for(int i=0;i<='z'-'a';i++){
    if(b[i]<=1){
      continue;
    }
    for(int j=1;j<=b[i]-1;j++){
      for(int k=j+1;k<=b[i];k++){
        if(a[i][k]-a[i][j]+1 < 2*(k-j+1)){
          flag=1;
          printf("%d %d",a[i][j]+1,a[i][k]+1);
          break;
        }
        if(flag==1){
          break;
        }
      }
      if(flag==1){
        break;
      }
    }
    if(flag==1){
      break;
    }
  }
  
  if(flag==0){
    printf("-1 -1");
  }
  
  return 0;
}


Measured memory_bytes: 8576
a=int(input())
b=int(input())
c=int(input())
x=int(input())
cnt=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            total = 500*i+100*j+k*50
            if total == x:
                cnt+=1
print(cnt)

Measured memory_bytes: 3060
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
S = LS2()

ans = 0
for i in range(N-2):
    if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C':
        ans += 1

print(ans)

Measured memory_bytes: 61720
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int A, B, Q; cin >> A >> B >> Q;
    vector<long long> s,t;
    long long input;
    s.push_back(-100000000000000); for (int i=0; i<A; i++) { cin >> input; s.push_back(input); }; s.push_back(100000000000000);
    t.push_back(-100000000000000); for (int i=0; i<B; i++) { cin >> input; t.push_back(input); }; t.push_back(100000000000000);

    long long result, start;
    for (int i=0; i<Q; i++) {
        cin >> start;
        int s_place = lower_bound(s.begin(), s.end(), start) - s.begin();
        int t_place = lower_bound(t.begin(), t.end(), start) - t.begin();
        long long s_left = s[s_place-1], s_right = s[s_place];
        long long t_left = t[t_place-1], t_right = t[t_place];

        long long sl_tr = min( start - s_left, t_right - start ) + ( t_right - s_left );
        long long sl_tl = start - min( s_left, t_left );
        long long sr_tr = max( s_right, t_right ) - start;
        long long sr_tl = min( s_right - start, start - t_left ) + ( s_right - t_left );

        result = min({sl_tr, sl_tl, sr_tr, sr_tl});
        cout << result << endl;
    }
    return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i, m) cin >> a[i];
    
    int cnt = 0;
    rep(i, m) cnt += a[i];
    if (cnt > n) cout << "-1" << endl;
    else cout << n-cnt << endl;
}

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

int main(){
  int n,sum = 0;
  cin >> n;
  vector<int> a(n),b(n-1);
  a.at(0) = 100000+1;
  for(int i = 0;i<n-1;i++){
    cin >> b.at(i);
    if(a.at(i)>b.at(i)){
     a.at(i) = b.at(i); 
    }
    a.at(i+1) = b.at(i);
  }
  for(int i = 0;i<n;i++){
    sum += a.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;


int main() {
	string S;
	cin >> S;
	bool* B = new bool[3];
	for (int i = 0; i < 3; i++) {
		B[S[i] - 'a'] = true;
	}

	for (int i = 0; i < 3; i++) {
		if (!B[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {

    static final int LEFT = 0;
    static final int RIGHT = 1;
    
    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);

	int[][] no = new int[4][2];

	while ( stdin.hasNextDouble() ) {
	    final double left = stdin.nextDouble();
	    no[index( left )][LEFT]++;
	    final double right = stdin.nextDouble();
	    no[index( right )][RIGHT]++;	    
	}

	for ( int c = 0; c < no.length; c++ ) {
	    System.out.printf( "%d %d\n", no[c][LEFT], no[c][RIGHT] );
	}	
    }

    static int index( double sight ) {
	if ( sight < 0.2 ) {
	    return 3;
	} else if ( 0.2 <= sight && sight < 0.6 ) {
	    return 2;
	} else if ( 0.6 <= sight && sight < 1.1 ) {
	    return 1;
	} else {
	    return 0;
	}	
    }
    
}

Measured memory_bytes: 20448
#include <iostream>
#include <cstdio>

bool prime[10000000];
void primenum(void)
{
	for (int i = 0; i < 10000000; i++){
		prime[i] = true;
		if(i%2==0)prime[i]=false;
	}
	prime[1] = prime[0] = false;
	prime[2]=true;
	for (int i = 3; i*i < 10000000; i+=2){
		for (int j = i * 2; j < 10000000; j += i){
			prime[j] = false;
		}
	}
}

int main(void)
{
	int n;
	primenum();
	while (scanf("%d", &n), n){
		for (int i = n; 0 <= i; i--){
			if (prime[i]&&prime[i-2]&&prime[i-6]&&prime[i-8]){
				printf("%d\n", i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 10000
N = int(input())
A = list(map(int, input().split()))

def gcd(a, b):
	if not a % b:
		return b
	return gcd(b, a % b)

gcd_num = A[0]
for n in range(1, N):
	gcd_num = gcd(gcd_num, A[n])

print(gcd_num)


Measured memory_bytes: 15020
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<stdbool.h>
#include<vector>
#include<algorithm>
#include<string>
typedef long long ll;
using namespace std;

int main(void) {
	int x, a, b;
	cin >> x >> a >> b;
	if (x >= b - a) {
		if (b - a > 0)cout << "safe" << endl;
		else cout << "delicious" << endl;
	}
	else cout << "dangerous" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

int main(int argc, char *argv[]){
    int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
    int t1 = a * x + b * y;
    // int t2 = 2 * c * max(x, y);
    // int p = x < y ? a : b;
    // int t3 = 2 * c * max(x, y) + p * abs(x - y);
    // cout << min(t1, min(t2, t3)) << endl;
    int t2 = t1;
    for(int i = 1; i < max(x, y) + 1; i++){
        int t = 2 * c * i; // abをi個買う
        t2 = min(t2, max(0, (x - i)) * a + max(0, (y - i)) * b + t);
    }
    cout << min(t1, t2) << endl;
    return 0;
}

Measured memory_bytes: 256
#define DEBUGGING  // Enables DEBUG macro.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifndef DEBUGGING
#define debug(...)
#define DEBUG(...)
#else
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                     \
  do {                                 \
    cerr << " (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ": ";      \
    debug(__VA_ARGS__);                \
    cerr << endl;                      \
  } while (0)
#endif

using P = complex<double>;
const double EPS = 1e-6;

int main() {
  int N;
  cin >> N;
  vector<P> points;
  REP(i, N) {
    int x, y;
    cin >> x >> y;
    points.emplace_back(double(x), double(y));
  }

  if (N == 2) {
    double ans = abs(points[0] - points[1]) / 2.0;
    printf("%.18f\n", ans);
    return 0;
  }
  assert(N >= 3);

  auto contains_all = [&](const P& center, double radius) -> bool {
    REP(i, N) {
      double d = abs(points[i] - center);
      if (d > radius + EPS) {
        return false;
      }
    }
    return true;
  };

  auto check = [&](double r) -> bool {
    REP(i, N) REP(j, i) {
      const P& p1 = points[i];
      const P& p2 = points[j];
      if (abs(p2 - p1) > 2.0 * r + EPS) return false;

      P m = (p1 + p2) / 2.0;
      P x = (p2 - p1) * P(0.0, 1.0);
      x /= abs(x);
      double b = abs(m - p1);
      double h = sqrt(r * r - b * b);
      x *= h;
      vector<P> ps = {m + x, m - x};
      for (auto& p : ps) {
        if (contains_all(p, r)) return true;
      }
    }
    return false;
  };

  double ng = 0.0, ok = 1e6;
  REP(_, 50) {
    double r = (ok + ng) / 2.0;
    if (check(r)) {
      ok = r;
    } else {
      ng = r;
    }
  }

  printf("%.18f\n", ok);
}


Measured memory_bytes: 256
import collections
N = int(input())
s = [list(input()) for _ in range(N)]
mydict = {}
ans = 0
for i in s:
  a = str(sorted(i))
  if a in mydict:
    ans += mydict[a]
    mydict[a] += 1
  else:
    mydict.setdefault(a,1)
print(ans)

Measured memory_bytes: 43528
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string> 
#include <iomanip>
#include <list>
#include <random>
#include <numeric> //iota - iota(v.begin(), v.end(), x) x, x + 1, x + 2...

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef int INT;
#define int ll
#define mmin(a, b) a = min(a, b)
#define mmax(a, b) a = max(a, b)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end()
#define sz(a) ((int)(a.size()))
#define x first
#define y second
#define watch(x) cout << (#x) << " = " << x << endl;
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

/*
tuple<int, string> f() {
return {485, "Hello"};
}
int a;
string b;
tie(a, b) = f();
*/

const double PI = 2 * acos(0.0), eps = 1e-8;
const int oo = 1000000000000000000;

template<class T>
void show(const vector<T> &a) {
	cout << sz(a) << endl;
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const ll M = 998244353;

ll MOD(ll a) {
	if (a >= 0) return a >= M ? a % M : a;
	if (a <= -M) a %= M;
	return a ? a + M : a;
}

/*______________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
______________________________________________________________________________________________________________________________*/

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

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

	int sum = 0;
	for (int i = 1; i < n; i++)
	{
		if (a[i] == a[i - 1])
		{
			sum++;
			i++;
		}
	}

	cout << sum;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	Main(){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String str = sc.nextLine();
			char[] ch = str.toCharArray();
			
			for(int i = 0; i < 26; i++){
				int l = str.length();
				char[] ch2 = new char[l];
				for(int j = 0; j < l; j++){
					char w = ch[j];
					if(w == ' ' || w == '.'){
						ch2[j] = w;
						continue;
					}
					
					w = (char)(w+i);
					if(w > 'z'){
						w -= 26;
					}
					ch2[j] = w;
				}
				String[] st = (String.valueOf(ch2)).split(" ");
				boolean f = false;
				for(String s: st){
					if(s.equals("this") || s.equals("the") || s.equals("that")){
						f = true;
						break;
					}
				}
				if(f){
					System.out.println(String.valueOf(ch2));
					break;
				}
			}
		}
	}
	
	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 12000
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class DGatheringChildren {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string S;
	    in >> S;
	    vector<int> childrens(S.size());
	    vector<int> lefts, rights;
        REP(i,0,S.size()) {
            if(S[i] == 'L') lefts.push_back(i);
            if(S[i] == 'R') rights.push_back(i);
        }
	    REP(i,0,S.size()) {
            if (S[i] == 'R') {
                const auto itr = lower_bound(all(lefts), i);
                if ((*itr - i) % 2 == 0) childrens[*itr]++;
                else childrens[*itr - 1]++;
            } else {
                const auto itr = --lower_bound(all(rights), i);
                if ((i - *itr) % 2 == 0) childrens[*itr]++;
                else childrens[*itr + 1]++;
            }
	    }
	    REP(i,0,childrens.size()-1) {
	        out << childrens[i] << " ";
	    }
	    out << childrens.back() << "\n";
	}
};


signed main() {
	DGatheringChildren solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1532
s = input().split(" ")
n = int(s[0])
x = int(s[1])
L = [0] + list(map(int, input().split(" ")))
dist = 0
ans = 0
for i in range(n+1):
    dist = dist + L[i]
    if dist <= x:
        ans += 1
    else:
        break

print(ans)


Measured memory_bytes: 3060
n = int(input())
s = input()

w = [0]
e = [0]

# tmp_w = 0
tmp_e = 0

for i in range(1, n):

    j = (n - 1) - i

    if (s[i-1] == 'W'):
        w.append(w[i-1] + 1)
        # tmp_w += 1
    else:
        w.append(w[i-1])

    if (s[j+1] == 'E'):
        e.append(tmp_e + 1)
        tmp_e += 1
    else:
        e.append(tmp_e)

e.reverse()

ans = 10 ** 6 
for i in range(n):
    ans = w[i] + e[i] if w[i] + e[i] < ans else ans

print(ans)

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main() {
  ll h, w;
  cin >> h >> w;
  char board[h][w];
  rep(i,h){
    rep(j,w){
      cin>>board[i][j];
    }
  }
  
  vector<int>vec;
  rep(i,h){
    rep(j,w){
      if(board[i][j]=='#'){
        vec.push_back(j);
      }
    }
  }
  
  bool can=true;
  int sum=0;
  rep(i,vec.size()-1){
    if(vec[i]+1 ==vec[i+1] || vec[i] ==vec[i+1]){
      if(vec[i] ==vec[i+1]) sum++;
    }
    else{
      can=false;
      break;
    }
  }
  if(can){
    if(sum==h-1) cout<<"Possible";
    else cout<<"Impossible";
  }
  else cout<<"Impossible";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
long long l[101010],r[101010];
bool cmp(const int &x,const int &y)
{
	return x>y;
}
int main()
{
	int n;
	long long ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&l[i],&r[i]);
	sort(l+1,l+1+n,cmp);
	sort(r+1,r+1+n);
	for(int i=2;i<=n;i++)
		l[i]+=l[i-1];
	for(int i=2;i<=n;i++)
		r[i]+=r[i-1];
	for(int i=1;i<=n;i++)
		ans=max(ans,l[i]*2-r[i]*2);
	for(int i=1;i<n;i++)
	{
		ans=max(ans,l[i]*2-r[i+1]*2);
		ans=max(ans,l[i+1]*2-r[i]*2);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	const string p="CODEFESTIVAL2016";string a;
	int sum=0;
	getline(cin,a);
	for(int i=0;i<=15;i++)
		if(a[i]!=p[i]) sum++;
	printf("%d",sum);
	return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  int buf[9];
  for(int i=1;i<=9;i++){
    buf[i-1]=i*100+i*10+i;
  }
  for(int i=0;i<9;i++){
    if(N<=buf[i]){
    	cout << buf[i];
    	break;
    }
  }
}


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

int main(){

  int A, B; cin >> A >> B;
  // |A-K| = |B-K|
  int K;
  string ans;
  if(A == B){
    ans = to_string(0);
  } else if ((A+B) % 2 == 1){
    ans = "IMPOSSIBLE";
  } else {
    K = (A + B) / 2;
    if (A-K == K-B){
      ans = to_string(K);
    } else {
      ans = "IMPOSSIBLE";
    }
  }

  cout << ans << endl;

}


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

using namespace std;

const int MOD = 1e9 + 7;
const int H = 1000;
const int W = 1000;

int h, w;
vector<vector<int>> dp(H + 1, vector<int>(W + 1));
vector<vector<bool>> vis(H + 1, vector<bool>(W + 1));
vector<vector<char>> grid(H + 1, vector<char>(W + 1));

int ways(int i, int j)
{
	if (!vis[i][j]) {
		if (grid[i][j] == '.') {
			if (i == h && j == w) {
				dp[i][j] = 1;
			} else if (i == h) {
				dp[i][j] = ways(i, j + 1);
			} else if (j == w) {
				dp[i][j] = ways(i + 1, j);
			} else {
				dp[i][j] = ((ways(i + 1, j) % MOD) + (ways(i, j + 1) % MOD)) % MOD;
			}
		}
		vis[i][j] = true;
	}
	return dp[i][j];
}

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

	cin >> h >> w;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			cin >> grid[i][j];
		}
	}
	cout << ways(1, 1) << endl;
}

Measured memory_bytes: 5632
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N, M;
P p[200000];
bool b[200000];

void init()
{
}

void solve()
{
    bool ok = false;
    REP(i, M){
        if(p[i].fi != 0 && p[i].se == N-1) b[p[i].fi] = true;
    }
    REP(i, M){
        if(p[i].fi == 0 && b[p[i].se]){
            ok = true;
            break;
        }
    }
    cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    REP(i, M){
        cin >> p[i].fi >> p[i].se;
        p[i].fi--;
        p[i].se--;
    }
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 2048
N = int(input())
lst = list(input().split())
lst2 = []
for i in lst:
    lst2.append(i)

def bubble_sort(lst):

    flag = 1
    while flag:
        flag = 0
        for i in reversed(list(range(1,len(lst)))):
            if int(lst[i-1][1])>int(lst[i][1]):
                lst[i-1],lst[i] = lst[i],lst[i-1]
                flag = 1

    return lst

def selection_sort(lst):


    for i in range(len(lst)):
        min_i = i
        for j in range(i+1,len(lst)):
            if int(lst[j][1]) < int(lst[min_i][1]):
                min_i = j
        lst[i],lst[min_i] = lst[min_i],lst[i]

    return lst

list1 = bubble_sort(lst)
list2 = selection_sort(lst2)

print(' '.join(map(str,list1)))
print("Stable")
print(' '.join(map(str,list2)))
if list1 == list2:
    print("Stable")
else:
    print("Not stable")



Measured memory_bytes: 5612
#include <stdio.h>
int main(void){
	int n, a, b;
	scanf("%d %d %d\n", &n, &a, &b);

	unsigned long int ans=0;
	unsigned long int x[n];
	int i;

	for(i=0; i<n; i++){
		scanf("%lu", &x[i]);
	}
	
	for(i=0; i<n-1; i++){
		if((x[i+1]-x[i])*a < b){
			ans += (x[i+1]-x[i])*a;
		}else{
			ans += b;
		}
	}

	printf("%lu\n", ans);
	return 0;
}

Measured memory_bytes: 896
from collections import Counter

n=int(input())
s=list(map(int,input().split()))
e=Counter(s[0::2])
o=Counter(s[1::2])
e[0]=0
o[0]=0
e1,e2=e.most_common(2)
o1,o2=o.most_common(2)
if e1[0]!=o1[0]:
    print(n-(e1[1]+o1[1]))
else:
    print(n-max(e1[1]+o2[1],e2[1]+o1[1]))

Measured memory_bytes: 18656
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [long(input_raw[0])]
    A = read_func().strip()
    B = read_func().strip()
    C = read_func().strip()
    count = 0
    for i in range(N):
        a = A[i]
        b = B[i]
        c = C[i]
        if a != b and b != c and a != c:
            count += 2
        elif a == b and a == c and b == c:
            count += 0
        else:
            count += 1
    print count


if __name__ == '__main__':
    main()


Measured memory_bytes: 2932
#include<cstdio>
#include<cstdlib>
#include<map>
using namespace std;
 
int n, m;
int a[300000], b[300000];
map<int,int> mp;
int main()
{
  scanf("%d",&n);
  for(int i=1; i<=n; ++i){scanf("%d",&a[i]); mp[a[i]]++;} //("%d",&a[i]);
  scanf("%d",&m);
  for(int i=1; i<=m; ++i) 
  {
    scanf("%d",&b[i]);
    if(mp[b[i]]<=0) {puts("NO"); return 0;}
    mp[b[i]]--;
  }
  puts("YES");
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>

using namespace std;
int a,b,c;

int main(){
    string op;
    cin >> a >> b >> c;
    if ( a > b ){
        int tmp = a;
        a = b;
        b = tmp;
    }

    if ( b > c ){
        int tmp = b;
        b = c;
        c = tmp;
    }

    if ( a > b ){
        int tmp = a;
        a = b;
        b = tmp;
    }
    cout << a << " " << b << " " << c << endl;

    return 0;
}


Measured memory_bytes: 3104
#include "bits/stdc++.h"

using namespace std;

void solve()
{
	int N, A, B;
	cin >> N >> A >> B;
	vector<int> as(3);
	for (int i = 0; i < N; i++)
	{
		int p;
		cin >> p;
		if (p <= A) as[0]++;
		else if (p <= B) as[1]++;
		else as[2]++;
	}

	cout << *min_element(as.begin(), as.end()) << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#ifdef on_linux
	#include <sys/resource.h>
#endif

#ifdef dobby_is_a_free_elf
	#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
	#define trace(...) 0;
#endif

using namespace std;
using namespace __gnu_pbds;

#define int                     long long
#define ll                      long long

#define fi                      first
#define sc                      second
#define mp                      make_pair
#define pb                      push_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define sqr(a)                  ((a) * (a))
#define lbd                     lower_bound
#define ubd                     upper_bound
#define sz(x)                   (int)((x).size())
#define all(x)                  (x).begin(), (x).end()
#define mem0(x)                 memset(x, 0, sizeof (x))
#define mem1(x)                 memset(x, -1, sizeof (x))
#define pii                     pair<int32_t, int32_t>
#define pll                     pair<long long, long long>

#define DECIMAL(n)              cout << fixed << setprecision(n);
#define rep(i,a,b)              for(int32_t i = (a); i < (b); ++i)
#define between(i,x,y)          ((i) >= (x) && (i) <= (y))
// #define clamp(i,x,y)            (((i) < (x)) ? (x) : ((y) < (i)) ? (y) : (i));

template<typename T, typename U> static inline void remax(T &x, U y) {if (x < y) {x = y;}}
template<typename T, typename U> static inline void remin(T &x, U y) {if (y < x) {x = y;}}

static mt19937_64 gen(chrono::duration_cast<chrono::nanoseconds>
                      (chrono::high_resolution_clock::now().time_since_epoch()).count());

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase, insert same as normal set

const long double PI = 3.14159265358979323846264338;
const double eps = 1e-10;
#ifdef int
	const long long INF = 1e18;
#else
	const long long INF = 1e9;
#endif
const int32_t fftmod = 998244353;
const int32_t MOD = 1000000007;
const int32_t N = 1e5 + 10;
const int32_t NN = 1e6 + 10;



inline void elf_magic(int testcase)
{
	int k;
	cin >> k;

	queue<int> q;
	for (int i = 1; i <= 9; ++i) {
		q.push(i);
	}
	int ctr = 0;
	while (!q.empty()) {
		ctr++;
		int x = q.front();
		q.pop();
		if (ctr == k) {
			cout << x;
			return;
		}
		if (x % 10 != 0) { q.push(x * 10 + x % 10 - 1); }
		q.push(x * 10 + x % 10);
		if (x % 10 != 9) { q.push(x * 10 + x % 10 + 1); }
	}

	return;
}

int32_t main()
{
	#ifdef on_linux
	rlimit cpu_time {.rlim_cur = 2, .rlim_max = RLIM_INFINITY};
	setrlimit(RLIMIT_CPU, &cpu_time);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int TESTS = 1;
	//cin >> TESTS;
	for (int i = 1; i <= TESTS; ++i) {
		// cout << "Case #" << i << ": ";
		elf_magic(i);
		if (i != TESTS)	{ cout << '\n'; }
	}
	return 0;
}

Measured memory_bytes: 4704
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
      
n=int(input())
print(num2alpha(n).lower())

Measured memory_bytes: 61804
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
A, B, C, K = ri_()
if K <= A:
    ans = K
elif A < K <= B:
    ans = A
else:
    ans = A - (K - (A + B))
print(ans)

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

typedef long long ll;
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(c) c.begin(),c.end()
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
#define pu push
#define pb push_back
ll f_min(ll a,ll b){
    return (a>b)?b:a; 
}
ll f_max(ll a,ll b){
    return (a>b)?a:b;
}
ll f_abs(ll a){
    return abs(a);
}
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
const ll MOD = 1000000007;
const int inf = 1000000001;
const ll INF = 1e16;
ll i,j,k;
// #define max 105
ll solve(ll num){
    if(num == 0||num == 1)
        return 0;
    else{
        return num*(num-1)/2;
    }
}
int main(){
    fio();
    
    ll a,b;
    cin>>a>>b;
    cout<<(solve(a)+solve(b));

}

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

int main() {
  // ここにプログラムを追記
  int a;//現在のレーティング
  int b;//次のレーティング
  cin >> a >> b;
  //b = (a + P)/2 ⇨
  cout << a*a -b << endl;
}

Measured memory_bytes: 256