akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


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

	int n;
	cin >> n;
	vector<vector<int>> graph(n, vector<int>());
	vector<int> deg(n);
	vector<int> a(n - 1), b(n - 1);
	rep(i, n - 1) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		graph[a[i]].pb(b[i]);
		graph[b[i]].pb(a[i]);
		deg[a[i]]++;
		deg[b[i]]++;
	}
	int cnt = 0;
	queue<int> que;
	rep(i, n) if (deg[i] == 1) que.push(i);
	while (!que.empty()) {
		int p = que.front(); que.pop();
		if (deg[p] != 1) continue;
		int q;
		for (int i : graph[p]) {
			if (deg[i]) q = i;
		}
		if (deg[q]) cnt++;
		deg[p] = 0; deg[q] = 0;
		for (int i : graph[q]) {
			if (i == p || !deg[i]) continue;
			deg[i]--;
			if (deg[i] == 1) {
				que.push(i);
			}
		}
	}
	cout << (cnt * 2 != n ? "First" : "Second") << endl;
}

Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <string>
#include <queue>

const int INF = 1<<28;
using namespace std;
string IntToString(int);
int StringToInt(string);
struct edje{
public:
  int from;
  int to;
  int cost;
  edje(int f,int t,int c){
    from = f;
    to = t;
    cost = c;
  }
};

void bellmanFord(vector<int> &map,vector<edje> &cost){
  while(1){
    bool update = false;
    for(int j = 0;j < cost.size();j++){
      if(map[cost[j].to] > map[cost[j].from] + cost[j].cost){
	map[cost[j].to] = min(map[cost[j].to],map[cost[j].from] + cost[j].cost);
	update = true;
      }
    }
    if(!update)break;
  }
}
int main(){
  while(1){
    int n,m;
    cin >> n >> m;
    if(n == 0 && m == 0)break;
    vector<edje> cost;
    vector<edje> time;
    
    for(int i = 0;i < n;i++){
      int a,b,c,t;
      cin >> a >> b >> c >> t;
      edje cs(a-1,b-1,c);
      cost.push_back(cs);
      cs= edje(b-1,a-1,c);
      cost.push_back(cs);
      edje tm(a-1,b-1,t);
      time.push_back(tm);
      tm = edje(b-1,a-1,t);
      time.push_back(tm);
    }
    int k;
    cin >> k;
    for(int i = 0;i < k;i++){
      int s,g,q;
      cin >> s >> g >> q;
      vector<edje> tmp;
      if(q == 0) tmp = vector<edje>(cost);
      else if(q == 1) tmp = vector<edje>(time);
      vector<int> map(m,INF);
      map[s-1] = 0;
      bellmanFord(map,tmp);
      cout << map[g-1] << endl;
      

    }
  }
  return 0;   
}
string IntToString(int number){
  stringstream ss;
  ss << number;
  return ss.str();
}
int StringToInt(string number){
  stringstream ss;
  ss << number;
  int numInt;
  ss >> numInt;
  return numInt;
  
}

Measured memory_bytes: 1420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)

int main(){
    int n,k;
    cin >> n >> k;
    ve<int> a(n);
    int s = 0;
    rep(i,n){
        cin >> a[i];
        s += a[i];
    }
    ve<int> fac;
    for (int i = 2; i < s; i++) {
        while(s%i == 0){
            s /= i;
            fac.push_back(i);
        }
    }
    if(s != 1) fac.push_back(s);
    
    int fs = (int)fac.size();
    
    int ans = 1;
    
    rep(i, 1<<fs){
        int x = 1;
        rep(j,fs){
            if((i>>j)&1){
                x *= fac[j];
            }
        }
        int memo = 2e9;
        ve<int> m(n);
        rep(j,n){
            m[j] = a[j] % x;
        }
        sort(m.begin(), m.end());
        ve<int> sl(n+1),sr(n+1);
        sl[0] = 0; sr[0] = 0;
        rep(j,n) sl[j+1] = sl[j] + m[j];
        rep(j,n) sr[j+1] = sr[j] + (x-m[n-1-j]);
        rep(j,n+1) {
            if(sl[j] == sr[n-j]){
                memo = sl[j];
                break;
            }
        }
        if(memo <= k){
            ans = max(ans,x);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
package main

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

// UnionFind is union find structure
type UnionFind struct {
	Par   []int
	Ranks []int
	Sizes []int
}

// NewUnionFind generates a new union find
func NewUnionFind(n int) *UnionFind {
	uf := &UnionFind{make([]int, n), make([]int, n), make([]int, n)}
	for i := range uf.Par {
		uf.Par[i] = i
		uf.Ranks[i] = 0
		uf.Sizes[i] = 1
	}
	return uf
}

// Root searches the root of the arguement
func (uf *UnionFind) Root(x int) int {
	if x == uf.Par[x] {
		return x
	}
	uf.Par[x] = uf.Root(uf.Par[x]) // 経路圧縮
	return uf.Par[x]
}

// Unite unites two trees by adding one root to another
func (uf *UnionFind) Unite(x, y int) {
	rx := uf.Root(x)
	ry := uf.Root(y)
	if rx == ry {
		return
	}
	if uf.Ranks[rx] < uf.Ranks[ry] {
		uf.Par[rx] = ry
		uf.Sizes[ry] += uf.Sizes[rx]
	} else {
		uf.Par[ry] = rx
		uf.Sizes[rx] += uf.Sizes[ry]
		if uf.Ranks[rx] == uf.Ranks[ry] {
			uf.Ranks[rx]++
		}
	}
}

// Same returns true when the two are in the same group
func (uf *UnionFind) Same(x, y int) bool {
	return uf.Root(x) == uf.Root(y)
}

// Size returns size of a group where x belongs
func (uf *UnionFind) Size(x int) int {
	return uf.Sizes[uf.Root(x)]
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n, m, k := nextInt(), nextInt(), nextInt()
	uf := NewUnionFind(n)

	friends := make(map[int]int)
	for i := 0; i < m; i++ {
		a, b := nextInt(), nextInt()
		uf.Unite(a-1, b-1)
		friends[a-1]++
		friends[b-1]++
	}

	blocks := make([]int, n)
	for i := 0; i < k; i++ {
		c, d := nextInt(), nextInt()
		if uf.Same(c-1, d-1) {
			blocks[c-1]++
			blocks[d-1]++
		}
	}

	for i := 0; i < n; i++ {
		ans := uf.Size(i) - friends[i] - blocks[i] - 1
		fmt.Printf("%v ", ans)
	}
	fmt.Println()
}


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

int main() {
    int N, K;
    int d[110];
    int A[110][110] = {0};
    int count = 0;
    cin >> N >> K;
    for (int i = 0; i < K; ++i){
        cin >> d[i];
        for (int j = 0; j < d[i]; ++j) {
            int idx;
            cin >> idx;
            A[idx-1][i] += 1;
        }
    }

    for (int i = 0; i < N; ++i) {
        int sum = 0;
        for (int j = 0; j < K; ++j) {
            sum += A[i][j];
        }
        if (sum == 0) count += 1;
    }

    cout << count << endl;
}

Measured memory_bytes: 3644
N, M = map(int, input().split())

pairs = [[] for _ in range(N + 1)]  # pairs[i]:iと直接つながっている部屋のリスト
for _ in range(M):
    input_list = list(map(int, input().split()))
    pairs[input_list[0]].append(input_list[1])
    pairs[input_list[1]].append(input_list[0])

ans = [0] * (N + 1)
n_ans = 0   # ansを埋めた回数 -> N-1になったら終了
done = [False] * (N + 1) # 探索済リスト
todo = [1]

while n_ans < N - 1:
    for n in todo:
        for m in pairs[n]:
            if not done[m]:
                done[m] = True
                ans[m] = n
                n_ans += 1
                todo.append(m)

print('Yes')
print(*ans[2:], sep='\n')

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

int main(){
	int i,j,k,y,a,b,c,x,sum=0;//10,2,1
	cin>>a>>b>>c>>x;
	x=x/50;
	
	//cout<<x<<endl;
	for(j=0;j<=a;j++){
		for(k=0;k<=b;k++){
			for(y=0;y<=c;y++){
				i=10*j+2*k+1*y;
				
				if(i==x)sum++;
				//cout<<i<<' ';//<<y<<' '<<j<<' '<<k<<' '<<dp[i][j][k]<<endl;
			}
		}
	}
	
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

struct UnionFind {
  vector<int> par;
  vector<int> rank;
  vector<int> num;
  
  UnionFind(int N) : par(N),rank(N),num(N) {
        for(int i = 0; i < N; i++){ 
          par[i] = i;
          rank[i] = 0;
          num[i] = 1;
        }
   }
      
  void init(int N){
        for(int i = 0; i < N; i++){ 
          par[i] = i;
          rank[i] = 0;
          num[i] = 1;
        }
  }
  
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  
  int ranker(int x){
    x = root(x);
    return rank[x];
  }
  
  int number(int x){
    x = root(x);
    return num[x];
   }
  
  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if ( rx == ry ) return;
    if ( rank[rx] < rank[ry] ){
      par[rx] = ry;
      num[ry] += num[rx];
      num[rx] = 0;
    } else {
      par[ry] = rx;
      num[rx] += num[ry];
      num[ry] = 0;
      if ( rank[rx] == rank[ry] ) rank[rx]++;
    }
   }
  
  bool same(int x, int y){
    return root(x) == root(y);
  }
};

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

    ll N, M;
    cin >> N >> M;
    UnionFind UF(N);

    rep(i, M){
        ll x, y, z;
        cin >> x >> y >> z;
        --x, --y;
        UF.unite(x, y);
    }

    set<ll> st;
    rep(i, N) st.insert(UF.root(i));
    print(len(st));

    return 0;
}

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

using namespace std;

char itoc ( const int x ) {
  if ( x < 0 || x > 10 ) return '0';

  return x+'0';
}

int ctoi  ( const char c ) {
  if ( c < '0' || c > '9' ) return 0;
  else return c-'0';
}

int sttoi ( const string s )
{
  int sum = 0;
  int rank = 1;

  for ( int i = s.size()-1; i >= 0; --i ) {
    sum += (s[i]-'0') * rank;
    rank *= 10;
  }

  return sum;

}

int judge ( const int x, const bool data[], const int ord )
{
  int i;
  int cnt = 0;
  for (  i = x; i < 10; i++ ) {
    if ( data[i] == true ) cnt++;
    if ( cnt == ord ) break;
  }

  if ( i == 10 ) return -1;
  else return i;
}

bool istrue ( int s, bool data[] )
{
  while ( s != 0 ) {
    int tmp = s % 10;
    if ( data[tmp] == false ) return false;
    s /= 10;
  }

  return true;
}

void hana ( string s, bool data[] )
{
  int minno = judge( 0, data, 1);
  int necmin = judge( 0, data, 2);

  string l = s;
  for ( int i = 0; i < l.size(); ++i ) l[i] = itoc(minno);
  if ( minno != 0 ) l = itoc(minno) + l;
  else l = itoc(necmin) + l;

  int st = sttoi(s);
  int f = sttoi(l);


  for ( int i = st; i <= f; ++i ) if ( istrue(i,data) ) {
    cout << i << "\n";
    return;
  }
}


int main()
{
  string s;
  int x;
  int k;
  int minno;
  bool data[10];

  cin >> s;
  cin >> k;
  for ( int i = 0; i < 10; ++i ) data[i] = true;
  for ( int i = 0; i < k; ++i ) {
    int tmp;
    cin >> tmp;
    data[tmp] = false;
  }

  hana( s, data );

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define SORT(v) sort(ALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;

#define HOGE COUT("HOGE")

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
int main() {
    IN(int, n);
    VIN(int, a, n);
    REP(i, n){
        a[i]--;
    }
    int now = 0;
    vector<int> c(n,-1);
    c[0] = 0;
    while (true) {
        int next = a[now];
        if (c[next]!=-1) {
            break;
        }
        c[next] =c[now]+1;
        now = next;
    }
    COUT(c[1]);
}


Measured memory_bytes: 1024
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
typedef pair<int, int> P;
int X[200000];
int main() {
	int N, Q;
	cin >> N >> Q;
	vector<P> eve;
	for (int i = 0; i < N; i++) {
		int S, T;
		cin >> S >> T >> X[i];
		eve.emplace_back(max(S - X[i], 0), -i);
		eve.emplace_back(max(T - X[i], 0), -i);
	}
	for (int i = 1; i <= Q; i++) {
		int D;
		cin >> D;
		eve.emplace_back(D, i);
	}
	sort(ALL(eve));
	set<int> S;
	multiset<int> val;
	for (P p : eve) {
		if (p.second <= 0) {
			if (S.count(-p.second) == 0) {
				S.insert(-p.second);
				val.insert(X[-p.second]);
			}
			else {
				val.erase(val.find(X[-p.second]));
				S.erase(-p.second);
			}
		}
		else {
			if (val.empty()) cout << -1 << endl;
			else cout << *val.begin() << endl;
		}
	}
}

Measured memory_bytes: 27368
import math
def isPrime(x):
    if x == 2:
        return True
    
    if (x < 2) or (x % 2) == 0:
        return False
    
    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            return False
        i = i+2
    
    return True
N = int(input())
A = [int(input()) for i in range(N)]
cnt = 0
for i in range(N):
    if isPrime(A[i]):
        cnt += 1

print(cnt)


Measured memory_bytes: 6012
N = int(input())
max_c = N//4 
max_d = N//7
flag = 0
for i in range(max_c + 1):
	for j in range(max_d + 1):
		cost = 4*i + 7*j
		if cost == N:
			flag = 1

if flag == 1:
	print('Yes')
else:
	print('No')


Measured memory_bytes: 2940
import heapq
N,M=map(int,input().split())
l=[tuple(map(int,input().split())) for i in range(N)]
l.sort(reverse=True)

h=[]
ans=0
for i in range(1,M+1):
    while l and l[-1][0]==i:
        heapq.heappush(h,l.pop()[1]*(-1))
    if h:
        ans-=heapq.heappop(h)
print(ans)

Measured memory_bytes: 17160
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,w,h;
int pos(int x,int y){
  if(y==0) return x;
  if(y==h) return w+h+(w-x);
  if(x==0) return w+h+w+(h-y);
  if(x==w) return w+y;
  assert(0);
}
typedef pair<int,int> P;
signed main(){
  cin>>n>>w>>h;
  int x[n],y[n];
  char f[n];
  for(int i=0;i<n;i++) cin>>x[i]>>y[i]>>f[i];
  vector<P> v;
  for(int i=0;i<n;i++){
    int a,b,c,d;
    a=min(w-x[i],h-y[i]);
    b=min(w-x[i],y[i]);
    c=min(x[i],y[i]);
    d=min(x[i],h-y[i]);
    int l,r;
    if(f[i]=='E'){
      r=pos(x[i]+a,y[i]+a);
      l=pos(x[i]+b,y[i]-b);
    }
    if(f[i]=='S'){
      r=pos(x[i]+b,y[i]-b);
      l=pos(x[i]-c,y[i]-c);
    }
    if(f[i]=='W'){
      r=pos(x[i]-c,y[i]-c);
      l=pos(x[i]-d,y[i]+d);
    }
    if(f[i]=='N'){
      r=pos(x[i]-d,y[i]+d);
      l=pos(x[i]+a,y[i]+a);
    }
    if(r<l) r+=2*(w+h);
    v.push_back(P(l,r));
  }
 
  bool ovlp[n];
  for(int i=0;i<n;i++){
    ovlp[i]=0;
    for(int j=0;j<n;j++){
      ovlp[i]|=(i!=j)&&(v[i].first<=v[j].first&&v[j].second<=v[i].second);
      ovlp[i]|=(i!=j)&&(v[i].first<=v[j].first+2*(w+h)&&
			v[j].second+2*(w+h)<=v[i].second);
    }
    //cout<<i<<" "<<ovlp[i]<<endl;
  }
  
  for(int i=n-1;i>=0;i--) if(ovlp[i]) v.erase(v.begin()+i),n--;

  sort(v.begin(),v.end());
  for(int i=0;i<n;i++)
    v.push_back(P(v[i].first+2*(w+h),v[i].second+2*(w+h)));

  //for(int i=0;i<n;i++) cout<<v[i].first<<" "<<v[i].second<<endl;

  int ans=n;
  for(int i=0;i<n;i++){
    int tmp=0;
    int j=i,p;
    while(j<i+n){
      tmp++;
      p=v[j].second;
      while(j<i+n&&v[j].first<=p) j++;
    }
    //cout<<tmp<<endl;
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <vector>
#include <map>
#include <unordered_map>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <limits.h>
#include <tgmath.h>

using namespace std;

typedef uint16_t ui16;
typedef uint32_t ui32;
typedef uint64_t ui64;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
typedef long double ld;
typedef pair<int, int> pr;

//template<typename T> inline T abs(T a) { return ((a < 0) ? -a : a); }
template<typename T> inline T sqr(T a) { return a * a; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) {for (int i = 0; i < v.size(); ++i) cout << v[i] << " "; cout << endl; return cout; }
void print() { cout << endl; }
template<typename T, typename... Ts> void print(T x, Ts... xs) { cout << x << " "; print(xs...); };
template<typename T> void read(vector<T>& v) { for (int i = 0; i < v.size(); ++i) cin >> v[i]; };

long long dp[100001] = { 0 };

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> v(N + 1, 0);
    vector<int> w(N + 1, 0);

    for (int i = 1; i <= N; ++i) {
        cin >> w[i] >> v[i];
    }

    for (int i = 1; i <= N; ++i) {
        for (int j = W; j > 0; --j) {
            if (w[i] <= j) {
                dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
            }
        }
    }

    cout << dp[W];

    return 0;
}


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

int main() {
  vector<int> a(5);
  for(int i=0;i<5;++i) cin>>a[i];
  int k;cin>>k;

  bool ok = true;
  for(int i=0;i<5;++i)
    for(int j=0;j<5;++j)
      ok &= abs(a[i]-a[j])<=k;
  cout<<(ok?"Yay!":":(")<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
using namespace std;
template<class T>il read(T &x){
	x=0;int f=1;char k=getchar();
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>9) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
int n,cnt[20][20];
ll ans;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	for(ri i=1;i<=n;++i){
		int pre=i,lst=i%10;
		while(pre>=10) pre/=10;
		ans+=2*cnt[lst][pre];
		++cnt[pre][lst];
		if(pre==lst) ++ans;
	}
	print(ans);
	return 0;
}

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


using namespace std;


 
 
int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    
 int t=1;
 while(t--)
 {
     long long int x,y,z,t=0;
     cin>>x>>y>>z;
     t=(x/(y+z))*y;
     t+=min(x%(y+z),y);
     cout<<t;
     
}     
  
 return 0;
}

 
 
 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define s(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;
int main() {
	int a,b,ans;
	cin >> a>>b;
	if (a > b)ans = a - 1;
	else ans = a;
	cout << ans << endl;

	return 0;
}
	



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main(void)
{
	char str[101] = {};

	scanf("%s", str);
	for (int i = 0; str[i] != '\0'; i++)
	{
		str[i] = 'x';
	}
	printf("%s\n", str);
	return 0;
}

Measured memory_bytes: 128
n = int(input())
k = int(input())
nums = [int(i) for i in input().split()]


mid = k // 2
t = 0
for i in range(n):
    if nums[i] < mid:
        t += nums[i] * 2
    else:
        t += (k - nums[i]) * 2

mid = (k + 1) // 2
ans = 0
for i in range(n):
    if nums[i] < mid:
        ans += nums[i] * 2
    else:
        ans += (k - nums[i]) * 2
ans = min(ans, t)
print(ans)

Measured memory_bytes: 38256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int n;
string s;
int q;
int k[75];


long long sd[1000000];
long long sm[1000000];
long long sc[1000000];

long long imos1[1000001];


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


	cin >> n;
	cin >> s;
	cin >> q;
	rep(i, q)cin >> k[i];

	rep(i, n)sd[i ] = s[i] == 'D';
	rep(i, n)sm[i ] = s[i] == 'M';
	rep(i, n)sc[i ] = s[i] == 'C';

	rep(i, n-1)sd[i + 1] += sd[i];
	rep(i, n-1)sm[i + 1] += sm[i];
	rep(i, n-1)sc[i + 1] += sc[i];



	long long all = 0;
	rep(i,n) {
		if (s[i]=='M') {
			all += sd[i] * (sc[n - 1] - sc[i]);
		}
	}

	rep(i, q) {
		memset(imos1, 0, sizeof(imos1));

		long long cc = 0;
		for(int j=n-1;j>=0;j--){
			if (s[j]=='C') {
				cc++;
			} 
			else if (s[j] == 'M') {
				imos1[j] += cc;
			}
		}
		for (int j = n - 1; j > 0;  j--) {
			imos1[j - 1] += imos1[j];
		}

		long long cnt = 0;
		for (int j = 0; j + k[i] < n; j++) {
			if (s[j] == 'D') {
				cnt += imos1[j + k[i]];
				cnt += (sc[n - 1] - sc[j + k[i] - 1]) * (sm[j + k[i] - 1] - sm[j]);
			}
		}

		cout << all - cnt << endl;
	}



	return 0;
}

Measured memory_bytes: 32668
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<bitset>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

void erase_island (int ocean[][50], int h, int w, int i, int j) {
    ocean[i][j] = 0;
    for(int dy = -1; dy <= 1; dy++) {
        for(int dx = -1; dx <= 1; dx++) {
            if (i + dy >= 0 && i + dy < h && j + dx >= 0 && j + dx < w) {
                if(ocean[i+dy][j+dx] == 1)  erase_island(ocean, h, w, i+dy, j+dx);
            }
        }
    }
}

int main() {

    int w, h;
    while(cin >> w >> h && (w || h)) {
        int ocean[h][50];
        for(int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cin >> ocean[i][j];
            }
        }
        int answer = 0;
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if (ocean[i][j] == 1) {
                    erase_island(ocean, h, w, i, j);
                    answer += 1;
                }
            }
        }
        cout << answer << endl;
    }
     
    return 0;
}

Measured memory_bytes: 0
import collections
N = int(input())

D = [int(a) for a in input().split() ]

counted = collections.Counter(D)

if D[0] != 0 or counted[0] !=1:
    print("0")
    exit()

#calc
result = 1
x = counted[1]
for i in range(2,N+1):
    y = counted[i]
    result = result * pow(x,y) %998244353
    x = y
print(result)


Measured memory_bytes: 19936
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll


int n, m, k, a, q, l, r;
string s, t;


int32_t main(){
INIT
cin>>s>>t;
n=s.length();

int res=0;
for(int i=0; i<n; i++){
    if(s[i]!=t[i]){res++;}
}
cout<<res;


return 0;
}


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

#define ll long long

int no_of_divisors(int n){
    int count = 0;

    for (int i = 1; i <= n; i++){
        if (n%i == 0) count++;
    }

    return count;
}

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

    int n;
    cin >> n;

    int ans = 0;
    for(int i = 1; i <= n; i+=2){
        if (no_of_divisors(i) == 8) ans++;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;

const int N=2e5+5;
int n,a[N],b[N],cnt[N],dem[N],res[N];
set<pii>pq;
vector<int>pos[N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
    }
    for(int i=1;i<=n;i++)
    {
        cin>>b[i];
        cnt[b[i]]++;
        dem[b[i]]++;
    }
    for(int i=1;i<=n;i++) if(dem[i]) pq.insert(mp(cnt[i],i));
    for(int i=1;i<=n;i++)
    {
        int id=(*pq.rbegin()).se;
        pq.erase(mp(cnt[id],id));
        if(id==a[i])
        {
            if(pq.empty()) return cout<<"No",0;
            id=(*pq.rbegin()).se;
            pq.erase(mp(cnt[id],id));
            pq.insert(mp(cnt[a[i]],a[i]));
        }
        pq.erase(mp(cnt[id],id));
        dem[id]--;
        cnt[id]--;
        if(dem[a[i]]) pq.erase(mp(cnt[a[i]],a[i]));
        cnt[a[i]]--;
        if(dem[id]) pq.insert(mp(cnt[id],id));
        if(dem[a[i]]) pq.insert(mp(cnt[a[i]],a[i]));
        res[i]=id;
    }
    cout<<"Yes"<<'\n';
    for(int i=1;i<=n;i++) cout<<res[i]<<' ';
}


Measured memory_bytes: 21608
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

struct  b_tree {
	unique_ptr<b_tree>ltree;
	unique_ptr<b_tree>rtree;
	b_tree() {

	}

};
unique_ptr<b_tree> make_tree(string st, int&a) {
	unique_ptr<b_tree> tree=make_unique<b_tree>();
	assert(st[a] == '(');
	a++;
	if (st[a] == '(') {
		tree->ltree = make_tree(st, a);
	}
	else {
		tree->ltree = nullptr;
	}
	assert(st[a] == ',');
	a++;
	if (st[a] == '(') {
		tree->rtree = make_tree(st, a);
	}
	else {
		tree->rtree = nullptr;
	}
	assert(st[a] == ')');
	a++;
	return (tree);
}
unique_ptr<b_tree>connect(const unique_ptr<b_tree>&l, const unique_ptr<b_tree>&r, bool isuni) {
	unique_ptr<b_tree> tree = make_unique<b_tree>();
	if (isuni) {
		if (l&&l->ltree&&r&&r->ltree) {
			tree->ltree = connect(l->ltree, r->ltree, isuni);
		}
	}
	else {
		if (l&&l->ltree) {
			if (r)tree->ltree = connect(l->ltree, r->ltree, isuni);
			else tree->ltree = connect(l->ltree, nullptr, isuni);
		}
		else if (r&&r->ltree) {

			if (l)tree->ltree = connect(l->ltree, r->ltree, isuni);
			else tree->ltree = connect(nullptr,r->ltree, isuni);
		}
	}

	if (isuni) {
		if (l&&l->rtree&&r&&r->rtree) {
			tree->rtree = connect(l->rtree, r->rtree, isuni);
		}
	}
	else {
		if (l&&l->rtree) {
			if (r)tree->rtree = connect(l->rtree, r->rtree, isuni);
			else tree->rtree = connect(l->rtree, nullptr, isuni);
		}
		else if (r&&r->rtree) {
			if (l)tree->rtree = connect(l->rtree, r->rtree, isuni);
			else tree->rtree = connect( nullptr, r->rtree,isuni);
		}
	}
	return (tree);
}
void getst(string&ans,unique_ptr<b_tree>&tree) {
	ans.push_back('(');
	if (tree->ltree) {
		getst(ans, tree->ltree);
	}
	ans.push_back(',');
	if (tree->rtree) {
		getst(ans, tree->rtree);
	}
	ans.push_back(')');
	return;
}

int main() {
	string line;
	while (getline(cin, line)) {
		int fstc = line.find(' ');
		int scdc = line.find(' ', fstc + 1);
		string ch = line.substr(0, fstc);
		string lst = line.substr(fstc + 1, scdc-fstc-1);
		string rst = line.substr(scdc+1);
		bool uni = ch == "i";
		int a = 0;
		unique_ptr<b_tree>l = make_tree(lst, a);
		a = 0;
		unique_ptr<b_tree>r(make_tree(rst, a));
		
		unique_ptr<b_tree>ans(connect(l,r,uni));
		string st;
		getst(st, ans);
		cout << st << endl;
		
	}
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
const int inf = pow(10,9);
const int nil = -1;
int i, j, n, m, k, l;
int a[50][50];
int b[50][50];
char c;

int gcd(int p, int q) {
    if (p % q == 0) return p;
    return gcd(q, p%q);
}

int main() {
    scanf(" %d %d", &n, &m);
    rep(0,n) repj(0,n) {
        scanf(" %c", &c);
        a[i][j] = c == '.';
    }
    rep(0,m) repj(0,m) {
        scanf(" %c", &c);
        b[i][j] = c == '.';
    } 
    for (l=0;l<n-m+1;l++) for (k=0;k<n-m+1;k++) {
        bool match = true;
        rep(0,m) repj(0,m) {
            if (a[l+i][k+j] != b[i][j]) match = false;
        }
        if (match) {
            printf("Yes\n");exit(0);
        }
    }
    printf("No\n");
}

Measured memory_bytes: 256
N, K = map(int, input().split())
mx = (N-1)*(N-2)/2
if mx < K:
  print(-1)
  exit()
pair = []
for i in range(N-1):
  pair += [[i+1, N]]
add = mx - K
edge = []
for i in range(N-1):
  for j in range(i):
    edge += [[i+1, j+1]]

for i in range(int(add)):
  pair += [edge[i]]

print(len(pair))
for i, j in pair:
  print(i, j)

Measured memory_bytes: 44016
# coding: utf-8

(n,k,q) = map(int, input().rstrip().split(" "))

log = {}

for i in range(q):
    answer = int(input().rstrip()) - 1
    if answer not in log:
        log[answer] = []
    log[answer].append(i)

ans = []
for i in range(n):
    score = k
    if i in log:
        prev = 0
        for j in log[i]:
            score -= (j - prev)
            prev = j + 1
            if score <= 0:
                break
        score -= q - prev
    else:
        score -= q
    if score > 0:
        ans.append("Yes")
    else:
        ans.append("No")

for i in ans:
    print(i)

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

int main() {
  string a,b,c;
  char next = 'a';
  cin >> a >> b >> c;
  while(true) {
    if(next  == 'a') {
      if(a.empty()) {
        cout << 'A' << endl;
        break;
      }
      next = a[0];
      a.erase(0,1);
    }
    else if(next  == 'b') {
      if(b.empty()) {
        cout << 'B' << endl;
        break;
      }
      next = b[0];
      b.erase(0,1);
    }
    else if(next  == 'c') {
      if(c.empty()) {
        cout << 'C' << endl;
        break;
      }
      next = c[0];
      c.erase(0,1);
    }
  }
}

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

typedef long long ll;

#define v(T) vector<T>
#define ttt(T) tuple<T, T, T>
#define pb push_back
#define mp make_pair
#define rep(i, s, n) for(int i=s;i<n;i++)
#define repeq(i,s,n) for(int i=s;i<=n;i++)
#define poiu(n) for(int i=0; i < n; i++)
#define MOD (int)10e9+7
#define endl '\n'

template<typename T>
void max_self(T& a, T b) { a=a>b?a:b; }
template<typename T>
void min_self(T& a, T b) { a=a<b?a:b; }

using namespace std;

int n;

int temp_one, temp_two;


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

    cin >> temp_one >> temp_two;

    cout << (temp_one*(temp_one-1))/2 + (temp_two*(temp_two-1))/2 << endl;
    


    return 0;

}



Measured memory_bytes: 256
import math

n, d, a = map(int,input().split())
xh = [[0 for i in range(2)] for j in range(n)]
left = [i for i in range(n)]
for i in range(n):
    x,h = map(int,input().split())
    xh[i] = [x,h]

num = 0
xh.sort(key=lambda xh:xh[0])

for i in range(n):
    for j in range(left[i-1],i):
        if xh[j][0]+d >= xh[i][0]-d:
            left[i] = j
            break

dam = [0]*n

def dsum(k):
    if k == 0:
        return 0
    elif left[k] == 0:
        return dam[k-1]
    else:
        return dam[k-1]-dam[left[k]-1]

for i in range(n):
    res = xh[i][1]-dsum(i)
    nat = max([math.ceil(res/a),0])
    dam[i] = dam[i-1]+a*nat
    if res > 0:
        num += nat

print(num)


Measured memory_bytes: 55272
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,K;
  cin >> N >> K;
  vector<vector<int>> G(K*2,vector<int> (K*2,0));
  for(int i=0; i<N; i++){
    int x,y;
    cin >> x >> y;
    char c;
    cin >> c;
    if(c == 'W') x += K;
    G[x%(2*K)][y%(2*K)]++;
  }
  vector<vector<int>> S(2*K+1,vector<int> (2*K+1,0));
  for(int i=0; i<2*K; i++){
    for(int j=0; j<2*K; j++){
      S[i+1][j+1] = S[i+1][j] + S[i][j+1] - S[i][j] + G[i][j];
    }
  }
  auto f = [&](int lx,int ly,int ux,int uy){
    chmin(lx,2*K);
    chmin(ly,2*K);
    chmin(ux,2*K);
    chmin(uy,2*K);
    chmax(lx,0);
    chmax(ly,0);
    chmax(ux,0);
    chmax(uy,0);
    int sum = S[ux][uy] - S[ux][ly] - S[lx][uy] + S[lx][ly];
    // if(sum < 0){
    //   cout << lx << " " << ly << " " << ux << " " << uy << "\n";
    //   cout << sum << "\n";
    // }
    return sum;
  };
  // for(int i=0; i<=2*K; i++){
  //   for(int j=0; j<=2*K; j++){
  //     cout << S[i][j] << " \n"[j==2*K];
  //   }
  // }
  int ans = 0;
  for(int i=0; i<2*K; i++){
    for(int j=0; j<2*K; j++){
      int sum = 0;
      sum += f(i,j,i+K,j+K);
      sum += f(i-K,j-K,i,j);
      sum += f(i+K,j-K,i+2*K,j);
      sum += f(i-K,j+K,i,j+2*K);
      sum += f(i+K,j+K,i+2*K,j+2*K);
      chmax(ans,sum);
      sum = 0;
      sum += f(i-K,j,i,j+K);
      sum += f(i,j-K,i+K,j);
      sum += f(i+K,j,i+2*K,j+K);
      sum += f(i,j+K,i+K,j+2*K);
      chmax(ans,sum);
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 34620
n,p=map(int,input().split())
a=[int(x)%2 for x in input().split()]
even=0
for aa in a:
    if aa%2==0:
        even+=1

if even==n:
    if p==0:
        print(2**n)
    else:
        print(0)
else:
    print(2**(n-1))




Measured memory_bytes: 2940
import           Control.Monad
import           Data.List

main :: IO ()
main = do
    [h, _] <- fmap (map read . words) getLine :: IO [Int]
    ass    <- replicateM h $ getLine :: IO [String]
    putStr . unlines . transpose . del . transpose . del $ ass

del :: [String] -> [String]
del = filter (\s -> not . all (== '.') $ s)


Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

bool can(int y,int x) {
	if(0 <= y && y < h && 0 <= x && x < w) return true;
	return false;
}

int cnt = 0, sy = 0, sx = 0;
bool used[10][10];
vector< vector<int> > v;

void rec(int y, int x) {
	used[y][x] = true;
	cnt++;

	rep(i, 4) {
		int ny = y + dy[i];
		int nx = x + dx[i];

		if(can(ny, nx) && !used[ny][nx] && v[ny][nx] == v[sy][sx]) {
			rec(ny, nx);
		}
	}
}

int target, change;

void dfs(int y, int x) {
	v[y][x] = change;
	rep(i, 4) {
		int ny = y + dy[i];
		int nx = x + dx[i];

		if(can(ny, nx) && v[ny][nx] == target) {
			dfs(ny, nx);
		}
	}
}

int ans = 0;
void func(vector< vector<int> > t, int id) {
	// cout << " ------ func ---- :" << id << endl;
	// rep(i, h) {
	// 	rep(j, w) cout << t[i][j] << " ";
	// 	cout << endl;
	// }
	if(id == 4) {
		v = t;
		target = t[sy][sx];

		if(target == c) return;
		change = c;
		dfs(sy, sx);

		cnt = 0;
		memset(used, 0, sizeof(used));
		rec(sy, sx);
		ans = max(ans, cnt);
		return;
	}

	REP(i, 1, 7) {
		if(i == t[sy][sx]) continue;
		v = t;
		target = t[sy][sx]; change = i;
		dfs(sy, sx);
		func(v, id + 1);
	}
}

int main() {
	while(cin >> h >> w >> c) {
		if(h == 0 && w == 0 && c == 0) break;

		v.resize(h);
		rep(i, h) {
			v[i].resize(w);
			rep(j, w) cin >> v[i][j];
		}

		ans = 0;
		func(v, 0);

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

Measured memory_bytes: 1228
#include <iostream>
using namespace std;
int main() {
    int n, a, b; cin >> n >> a >> b;
    int c1 = 0, c2 = 0, c3 = 0;
    while (n--) {
        int p; cin >> p;
        if (p <= a) c1++;
        else if (p <= b) c2++;
        else c3++;
    }
    cout << min(min(c1, c2), c3) << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
#from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
#inf = 10**17
#mod = 10**9 + 7
#s=input().rstrip()
    
n=I()
A=LI()
ans=[0]*n
for a in A:
    ans[a-1]+=1
for answer in ans:
    print(answer)

Measured memory_bytes: 33416
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{   char s[10][10];

    for(int i=0 ; i<2 ;i++)
      {
          scanf("%s",s[i]);
      }
       if(s[0][0]==s[1][2] && s[0][1]==s[1][1] && s[0][2]==s[1][0])
          {printf("YES");
               }
      else
      {
          printf("NO");
        }

    return 0;
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 2007;

int n;lint val[_],per;
lint sval=0,now[_],ans=1e18;

int main()
{
	n=ty(),per=ty();
	for(int i=0;i<n;i++)val[i]=ty(),sval+=val[i];
	ans=sval;

	for(int i=0;i<n;i++)now[i]=val[i];
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<n;j++)now[j]=min(now[j],val[(j-i+n)%n]);
		sval=per*i;
		for(int j=0;j<n;j++)sval+=now[j];
		ans=min(ans,sval);
	}
	printf("%lld\n",ans);

	return 0;
}


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

void print_vec(vector<int> vec) {
  cout << "[";
  for (int i = 0; i < vec.size(); i++) {
    if (i) {
      cout << ", ";
    }
    cout << vec.at(i);
  }
  cout << "]...size: " << vec.size() << endl;
}

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i, n) { cin >> vec[i]; }

  vector<vector<int>> ans;
  ans.push_back(vec);

  for (int i = 1; i < n; i++) {
    int v = vec[i];
    int j = i - 1;

    while (j >= 0 && vec[j] > v) {
      vec[j + 1] = vec[j];
      j--;
    }

    vec[j + 1] = v;
    ans.push_back(vec);
  }

  for (auto &&i : ans) {
    rep(j, n) {
      if (j) {
        printf(" ");
      }
      printf("%d", i[j]);
    }
    printf("\n");
  }
}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

int main(){
    ll N; cin >> N;
    cout << (1000 - N % 1000) % 1000 << endl;
    

}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <cmath>

template <typename T>
T gcd(T x, T y)
{
	return y == 0 ? x : gcd(y, x % y);
}

template <typename T>
std::vector<T> EratosthenesSieve(T n)
{
	std::vector<char> sieve(n + 1, 1);	
	const T sqrt_n = static_cast<T>(std::sqrt(n));
	for (T i = 2; i <= sqrt_n; ++i)
	{
		if (sieve.at(i) == 1)
		{
			for (T j = i * 2; j <= n; j += i)
			{
				sieve.at(j) = 0;
			}
		}
	}

	std::vector<T> prime_numbers;
	for (T i = 2; i <= n; ++i)
	{
		if (sieve.at(i) == 1)
		{
			prime_numbers.push_back(i);
		}
	}

	return std::move(prime_numbers);
}

template <typename T>
std::vector<std::pair<T, int>> primeFactorizationWithEratosthenesSieve(T n)
{
	std::vector<std::pair<T, int>> answer;

	std::vector<T> prime_numbers = EratosthenesSieve(static_cast<T>(std::sqrt(n)));
	for (T prime_number : prime_numbers)
	{
		if (prime_number * prime_number > n)
		{
			break;
		}

		if (n % prime_number != 0)
		{
			continue;
		}

		answer.emplace_back(prime_number, 0);
		do
		{
			n /= prime_number;
			answer.back().second++;
		} while (n % prime_number == 0);
	}

	if (n != 1)
	{
		answer.emplace_back(n, 1);
	}

	return std::move(answer);
}

int main()
{
	long long A, B;
	std::cin >> A >> B;

	auto g = gcd(A, B);
	auto pf = primeFactorizationWithEratosthenesSieve(g);

	std::cout << pf.size() + 1;

	return 0;
}

Measured memory_bytes: 2424
ranks = ["S", "H", "C", "D"]
cards = []
for rank in ranks:
    for i in range(1, 14, 1):
        cards.append([rank, str(i)])

n = int(input())
for i in range(n):
    x, y = map(str, input().split())

    for card in cards:
        if card[0] == x:
            if card[1] == y:
                cards.remove([x, y])

for card in cards:
    print(" ".join(card))



Measured memory_bytes: 5604
R, G, B, N = map(int, input().split())
ans = 0
for i in range(N + 1):
    if i * R > N:
        break
    for j in range(N + 1):
        if i * R + j * G > N:
            break
        if (N - i * R - j * G) % B == 0:
            ans += 1
print(ans)

Measured memory_bytes: 40428
import collections

N = int(input())
S = list(map(int, input().split()))
C = collections.Counter(S)
X = list(C.values())
Z  =''
for i in range(N):
    if X[i] == 1:
        Z = 'YES'
        continue
    elif X[i] != 1:
        Z = 'NO'
        break
print (Z)

Measured memory_bytes: 33996
#include <iostream>
#include <cmath>
#include <algorithm> 
using namespace std;

int main()
{
    int n;
    cin >> n;
    int pre_previous_height, previous_height, height;
    cin >> pre_previous_height;
    if (n == 1){
        cout << 0;
        return 0;
    }
    
    cin >> previous_height;
    if (n == 2){
        cout << abs(previous_height - pre_previous_height);
        return 0;
    }
    int pre_previous_cost, previous_cost, cost;
    pre_previous_cost = 0;
    previous_cost = abs(previous_height - pre_previous_height);
    for (int i = 3; i<= n; i++){
        cin >> height;
        cost = min(abs(pre_previous_height - height) + pre_previous_cost,
        abs(previous_height - height) + previous_cost);
        pre_previous_cost = previous_cost;
        previous_cost = cost;
        pre_previous_height = previous_height;
        previous_height = height;
    }
    cout << cost;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <set>
#include <cstring>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int bit[11234567], bit_n;

int bit_sum(int i)
{
    int s = 0;
    while (i > 0)
    {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void bit_add(int i, int x)
{
    while (i <= bit_n)
    {
        bit[i] += x;
        i += i & -i;
    }
}

int main()
{
    int n;
    ll k, a[212345];

    cin >> n >> k;
    REP(i, n)
    {
        cin >> a[i];
        a[i] -= k;
    }

    set<ll> num;

    ll sum[212345];
    sum[0] = 0;
    num.insert(0);
    REP(i, n)
    {
        sum[i + 1] = sum[i] + a[i];
        num.insert(sum[i + 1]);
    }

    vector<ll> nv;

    for (ll i : num)
        nv.push_back(i);

    SORT(nv);

    map<ll, int> mp;

    REP(i, nv.size())
    mp[nv[i]] = i;

    for (int i = 0; i <= n; i++)
        sum[i] = mp[sum[i]];

    memset(bit, 0, sizeof(bit));
    bit_n = nv.size();

    ll res = 0;

    for (int i = 0; i <= n; i++)
    {
        res += bit_sum(sum[i] + 1);
        bit_add(sum[i] + 1, 1);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 70772
// https://atcoder.jp/contests/abc174/tasks/abc174_e

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

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 1
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 2*1e5;
const int K_MAX = 1e9;
const int A_I_MAX = 1e9;

int N, K;
vector<int> A;

bool C(double l) {
  ll c = 0;
  REP(i, N) {
    c += ceil(A[i] / l);
  }
  return c <= (N + K);
}

int main() {
  cin >> N >> K;
  A = vector<int>(N);
  REP(i, N) cin >> A[i];

  sort(A.begin(), A.end());

  double hi = A[N - 1];
  double lo = 0;
  REP(i, 100) {
    double mi = (hi + lo) / 2;
    if (C(mi)) hi = mi;
    else lo = mi;
  }

  cout << (int) ceil(hi) << endl;
}


Measured memory_bytes: 4008