akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;


int sum_object(int n){
  int sum = 0;
  while (n > 0) {
    sum += n%10;
    n /= 10;
    }
    return sum;
  }

int main() {
  int N, num;
  cin >> N;
  string output;
  num = sum_object(N);
  if (N%num == 0){
    output = "Yes";
  }
  else {
    output = "No";
  }
  
  cout << output << endl;
}



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

typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define SORT(s) sort((s).begin(),(s).end())

struct Box{
    bool red;
    int count;
};


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

    vector<Box> b(N);
    REP(i,N){
        b.at(i).red = false;
        b.at(i).count = 1;
    }
    b.at(0).red = true;
    REP(i,M){
        int x; cin >> x;
        int y; cin >> y;
        x -= 1;
        y -= 1;
        b.at(x).count -= 1;
        b.at(y).count += 1;
        if (b.at(x).red) {
            b.at(y).red = true;
        }
        if (b.at(x).count == 0){
            b.at(x).red = false;
        }
    }
    int ans = 0;
    for(auto v : b){
        if (v.red){
            ans += 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4000
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

n=int(input())

a=list(map(int,input().split()))

d1={-1:0}
for i in a[::2]:
    if i in d1: d1[i]+=1
    else: d1[i]=1

d2={-2:0}
for i in a[1::2]:
    if i in d2: d2[i]+=1
    else: d2[i]=1

l1=list(d1.items())
l1.sort(key=lambda x:-x[1])
l2=list(d2.items())
l2.sort(key=lambda x:-x[1])

l1=l1[:5]
l2=l2[:5]

keep=0
for i,j in l1:
    for k,l in l2:
        if i==k: continue
        keep=max(keep,j+l)
print(n-keep)


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

using namespace std;


void solve() {
    int n, k;
    cin >> n >> k;
    int lim = (n-1) * (n-2) /2;
    if (k > lim) {
        cout << -1; return;
    }
    int m = n*(n-1)/2 - k;
    cout << m << "\n";
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i+1; j < n; j++) {
            if (cnt < k) {cnt++;}
            else {
                cout << i << ' ' << j << "\n";
            }
        }
    }
    for (int i = 1; i < n; i++) {
        cout << i << ' ' << n << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in range(n-2):
    if max(l[i], l[i+1], l[i+2]) != l[i+1] and min(l[i], l[i+1], l[i+2]) != l[i+1]:
        cnt += 1
print(cnt)

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

bool Check(const string& P)
{
  const int Q[] = {0, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6};
  int base = 0;
  for(int i = 0; i < P.size() - 1; i++) {
    base += (P[i] - '0') * Q[11 - i];
    base %= 11;
  }
  if(base <= 1) return(P.back() == '0');
  else return(P.back() == (char)(11 - base + '0'));
}

int main()
{
  string S;
  char ret;
  cin >> S;
  int qp = S.find('?');

  int match = 0;
  for(char i = '0'; i <= '9'; i++) {
    S[qp] = i;
    if(Check(S)) {
      ret = i;
      ++match;
    }
  }

  if(match > 1) cout << "MULTIPLE" << endl;
  else cout << ret << endl;
}

Measured memory_bytes: 3196
#include<stdio.h>
#include<algorithm>
using namespace std;
int n, a, b, c;
int dp[3][2];//一维：3个项目的选择   二维：切换今天 和 昨天  今天i=0  昨天  1-i  i = i-1

int main(){
//	freopen("inf.txt","r",stdin);
	scanf("%d", &n);
	int i = 0;
	while(n--){
		scanf("%d%d%d", &a, &b, &c);
		dp[0][i] = max(dp[1][1-i]+a,dp[2][1-i]+a);
		dp[1][i] = max(dp[0][1-i]+b,dp[2][1-i]+b);
		dp[2][i] = max(dp[0][1-i]+c,dp[1][1-i]+c);
		i = 1-i;
	}
	printf("%d\n", max(dp[0][1-i],max(dp[1][1-i],dp[2][1-i])));
	return 0;
}

Measured memory_bytes: 128
#n = int(input())
#s = input()
n, m = map(int,input().split())
da = list(map(int,input().split()))

now = 0
for i in range(m):
    now += da[i]/2 + 0.5
ans = now
for i in range(m,n):
    now -= da[i-m]/2 - da[i]/2
    ans = max(ans, now)
print(ans)

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


pair<ll, ll> min_max(vector<ll>& a) {
    ll amin = LLONG_MAX, amax = LLONG_MIN;
    for (int i=a.size()-1; i>=0; --i) {
        amin = min(amin, a[i]);
        amax = max(amax, a[i]);
    }
    return make_pair(amin, amax);
}

ll solve(ll N, vector<ll>& a) {
    auto amm = min_max(a);
    ll amin = amm.first, amax = amm.second;
    if (amax <= N-1) return 0;

    ll s = 0;
    if (amax - amin >= N+1) {
        rep(i, N) {
            s += a[i] / (N+1);
            a[i] %= (N+1);
        }
        rep(i, N) {
            a[i] += s;
        }
    }
    // amax - amin < N+1
    amm = min_max(a);
    amin = amm.first; amax = amm.second;
    if (amin > N*2) {
        ll d = amin - N*2;
        rep(i, N) a[i] -= d;
        s += N * d;
    }
    // amin <= 2N
    priority_queue<ll> pq;
    rep(i, N) pq.push(a[i]);
    ll ofs = 0;
    while (true) {
        ll t = pq.top(); pq.pop();
        if (ofs + t <= N-1) break;
        pq.push(t - (N+1));
        ++ofs;
        ++s;
    }

    return s;
}

int main() {
    int N; cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    cout << solve(N,a) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi >
#define vvvi vector<vvi >
#define INF 1e9
#define MOD 1e9+7
typedef long long llong;
using namespace std;

int main(){
	int r,g,b,n;
	cin>>r>>g>>b>>n;
	
	int ans=0;
	for(int i=n/r;i>=0;--i){
		int tmp=n-r*i;
		for(int j=tmp/g;j>=0;--j){
			int tmpp=tmp-g*j;
			for(int k=tmpp/b;k>=0;--k){
				if(r*i+g*j+b*k==n){
					ans++;
					break;
				}
			}
		}
	}
	
	cout<<ans<<endl;
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// 角を使えばどんな状況でも最悪16回で描ける
// 16マスそれぞれを正しい色で塗られている/塗られていないの2進数で表せば状態の数は2^16通り
// でBFS

int n, h[16], w[16], d[1<<16], s[4][4];
string S[4];

signed main() {
	cin >> n;
	rep(i,n) cin >> h[i] >> w[i];
	rep(i,4) {
		cin >> S[i];
		rep(j,4) {
			if (S[i][j]=='R') s[i][j] = 0;
			else if (S[i][j]=='G') s[i][j] = 1;
			else s[i][j] = 2;
		}
	}
	rep(i,1<<16) d[i] = inf;
	d[0] = 0;
	
	
	queue<int> q;
	q.push(0);
	while (!q.empty()) {
		int b = q.front(); q.pop();
		if (__builtin_popcount(b)==16) continue;
		rep(i,n) rep(c,3) reps(x,-3,4) reps(y,-3,4) {
			int bb = b;
			reps(xx,max(x,0),min(x+h[i],4)) reps(yy,max(y,0),min(y+w[i],4)) {
				if (s[xx][yy]==c) bb |= (1<<(xx*4+yy));
				else bb ^= (bb&1<<(xx*4+yy));
			}
			if (d[bb]>d[b]+1) d[bb] = d[b]+1, q.push(bb);
		}
	}
	cout << d[(1<<16)-1] << ln;
}


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

int main() {
    
    int n = 3;
    vector<int> v;
    while (n--) {
        int x;
        cin >> x;
        v.push_back(x);
    }

    sort(v.begin(), v.end(), greater<int>());

    int cnt=0;
    if(v[1]%2==v[2]%2) {
        cnt += v[0] - v[1];
        cnt += v[0] - v[2];
        cnt /= 2;
    }
    else {
        ++v[0];
        ++v[2];
        cnt += v[0] - v[1];
        cnt += v[0] - v[2];
        cnt /= 2;
        ++cnt;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#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;

// #define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE     ;
#define dumpV(v);
#define STOP     ;
#endif
#define mp make_pair

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


int main(){
    int N, Q;
    cin >> N >> Q;
    string s;
    cin >> s;
    vector<int> sumR(N+1);
    vector<int> sumL(N+1);
    rep(i, N) {
        sumR[i+1] += sumR[i];
        sumL[i+1] += sumL[i];
        if(i - 1 >= 0 && s[i-1] == 'A' && s[i] == 'C') sumR[i+1]++;
        if(i+1 < N && s[i] == 'A' && s[i+1] == 'C') sumL[i+1]++;
    }
    LINE;
    dumpV(sumR);
    dumpV(sumL);
    rep(i, Q) {
        int l, r;
        cin >> l >> r;
        --l;
        cout << sumR[r] - sumL[l] << '\n';
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
 
int main()
{
    priority_queue< int,vector<int>,less<int> > que;
    int in;
 
    for(int i = 0; i < 10; i++){
        cin >> in;
        que.push(in);
    }
 
 
    for(int j = 0; j < 3; j++){
        cout << que.top() << '\n';
        que.pop();
    }
 
    return 0;
}

Measured memory_bytes: 3112
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<cmath>
#include<sstream>
#include<queue>
#include<stack>
#include<cstring>
#include<iomanip>
using namespace std;
typedef long long ll;

int main()
{
 	long double n,d;
 	cin >> n >> d;
 	//cout << sqrt(d)<<endl;
 	int ans=0;
 	while(n--){
  		long double x,y;
  		cin >> x >> y;
  		if((double)sqrt((x*x+y*y))<=d){
  			ans++;
		}
		//cout << (double)sqrt((x*x+y*y)) << endl;
 	}
 	cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 3156
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=998244353;

const ll INF=1e9;

int main(){
    ll n;
    cin >> n;
    vector<ll> l(2*n);
    rep(i,2*n){
        cin >> l[i];
    }
    ll ans=0;
    sort(l.begin(),l.end());
    for(ll i=0;i<2*n;i+=2){
        ans+=l[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>

int A[1000000];

int  main(){
  int i,n,key,temp,big=0,sml=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);

  key = A[n-1];
 
  for(i=0;i<n-1;i++){
    if(i == 0 && key >= A[i]){
      sml++;
      big++;
    }
    else if(key >= A[i]){
      temp = A[i];
      A[i] = A[sml];
      A[sml] = temp;
      sml++;
      big++;
    }
    else
      big++;
  }
  
  temp = key;
  A[n-1] = A[sml];
  A[sml] = temp;

  printf("%d",A[0]);
  for(i=1;i<n;i++){
    if(i == sml)
      printf(" [%d]",A[i]);
    else printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}



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

int main(void) {
  int n, x;
  cin >> n >> x;
  int d = 0;
  int res = 1;
  REP(i, n) {
    int l;
    cin >> l;
    d += l;
    if(d <= x) {
      ++res;
    }
  }
  cout << res << endl;
  return 0;
}


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

long double to_deg(long double r)
{
    return r * 180.0 / acos(-1);
}

int main()
{
    long double a, b, x;
    long double ans = 0;
    cin >> a >> b >> x;
    long double v = a * a * b;
    long double s;
    if (x > v / 2)
    {
        x = v - x;
        s = x / a * 2 / a;
        long double t = atan2(s, a);
        ans = to_deg(t);
    }
    else
    {
        s = x / a * 2 / b;
        long double t = atan2(b, s);
        ans = to_deg(t);
    }

    cout << std::setprecision(10) << ans << endl;
}
  

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n); for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
typedef pair<int, int> P;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int main(){
  ll N;cin>>N;vl A(N),B(N),C(N);
  rep(i,N)cin>>A[i];
  rep(i,N)cin>>B[i];
  rep(i,N)cin>>C[i];
  sort(all(A));
  sort(all(B));
  sort(all(C));
  ll cnt=0;
  rep(i,N){
    
    auto ir=lower_bound(all(A),B[i]);
    auto te=upper_bound(all(C),B[i]);
    ll as=ir-A.begin();
    ll fa=C.end()-te;
    cnt+= as*fa;
    
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 2560
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N,A,B;
    cin >> N >> A >> B;
    lint H[N];
    rep(i,N) cin >> H[i];
    lint lo=0,hi=1e9;
    lint ex=A-B;
    while(hi-lo>1){
        lint mid=(hi+lo)/2;
        lint cnt=0;
        rep(i,N) if(mid*B<H[i]) cnt+=(H[i]-mid*B+ex-1)/ex;
        if(cnt>mid) lo=mid;
        else hi=mid;
    }
    cout << hi << endl;
}

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

int main(void)
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int count = 0;
    rep(i, a + 1)
    {
        rep(j, b + 1)
        {
            rep(k, c + 1)
            {
                if (500 * i + 100 * j + 50 * k == x) {
                    count++;
                }
            }
        }
    }
    cout << count << endl;
}



Measured memory_bytes: 256
using System;
class Program
{
  static void Main(string[] args)
  {
    string[] str = Console.ReadLine().Split(' ');
    int a, b;
    a = int.Parse(str[0]);
    if (a <= 0 || a > 9)
    {
      Console.WriteLine("-1");
      return;
    }
    b = int.Parse(str[1]);
    if (b <= 0 || b > 9)
    {
      Console.WriteLine("-1");
      return;
    }
    Console.WriteLine("{0}", a * b);
  }
}

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

char a,b;

using namespace std;

int main(void)
{
    scanf("%c %c" ,&a ,&b);
    if(a>b)
        cout << '>';
    else if(a<b)
        printf("<");
    else
        cout << '=';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stdlib.h>
#include<vector>
#include<stack>
#include<bitset>
#include<set>
#define maxn 400005
using namespace std;
#define int long long
typedef long long ll;
const ll mod=1e9+7;
int n,k;
int a[maxn];
int myabs(int now)
{
	return now>0 ? now : -now;
}
int cmp(int a,int b)
{
	return myabs(a)>myabs(b);
}
int cmp1(int a,int b)
{
	return myabs(a)<myabs(b);
}
vector<int> edge1,edge2;
long double sum1[maxn],sum2[maxn];
signed main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		if(a[i]<0)
		{
			edge2.push_back(-a[i]);
		}
		else if(a[i]>0)
		{
			edge1.push_back(a[i]);
		}
	}
	if(k==n)
	{
		ll gg=1;
		for(int i=1;i<=n;i++)
			gg=(gg*a[i])%mod;
		printf("%lld\n",(gg+mod)%mod);
		return 0;
	}
	sort(edge1.begin(),edge1.end(),cmp);
	sort(edge2.begin(),edge2.end(),cmp);
	
	int len1=edge1.size(),len2=edge2.size();
	for(int i=0;i<len1;i++)
		sum1[i+1]=sum1[i]+log2(edge1[i]);
	for(int i=0;i<len2;i++)
		sum2[i+1]=sum2[i]+log2(edge2[i]);
	
	double ans=-1;
	int pos=0,flag=1;
	for(int i=0;i<=len2;i+=2)
	{
		int temp=k-i;
		if(temp>len1 || temp<0) continue;
		flag=0;
		if(sum1[temp]+sum2[i]>ans)
		{
			ans=sum1[temp]+sum2[i];
			pos=i;
		}
	}
	
	if(flag==1)
	{
		for(int i=1;i<=n;i++)
		{
			if(a[i]==0)
			{
				printf("0\n");
				return 0;
			}
		}
		
		sort(edge1.begin(),edge1.end(),cmp1);
		sort(edge2.begin(),edge2.end(),cmp1);
		int len1=edge1.size(),len2=edge2.size();
		for(int i=0;i<len1;i++)
			sum1[i+1]=sum1[i]+log2(edge1[i]);
		for(int i=0;i<len2;i++)
			sum2[i+1]=sum2[i]+log2(edge2[i]);
		double ans=1e18;
		pos=0;
		for(int i=1;i<=len2;i+=2)
		{
			int temp=k-i;
			if(temp>len1 || temp<0) continue;
			if(sum1[temp]+sum2[i]<ans)
			{
				ans=sum1[temp]+sum2[i];
				pos=i;
			}
		}
		ll res=1;
		for(int i=0;i<pos;i++)
		{
			res=(res*edge2[i])%mod;
		}
		for(int i=0;i<k-pos;i++)
		{
			res=(res*edge1[i])%mod;
		}
		printf("%lld\n",(-res+mod)%mod);
	}
	else
	{
		ll res=1;
		for(int i=0;i<pos;i++)
		{
			res=(res*edge2[i])%mod;
		}
		for(int i=0;i<k-pos;i++)
		{
			res=(res*edge1[i])%mod;
		}
		printf("%lld\n",res);
	}
}


Measured memory_bytes: 9976
graph = []

def init():
    global graph
    graph = [[False] * 26 + [True] for _ in xrange(27)]
    graph[26][26] = False

def atoi(c):#index
    if c == "#":
        return 26
    return ord(c) - ord("a")

def make_graph(L):
    global graph
    cur = 0
    L = [L[0]] + [L[i] for i in xrange(1, len(L)) if L[i] != L[i-1]] #
    #while "" in L:
    #    L.remove("")
    tmp = []
    for s1, s2 in zip(L, L[1:]):
        if s1[0] == s2[0]:
            tmp += [s1[1:], s2[1:]]
        else:
            if not tmp == []:
                make_graph(tmp)
            tmp = []
            graph[atoi(s2[0])][atoi(s1[0])] = True
    if not tmp == []:
        make_graph(tmp)

def check(start):
    stack = set([start])
    visited = [False] * 27
    while len(stack) != 0:
        cur = stack.pop()
        visited[cur] = True
        if graph[cur][start]:
            return False
        for i in xrange(27):
            if graph[cur][i] and not visited[i]:
                stack.add(i)
    return True

while True:
    n = input()
    if n == 0:
        break
    L = [raw_input() + "#" for _ in xrange(n)]
    init()
    make_graph(L)
    for i in xrange(27):
        if not check(i):
            print "no"
            break
    else:
        print "yes"

Measured memory_bytes: 4340
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N, M; cin >> N >> M;
	int deg[N] = {0};

	REP(i,M){
		int a, b; cin >> a >> b;
		deg[--a]++;
		deg[--b]++;
	}

	REP(i,N) cout << deg[i] << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl

ull BASE = 131;
// ull MOD = 140814840257324803;

ull powMod(ull x, ull y) {
  ull res = 1;
  for(; y > 0; y >>= 1, (x *= x)) {
    if(y & 1) (res *= x);
  }
  return res;
}

signed main() {
  ios::sync_with_stdio(false);
  string S, T; cin >> S >> T;
  vector<int> match;
  ull target = 0;
  REP(i,T.size()) {
    target *= BASE;
    target += T[i];
    // target %= MOD;
  }
  // DEBUG(target);
  ull hash = 0;
  REP(i,S.size()) {
    if(i >= T.size()) {
      hash -= S[i - T.size()] * powMod(BASE, T.size() - 1);
      // if(hash < 0) hash += MOD;
    }
    hash *= BASE;
    hash += S[i];
    // DEBUG(hash);
    // hash %= MOD;
    if(hash == target) match.push_back(i - T.size() + 1);
  }
  for(int m : match) cout << m << endl;
}

Measured memory_bytes: 13104
def main():
    import sys
    input = sys.stdin.readline

    mod = 1000000007
    r1, c1, r2, c2 = map(int, input().split())

    # comb init
    nmax = 2 * 10 ** 6 + 5  # change here
    fac = [0] * nmax
    finv = [0] * nmax
    inv = [0] * nmax
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2, nmax):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

    def comb(n, r):
        if n < r:
            return 0
        else:
            return (fac[n] * ((finv[r] * finv[n - r]) % mod)) % mod

    def f(r, c):
        ret = 0
        for i in range(r+1):
            ret = (ret + comb(i+1+c, c))%mod
        return ret

    print((f(r2, c2) - f(r2, c1-1) - f(c2, r1-1) + f(r1-1, c1-1))%mod)


if __name__ == '__main__':
    main()


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

int main() {
  int h,w;
  cin >> h >> w;
  
  vector<vector<char>>a(h,vector<char>(w));
  for(int i=0; i<h; i++){
   for(int j=0; j<w; j++){
     cin >> a[i][j];
   }
  }
  
  int count=0;
  for(int i=0; i<h; i++){
    int j=count;
    while(a[i][j]=='#'){
     count++;
     j++;
   }
    
    for(int ex=j+1; ex<h; ex++){
     if(a[i][ex]=='#'){
       cout << "Impossible" << endl;
       return 0; 
     }
    }
    
    
    for(int k=i+1; k<h; k++){
     for(int l=0; l<count-1; l++){
       if(a[k][l]=='#'){
         cout << "Impossible" << endl;
         return 0;
       }
     }
    }
  }
    
  cout << "Possible" << endl;
  
  return 0;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> a >> b;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------

  if(a>=13) ans = b;
  else if(a>= 6) ans = b/2;
  else ans = 0;

  cout << (a*3+b)/2 << endl;

}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

from collections import Counter
a=Counter(a)
a=sorted(a.items(), reverse=True)

x=0
y=0

for p,q in a:
  if q>=4:
    if x==0:
      x=y=p
      break
    else:
      y=p
      break
  elif q>=2:
    if x==0:
      x=p
    else:
      y=p
      break
print(x*y)

Measured memory_bytes: 21412
/*input
abracadabra
avadakedavra

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main(){
	IOS
	string s,t;cin>>s>>t;
	ll dpt[s.size()+1][t.size()+1];
	memset(dpt,0,sizeof(dpt));
	ll i=1,j=1;
	for(i=1;i<=s.size();++i){
		for(j=1;j<=t.size();++j){
			if(s[i-1]==t[j-1]){
				dpt[i][j]=dpt[i-1][j-1]+1;
			}
			else{
				dpt[i][j]=max(dpt[i-1][j],dpt[i][j-1]);
			}
		}
	}
	i=s.size();j=t.size();
	string ans="";
	while(i>=1 && j>=1){
		if(max(dpt[i-1][j],dpt[i][j-1])==dpt[i][j]){
			// ans+=s[i-1];
			if(dpt[i-1][j]>=dpt[i][j-1])
				--i;
			else
				--j;
		}
		else{
			ans+=s[i-1];
			--i;--j;
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
int main(int argc, const char * argv[]) {
    int n, i, flag, j;
    vector<string> s;
    string st;
    flag = 0;
    cin >> n;
    cin >> st;
    s.emplace_back(st);
    for(i = 1;i < n;i++){
        cin >> st;
        s.emplace_back(st);
        if(s[i-1].back() != s[i].front())flag = 1;
    }
    for(i = 0;i < n;i++){
        st = s[i];
        for(j = i+1;j < n;j++){
            if(st == s[j])flag = 1;
        }
    }
    if(flag == 0)printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	int s = abs(a-b);
	if(s%2 == 1) cout << "Borys" << endl;
	if(s%2 == 0) cout << "Alice" <<endl;
}


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

int main() {
  string s,t;
  cin >>s >>t;
  int a = 0;
  for(int i=0; i<3; i++){
    if(s.at(i)==t.at(i)){
      a++;
    }
  }
  cout <<a <<endl;
}

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

using namespace std;
const static int N = 100;
const static int INFTY = (1 << 21);

int n, M[N][N];
int d[N];


void bfs(int s) {
    queue<int> Q;
    Q.push(s);
    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
    }
    d[s] = 0;
    int u;
    while(!Q.empty()){
        u = Q.front();
        Q.pop();
        for (int v = 0; v < n; v++){
            if (M[u][v] == 0) continue;
            if (d[v] != INFTY) continue;
            d[v] = d[u] + 1;
            Q.push(v);
        }
    }
    for (int i = 0; i < n; i++) {
        if (d[i] == INFTY) d[i] = -1;
        cout << i +1 << " " << d[i] << endl;
    }
}

int main() {
    int u, k;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++){
            int v;
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    bfs(0);
    return 0;
}


Measured memory_bytes: 3096
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

if (A + B)%2 == 0:
	print((A + B)//2)
else:
	print("IMPOSSIBLE")

Measured memory_bytes: 5456
n = int(input())
s = list()
counter = 0

for i in range(n):
    s.append(input())
    
m = int(input())
t = list()

for i in range(m):
    t.append(input())

for word in s:
    counter = max(counter,s.count(word) -t.count(word))
print(counter)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

class Program {

    static int Main(string[] args) {
        string v = Console.ReadLine();

        for (int i = v.Length - 1; i >= 0; i--) {
            Console.Write(v.Substring(i, 1));
        }
        Console.WriteLine("");
        return 0;
        
        //List<decimal[]> list = new List<decimal[]>();

        //while (true) {
        //    string v = Console.ReadLine();
        //    if (string.IsNullOrEmpty(v) == true) { break; }

        //    decimal a = decimal.Parse(v.Split(' ')[0]);
        //    decimal b = decimal.Parse(v.Split(' ')[1]);

        //    list.Add(new decimal[] { a, b });
        //}

        //for (int i = 0; i < list.Count; i++) {
        //    List<decimal> aList = GetYakusu(list[i][0]);
        //    List<decimal> bList = GetYakusu(list[i][1]);

        //    decimal max = GetMaxYakusu(aList, bList);
        //    decimal min = GetMinBaisu(aList, bList);

        //    Console.WriteLine("{0} {1}", max, min);
        //}

        //return 0;
    }

    static decimal GetMinBaisu(List<decimal> a, List<decimal> b) {
        decimal v = 1;
        for (int i = 0; i < a.Count; i++) {
            v *= a[i];
        }
        for (int i = 0; i < b.Count; i++) {
            v *= b[i];
        }
        return v;
    }

    static decimal GetMaxYakusu(List<decimal> a, List<decimal> b) {
        decimal v = 1;

        for (int i = 0; i < a.Count; i++) {
            if (b.Contains(a[i]) == true) {
                v *= a[i];
                b.Remove(a[i]);
            }
        }

        return v;
    }

    static List<decimal> GetYakusu(decimal v) {
        List<decimal> list = new List<decimal>();

        decimal c = 2;
        while (true) {
            if (v < 2) { break; }

            if (v % c == 0) {
                list.Add(c);
                v = v / c;
            }
            else {
                c++;
            }
        }

        return list;
    }

    static int InputN() {
        string v = Console.ReadLine();
        return int.Parse(v);
    }

    static int[] InputInt() {
        string v = Console.ReadLine();
        string[] vs = v.Split(' ');

        return new int[] { int.Parse(vs[0]), int.Parse(vs[1]) };
    }

    static void Check(int n, List<int[]> list) {
        SortedDictionary<int, int> v = new SortedDictionary<int, int>();

        int maxValue = 0;
        for (int i = 0; i < list.Count; i++) {
            int id = list[i][0];
            if (v.ContainsKey(id) == false) {
                v.Add(id, 0);
            }

            v[id] += list[i][1];

            if (maxValue < v[id]) {
                maxValue = v[id];
                Console.WriteLine("{0} {1}", id, maxValue);
            }
            else {
                maxValue = v.Values.Max();
                var q = v.Where((x) => x.Value == maxValue);
                foreach (var item in q) {
                    Console.WriteLine("{0} {1}", item.Key, maxValue);
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 8660
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,W = map(int,input().split())
weight = []
val = []
for i in range(n):
    a,b = map(int,input().split())
    weight.append(a)
    val.append(b)
max_v = sum(val) + 10 # 全部使ったとしてもこれ以上の勝ちにはならない
# point : v < =10^3 でn <= 10^2なので、n**2 vでもOK
# wが使えないときには変数を入れ替える
INF = 10**12+7 #Wより大きな値
dp = [[INF]*(max_v+1) for i in range(n+1)]
#初期化は 価値が0になる最小の重さが0なので、dp[i][0] = 0
# 漸化式：dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i])
# i+1　は i番目までの品物を使うとする
# 先にどっちからループを回した方が良い？価値か、品数か
#　品数が全部埋まってから、価値を更新する方が楽そう
for i in range(n+1):
    dp[i][0] = 0
for i in range(n):
    for j in range(max_v+1):
        if j-val[i] >= 0:
            #print("yes")
            dp[i+1][j] = min(dp[i][j],dp[i][j-val[i]]+ weight[i])
        else: dp[i+1][j] = dp[i][j]
    if i == n-1:
        #print("Yes")
        #print(dp[i+1])
        #大きい方から見ていく
        for j in range(1,max_v+1):
            #print(j)
            if dp[i+1][-j] <= W:
                print(max_v - j + 1)
                break


Measured memory_bytes: 119916
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if(a <= 5) b = 0;
  else if(a <= 12) b /= 2;
  cout << b << endl;
  return 0;
}
//templete by private_yusuke

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

using namespace std;

int main() {
    long long u,v,w;
    cin>>u>>v>>w;
    if(u%2 == 0 || v%2 == 0 || w %2 == 0) {
        cout<<"0";
    } else {

        cout<<min(u*v, min(v*w, u*w));
    }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int a,b,c;
	int i,j=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++)if(c%i==0)j++;
	printf("%d\n",j);
	return 0;
}



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

using namespace std;

string str;
bool vis[26];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i;
    ios::sync_with_stdio(false);
    cin >> str;
    for(i = 0; i < str.size(); i++) {
        vis[str[i] - 'a'] = 1;
    }
    if(str.size() == 26) {
        bool ok = 0;
        for(i = 0; i < 26; i++) {
            if(str[i] != 'a' + 25 - i)
                ok = 1;
        }
        if(ok == 0) {
            cout << -1;
            return 0;
        }
        memset(vis, 0, sizeof(vis));
        char mx = 'a' - 1;
        while(mx < str.back()) {
            mx = max(mx, str.back());
            vis[str.back() - 'a'] = 1;
            str.pop_back();
        }
        char ch = str.back();
        str.pop_back();
        cout << str;
        for(i = ch - 'a' + 1; i < 26; i++) {
            if(vis[i] == 1){
                cout << char (i + 'a');
                break;
            }
        }
    }
    else {
        cout << str;
        for(i = 0; i < 26; i++) {
            if(vis[i] == 0) {
                cout << (char) (i + 'a');
                break;
            }
        }
    }
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
/*
    Author - Param Kothari
    Ah shit, here we go again
*/
 
/* Ordered Set Implementaton:

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;

typedef tree<
    int,
    null_type,
    less<int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
ordered_set;
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    int n = 0;
    cin >> n;
    string s;
    cin >> s;
    vector<set<int> > v(26);
    int q = 0;
    cin >> q;
    for(int i = 0; i < s.size(); i++){
        v[s[i]-'a'].insert(i);
    }
    for(int i = 0; i < q; i++){
        int x = 0;
        cin >> x;
        if(x == 1){
            int pos;
            char c;
            cin >> pos >> c;
            pos--;
            v[s[pos]-'a'].erase(pos);
            v[c-'a'].insert(pos);
            s[pos] = c;
        }
        else{
            int l = 0, r = 0;
            cin >> l >> r;
            l--;
            r--;
            int res = 0;
            for(int i = 0; i < 26; i++){
                auto t = v[i].lower_bound(l);
                if(t != v[i].end()){
                    if(*t <= r){
                        res++;
                    }
                }
            }
            cout << res << "\n";
        }
    }
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 24220
import sys
import math
import itertools
x, n = map(int, input().split())
p = list(map(int, input().split()))
if (n == 0):
    print(x)
    sys.exit()
diff = 1000
ans = 0
p.sort()
diff=1000
for i in range(-110,110):
    if (i in p):
       continue
    else:
        if (abs(x - i) < diff):
            diff = abs(x - i)
            ans = i
print(ans)

Measured memory_bytes: 9152
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//const int mod = 1e9+7;
const int N = 200010;
int score[N], n, k;
inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

void solve() {
    for(int i = k + 1; i <= n; i ++) {
        if(score[i] > score[i-k]) cout << "Yes" << endl;
        else cout <<"No" << endl;
    }
}
int main() {
    quickread();
    cin >> n >> k;
    for(int i = 1; i <= n; i ++) cin >> score[i];
    solve();
    return 0;
}


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

int main(){
	int a,b[100];
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> b[i];
	}
	for (int i = a - 1; i >= 0; i--) {
		if (i > 0) { cout << b[i] << ' '; }
		else cout << b[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3092
import sys

dishesList = [int(input()) for i in range(5)]
min = 100000
targetIndex=9999

for i,v in enumerate(dishesList):
    last = v%10
    if last !=0 and last < min:
        min = last
        targetIndex=i

newList = []
for i,v in enumerate(dishesList):

    if i==targetIndex:
        newList.append(v)
        continue

    last = v%10
    if last==0:
        diff=abs(10-last)
        add=v+diff
        newList.append(v)
    else:
        diff=10 - last
        add=v+diff
        newList.append(add)

ans=0

for i in newList:
    ans += i

print(ans)



    

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

using namespace std;

int main()
{
	char s[10];
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<len;i++)
    {
        if(s[i]=='9')
            s[i]='1';
        else if(s[i]=='1')
            s[i]='9';
    }
	printf("%s\n",s);






    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
MOD = 10**9 + 7
kai = []
kai.append(1)
for idx in range(1, N+5):
	kai.append((kai[idx-1] * idx) % MOD)

#Mod pow
#def modpow(ori, po, mod):
#	res = 1;
#	while(po > 0):
#		if(po&1):
#			res *= ori;
#			res %= mod;
#		ori *= ori;
#		ori %= mod;
#		po >>= 1;
#	return res;



comb = [[0] * 2005 for i in range(2005)]

def combination():
	for i in range(2000):
		comb[i][0] = 1;
		for j in range(1, i+1):
			comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
			comb[i][j] %= MOD





#def comb(n, k):
#	return (kai[n] * modpow(kai[k], MOD-2, MOD) * modpow(kai[n-k], MOD-2, MOD))%MOD

combination()

for i in range(K):
	blue=comb[K-1][i]%MOD
	red=comb[N-K+1][i+1]%MOD
	print((blue*red)%MOD)

Measured memory_bytes: 98388
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;
import std.numeric;
import std.bigint;
import core.checkedint;

void main()
{
	for (;;) {
		int n = readln.chomp.to!int;
		if (n == 0) {
			break;
		}
		int[] r = [0, 0];
		foreach (i; 0..n) {
			int[] v = readln.chomp.split.map!(to!int).array;
			if (v[0] > v[1]) {
				r[0] += v.sum;
			} else if (v[0] < v[1]) {
				r[1] += v.sum;
			} else {
				r[] += v[];
			}
		}
		writeln(r[0], " ", r[1]);
	}
}

void tie(R, Args...)(R arr, ref Args args)
		if (isRandomAccessRange!R || isArray!R)
in
{
	assert (arr.length == args.length);
}
body
{
	foreach (i, ref v; args) {
		alias T = typeof(v);
		v = arr[i].to!T;
	}
}

void verbose(Args...)(in Args args)
{
	stderr.write("[");
	foreach (i, ref v; args) {
		if (i) stderr.write(", ");
		stderr.write(v);
	}
	stderr.writeln("]");
}



Measured memory_bytes: 3128
package main

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

type Alds13d struct {
}

func main() {
	a := &Alds13d{}
	a.main()
}

func (a *Alds13d) main() {
	scanner := bufio.NewScanner(os.Stdin)
	fmt.Print(a.solve(scanner))
}

func (a *Alds13d) solve(scanner *bufio.Scanner) string {

	sum := 0
	s1 := make([]int, 0)
	s2 := make([]struct {
		I int
		S int
	}, 0)

	i := 0
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	for _, r := range scanner.Text() {
		c := string(r)

		if c == "\\" {
			s1 = append(s1, i)

		} else if c == "/" && len(s1) > 0 {
			j := s1[len(s1)-1]
			s1 = s1[:len(s1)-1]
			s := i - j

			sum += s

			t := s
			if len(s2) > 0 {
				v := s2[len(s2)-1]
				for v.I > j {
					t += v.S
					s2 = s2[:len(s2)-1]

					if len(s2) == 0 {
						break
					}

					v = s2[len(s2)-1]
				}
			}
			s2 = append(s2, struct {
				I int
				S int
			}{j, t})
		}

		scanner.Scan()
		c = scanner.Text()
		i++
	}

	// output
	result := fmt.Sprintln(sum)
	result += fmt.Sprintf("%d", len(s2))
	for _, v := range s2 {
		result += fmt.Sprintf(" %d", v.S)
	}
	result += fmt.Sprintln()

	return result
}



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

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;

const int maxn = 200010;

int n, fa[maxn], v[maxn], c1[maxn], c0[maxn];
ll ans = 0;

struct Node {
    int c1, c0, u;
	Node(int c1_=0, int c0_=0, int u_=0) : c1(c1_), c0(c0_), u(u_) {}
};

bool operator<(const Node &p1, const Node &p2) {
    if (1LL * p1.c1 * p2.c0 == 1LL * p1.c0 * p2.c1) return p1.u < p2.u;
    return 1LL * p1.c1 * p2.c0 > 1LL * p1.c0 * p2.c1;
}

bool operator==(const Node &p1, const Node &p2) {
    return 1LL * p1.c1 * p2.c0 == 1LL * p1.c0 * p2.c1 && p1.u == p2.u;
}

namespace DSU {
    int fa[maxn];
    void init() {
        for (int i = 1; i <= n; i++) fa[i] = i;
    }
    int getroot(int x) {
        if (x == fa[x]) return x;
        return fa[x] = getroot(fa[x]);
    }
}

priority_queue<Node> pq, del;

int main() {
    scanf("%d", &n);
    for (int i = 2; i <= n; i++) scanf("%d", &fa[i]);
    for (int i = 1; i <= n; i++) scanf("%d", &v[i]);
    DSU::init();
 	for (int i = 1; i <= n; i++) c0[i] = (v[i] == 0), c1[i] = (v[i] == 1);
    for (int i = 2; i <= n; i++) pq.push(Node(c1[i], c0[i], i));
    while (!pq.empty()) {
        Node p = pq.top(); pq.pop();
        int u = p.u;
        int r = DSU::getroot(fa[u]);
        DSU::fa[u] = r;
        ans += 1LL * c1[r] * c0[u];
        if (r != 1) {
            del.push(Node(c1[r], c0[r], r));
            c1[r] += c1[u], c0[r] += c0[u];
            pq.push(Node(c1[r], c0[r], r));
        } else {
            c1[r] += c1[u], c0[r] += c0[u];
        }
        while (!del.empty() && del.top() == pq.top()) {
            del.pop();
            pq.pop();
        }
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  
  int d1, d2, doublet_count = 0;
  bool satisfied = false;
  for (int i = 0; i < n; i++) {
    cin >> d1 >> d2;
    if (d1 == d2) {
      doublet_count++;
    } else {
      doublet_count = 0;
    }
    if (doublet_count >= 3) {
      satisfied = true;
      break;
    }
  }
  
  if (satisfied) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3616