akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int n;
int powi(int a, int b, int m)
{
    int c = 1;
    for (; b; b >>= 1, a = 1ll * a * a % m)
        if (b & 1) c = 1ll * c * a % m;
    return c;
}
const int BAS = 233;
const int MOD1 = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int BIV1 = powi(BAS, MOD1 - 2, MOD1);
const int BIV2 = powi(BAS, MOD2 - 2, MOD2);
const int N = 500000;
char st[N];
pair <int, int> V[N], S[N];
map <pair <int, int>, int> C;
LL res;
int main()
{
    scanf("%d", &n);
    scanf("%s", st + 1);
    V[0] = make_pair(1, 1);
    for (int i = 1; i <= n; ++ i)
    {
        if (st[i] == '>')
            V[i] = make_pair(1ll * V[i - 1].first * BAS % MOD1, 1ll * V[i - 1].second * BAS % MOD2),
            S[i] = S[i - 1];
        else if (st[i] == '<')
            V[i] = make_pair(1ll * V[i - 1].first * BIV1 % MOD1, 1ll * V[i - 1].second * BIV2 % MOD2),
            S[i] = S[i - 1];
        else if (st[i] == '+')
            V[i] = V[i - 1],
            S[i] = make_pair((S[i - 1].first + V[i].first) % MOD1, (S[i - 1].second + V[i].second) % MOD2);
        else if (st[i] == '-')
            V[i] = V[i - 1],
            S[i] = make_pair((S[i - 1].first - V[i].first + MOD1) % MOD1, (S[i - 1].second - V[i].second + MOD2) % MOD2);
    }
    for (int i = n; ~i; -- i)
    {
        res += C[make_pair((1ll * S[n].first * V[i].first + S[i].first) % MOD1,
            (1ll * S[n].second * V[i].second + S[i].second) % MOD2)];
        C[S[i]] ++;
    }
    printf("%lld\n", res);
}


Measured memory_bytes: 39552
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(bf.readLine())+1;
        StringTokenizer st = new StringTokenizer(bf.readLine());
        int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        st = new StringTokenizer(bf.readLine());
        int[] b = new int[n-1]; for(int i=0; i<n-1; i++) b[i] = Integer.parseInt(st.nextToken());
        long ans = 0;
        for(int i=0; i<n-1; i++) {
          if(b[i] >= a[i]) {
            b[i] -= a[i];
            ans += a[i];
            a[i] = 0;
            if(b[i] >= a[i+1]) {
              b[i] -= a[i+1];
              ans += a[i+1];
              a[i+1] = 0;
            }
            else {
              a[i+1] -= b[i];
              ans += b[i];
              b[i] = 0;

            }
          }
          else {
            ans += b[i];
            a[i] -= b[i];
            b[i] = 0;


          }
        }
        out.println(ans);
        // int n = Integer.parseInt(st.nextToken());

        out.close(); System.exit(0);
    }
}


Measured memory_bytes: 50700
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

string s, t, a;
int dp[3030][3030];

signed main()
{
    ///s0-si & t0-tj no LCS
    cin >> s >> t;
    for(int i = 0; i < s.size(); i++){
        for(int j = 0; j < t.size(); j++){
            if(s[i] == t[j]){
                dp[i + 1][j + 1] = dp[i][j] + 1;
            }
            else {
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
            }
        }
    }
    int L = dp[s.size()][t.size()];
    int d = s.size() + 1, r = t.size() + 1;
    for(int i = s.size(); i > 0; i--){
        for(int j = t.size(); j > 0; j--){
            if(L == dp[i][j] && s[i - 1] == t[j - 1] && i < d && j < r){
                L--;
                a = s[i - 1] + a;
                d = i;
                r = j;
            }
        }
    }
    cout << a << endl;

    return 0;
}
/*



*/



Measured memory_bytes: 72064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		}
		
		int[] tintin = new int[n+1];
		tintin[0] = Math.abs(a[0]);
		for(int i=1;i<n;i++) {
			tintin[i] = tintin[i-1] + Math.abs(a[i]-a[i-1]);
		}
		tintin[n] = tintin[n-1] + Math.abs(a[n-1]);
		
		int[] tkb = new int[n];
		tkb[0] = Math.abs(a[1]);
		for(int i=1;i<n-1;i++) {
			tkb[i] = Math.abs(a[i+1]-a[i-1]);
		}
		tkb[n-1] = Math.abs(a[n-2]);
		
		String ls = System.lineSeparator();
		StringBuilder sb = new StringBuilder();
		sb.append(tkb[0]+tintin[n]-tintin[1]);
		sb.append(ls);
		for(int i=1;i<n-1;i++) {
			sb.append(tintin[i-1]+tkb[i]+tintin[n]-tintin[i+1]);
			sb.append(ls);
		}
		sb.append(tintin[n-2]+tkb[n-1]);
		sb.append(ls);
		System.out.println(sb.toString());
		in.close();
	}

}


Measured memory_bytes: 55528
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	cin >> str;
	if (str[0] == '9' || str[1] == '9') puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();
int main(){
  int a,b;
  char op;
  cin>>a>>op>>b;
  if(op=='+'){
    cout<<a+b<<"\n";  
  }
  else{
    cout<<a-b<<"\n";  
  }
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string S, T;
  IN(S,T);
  ll A, B;
  IN(A,B);
  string U;
  IN(U);

  map<string, ll> mp;
  mp[S] = A;
  mp[T] = B;
  mp[U]--;

  printf("%lld %lld\n", mp[S], mp[T]);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG



int main() {
  string S, T;
  cin >> S >> T;
  //vector<ll> a(N);
  //vector<vector<int>> data(3, vector<int>(4));
  ll A, B;
  cin >> A >>B;

  string U;
  cin >> U;
  if(U == S) cout << A-1 << " " << B << endl;
  else cout << A << " " << B-1 << endl;

  return 0;
}


Measured memory_bytes: 3580
import sys
from collections import Counter
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N = int(input().strip())
    a_list = [int(n) for n in input().strip().split()]
    count = Counter(a_list)
    ans = 0
    for k, v in count.items():
        if v == k:
            continue
        elif v > k:
            ans += v - k
        else:
            ans += v
    return ans


if __name__ == '__main__':
    print(main())


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

using namespace std;

int main()
{
  string S;
  int A, B, C, D;
  bool mas[9][9];

  while(cin >> S, S != "#") {
    cin >> A >> B >> C >> D;

    memset(mas, false, sizeof(mas));
    int y = 0, x = 0;
    for(char &c : S) {
      if(c == '/') y++, x = 0;
      else if(isdigit(c)) x += c - '0';
      else mas[y][x++] = true;
    }
    swap(mas[--A][--B], mas[--C][--D]);
    for(int i = 0; i <= y; i++) {
      if(i > 0) cout << "/";
      int ret = 0;
      for(int j = 0; j < x; j++) {
        if(mas[i][j]) {
          if(ret > 0) cout << ret;
          cout << "b";
          ret = 0;
        } else {
          ++ret;
        }
      }
      if(ret > 0) cout << ret;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3032
n = int(input())
tb, xb, yb = 0, 0, 0
for _ in range(n):
    ta, xa, ya = list(map(int, input().split()))
    tdiff = abs(ta - tb)
    mdiff = abs(xa - xb) + abs(ya - yb)
    if tdiff < mdiff or (tdiff + mdiff) & 1:
        print('No')
        exit()
        
    tb, xb, yb = ta, xa, ya
print('Yes')

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll L;
    cin >> L;
    cout << setprecision(12) << (L/3.0)*(L/3.0)*(L/3.0) << endl;

    return 0;
}

/*



*/

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int Mod=924844033,g=5,gi=554906420;
const int N=200005;
inline int qpow(int a,int b){
	int ans=1;
	while (b){
		if (b&1) ans=1ll*ans*a%Mod;
		a=1ll*a*a%Mod,b>>=1;
	}
	return ans;
}
int rev[N<<2],a[N<<2],b[N<<2],lim;
inline void NTT_init(int n){
	int l=0;for (lim=1;lim<=(n<<1);lim<<=1) ++l;
	for (int i=1;i<=lim;i++) rev[i]=(rev[i>>1]>>1)|((i&1)<<(l-1));
}
inline void NTT(int*s,int t){
	for (int i=0;i<lim;i++) if (i<rev[i]) swap(s[i],s[rev[i]]);
	for (int mid=1;mid<lim;mid<<=1){
		int wn=qpow(t==1?g:gi,(Mod-1)/(mid<<1));
		for (int i=0;i<lim;i+=(mid<<1)){
			int w=1;
			for (int j=0;j<mid;j++,w=1ll*w*wn%Mod){
				int x=s[i+j],y=1ll*s[i+j+mid]*w%Mod;
				s[i+j]=(x+y)%Mod,s[i+j+mid]=(x-y+Mod)%Mod;
			}
		}
	}
	if (t==-1) {
		int inv=qpow(lim,Mod-2);
		for (int i=0;i<=lim;i++) s[i]=1ll*s[i]*inv%Mod;
	}
}
int size[N],cnt[N],fac[N],fac_inv[N];
int n;
inline void binom_init(){
	fac[0]=1;
	for (int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%Mod;
	fac_inv[n]=qpow(fac[n],Mod-2);
	for (int i=n-1;i>=0;i--) fac_inv[i]=1ll*fac_inv[i+1]*(i+1)%Mod; 
}
inline int C(int x,int y){
	return 1ll*fac[x]*fac_inv[y]%Mod*fac_inv[x-y]%Mod;
}
int Head[N],Next[N<<1],Adj[N<<1],tot=0;
inline void addedge(int u,int v){
	Next[++tot]=Head[u];
	Head[u]=tot;
	Adj[tot]=v;
	Next[++tot]=Head[v];
	Head[v]=tot;
	Adj[tot]=u;
}
inline void dfs(int x,int f){
	size[x]=1;
	for (int e=Head[x];e;e=Next[e])
		if (Adj[e]!=f){
			dfs(Adj[e],x);
			size[x]+=size[Adj[e]];
		}
	if (f) cnt[size[x]]++,cnt[n-size[x]]++;
}
int f[N];
int main (){
	scanf ("%d",&n);
	for (int i=1,u,v;i<n;i++){
		scanf ("%d%d",&u,&v);
		addedge(u,v);
	}
	dfs(1,0);
	binom_init();
	NTT_init(n);
	for (int i=1;i<=n;i++) a[i]=1ll*cnt[i]*fac[i]%Mod;
    for (int i=0;i<=n;i++) b[n-i]=fac_inv[i];
    NTT(a,1),NTT(b,1);
    for (int i=0;i<=lim;i++) a[i]=1ll*a[i]*b[i]%Mod;
    NTT(a,-1);
    for (int i=1;i<=n;i++) f[i]=1ll*a[n+i]*fac_inv[i]%Mod;
    for (int i=1;i<=n;i++) printf ("%d\n",(1ll*n*C(n,i)%Mod-f[i]+Mod)%Mod);
	return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define INF LLONG_MAX/2
#define PI acos(-1.0)
//#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int n;
    cin>>n;
    Vi a(n);
    REP(i,0,n) cin>>a[i];

    int xorsum=0;
    REP(i,0,n) xorsum ^= a[i];

    REP(i,0,n-1) cout<<(xorsum^a[i])<<" ";
    cout<<(xorsum^a[n-1])<<endl;
    return 0;
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
int main(){
  double a, b, x;
  cin >> a >> b >> x;
  if(x > a * a * b /2){
    cout << fixed << setprecision(10) << atan2(2 * b - 2 * x / (a * a), a)  * 180 / M_PI << endl; 
  }
  else{
    cout << fixed << setprecision(10) << atan2(a * b * b, 2 * x)  * 180.0 / M_PI << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,m = map(int, input().split())
pp =[1]*(n+1)

pl =[1]*(m)
mm={}

for i in range(0,m):
  p,l = map(int, input().split())
  pl[i]=p
  mm[i]=p*100000+l
a=[""]*(m+1)
for k, v in sorted(mm.items(), key=lambda x: x[1]):
  pre=pl[k]
  a[k]="{:06}{:06}".format(pl[k],pp[pre])
  pp[pre]=pp[pre]+1
for i in range(0,m):
  print(a[i])


Measured memory_bytes: 38104
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
//#include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
typedef unsigned long long ll;
typedef unsigned char Byte;
using namespace std;

//string ans = "Yes";
long double ans = 0;
long double A;
long double B;
int main() {
	cin >> A >> B;
	cout << ll(A * B);
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
//      freopen("q.in","r",stdin);
//      freopen("q.out","w",stdout);
      int n;
      cin>>n;
      vector<ii>Y;
      for(int i=0;i<n;i++){
            int x,y;
            cin>>x>>y;
            Y.pb({x+y,x-y});
      }
      sort(all(Y));
      int ans=0;
      int curr=-INF;
      for(int i=0;i<n;i++){
            if(curr<=Y[i].second){
                  ans++;
                  curr=Y[i].first;
            }
      }
      cout<<ans;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
void solve()
{

}
int main()
{
    string str; cin >> str;
    int n = str.size();
    vector<int>v;
    int c = 0;
    for(int i = 0; i < n; i++)
    {
        if(str[i] == 'S')
        {
            v.push_back(c);
            c = 0;
        }
        else
        {
            c++;
        }
    }
    if(c > 0)
    {
        v.push_back(c);
    }
    sort(v.begin(), v.end(), greater<int>());
    if(v.size() > 0)
    {
        cout << v[0] << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
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 <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    ll n;
    cin >> n;
    int ans = 0;
    for (ll d = 2; d * d <= n; d++) {
        if (n % d) continue;
        int cnt = 0;
        while (n % d == 0) {
            n /= d;
            cnt++;
        }
        int now = 1;
        while (cnt - now >= 0) {
            ans++;
            cnt -= now;
            now++;
        }
    }
    if (n > 1) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()
B = LIST()

good = []
bad = []
for i in range(N):
    need = A[i] - B[i]
    if need >= 0:
        good.append(need)
    else:
        bad.append(need)

if sum(good) + sum(bad) < 0:
    print(-1)
    exit()

good.sort(reverse=True)
# このあとの二分探索用に累積和にする
good.insert(0, 0)
for i in range(len(good)-1):
    good[i+1] += good[i]

# badを補填するために必要なgoodの数 + badの総数
print(bisect_left(good, -sum(bad)) + len(bad))


Measured memory_bytes: 20388
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int ope(int a, int b, int i){
    if(i == 0)
        return a + b;
    else if(i == 1)
        return a - b;
    else
        return a * b;
}

void solve(vector<int> a)
{
    char c[] = {'+', '-', '*'};

    do{
        for(int i=0; i<3; ++i){
            for(int j=0; j<3; ++j){
                for(int k=0; k<3; ++k){
                    if(ope(ope(a[0], a[1], i), ope(a[2], a[3], j), k) == 10){
                        cout << "((" << a[0] << c[i] << a[1] << ')' << c[k] << '(' << a[2] << c[j] << a[3] << "))" << endl;
                        return;
                    }
                    if(ope(ope(ope(a[0], a[1], i), a[2], j), a[3], k) == 10){
                        cout << "(((" << a[0] << c[i] << a[1] << ')' << c[j] << a[2] << ')' << c[k] << a[3] << ')' << endl;
                        return;
                    }
                    if(ope(ope(a[0], ope(a[1], a[2], i), j), a[3], k) == 10){
                        cout << "((" << a[0] << c[j] << '(' << a[1] << c[i] << a[2] << "))" << c[k] << a[3] << ')' << endl;
                        return;
                    }
                }
            }
        }
    }while(next_permutation(a.begin(), a.end()));

    cout << '0' << endl;
}

int main()
{
    for(;;){
        vector<int> a(4);
        for(int i=0; i<4; ++i){
            cin >> a[i];
            if(a[i] == 0)
                return 0;
        }
        sort(a.begin(), a.end());

        solve(a);
    }
}

Measured memory_bytes: 0
#include <cstdio>

void maxHeapify(int *a, int i, int h){
    int l = i*2;
    int r = i*2+1;

    int largest, tmp;
    if(l<=h and a[l]>a[i])largest = l;
    else largest = i;
    if(r<=h and a[r]>a[largest])largest = r;

    if(largest != i){
        tmp = a[i];
        a[i] = a[largest];
        a[largest] = tmp;
        maxHeapify(a, largest, h);
    }else return;
}

void buildMaxHeap(int *a, int h){
    int i;
    for(i=h/2;i>0;i--)maxHeapify(a,i,h);
}

int main(){
    int i, h;
    scanf("%d",&h);
    int a[h+1];
    for(i=1;i<=h;i++)scanf("%d",a+i);
    buildMaxHeap(a, h);
    for(i=1;i<=h;i++)printf(" %d",a[i]);
    printf("\n");
    return 0;
}



Measured memory_bytes: 4648
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn print_table(t: &Vec<(usize, usize, usize, usize)>, h: usize, w: usize){
    let mut table = vec![vec![0;w];h];
    for k in 0..t.len(){
        let r = &t[k];
        for i in r.0..r.2{
            for j in r.1..r.3{
                table[i][j] = k+1;
            }
        }
    }

    for i in 0..h{
        for j in 0..w{
            print!("{} ", table[i][j]);
        }
        println!("");
    }
}

fn main(){
    let line = read_as_vec::<usize>();
    let (h, w, k) = (line[0], line[1], line[2]);

    let mut straws = vec![];
    for i in 0..h{
        let line = read_as_string().chars().collect::<Vec<char>>();
        for j in 0..line.len(){
            if line[j] == '#'{
                straws.push((i, j));
            }
        }
    }

    straws.sort();

    let mut cur_top = 0;
    let bottom_i: usize = {
        let mut tmp = straws.clone();
        tmp.sort_by_key(|x| x.0);
        tmp.last().unwrap().0
    };
    let mut ranges: Vec<(usize, usize, usize, usize)> = vec![];
    for i in 0..h{
        let mut cur_left = 0;
        let filted_straws = straws.iter().filter(|x| x.0 == i).collect::<Vec<&(usize, usize)>>();
        if filted_straws.len() == 0{
            continue;
        }
        //println!("{:?}", filted_straws);
        for &straw in &filted_straws{

            if i == bottom_i{
                ranges.push((cur_top, cur_left, h, straw.1+1));
            }else{
                ranges.push((cur_top, cur_left, straw.0+1, straw.1+1));
            }
            cur_left = straw.1+1;
        }
        let last_i = ranges.len()-1;
        ranges[last_i].3 = w;
        cur_top = ranges[last_i].2;

    }
    //println!("calculated is over");
    print_table(&ranges, h, w);
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll sepSum(string S, ll bit){
    string tmpS;
    tmpS.push_back(S[0]);
    ll res=0;
    RREP(i,0,S.size()-1){
        if(bit&(1<<i)){
            //P(tmpS);
            res+=stoll(tmpS);
            tmpS.clear();
        }
        tmpS.push_back(S[S.size()-i-1]);
    }
    res+=stoll(tmpS);
    return res;
}

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

    ll ans=0;
    REP(i,0,1<<(S.size()-1)){
        ans+=sepSum(S,i);
    }
    P(ans);
}

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

int main() {
  string s;
  cin >> s;
  bool good = true;
  for(int i=0;i<s.size()-1;i++) {
    if(s[i] == s[i+1]) {
      good = false;
      break;
    }
  }

  if(good) {
    cout << "Good" << endl;
  } else {
    cout << "Bad" << endl;
  }
}

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int>p(n);
  rep(i,n) cin >> p[i];
  vector<int>s(n+1,0);
  rep(i,n){
    s[i+1] = s[i]+p[i];
  }
  int res = 0;
  for (int i = 0; i <= n-k; ++i){
    int val = s[k+i]-s[i];
    res = max(val,res);
  }
  double ans = (double)(res+k)/2.0;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  int a, b; cin >> a >> b;
  if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 ==0){
    cout << "Possible" << endl;
  }
  else cout << "Impossible" << endl;
  system("pause");
}

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

using namespace std;

#define FC ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define FIN freopen("in.txt","r",stdin)
#define FOUT freopen("out.txt","w",stdout)
#define deb(x) cerr<<"DEBUG------"<<'\n';cerr<<#x<<"------>";err(x)

template<typename T>
void err(T a){
    cerr<<a<<'\n';
    cerr<<"END OF DEBUG"<<'\n'<<'\n';
}

const long double PI=acos(-1.0);  
const long double eps=1e-6;
const long long maxw=(long long)1e17+(long long)10;

using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

/*head------[@cordercorder]*/

const int maxn=310; 

int cnt[4];
int n;
double E[maxn][maxn][maxn];

void solve(){
    for(int k=0;k<maxn;k++){
        for(int j=0;j+k<maxn;j++){
            for(int i=0;i+j+k<maxn;i++){
                if((i!=0)||(j!=0)||(k!=0)){
                    if(i){
                        E[i][j][k]+=E[i-1][j][k]*i/(i+j+k);
                    }
                    if(j){
                        E[i][j][k]+=E[i+1][j-1][k]*j/(i+j+k); 
                    }
                    if(k){
                        E[i][j][k]+=E[i][j+1][k-1]*k/(i+j+k); 
                    }
                    E[i][j][k]+=(double)n/(i+j+k);
                }
            }
        }
    }
    printf("%.11lf\n",E[cnt[1]][cnt[2]][cnt[3]]);
}

int main(void){
    int x;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        cnt[x]++;
    }
    solve();
    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

#define x(p) real(p)
#define y(p) imag(p)

const double eps=1e-10;
const double inf=1e12;
typedef complex<double> P;

namespace std{
  bool operator<(const P& a,const P& b){
    return x(a)==x(b)?y(a)<y(b):x(a)<x(b);
  }
}
double cross(const P& a,const P& b){
  return y(conj(a)*b);
}
double dot(const P& a,const P& b){
  return x(conj(a)*b);
}
struct L : public vector<P> { // line and segment
  L(const P& a,const P &b){
    push_back(a);
    push_back(b);
  }
};

P projection(const L& l,const P& p){
  P b=l[1]-l[0],c=p-l[0];
  return l[0]+b*x(c/b);
}
P reflection(const L& l,const P& p){
  return p+2.0*(projection(l,p)-p);
}

int main(){
	cin.sync_with_stdio(false);
  int q;
  double x1,x2,x3,y1,y2,y3;
  cin>>x1>>y1>>x2>>y2;
  cin>>q;
  rep(i,q){
    cin>>x3>>y3;
    P res=reflection(L(P(x1,y1),P(x2,y2)),P(x3,y3));
    printf("%.10f %.10f\n", x(res),y(res));
  }
	return 0;
}

Measured memory_bytes: 3312
n = int(input())
h = list( map(int, input().split())) 

invh = h[::-1]
diff = 0

for i in range(n-1):
    if invh[i+1] - invh[i] >= 2:
        print('No')
        exit()
    elif invh[i+1] - invh[i] == 1:
        diff += 1
        if diff > 1:
            print('No')
            exit()
    elif invh[i+1] - invh[i] < 0:
        diff = 0
print('Yes')

Measured memory_bytes: 14116
#include <stdio.h>
#include <stdlib.h>

int main(){
	int A, B, C, D, op1, op2, op3;
	scanf("%1d%1d%1d%1d", &A, &B, &C, &D);
	for(op1 = -1; op1 <= 1; op1 += 2){
		for(op2 = -1; op2 <= 1; op2 += 2){
			for(op3 = -1; op3 <= 1; op3 += 2){
				if(A + op1 * B + op2 * C + op3 * D == 7){
					printf("%d", A);
					if(op1 == -1){
						printf("-");
					}
					else{
						printf("+");
					}
					printf("%d", B);
					if(op2 == -1){
						printf("-");
					}
					else{
						printf("+");
					}
					printf("%d", C);
					if(op3 == -1){
						printf("-");
					}
					else{
						printf("+");
					}
					printf("%d=7\n", D);
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int a,b;
    cin >> a >> b;
    cout << max(a-b,max(a+b,a*b)) << endl;
    return 0;
}

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

#ifdef LOCAL
#include "../debug.h"
#else
#define debug(x...) 141
#endif
#define forn(i,x,n) for(int i = x; i < n; ++i)
#define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it)
typedef long long ll;

ll p = 1000000007ll;

ll maxProductSubarrayOfSizeK(ll A[], ll n, ll k) { 
	sort(A, A+n); 
	ll product = 1;
	if(A[n-1] == 0 && (k&1)) 
		return 0;
	if(A[n-1]<=0 && (k&1)){ 
		for(int i = n-1; i>=n-k; i--) 
			product *= A[i], product%=p, product+=p, product%=p; 
		return product; 
	} 
	int i = 0, j = n-1;
	if(k & 1){ 
		product *= A[j], product%=p, product+=p, product%=p; 
		j--,k--; 
	}
	k >>= 1; 
	for(int itr = 0; itr < k; itr++) { 
		ll left_product = (A[i]*A[i+1]); 
		ll right_product = (A[j]*A[j-1]); 
		if (left_product > right_product) {
			left_product%=p; left_product+=p, left_product%=p; 
			product *= left_product, product%=p, product+=p, product%=p; 
			i += 2; 
		} 
		else { 
			right_product%=p; right_product+=p, right_product%=p; 
			product *= right_product, product%=p, product+=p, product%=p; 
			j -= 2; 
		} 
	} 
	product+=p, product%=p;
	return product; 
} 

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    ll A[n];
    forn(i,0,n)
    	cin>>A[i];
	cout << maxProductSubarrayOfSizeK(A, n, k); 
    
    return 0;
}

Measured memory_bytes: 5204
import numpy as np

H,W = [int(i) for i in input().split()]

maze = [['.']*(W+2)]
for i in range(H):
    maze.append(list('.'+input()+'.'))
maze.append(['.']*(W+2))

for i in range(1,H+1):
    for j in range(1,W+1):
        if maze[i][j] == '#':
            if maze[i-1][j] != '#' and maze[i+1][j] != '#' and maze[i][j-1] != '#' and maze[i][j+1] != '#':
                print('No')
                exit()

print('Yes')


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

using namespace std;

int main()
{

    long long x,p=100;
    cin>>x;
    int i=0;
    while(1){
        p=p*(1.01);
        i++;
        if(p>=x){
            cout<<i;
            break;
        }
    }

}


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

typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9+10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert
#define era erase
typedef vector<int> vi;
typedef queue<int> qi;
typedef greater<int> gi;
typedef priority_queue<int> pqi;
typedef priority_queue<int,vi,gi> pqgi;

int read() {
	int xx=0,ww=1;
	char ch=getchar();
	while(ch>'9'||ch<'0') {
		if(ch=='-') ww=-ww;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		xx=10*xx+ch-48;
		ch=getchar();
	}
	return xx*ww;
}

int n;
struct node {
	double d;
	int id;
} a[100010];
bool cmp(node a,node b) {
	if(a.d!=b.d) return a.d<b.d;
	return a.id<b.id;
}
double sum;

int main() {
	n=read();
	for(int i=0; i<n; i++) {
		cin>>a[i].d;
		a[i].id=i;
		sum+=a[i].d;
	}
	sum/=n;
	for(int i=0; i<n; i++)
		a[i].d=abs(sum-a[i].d);
	sort(a,a+n,cmp);
	printf("%d\n",a[0].id);
	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  vector <vector <int> > dp(SZ(s) + 1, vector <int>(SZ(t) + 1, 0));
  REP1(i, SZ(s)) {
	REP1(j, SZ(t)) {
	  dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
	  if (s[i - 1] == t[j - 1]) {
		  dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
		}
	}
  }
  string ans = "";
  int i      = SZ(s);
  int j      = SZ(t);
  while (1) {
	  if (dp[i][j] == dp[i - 1][j]) {
		  i--;
		}
	  else if (dp[i][j] == dp[i][j - 1]) {
		  j--;
		} else {
		  i--;
		  j--;
		  ans = s[i] + ans;
		}
	  if (SZ(ans) == dp[SZ(s)][SZ(t)]) {
		  break;
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 35584
n,m = map(int, input().split())
list_stu = []
for i in range(0,n):
    list_stu.append(list((map(int, input().split()))))
#print(list_stu)
list_check = []
for i in range(0,m):
    list_check.append(list((map(int, input().split()))))
#print(list_check)
for stu in list_stu:
    min = 10 ** 9
    min_point = 0
    for check in list_check:
        #print(abs(stu[0] - check[0]) + abs(stu[1] - check[1]))
        if min > (abs(stu[0] - check[0]) + abs(stu[1] - check[1])):
            min = abs(stu[0] - check[0]) + abs(stu[1] - check[1])
            min_point = list_check.index(check) + 1
    print(min_point)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
    int n, k, ans = 0, x;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        if (x > k / 2) ans += (k - x) * 2;
        else ans += x * 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())
k = int(input())

if a >= b:
    while a >= b:
        if k == 0:
            print("No")
            exit()
        b *= 2
        k -= 1

if b >= c:
    while b >= c:
        if k == 0:
            print("No")
            exit()
        c *= 2
        k -= 1

print("Yes")



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

const int NMAX = 120, WMAX = 10020, INF = 1000000;
int dp[NMAX][WMAX];
int w[NMAX], v[NMAX];

int main() {
  int N, W;
  cin >> N >> W;
  REP(i, N) {
    cin >> v[i+1] >> w[i+1];
  }

  for (int m = 0; m <= W; m++) {
    for (int i = 1; i <= N; i++) {
      int cmp = (m - w[i] >= 0 ? dp[i][m-w[i]] : -INF);
      dp[i][m] = max(dp[i-1][m], cmp + v[i]);
    }
  }

  cout << dp[N][W] << endl;
}

Measured memory_bytes: 5212
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
    char a[101];
    char b[101];
    char c[101];
    cin >> a >> b >> c;
    int l_a = strlen(a);
    int l_b = strlen(b);
    int l_c = strlen(c);
    int count_a=0;
    int count_b=0;
    int count_c=0;
    char turn='a';
    while(1){
        if (turn=='a'){
            turn=a[count_a];
            count_a++;
        }else if(turn=='b'){
            turn=b[count_b];
            count_b++;
        }else{
            turn=c[count_c];
            count_c++;
        }
        if (l_a+1==count_a){
            cout << 'A';
            break;
        }else if(l_b+1==count_b){
            cout << 'B';
            break;
        }else if(l_c+1==count_c){
            cout << 'C';
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
if (x in a) and (y in a):
  print("Yes")
elif (x in b) and (y in b):
  print("Yes")
elif (x in c) and (y in c):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>
typedef long long LL;

using namespace std;

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}


int main(void) {
	int n, a, b;
	cin >> n >> a >> b;
	vector<int>p(n);
	for (int i = 0; i < n; i++)cin >> p[i];
	int count_a = 0, count_ab = 0, count_b = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] <= a) {
			count_a++;
		}
		else if(p[i]>=a+1&&p[i]<=b){
			count_ab++;
		}
		else {
			count_b++;
		}
	}
	cout << min(count_a, min(count_ab, count_b));
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N, M = [int(t) for t in input().split()]
A    = [int(t) for t in input().split()]
assert len(A) == N

def prefixsum(A):
    '''S[i] == sum(A[:i]) % M かつ len(S) == len(A) + 1 であるSを返す.'''
    S = [0]
    for a in A:
        S.append((S[-1] + a) % M)
    return S

def eqlen(S):
    '''Sは整列済みリスト. 等しい要素の個数からなるリストを返す.'''
    T = []
    p = None
    for s in S:
        if p == s:
            T[-1] += 1
        else:
            T.append(1)
            p = s
    return T

S = prefixsum(A)
S.sort()
T = eqlen(S)
print(sum(t * (t - 1) // 2 for t in T))

Measured memory_bytes: 14228
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A, B, M;
	cin >> A >> B >> M;
	VI a(A), b(B);
	REP(i, A)cin >> a[i];
	REP(i, B)cin >> b[i];

	int ans = INF;

	REP(i, M) {
		int aa, bb, c; cin >> aa >> bb >> c;
		aa--; bb--;

		chmin(ans, a[aa] + b[bb] - c);
	}
	SORT(a);
	SORT(b);
	chmin(ans,a[0] + b[0]);
	cout << ans << endl;





	return 0;
}



Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int a = sc.nextInt();
    System.out.println(a + a * a + a * a * a);
  }
}

Measured memory_bytes: 32580
<?php

$array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
];
print $array[(int)(fgets(STDIN)) - 1];


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.00000001
#define pi 3.141592653589793
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti multiset <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    string s;
    cin>>s;
    ll n=s.length();
    ll a[n+1]={0};
    ll ans=0,count=0,f1=0,f2=0;
    for(ll i=n-2;i>=0;i--)
    {
        if(s[i]=='A')
        {
            ans+=a[i+1];
            a[i]=a[i+1];
        }
        else if(s[i]=='B'&&s[i+1]=='C')
        {
            a[i]=a[i+2]+1;
        }
        else
        {
            count=0;
        }
    }
    cout<<ans;
}

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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;


const int N = 2e5 + 5;


void solve() {

  int n;
  cin>>n;
  cout<<(1000-n%1000)%1000;
   
          
}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
    //cin >> t;

    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}




int powm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}


int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}


Measured memory_bytes: 3644