akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a;
  cin>>a;
  vector<ll>vec(a);
  vector<ll>vece(a);
  vector<ll>vecw(a);
  ll b=0;
  for(ll i=0;i<a;i++){
    char c;
    cin>>c;
    vece.at(i)=b;
    if(c=='W'){
      vec.at(i)=1;
      b+=1;
    }
  }
  b=a-b;
  for(ll i=0;i<a;i++){
    if(vec.at(i)==0){
      b-=1;
    }
    vecw.at(i)=b;
  }
  ll d=a;
  for(ll i=0;i<a;i++){
    d=min(d,vecw.at(i)+vece.at(i));
  }
  cout<<d<<endl;     
  return 0;
}

Measured memory_bytes: 10324
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N];
int main() {
	int n;
	scanf("%d", &n);
	long long ans = 0;
	int las = 1;
	for (int i = 1; i <= n; ++ i) {
		scanf("%d", &a[i]);
		if (i == 1) {
			ans += a[i] - 1;
		}
		else if (a[i] >= las + 2) {
			ans += (a[i] - 1) / (las + 1);
		}
		else {
			las = max(las, a[i]);
		}
	}
	printf("%lld\n", ans);
}



Measured memory_bytes: 640
#include<iostream>
using namespace std;
const int md=1e9+7,N=6e5+2;
typedef long long LL;
int n,m,L,R,fac[N],iv[N],k;
inline void upd(int&a){a+=a>>31&md;}
inline int reduce(int x){return(x>>31&md)+x;}
inline int C(int n,int m){return(LL)fac[n]*iv[m]%md*iv[n-m]%md;}
int solve(int S,int a,int b){
	if(a*m>S)return 0;
	S-=a*m;
	int r=0;
	for(int i=0,f=1;i<=k&&S>=0;++i,f=md-f,S-=b)
	r=(r+(LL)f*C(S+n,n)%md*C(k,i))%md;
	return(LL)r*C(n,m)%md;
}
int solve(int R){
	int ans=C(n+R,n);
	for(int i=0;i*m<=R;++i)
	upd(ans-=reduce(solve(R,i,i)-solve(R,i+1,i)));
	return ans;
}
int main(){
	cin>>n>>m>>L>>R,k=n-m;
	for(int i=*fac=1;i<N;++i)fac[i]=fac[i-1]*(LL)i%md;
	iv[N-1]=317746424;
	for(int i=N-2;~i;--i)iv[i]=(i+1LL)*iv[i+1]%md;
	cout<<reduce(solve(R)-solve(L-1))<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <math.h>

int main(void){
  char s[11];
  int a;
  
  scanf("%d",&a);
  scanf("%s",s);
  
  if(a<3200){
    printf("red\n");
  }else if(a>=3200){
    printf("%s\n",s);
  }
  
  return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")

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

typedef unsigned long long int ull;
typedef long long ll;
#define pb push_back

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //your code starts here
    int n;
    cin >> n;
    ll diff[2][n];
    for (int i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        diff[0][i] = x + y;
        diff[1][i] = x - y;
    }
    for (int i = 0; i < 2; i++)
        sort(diff[i], diff[i] + n);
    ll ans = INT_MIN;
    for (int i = 0; i < 2; i++)
        ans = max({ans, diff[i][n - 1] - diff[i][0], diff[i][0] - diff[i][n - 1]});
    cout << ans << "\n";
    return 0;
}


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

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

  int G[10][100];
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 100; j++) {
      G[i][j] = 0;
    }
  }

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    G[a][b] = 1;
    G[b][a] = 1;
  }
  vector<int> r_comb;
  for (int i = 1; i <= N; i++) {
    r_comb.emplace_back(i);
  }

  set<string> ans_set;
  do {
    int start = 1;
    int chk[M];
    for (int i = 1; i <= M; i++) {
      chk[i] = 0;
    }
    chk[start] = 1;

    string comb = to_string(start);
    for (auto itr = r_comb.begin() + 1; itr != r_comb.end(); itr++){
      if (G[start][*itr] == 1 && G[*itr][start] == 1 && chk[*itr] != 1) {
        chk[*itr] = 1;
        comb = comb + to_string(*itr);
        start = *itr;
      } else {
        start = 1;
        itr = r_comb.end();
        break;
      }
    }
    if ((int)comb.length() == N) {
      ans_set.insert(comb);
    }
  } while (next_permutation(r_comb.begin() + 1, r_comb.end()));
  cout << ans_set.size() << endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
const int N=3300;
int n,mod,f[N][N],c[N][N],ans;
int qpw(int x,int n,int mod=::mod){
    int ret=1; for(;n;n>>=1,x=1ll*x*x%mod)
    if(n&1) ret=1ll*ret*x%mod; return ret;
}
main(){
    scanf("%d%d",&n,&mod), f[0][0]=c[0][0]=1;
    for(int i=1;i<=n+1;i++) for(int j=0;j<=i;j++)
        f[i][j]=j?(f[i-1][j-1]+1ll*j*f[i-1][j])%mod:0,
        c[i][j]=j?(c[i-1][j-1]+c[i-1][j])%mod:1;
    for(int i=0;i<=n;i++){
        int res=0,tmp=qpw(2,n-i),k=1;
        for(int j=0;j<=i;j++,k=1ll*k*tmp%mod)
            (res+=1ll*k*f[i+1][j+1]%mod)%=mod;
        (ans+=(i&1?-1ll:1ll)*c[n][i]*qpw(2,qpw(2,n-i,mod-1))%mod*res%mod)%=mod;
    }
    printf("%d\n",(ans+mod)%mod);
}


Measured memory_bytes: 78720
#include<stdio.h>
int main(void)
{
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);

    d=a/b;
    r=a%b;
    f=(double)a/(double)b;

    printf("%d %d %lf",d,r,f);

    return 0;
}

Measured memory_bytes: 636
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl A(N);
  REP(i, N) cin >> A[i];
  bool ok = true;
  REP(i, N) {
    if (A[i] % 2 == 0 && (A[i] % 3 != 0 && A[i] % 5 != 0)) {
      ok = false;
    }
  }
  if (!ok)
    cout << "DENIED" << endl;
  else
    cout << "APPROVED" << endl;
  return 0;
}


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

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N;
	cin >> N;
	int m = -INF;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		if (tmp >= m) {
			ans++;
			m = tmp;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(){
  
int n,i,j,A[N],min,b;

int c=0;
 
  scanf("%d",&n);
  
   for(i = 0; i < n; i++){
    
   scanf("%d",&A[i]);
  
 }
  
  for(i = 0; i < n; i++){
    
      min = i;
   
  for(j = i; j < n; j++){
      
      if(A[j] < A[min]){
   
        min = j;
      
    }
    
 }
   
      if(min != i){
    
      b = A[i];
    
      A[i] = A[min];
    
      A[min] = b;
    
        c++;
    
      }
 
  }
 
  for(i = 0; i < n-1; i++){
    
      printf("%d ",A[i]);
  
  }                              

      printf("%d\n",A[n-1]);

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

}

Measured memory_bytes: 1848
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int[][] switchPatterns = new int[m][];
		int[] p = new int[m];
		for ( int i = 0; i < m; i++ ) {
			int k = in.nextInt();
			int[] s = new int[k];
			for ( int j = 0; j < k; j++ ) {
				s[j] = in.nextInt();
			}
			switchPatterns[i] = s;
		}
		for ( int i = 0; i < m; i++ ) {
			p[i] = in.nextInt();
		}

		int Allpatterns = 2 << (n - 1); // 2のn乗
		int cnt = Allpatterns;

		// スイッチのパターンを上限まで列挙
		for ( int ptr = 0; ptr < Allpatterns; ptr++ ) {
			// 電球ごとのスイッチパターンと照らし合わせる
			for ( int d = 0; d < m; d++ ) {
				// パターン作成
				int sptr = 0;
				for ( int i : switchPatterns[d] ) {
					sptr += 1 << i - 1;	// 順序：四則演算 → ビットシフト → 論理演算 → 代入
				}
				if ( Integer.bitCount(ptr & sptr) % 2 != p[d] ) {
					cnt--;
					break;
				}
			}
		}
		System.out.println(cnt);
		in.close();
	}
}

Measured memory_bytes: 23764
#include <stdio.h>
int main(){
  int N;
  int A;
  int B;
  scanf("%d %d %d" ,&N,&A,&B);
  int X =N*A;
  if(X < B){
    printf("%d",X);
  }else{
    printf("%d",B);
  }
  return 0;
}
  
  

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

int main(){
    int mod=1000000007;
    int n,m;
    char s[30005];
    int d[10][2];
    set<int> ans;
    for (int i=0;i<10;i++) {
        d[i][0]=30005;
        d[i][1]=-1;
    }
    scanf("%d",&n);
    scanf("%s",s);
    for (int i=0;i<n;i++) {
        int p=s[i]-'0';
        if (d[p][0]==30005) {
            d[p][0]=i;
            d[p][1]=i;
        } else {
            d[p][1]=i;
        }
    }
    for (int i=1;i<n-1;i++) {
        for (int j=0;j<10;j++) {
            if (d[j][0]<i) {
                for (int k=0;k<10;k++) {
                    if (d[k][1]>i) ans.insert(j*100+(s[i]-'0')*10+k);
                }
            }
        }
    }
    printf("%ld\n",ans.size());
    return 0;
}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 1e5+10;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
int n;
vector<int> g[N+5];
ll dp[N+5][2];
void dfs(int cur,int par)
{
	dp[cur][1]=dp[cur][0]=1;
	for(auto it : g[cur])
	{
		if(it==par)continue;
		dfs(it,cur);
		dp[cur][0]=1ll*dp[cur][0]*dp[it][1]%mod;
		dp[cur][1]=1ll*dp[cur][1]*(dp[it][1]+dp[it][0])%mod;
	}
	
}
int main()
{  fast
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		g[x].emplace_back(y);
		g[y].emplace_back(x);
	}
	dfs(1,0);
	cout<<(dp[1][0]+dp[1][1])%mod;
	
}

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

int main() {
  int ans = 0;
  int n;
  cin >> n;
  multiset<int> st;
  rep (i, n) {
    int l;
    cin >> l;
    st.insert(l);
  }
  auto iti = st.begin();
  for (; iti != st.end(); ++iti) {
    auto itj = iti;
    ++itj;
    for (; itj != st.end(); ++itj) {
      auto itk = itj;
      ++itk;
      for (; itk != st.end(); ++itk) {
        if (*iti != *itj && *itj != *itk && *iti + *itj > *itk) {
          //cout << *iti << " " << *itj << " " << *itk << endl;
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int main() {

	string S;
	int a = -5, z = -5;

	cin >> S;

	for (int i = 0; i < S.size(); i++) {

		if (a == -5 && S[i] == 'A')a = i;
		if (z == -5 && S[S.size() - i - 1] == 'Z')z = S.size() - i - 1;

	}

	cout << z - a + 1 << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;

int main() {
    srand(time(0));
    
    ios_base :: sync_with_stdio(false);
    int n, m; cin >> n >> m;
    
    vector<int> a(m, 0), b(m, 0), c(m, 0);
    vector<int> v(n, inf);
    vector<pair<int, int>> edges;

    for(int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i] >> c[i];
        v[a[i]] = min(v[a[i]], c[i] + 1);
        v[b[i]] = min(v[b[i]], c[i] + 2);
    }
    
    int best = inf;

    for(int i = 0; i < 3 * n; ++i) {
        best = min(best + 2, v[i % n]);
        v[i % n] = min(best, v[i % n]);
    }

    for(int i = 0; i < n; ++i) {
        a.push_back(i);
        b.push_back((i + 1) % n);
        c.push_back(v[i]);
    }

    for(int i = 0; i < n + m; ++i) {
        edges.push_back({c[i], i});
    }

    sort(edges.begin(), edges.end());
    long long ans = 0;

    vector<int> dad(n, 0);
    for(int i = 0; i < n; ++i)
        dad[i] = i;

    auto f = [&] (int x) {
        int root = x;
        while(root != dad[root])
            root = dad[root];
        while(x != root) {
            int temp = dad[x];
            dad[x] = root;
            x = temp;
        }
        return root;
    };

    auto unite = [&] (int a, int b) {
        dad[a] = b;
    };

    for(auto edge : edges) {
        int x = a[edge.second];
        int y = b[edge.second];
        if(f(x) != f(y)) {
            unite(f(x), f(y));
            ans += edge.first;
        }
    }

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

Measured memory_bytes: 11900
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int k, a, b;

	cin >> k >> a >> b;

	for (int i = 1; i < 10000; i++) {
		if (i*k >= a && i*k <= b) {
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;


	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define N 110
using namespace std;
const int INF = 1LL<<55;
int Max(int &a,int b){return a=max(a,b);}
int Min(int &a,int b){return a=min(a,b);}
struct dat{int cnt, num_door , dis;};
int n;
vector<int> G[N];
vector<int> rec;
vector<dat> A;

bool can_add_edge(int a,int b,int r){
  return A[a].cnt && A[b].cnt && A[a].dis - A[b].dis == r;
}

void add_edge(int a,int b){
  assert(A[a].cnt-- && A[b].cnt--);
  //  cout<<"add_edge "<<a<<" "<<b<<endl;
  G[a].push_back(b);
  G[b].push_back(a);
  sort(G[a].begin(),G[a].end());
  sort(G[b].begin(),G[b].end());
}

void erase_edge(int a,int b){
  A[a].cnt++,A[b].cnt++;
  for(auto it=G[a].begin();it!=G[a].end();it++)if(*it == b){G[a].erase(it);break;} 
  for(auto it=G[b].begin();it!=G[b].end();it++)if(*it == a){G[b].erase(it);break;} 
}


void dfs(int idx,int num){
  if(idx >= (int)rec.size()) return;
  int pos = num;
  //cout<<"idx="<<idx<<" pos="<<pos<<" num="<<num<<" dis="<<A[pos].dis<<endl;
  //for(dat a:A) cout<<"{"<<a.cnt<<","<<a.dis<<"}"<<" ";cout<<endl;

  while(idx<(int)rec.size() && rec[idx]<0){
    //cout<<rec[idx]<<endl;
    for(int i=0;i<(int)A.size()-1;i++){
      if(!can_add_edge(i,pos,rec[idx])) continue;
      add_edge(i,pos);
      idx++;
      break;
    }
    while(pos && A[pos].cnt == 0) pos--;
  }
  if(idx >= (int)rec.size()) return;

  while(A[pos].cnt == 0) pos--;
  A.push_back((dat){rec[idx],rec[idx],A[pos].dis+1});
  add_edge(pos,num+1);
  dfs(idx+1,num+1);
}


void solve(){
  n = 0;
  A.clear();
  A.push_back((dat){rec[0],rec[0],0});
  dfs(1,0);
}


signed main(){
  int q;
  cin>>q;
  while(q--){
    for(int i=0;i<N;i++) G[i].clear();    
    rec.clear();
    for(int a;cin>>a,a;)rec.push_back(a);

    solve();

    for(int i=0;i<(int)A.size();i++){
      cout<<i+1;
      for(int a:G[i]) cout<<" "<<a+1;
      cout<<endl;
    }
  }
  return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string S;
  cin >> S;
  
  if(S.at(0) != 'A'){
    cout << "WA" << endl;
    return 0;
  }
  
  int l = S.length();
  int c_count = 0;
  int c_index;
  for(int i=2; i<=l-2; ++i){
    if(S.at(i) == 'C'){
      ++c_count;
      c_index = i;
    }
  }
  if(c_count != 1){
    cout << "WA" << endl;
    return 0;
  }
  
  for(int i=1; i<l; ++i){
    if(i == c_index){
      continue;
    }
    
    if(!('a' <= S.at(i) && S.at(i) <= 'z')){
      cout << "WA" << endl;
      return 0;
    }
    
  }
  cout << "AC" << endl;   
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

int n;
int ans, x, y, h, w;
int _size;


int main() {
	while ( ~scanf( "%d", &n ) && n ) {
		ans = 0;
		for ( int i = 0; i < n; i++ ) {
			scanf( "%d %d %d %d", &x, &y, &h, &w );
			_size = x + y + h;
			if ( _size <= 60 && w <= 2 ) {
				ans += 600;
			}
			else if ( _size <= 80 && w <= 5 ) {
				ans += 800;
			}
			else if ( _size <= 100 && w <= 10 ) {
				ans += 1000;
			}
			else if ( _size <= 120 && w <= 15 ) {
				ans += 1200;
			}
			else if ( _size <= 140 && w <= 20 ) {
				ans += 1400;
			}
			else if ( _size <= 160 && w <= 25 ) {
				ans += 1600;
			}
		}
		printf( "%d\n", ans );
	}

	return 0;
}

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

int main() {
	int s, s1, s2, s3;

  	cin >> s;
  	s1 = s/100;
  	s2 = (s - s1 * 100)/10;
  	s3 = (s - s1 * 100 - s2 * 10);
  	cout << s1 + s2 + s3 << endl;
}

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

class UnionFindTree {
  vector<int> parent, rank;

  int find(int x) {
    if(parent[x] != x) {
      parent[x] = find(parent[x]);
    }
    return parent[x];
  }

public:

  UnionFindTree(int size) {
    parent = vector<int>(size);
    rank = vector<int>(size, 0);
    for(int i = 0; i < size; i++) parent[i] = i;
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y)return;

    if(rank[x] < rank[y]) {
      parent[x] = y;
    } else {
      parent[y] = x;
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }
};


int main () {
  int n, q;

  cin >> n >> q;

  UnionFindTree uft(n);
  for(int i = 0; i < q; i++) {
    int c, x, y;
    cin >> c >> x >> y;
    if(c == 0) {
      uft.unite(x, y);
      continue;
    }
    cout << uft.same(x, y) << endl;
  }

  return 0;
}



Measured memory_bytes: 3300
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

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

    int ret = 0;
    for (int k = 30; k > 0; k--) {
        if (!(x & (1 << (k-1)))) continue;

        for (int i = 0; i < n; i++) {
            if (a[i] == (1 << k) - 1) {
                x ^= (1 << k) - 1;
                ret++;
                a[i] = 0;
                break;
            }
        }
    }

    cout << (x > 0 ? -1 : ret) << "\n";
    return 0;
}

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


using namespace std;


using ll = long long;


class segment_tree {
    public:
        ll size;
        vector<ll> A;
        segment_tree(ll size);
        void update(ll i, ll x);
        ll find(ll s, ll t);
        ll find_sub(ll s, ll t, ll i, ll l, ll r);
};


segment_tree::segment_tree(ll size)
{
    ll tmp = 1;
    while (tmp < size)
        tmp *= 2;
    this->size = tmp;
    A.resize(tmp * 2 - 1, (1LL << 31) - 1);
}

void segment_tree::update(ll i, ll x)
{
    ll now = i + size - 1;
    A[now] = x;
    while (now > 0) {
        now = (now - 1) / 2;
        A[now] = min(A[2 * now + 1], A[2 * now + 2]);
    }
}


/*
 * [a, b): The area that we want to know the answer of.
 * [l, r): The area that we are currently checking.
 * k: The index of segment tree array (A),
 *      that corresponds to [l, r)
 */
ll segment_tree::find_sub(ll a, ll b, ll k, ll l, ll r)
{
    if (r <= a || b <= l)
        return (1LL << 31) - 1;
    else if (a <= l && r <= b)
        return A[k];
    else {
        ll x, y;
        x = find_sub(a, b, k * 2 + 1, l, (l + r) / 2);
        y = find_sub(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(x, y);
    }
}


ll segment_tree::find(ll s, ll t)
{
    return find_sub(s, t, 0, 0, size);
}


int main() {
    ll n, q;
    cin >> n >> q;

    segment_tree st(n);
    for (int i = 0; i < q; i++) {
        ll c, x, y;
        cin >> c >> x >> y;
        switch(c) {
            case 0:
                st.update(x, y);
                break;
            case 1:
                ll res = st.find(x, y + 1);
                cout << res << endl;
                break;
        }
    }
}



Measured memory_bytes: 4904
N=int(input().strip())
a=[0]
b=list(map(int, input().split()))
for i in range(N):
    a.append(b[i])
a.append(0)

su=0
for i in range(N+1):
    su+=abs(a[i+1]-a[i])

for i in range(1,N+1):
    print(su-(abs(a[i+1]-a[i]))-abs(a[i]-a[i-1])+abs(a[i+1]-a[i-1]))

Measured memory_bytes: 14048
import java.io.BufferedReader;
import java.io.InputStreamReader;

//public class Problem0020_Capitalize {
public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			Capitalizer test = new Capitalizer();
			String line;
			while((line = reader.readLine()) != null) {
				System.out.println(test.convert(line));
			}
			
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
}
class Capitalizer {
	private final char[] CAPITAL_ALPHABET_ARRAY;
	Capitalizer() {
		CAPITAL_ALPHABET_ARRAY = new char['Z' - 'A' + 1];	//ツ本ツ督鳴づ債配ツ療アツづ可猟環づァツつクUNICODEツづ個氾板債つゥツづァツ出ツつケツづゥツづ債つク
		char alphabetNumber = 'A';
		for(int i = 0; i < (CAPITAL_ALPHABET_ARRAY.length); i++) {
			CAPITAL_ALPHABET_ARRAY[i] = alphabetNumber;
			alphabetNumber++;
		}
	/*	for(char alphabet : CAPITAL_ALPHABET_ARRAY) {
			System.out.println(alphabet);
		}	*/
	}
	String convert(String txt) {
		char[] charArray = txt.toCharArray();
		for(int i = 0; i < charArray.length; i++) {
			if(charArray[i] == '.' || charArray[i] == ' ') {
				//do nothing
			} else {
				charArray[i] = CAPITAL_ALPHABET_ARRAY[charArray[i] - 'a'];
			}
		}
		
		return String.valueOf(charArray);
	}
}

Measured memory_bytes: 9344
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();

		int[] b = new int[m];
		for (int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}
		
		int[][] a = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				a[i][j] = sc.nextInt();
			}
		}

		int cnt = 0;
		for (int i = 0; i < n; i++) {
			long tmp = c;
			for (int j = 0; j < m; j++) {
				tmp += a[i][j] * b[j];
			}
			
			if (tmp > 0) {
				cnt++;
			}
		}

		pr.println(cnt);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct UnionFind {
    UnionFind() {}
    UnionFind(int n) {
        resize(n);
    }
    
    void resize(int n) {
        par.resize(n, -1);
    }
    
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    
    bool merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return false;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }
    
    bool is_same(int x, int y) {
        return (root(x) == root(y));
    }
    
    int size(int x) {
        return -par[root(x)];
    }
    
private:
    vector<int> par;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    UnionFind uf(n);
    vector<pair<ll, ll>> ab(m);
    rep(i, m) {
        cin >> ab[i].first >> ab[i].second;
        ab[i].first--; ab[i].second--;
    }
    vector<ll> ans(m);
    ll minus = 0;
    rrep(i, m) {
        ll ac = uf.size(ab[i].first);
        ll bc = uf.size(ab[i].second);
        ans[i] = n * (n - 1) / 2 - minus;
        if (uf.root(ab[i].first) != uf.root(ab[i].second)) {
            minus += uf.size(ab[i].first) * uf.size(ab[i].second);
            uf.merge(ab[i].first, ab[i].second);
        }
    }
    rep(i, m) printf("%lld\n", ans[i]);
    return 0;
}


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

#define pb push_back
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

using namespace std;
using ll = long long;

void solve() {
}

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

  int n, d;
  cin >> n >> d;
  int ans = n / (2 * d + 1);
  if (n % (2 * d + 1) != 0) ++ans;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc= new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
		int count = 0;

		while(n != 0) {
			n /= k;
			count++;
			}
		System.out.println(count);
		sc.close();
	}

}


Measured memory_bytes: 35884
s = input().strip()
ans = "keyence"
idx = 0
if s[:7] == ans:
    print("YES")
    exit()
for i in range(len(s) - 1):
    for j in range(i + 1, len(s), 1):
        if s[:i] + s[j:] == ans:
            print("YES")
            exit()
print("NO")


Measured memory_bytes: 38768
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <limits>
#include <math.h>

using namespace std;

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

  if (k == 0) {
    long long ans = pow((long long)n, 2LL);
    cout << ans << endl;
    return 0;
  }

  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    int p = n / i;
    int r = n - p * i;
    ans += (max(i - k, 0) * p) + max(r + 1 - k, 0);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N, K = list(map(int, input().split()))
S = input()

L = [[0, 0]]
re = S[0]
for i in range(1, len(S)):
  if S[i] != re:
    re = S[i]
    L[-1][1] = i
    L.append([i, 0])
l = len(L)
L[-1][1] = N

if S[0] == "0":
  z = (l // 2) + 1
else:
  z = (l + 1) // 2
  
if z <= K:
  print(N)
  exit()

ma = 0
if S[0] == "0":
  ma = max(ma, L[K * 2 - 1][1])
  s = 1
else:
  s = 0
if S[-1] == "0":
  ma = max(ma, N - L[-K * 2][0])

t = K * 2
for i in range(s, l - t, 2):
  ma = max(ma, L[t + i][1] - L[i][0])
print(ma)



Measured memory_bytes: 16500
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.16f\n", a)//少数出力
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {

	int n;
	scanf("%d", &n);
	vector<int> a(n);
	rep(i, n)scanf("%d", &a[i]);
	ll cost, mincost = LINF;
	for (int i = -100; i <= 100; ++i) {
		cost = 0;
		rep(j, n) {
			cost += (a[j] - i) * (a[j] - i);
		}
		mincost = min(mincost, cost);
	}
	printf("%lld\n", mincost);
}

Measured memory_bytes: 256
N = int(input())

ans_list = []
for a in range(1, int(N**0.5)+1, 1):
    if N%a==0:
        ans_list.append([a,N//a])

ans = float('inf')
for a,b in ans_list:
    ans = min(ans, a+b-2)

print(ans)

Measured memory_bytes: 3560
#define _CRT_SECURE_NO_WARNINGS


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <bitset>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <random>
#include <cassert>

using namespace std;

//#define FAST_ALLOCATOR_MEMORY 1e8
#undef LOCAL
//#include "optimization.h"

int main() {
	iostream::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	long long a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	long  long ans = 1e15;
	for (int i = 0; i < 2 * (x + y); i+=2) {
		long long res = i * c + max(0ll, (x - i / 2)) * a + max(0ll, (y - i / 2)) * b;
		ans = min(ans, res);
	}
	cout << ans;
	return 0;
}

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

P operator+(P a, P b) {
	return P(a.first + b.first, a.second + b.second);
}
#ifndef MAX
#define MAX 400000
#endif
template<class T>
class RAQ_RMQ {
public:
	int n;
	T dat[MAX], lazy[MAX], ZERO, DEFAULT;
	bool(*cmp)(T, T);
	void init(int n_,
		bool(*c)(T, T) = [](int a, int b) {return a < b; }, T d = INT_MAX) {
		cmp = c;
		DEFAULT = d;
		ZERO = T();
		n = 1; while (n < n_)n <<= 1;
		for (int i = 0; i < 2 * n - 1; i++) {
			dat[i] = lazy[i] = ZERO;
			if (i >= n - 1 + n_)dat[i] = DEFAULT;
		}
	}
	inline void push(int k) {
		if (lazy[k] == ZERO)return;
		dat[k] = dat[k] + lazy[k];
		if (k < n - 1) {
			lazy[k * 2 + 1] = lazy[k * 2 + 1] + lazy[k];
			lazy[k * 2 + 2] = lazy[k * 2 + 2] + lazy[k];
		}
		lazy[k] = ZERO;
	}
	inline void update_node(int k) {
		if (cmp(dat[k * 2 + 1], dat[k * 2 + 2]))dat[k] = dat[k * 2 + 1];
		else dat[k] = dat[k * 2 + 2];
	}
	inline void update(int a, int b, T x, int k, int l, int r) {
		push(k);
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			lazy[k] = lazy[k] + x; push(k); return;
		}
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
	}
	inline T query(int a, int b, int k, int l, int r) {
		push(k);
		if (r <= a || b <= l)return DEFAULT;
		if (a <= l&&r <= b)return dat[k];
		T lb = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T rb = query(a, b, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
		if (cmp(lb, rb))return lb;
		return rb;
	}
	inline void update(int a, int b, T x) {
		update(a, b, x, 0, 0, n);
	}
	inline void update(int a, T x) {
		update(a, a + 1, x);
	}
	inline T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
	inline T query(int a) {
		return query(a, a + 1);
	}
};
RAQ_RMQ<P>seg;
int main() {
	int n, q; scanf("%d%d", &n, &q);
	seg.init(n, [](P a, P b) {return a.second < b.second; }, P(0, INT_MAX));
	rep(i, q) {
		int a; scanf("%d", &a);
		if (a == 0) {
			int s, t, x; scanf("%d%d%d", &s, &t, &x); s--;
			seg.update(s, t, P(0, x));
		}
		else {
			int s; scanf("%d", &s); s--;
			printf("%d\n", seg.query(s).second);
		}
	}
}

Measured memory_bytes: 9484
#include<iostream>
using namespace std;
int main()
{
    int n,b=0,x=1;
    cin>>n;

    int a[n],i;

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

        if(a[i]!=x)
            b++;
        else
            x++;
    }
    if(x==1)
        cout<<-1<<endl;
    else
        cout<<b<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    int N, A, B;
    cin >> N >> A >> B;
    vector<int> P(N);
    cin >> P;

    int a = 0, b = 0, c = 0;
    REP(i, N) {
        if (P[i] <= A)
            a++;
        else if (P[i] <= B)
            b++;
        else
            c++;
    }

    cout << min({ a, b, c }) << endl;
    return 0;
}

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

int main() {
  string a, b;
  cin >> a >> b;
  int x = stoi(a + b);
  double y = sqrt(x);

  if (ceil(y) == floor(y))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  multiset<long long> h;
  for(int i=0;i<n;i++) {
    int hit;
    cin >> hit;
    h.emplace(hit);
  }
  int start = 1;
  int end = 1100100100;
  while(start != end) {
    int m = (start + end) / 2;
    auto it = h.upper_bound((long long)b * (long long)m);
    int dist = distance(h.begin(), it);
    long long tmp = 0;
    for(auto itr = it;itr != h.end();itr++) {
      int diff = *itr - b * m;
      if(diff % (a - b) == 0) tmp += diff / (a - b);
      else tmp += diff / (a - b) + 1;
    }
    if(tmp <= m) end = m;
    else start = m + 1;
  }
  cout << start << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<algorithm>
 
using namespace std;
 
int main(void){
 
  int n,m,in,sumt,sumh;
  vector<int>taro,hanako;
 
  while(cin >> n >> m,n|m){
    taro.clear();
    hanako.clear();
 
    sumt=0;
    sumh=0;
 
    for(int i=0;i<n;i++){
      cin >> in;
      sumt+=in;
      taro.push_back(in);
    }
     
    for(int i=0;i<m;i++){
      cin >> in;
      sumh+=in;
      hanako.push_back(in);
    }
 
    int Min=10000000,anst,ansh;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
    if(sumt-taro[i]+hanako[j]==sumh+taro[i]-hanako[j]){
      if(Min>taro[i]+hanako[j]){
        Min=taro[i]+hanako[j];
        anst=taro[i];
        ansh=hanako[j];
      }
    }
      }
    }
     
    if(Min==10000000)cout << -1 << endl;
    else cout << anst << " " << ansh << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1220
#include<string>
#include<vector>
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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


bool f(int n){
	int p;
	REP(i,2,n){
	if(n%i==0){
	p=i;
	break;
	}
	}
	if(p==n) return true;
	else return false;
}

int main(){

	int n;
	while(cin >> n){

	int p1,p2;

	for(int i=n+1;;i++){
	if(f(i)){ p1=i; break;}

	}

	for(int i=n-1;;i--){
	if(f(i)){ p2=i; break;}

	}

	cout << p2 << " " << p1 << endl;

	}

	return 0;
}

Measured memory_bytes: 1160
def solve(h, str)
  pics = []
  h.times do |i|
    pics << str[i]
    pics << str[i]
  end
  pics.compact
end

if $PROGRAM_NAME == __FILE__
  str = []
  h, w = gets.chomp.split(' ').map(&:to_i)
  h.times { str << gets.chomp }
  picture = solve(h * 2, str)
  (h * 2).times { |i| puts picture[i] }
end

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;



int main() {
	int n, k, s;
	cin >> n >> k >> s;
	vector<int> prime;
	prime.emplace_back(2);

	for (int i = 3; i*i <=s; i++) {
		bool isPrime = true;
		for (int p : prime) {
			if (i%p == 0) {
				isPrime = false;
				break;
			}
		}
		if (isPrime) {
			prime.emplace_back(i);
		}
	}


	for (int i = 0; i < k;i++) {
		cout << s << " ";
	}
	

	int num = -1;
	if (s < 1000000000) {

		num = s + 1;
	}
	else {
		num = 1;

	}
	for (int i = 0; i < (n - k); i++) {
		cout << num << " ";
	}
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	int vis[n+1]={0};
	for(int x=1;x*x<n;x++)
	{
		for(int y=1;y*y<n;y++)
		{
			for(int z=1;z*z<n;z++)
			{
				if(x*x+y*y+z*z+x*z+x*y+y*z>n)continue;
				++vis[x*x+y*y+z*z+x*z+x*y+y*z];
			}
		}
	}
	for(int i=1;i<=n;i++)
	cout<<vis[i]<<"\n";		
	return 0;
}

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

#define int long long int
#define vi vector<int>
#define pb push_back
#define vvi vector<vi>

signed main() {
    int n;
    cin >> n;
    vi a(n);
    vi cnt(n + 1, 0);
    int mx = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i] > n)    continue;
        if(a[i] == 1) {
            cnt[a[i]] = 1;
        }
        else if(cnt[a[i] - 1]) {
            cnt[a[i]] = cnt[a[i] - 1] + 1;
        }
        // cout << cnt[a[i]] << endl;
        mx = max(mx, cnt[a[i]]);
    }
    if(!mx) 
        cout << -1 << endl;
    else
        cout << n - mx << endl;
}

Measured memory_bytes: 6408
#include<bits/stdc++.h>
using namespace std;
map<string,int> QAQ;
int main()
{
	int n,m;
	cin>>n;
	string a[n];
	for(int i=0;i<n;i++)
	{
		string l;
		cin>>l;
		a[i]=l;
		QAQ[l]++;
	}
	cin>>m;
	string b[m];
	for(int i=0;i<m;i++)
	{
		string l;
		cin>>l;
		b[i]=l;
		QAQ[l]--;
	}
	int max=-100000;
	for(int i=0;i<n;i++)
	{
		if(QAQ[a[i]]>max) max=QAQ[a[i]];
	}
	for(int i=0;i<m;i++)
	{
		if(QAQ[b[i]]>max) max=QAQ[b[i]];
	}
	cout<<(max>0?max:0)<<endl;
	return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
 
using ull = unsigned long long int;
using ll = long long int;
using du = double;
using ld = long du;
using vi = vector<int>;
using vll = vector<ll>;
using vld = vector<ld>;
using vdu = vector<du>;
using vs = vector<string>;
using vc = vector<char>;
using si = set<int>;
using sll = set<ll>;
using sdu = set<du>;
using sld = set<ld>;
using pii = pair<int, int>;
using pll = pair<ll,ll>;
using pdu = pair<du,du>;
using pld = pair<ld,ld>;
using pis = pair<int,string>;
 
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define sp(x) setprecision(x)<<fixed
#define loop(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pi acos(-1)
#define meme(a,x) memset(a,x,sizeof(a))
#define all(a) a.begin(),a.end()
 
//debugger
 
#ifdef KAIZER
#include "debug.h"
#else
#define debug(x...)
#endif
//debugger
 
//functions
bool check_pow(ll a)
{
    if((a&(a-1))==0) return true;
    else return false;
}
ld my_pow(ld a,int b)
{
    ld ans=1;
    for(int i=0;i<b;i++) ans*=a;
    return ans;
}
ll digits(ll a)
{
    string line=to_string(a);
    return line.size();
}
bool prime_check(ll a)
{
    bool flag=true;
    for(ll i=2;i<=sqrt(a);i++)
    {
        if(a%i==0) {flag=false; break;}
    }
    return flag;
}
bool comp(const pair<int,int> &a , const pair<int,int> &b)
{
    if(a.ff!=b.ff) return a.ff>b.ff;
    else return a.ss<b.ss;
}
bool comp2(const ll &a, const ll &b)
{
     return a>b;
}
 
//functions

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FASTIO;
    ll n,k,ans=0;
    cin>>n>>k;
    loop(i,n)
    {
        ll x;
        cin>>x;
        if(x<=k/2) ans+=x;
        else ans+=(k-x);
    }
    ans*=2;
    cout<<ans<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    string s;
    cin >> s;
    sort(all(s));
    int zero = upper_bound(all(s), '0') - s.begin();
    int one = s.size() - zero;
    cout << min(zero, one) * 2 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

signed main(){
    ll N; cin >> N;
    vector<ll> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    ll ans = 0;
    for(ll digit = 0; digit <= 60; digit++){
        ll c0 = 0, c1 = 0;
        for(int i = 0; i < N; i++){
            if(1LL & (a[i] >> digit)) c1++;
            else c0++;
        }
        ll tmp = (1ll << digit) % MOD;
        ll c = c0 * c1 %MOD;
        tmp = tmp * c % MOD;
        ans += tmp;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5612