akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
    int n, x, ans = 1, d = 0;
    cin >> n >> x;
    vector<int> l(n);
    for (int i = 0; i < n; i++)
    {
        cin >> l[i];
    }
    
    for (int i = 0; i < n; i++)
    {
        d += l[i];
        if (d <= x) ans++;
        else break;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

int main()
{

    int n;

    cin>>n;
    map<char,int>occ;
 int ans=0;
      for(int i=0;i<n;i++){

          char c;

          cin>>c;

          if(!occ[c])
            ans++;
          occ[c]++;
      }
      if(ans>3)
        cout<<"Four";
      else
        cout<<"Three";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;


#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9+7;
vector<pair<int, int> > vp;
 
struct Less {
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first > y.first;
    }
};

ll GCD(ll a, ll b){
    if(b==0) return a;
    return GCD(b, a%b);
}


//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];
int scores[90100];
vector<int> v;
int main(void) {
    ll H, W, D;
    vector<pair<ll, ll> > vp(90100);
    cin >> H >> W >> D;
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            ll a; cin >> a;
            vp[a].first=i+1, vp[a].second=j+1;
        }
    }
    
    for(int i=1; i<=H*W; i++){
        if(i+D>H*W) break;
        scores[i+D] += scores[i]+abs(vp[i+D].first-vp[i].first)+abs(vp[i+D].second-vp[i].second);
    }
    int Q; cin >> Q;
    for(int i=0; i<Q; ++i){
        ll L, R; cin >> L >> R;
        ll ans=0;
        ans = scores[R]-scores[L];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

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

  vector<vector<ll>> A(10, vector<ll>(10, 0));
  vector<vector<ll>> B(10, vector<ll>(10, 0));

  for (ll i = 1; i <= N; i++)
  {
    ll y = i % 10;

    ll x = i;
    while (x > 9)
    {
      x /= 10;
    }

    //cerr << i << " " << x << " " << y << endl;

    A.at(x).at(y)++;
    B.at(y).at(x)++;
  }

  ll ans = 0;
  for (ll i = 0; i < 10; i++)
  {
    for (ll j = 0; j < 10; j++)
    {
      ans += A.at(i).at(j) * B.at(i).at(j);
    }
  }
  cout << ans << endl;

  /*
  for (ll i = 0; i < 10; i++)
  {
    for (ll j = 0; j < 10; j++)
    {
      cerr << A.at(i).at(j) << " ";
    }
    cerr << endl;
  }
  cerr << endl;

  for (ll i = 0; i < 10; i++)
  {
    for (ll j = 0; j < 10; j++)
    {
      cerr << B.at(i).at(j) << " ";
    }
    cerr << endl;
  }
  */
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
def main():
    r,c,k=map(int,input().split())
    v=[[0]*c for _ in range(r)]
    for _ in range(k):
        ri,ci,a=map(int,input().split())
        ri-=1
        ci-=1
        v[ri][ci]=a
    dp=[[[0]*c for _ in range(r)] for i in range(4)]
    #print(dp)
    if v[0][0]>0:
        dp[1][0][0]=v[0][0]
    for i in range(r):
        for j in range(c):
            for k in range(4):
                if i>0:
                    dp[1][i][j]=max(dp[1][i][j],dp[k][i-1][j]+v[i][j])
                    dp[0][i][j]=max(dp[0][i][j],dp[k][i-1][j])
                if j>0:
                    if k>0:
                        dp[k][i][j]=max(dp[k][i][j],dp[k-1][i][j-1]+v[i][j])
                    dp[k][i][j]=max(dp[k][i][j],dp[k][i][j-1])
    #print(dp)
    ans=0
    for i in range(4):
        ans=max(dp[i][r-1][c-1],ans)
    return print(ans)
if __name__=="__main__":
    main()

Measured memory_bytes: 422172
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let x = nextInt()
    if(x >= 30) {
        console.log("Yes")
    } else {
        console.log("No")
    }

}
Main()



Measured memory_bytes: 29676
#include<stdio.h>
int main(void)
{
	int a, b;
	char op;

	while (1)
	{
		scanf("%d %c %d", &a, &op, &b);
		if (op == '+')
		{
			printf("%d\n", a + b);
		}
		if (op == '-')
		{
			printf("%d\n", a - b);
		}
		if (op == '*')
		{
			printf("%d\n", a*b);
		}
		if (op == '/')
		{
			printf("%d\n", a/b);
		}
		if (op == '?')
		{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 2668
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int er[20],p[20][20],sum[40000],dp[20][40000],n; 
V<int> v[40000];
int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	int x,y,z,m;
	cin>>n>>m;
	FOR(i,1,m){
		cin>>x>>y>>z;p[x][y]=p[y][x]=z;
	}
	er[0]=1;
	FOR(i,1,n)er[i]=er[i-1]*2;
	FOR(i,1,er[n]-1){
		FOR(j,1,n)if(i&er[j-1])v[i].PB(j);
		sum[i]=sum[i^er[v[i][0]-1]];
		for(int j=1;j<v[i].size();j++){
			sum[i]+=p[v[i][0]][v[i][j]];
		}
	}
	FOR(i,0,er[n]-1)FOR(j,1,n)dp[j][i]=1000000000;
	dp[1][1]=0;
	FOR(mask,1,er[n]-1){
		FOR(i,1,n){
			if(!(mask&er[i-1])||dp[i][mask]>=1000000000)continue;
			FOR(j,1,n){
				if(mask&er[j-1]||!p[i][j])continue;
				dp[j][mask^er[j-1]]=min(dp[j][mask^er[j-1]],dp[i][mask]+sum[mask^er[i-1]^er[j-1]]-sum[mask^er[i-1]]);
			}
			int s=(er[n]-1)^mask,t=s;
			while(t){
				dp[i][mask^t]=min(dp[i][mask^t],dp[i][mask]+sum[mask^er[i-1]^t]-sum[mask^er[i-1]]-sum[t]);
				t=(t-1)&s;
			}
		}
	}
	cout<<dp[n][er[n]-1]<<'\n';
	RE 0;
}




Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
int n;
int m;
//int a[100009],b[100009];
string a;
int ans=0;
int main()
{
    cin>>a;
    for(int i=0;i<a.size();i++)
        if(a[i]=='1')ans++;
    cout<<ans;
}


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

using namespace std;

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

int n,k;
int vet[MAXN],memo[MAXN];

int solve(int stone){

    if(memo[stone] != -1) return memo[stone];

    if(stone==n) return 0;

    if(stone>n) return INF;

    int pulo=INF;
    for(int i=1;i<=k;i++){
        pulo=min(pulo,abs(vet[stone]-vet[stone+i]) + solve(stone+i));
    }

    return memo[stone] = pulo;
}

int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>vet[i];
    }

    memset(memo,-1,sizeof(memo));

    cout<<solve(1)<<endl;
}

Measured memory_bytes: 12164
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int b,r,g,c,s,t;

	while (1) {
		int coin = 100;

		cin >> b >> r >> g >> c >> s >> t;
		if (b == 0 && r == 0 && g == 0 && c == 0 && s == 0 && t == 0) {
			break;
		} else {
			t = t - s;
			coin += (b * 15);
			coin += (b * 5 * 15);
			coin -= (b * 5 * 2);
			t = t - b * 5;
			coin += (r * 15);
			coin += (r * 3 * 15);
			coin -= (r * 3 * 2);
			t = t - r * 3;
			coin += g * 7;
			coin += c * 2;
			coin -= t * 3;
			cout << coin << endl;
		}
	}
	return 0;
}

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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int>A(N),B(N);
  for(int i=0;i<N;i++){
    cin>>A[i]>>B[i];
  }
  vector<pair<int,int>>AB(N);
  for(int i=0;i<N;i++){
    AB[i]=make_pair(A[i],B[i]);
  }
  sort(AB.begin(),AB.end());
  long long ans=0;
  for(int i=0;i<N;i++){
    int buy=min(M,AB[i].second);
    ans+=(long long)buy*AB[i].first;
    M-=buy;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void judgement(bool a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
vec diviserlist(ll N){
  ll i;
  vec res;
  for(i=1;i*i<N;i++){
    if(N%i==0){
      res.pb(i);res.pb(N/i);
    }
  }
  if(i*i==N)res.pb(i);
  vsort(res);
  return res;
}
const double PI = acos(-1);
const double eps = 1e-9;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double a,b,x,ans,tp=PI/2.0,tm=0,mid;
  cin>>a>>b>>x;
  if(x*2.0<a*a*b){
    x=(x*2.0)/(a*b*b);
  }else{
    x=a*a*b-x;
    x=a*a*a/(x*2.0);
  }
  while(tp-tm>eps){
    mid=(tp+tm)/2.0;
    if(tan(mid)<x){
      tm=mid;
    }else{
      tp=mid;
    }
  }
	cout<<fixed<<setprecision(15);
  cout<<90.0-tp/PI*180.0<<endl;
  return 0;
}

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

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  int n, m, max = 0;
  map<int, int> g;

  cin >> n >> m;
  UnionFind tree(n);
  for (int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;
    tree.unite(a, b);
  }

  for (int i = 0; i < n; i++)
  {
    g[tree.root(i)]++;
  }
  for (auto og : g)
  {
    if (og.second > max)
    {
      max = og.second;
    }
  }
  cout << max << endl;
}


Measured memory_bytes: 13144
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); i++) 
int main() {
  int n;cin>>n;
  vector<int> a(n+1),b(n);
  rep(i,n+1)cin>>a[i];
  rep(i,n)cin>>b[i];
  ll ans=0;
  rep(i,n){
    if(a[i]>b[i])ans+=b[i];
    else{
      ans+=min(b[i],a[i]+a[i+1]);
      a[i+1]=max(0,a[i]+a[i+1]-b[i]);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3972
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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 h, w;
vector<vector<char>> s;

void solve() {
	cin >> h >> w;
    s.assign(h, vector<char>(w));
    rep(i, h) {
        rep(j, w) {
            cin >> s[i][j];
        }
    }
    vector<vector<int>> check(h, vector<int>(w - 1));
    rep(j, w - 1) {
        rep(i, h) {
            check[i][j] = ((s[i][j] == '#') ^ (s[i][j + 1] == '#'));
        }
    }
    // rep(i, h) {
    //     rep(j, w - 1) {
    //         cerr << check[i][j];
    //     }
    //     cerr << endl;
    // }
    vector<vector<int>> cnt(h, vector<int>(w - 1, 1));
    rep(j, w - 1) {
        int cur = 1, now = check[0][j];
        for(int i = 1; i < h; ++ i) {
            if(now == check[i][j]) {
                ++ cur;
                cnt[i][j] = cur;
            } else {
                cur = 1;
                cnt[i][j] = cur;
                now = check[i][j];
            }
        }
    }
    // rep(i, h) {
    //     rep(j, w - 1) {
    //         cerr << cnt[i][j];
    //     }
    //     cerr << endl;
    // }
    int ans = max(h, w);
    rep(i, h) {
        vector<int> l(w - 1), r(w - 1);
        stack<int> st;
        rep(j, w - 1) {
            while(st.size() and cnt[i][st.top()] >= cnt[i][j]) st.pop();
            l[j] = (st.empty() ? 0 : st.top() + 1);
            st.push(j);
        }
        while(st.size()) st.pop();
        per(j, w - 1) {
            while(st.size() and cnt[i][st.top()] >= cnt[i][j]) st.pop();
            r[j] = (st.empty() ? w - 1 : st.top());
            st.push(j);
        }
        rep(j, w - 1) {
            chmax(ans, cnt[i][j] * (r[j] - l[j] + 1));
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 69724
#include <bits/stdc++.h>
using namespace std;
#define ll unsighned long int(

int main(){
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> v(m);
    for(int i = 0; i < m; ++i) cin >> v[i];

    int a,ans = 0,r = 0;
    for(int i = 0; i < n; ++i){
        for(int i = 0; i < m; ++i){
            cin >> a;
            r += a * v[i];
        }
        if(r + c > 0) ans++;
        r = 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string.h>
#include<stdio.h>
#include<math.h>
using namespace std;
int a[1010];
int n;
bool solve(int i,int m)
{
    if(m==0)
        return true;
    else if(i>=n)
        return false;
    int res=solve(i+1,m)||solve(i+1,m-a[i]);
    return res;
}
int main()
{
    int q;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    scanf("%d",&q);
    while(q--)
    {
        int x;
        scanf("%d",&x);
        if(solve(0,x))
            printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


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

ll dp[101010][3];
ll abc[101010][3];

int main() {

    int N;
    cin >> N;
    for (int i=1; i<=N; ++i) {
        cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    }

    for (int i=1; i<=N; ++i) {
        for (int p1 = 0; p1 < 3; ++p1) {
            for (int p2 = 0; p2 < 3; ++p2) {
                if (p1 == p2) continue;
                dp[i][p1] = max(dp[i][p1], dp[i-1][p2] + abc[i][p1]);
            }
        }
    }

    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
}


Measured memory_bytes: 4992
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	string s;
	cin >> s;
	if(s == "Sunny")cout << "Cloudy" << endl;
	else if(s == "Cloudy")cout << "Rainy" << endl;
	else cout << "Sunny" << endl;
}


Measured memory_bytes: 256
#pragma optimize GCC ("O2")
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

ll read () {
	ll x = 0, f = 0; char c = getchar ();
	while (!isdigit (c)) f |= (c == '0'), c = getchar ();
	while (isdigit (c)) x = x * 10 + c - '0', c = getchar ();
	return f ? -x : x;
}

int main () {
	ll n = read (), a = read (), b = read ();
	ll lf = (n - 1) * a + b, rg = (n - 1) * b + a;
	if (lf > rg) puts ("0");
	else printf ("%lld\n", rg - lf + 1);
	return 0;
}

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

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz=" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = 1e9 + 7;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

struct Graph {
    Graph(int n)
    {
        edge.resize(n);
    }
    void addEdge(int from, int to)
    {
        edge[to].push_back(from);
        edge[from].push_back(to);
    }
    vector<vector<int>> edge;
};

int main()
{
    int n, m;
    cin >> n >> m;
    Graph g{n};
    for (ll i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g.addEdge(a, b);
    }
    for (int i = 0; i < n; i++) {
        sort(g.edge[i].begin(), g.edge[i].end());
    }
    for (const int from : g.edge[0]) {
        const auto it = lower_bound(g.edge[from].begin(), g.edge[from].end(), n - 1);
        if (it != g.edge[from].end() and (*it) == (n - 1)) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 12016
import itertools

n, m = map(int, input().split())
edge = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)

lst = [i + 1 for i in range(n - 1)]
ans = 0
for step in itertools.permutations(lst):
    flag = True
    now = 0
    for i in range(n - 1):
        if step[i] in edge[now]:
            now = step[i]
        else:
            flag = False
            break
    if flag:
        ans += 1

print(ans)

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

int main()
{
	int n,m,c;
	cin>>n>>m>>c;
	int a[m+1];
	for(int i=1;i<=m;i++) cin>>a[i];
	int b[n+1][m+1];
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	cin>>b[i][j];
	int t=0;
	for(int i=1;i<=n;i++)
	{
		int sum=0;
		for(int j=1;j<=m;j++)
		{
			sum+=b[i][j]*a[j];
		}
		if(sum+c>0)t++;
	}
	cout<<t;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int myfind(int i, vector<int>& v) {
	if (v[i] == i) return i;
	v[i] = myfind(v[i], v);
	return v[i];
}

void myunion(int i1, int i2, vector<int>& v) {
	int r1 = myfind(i1, v);
	int r2 = myfind(i2, v);
	if (r1 == r2) return;
	v[r1] = r2;
}

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> vp, vp1, vp2;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		vp.push_back(make_pair(x, y));
		vp1.push_back(make_pair(x, i));
		vp2.push_back(make_pair(y, i));
	}
	sort(vp1.begin(), vp1.end());
	sort(vp2.begin(), vp2.end());
	priority_queue<pair<int, pair<int, int>>> pq;
	for (int i = 1; i < n; i++) {
		pq.push(make_pair(-vp1[i].first + vp1[i - 1].first, make_pair(vp1[i].second, vp1[i - 1].second)));
		pq.push(make_pair(-vp2[i].first + vp2[i - 1].first, make_pair(vp2[i].second, vp2[i - 1].second)));
	}
	vector<int> v(n, 0);
	for (int i = 0; i < n; i++) v[i] = i;
	long long int res = 0;
	while (pq.size() > 0) {
		auto t = pq.top();
		int cost = -t.first;
		int i1 = t.second.first, i2 = t.second.second;
		pq.pop();
		if (myfind(i1, v) == myfind(i2, v)) continue;
		res += cost;
		myunion(i1, i2, v);
	}
	cout << res << endl;
}


Measured memory_bytes: 11240
#include <iostream>
#include <string>
using namespace std;
int main(){
    int x;
    int n = 0;
    string s;
    string t;
    cin >> s;
    cin >> t;
    x = s.length();
    for(int i=0;i<x;i++){
        if(s[i] != t[i]){
            n += 1;
        }
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3836
#include <stdio.h>

int main() {
  int n, A[100], i;
  scanf("%d", &n);
  for(i=0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  for(i=n-1; i >= 0; i--) {
    printf("%d", A[i]);
    if(i) printf(" ");
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2076
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d,x;
  int a[100];
  int choco[100];
  int ans;
  cin>>n;
  cin>>d>>x;
  ans=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    if(a[i]==1) choco[i]=d;
    else choco[i]=(d-1)/a[i]+1;
  }
  for(int i=0;i<n;i++){
    ans+=choco[i];
  }
  cout<<ans+x<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <vector> //vector
#include <cmath>

#define rep(i, n) for(int i=0; i<(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;

using namespace std;



lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;

bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;

    cin >> a >> b >> c >> d;



    cout <<  min(a,b)+min(c,d)    << endl;


//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define int ll
int a[1234567];
main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin>>n;
    int i;
    map<int,int> map1,map2;
    ll ans=0;
    rep(i,n){
    	cin>>a[i];
    	map1[a[i]+i]++;
    	ans+=map1[i-a[i]];
    }
   
    cout<<ans<<endl;
    return 0;   
}


Measured memory_bytes: 27716
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,m,n,i,j,k,l,c,f,h,w;
	cin>>h>>w>>m;
	unordered_map<ll,ll>x,y;
	map<pairs,ll>ff;
	ll mxx=0,mxy=0,cntx=0,cnty=0;
	for(i=1;i<=m;i++)
	{
	    cin>>j>>k;
	    x[j]++;y[k]++;
	    mxx=max(mxx,x[j]);
	    mxy=max(mxy,y[k]);
	    ff.insert({{j,k},1});
	}
	for(auto u:x)if(u.second==mxx)cntx++;
	for(auto u:y)if(u.second==mxy)cnty++;f=0;
	for(auto u:ff)
	{
	    pairs pp=u.first;
	    if((x[pp.first]==mxx)&&(y[pp.second]==mxy))f++;
	}
	if(f==cntx*cnty)f=1;else f=0;
	cout<<mxx+mxy-f;
	return 0;
}


Measured memory_bytes: 48796
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int fr=1e5,to=-1e5;
signed main(){
	ios_base::sync_with_stdio(0);
	int n;
	cin>>n;
	while(n--){
		int a;
		cin>>a;
		fr=min(fr,a);
		to=max(to,a);
	}
	cout<<to-fr;
	re 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int e = a*b;
		int f = c*d;
		int result = Math.max(e, f);
		System.out.println(result);
	}
}


Measured memory_bytes: 21972
let n, m = stdin.ReadLine().Split() |> fun array -> int array.[0], int array.[1]
let scPairs = [|
    for _ in 1.. m do
        yield stdin.ReadLine().Split() |> fun array -> int array.[0], int array.[1]
|]

let predicateDetail num (s,c) = 
    (string num).ToCharArray() 
    |> fun array ->
        if s-1 >= array.Length then false
        elif array.[s-1] <> char (string c) then false
        else true

let predicate num =
    scPairs 
    |> Seq.forall (predicateDetail num) 

match n with
| 1 -> [0..9]
| _ ->
    [pown 10 (n-1)..(pown 10 n) - 1]
|> Seq.tryFind (fun num -> predicate num)
|> function
| Some(v) -> v
| None -> -1
|> stdout.WriteLine


Measured memory_bytes: 13652
using System;
using System.Collections.Generic;
using static System.Console;

class Program
{
	static void Main(string[] args)
	{
		long N = long.Parse(ReadLine());
		string[] s = ReadLine().Split(' ');
		long[] A = new long[N];
		bool b = false;
		for (long i = 0; i < N; i++) A[i] = long.Parse(s[i]);
		Array.Sort(A);
		for(long i = 0;i < N - 1;i++)if (A[i] == A[i + 1]) b = true;
		if (b) Write("NO");
		else Write("YES");
	}
}

Measured memory_bytes: 30044
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 
typedef pair<ll, ll> P;
const ll INF=1LL<<60;
ll gcd(ll x,ll y){return y? gcd(y,x%y) :x;}

int main(){
    int n;
    ll h;
    cin>>n>>h;
    vector<ll>a(n),b(n+1);
    rep(i,n)cin>>a[i]>>b[i];
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    ll cnt=0;
    rep(i,n+1){
        cnt++;
        if(a[0]>=b[i]){
            ll kazu=h/a[0];
            if(h%a[0]!=0)kazu++;
            cnt+=kazu-1;
            break;
        }else h-=b[i];
        if(h<=0)break;
    }
    cout<<cnt<<endl;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if (A == B) {
    cout << 2 * A << endl;
  } else {
    cout << max(A, B) * 2 - 1 << endl;
  }
  
  return 0;
}

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

using namespace std;

long d[99999] = { 1 }, e[99999] = { 1 }, f = 1;
int main() {
	int n, p = 998244353, s = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		for (int j = (i + 1) * 333; j--;) {
			(d[j] += d[j] + d[max(0, j - a)]) %= p;
			(e[j] += e[max(0, j - a)]) %= p;
		}
		(f *= 3) %= p;
		s += a;
	}
	cout << ((e[(s + 1) / 2] - e[s / 2 + 1] - d[(s + 1) / 2] + p + p) * 3 + f) % p << endl;
	return 0;
}


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

using namespace std;

int main() {
    string s, res;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (i % 2 == 0) {
            res += s[i];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int[] wcnt = new int[n];
        int[] ecnt = new int[n];
        for(int i = 0; i < n; i++){
            char chk = s[i];
            if(chk == 'W'){
                wcnt[i]++;
            }else{
                ecnt[i]++;
            }
            if(i != 0){
                wcnt[i] += wcnt[i-1];
                ecnt[i] += ecnt[i-1];
            }
        }
        int ans = Integer.MAX_VALUE;
        for(int i = 0; i < n; i++){
            if(i == 0){
                ans = Math.min(ans,ecnt[n-1]-ecnt[i]);
            }else{
                ans = Math.min(ans,wcnt[i-1] + ecnt[n-1]-ecnt[i]);
            }
        }
        System.out.println(ans);
    }
}


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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int x, p;
  cin >> x >> p;
  long double res = ((x + 1) / 2) / (p / 100.0);
  cout << fixed << setprecision(10) << res << endl;
  return 0;
}



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

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

// end of #define 

// define globals ...


//write function from here ...



int Main(){




int x;
cin>>x;;
if(x<30){
	cout<<"No\n";
}
else{
	cout<<"Yes\n";
}

return 0;

}

















int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 3636
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long
void solve()
{

    ll A, B, K;
    cin >> A >> B >> K;
    A -= K;
    if (A < 0)
    {
        B += A;
        A = 0;
        if (B < 0)
        {
            B = 0;
        }
    }

    cout << A << " " << B << endl;

    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int n, m, s, d;
string str;
vint order[100];
vint ok[100];


void solve() {
	for (int i = 0; i < 100; ++i) order[i].clear(), ok[i].clear();
	vint now(n);
	for (int i = 1; i <= n; ++i) now[i-1] = i;
	order[0] = now;
	for (int i = 1; i <= d; ++i) {
		cin >> str;
		for (int j = 0; j < str.size(); ++j) {
			if (str[j] == '1') swap(now[j], now[j+1]);
			else {
				if (j == 0) {
					if (str[j+1] != '1') ok[i].PB(j);
				}
				else if (j == n-1) {
					if (str[j-1] != '1') ok[i].PB(j);
				}
				else {
					if (str[j-1] != '1' && str[j+1] != '1') ok[i].PB(j);
				}
			}
		}
		order[i] = now;
	}

	if (order[d][s-1] == m) {
		puts("0");
		return;
	}


	for (int i = 1; i <= d; ++i) {
		for (int j = 0; j < ok[i].size(); ++j) {
			int nj = ok[i][j];
			int a = order[i][nj], b = order[i][nj+1];
			if (a == m && order[d][s-1] == b) {
				cout << i << " " << nj+1 << endl;
				return;
			}
			if (b == m && order[d][s-1] == a) {
				cout << i << " " << nj+1 << endl;
				return;
			}
		}
	}
	puts("1");
	return;
}

int main() {
	while (cin >> n) {
		if (n == 0) break;
		cin >> m >> s >> d;
		solve();
	}
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  int ans=753;
  for (int i=0; i<=S.size()-3; i++) {
    int a=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
    ans=min(ans, abs(753-a));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {

	int n;
	cin >> n;
	int count=0;
	int dig;
	int su = n;
	while (n) {
		dig = n % 10;
		count= count + dig;
		n = n / 10;
	}
	if (su%count == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

int main() {
  int N, K, i, j;
  //int	N, H, h=0, i, s;
  string	S;
  // int	i, j, l, ll;
  // char b;
  //  int N, K, KK, x, s=0;
  cin >> N >> K >> S;
  int ss[N] = {};
  int ssss;
  i=0;
  j=0;
  char SSS='1';
  if (S[0] != SSS) {
    ss[0] = 0;
    j=1;
    SSS='0';
  }
  while ( i<N ) {
    if (S[i] == SSS) {
      ss[j] += 1;
    } else {
      j++;
      ss[j] += 1;
      SSS = S[i];
    }
    i++;
  }
  if (SSS != '1') {
    j++;
    ss[j] = 0;
  }
  int J = j+1;
  //for (j=0; j<J; j++) cout << ss[j]; /////////
  //cout << endl; /////////////////
  if ( J <= K * 2 + 1 ) {
    // cout << J << endl << K << endl; ////
    cout << N << endl;
    return 0;
  }
  ssss=ss[0];
  for (j=1; K>0; j+=2, K--) {
    ssss += ss[j] + ss[j+1];
  }
  int s0=0;
  int s9=ssss;
  while (j<J) {
    //cout << "ssss=" << ssss << endl; ///////////////////
    ssss = ssss + ss[j] + ss[j+1] - ss[s0] - ss[s0+1];
    //cout << ssss << "+=" << ss[j] << '+' << ss[j+1] << '-' << ss[s0] << '-' << ss[s0+1] << endl; /////////////////
    j +=2;
    s0 +=2;
    if (s9 < ssss) s9=ssss;
  }
  cout << s9 << endl;  
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}




int main() {
  int n;
  cin >> n;
  int a;
  vector<int> ans(n);
  rep(i,n-1) {
      cin >> a;
      ans[a-1]++;
  }
  rep(i,n) {
      pt(ans[i]);
  }
  return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

long long int A, B, N;

int main(void) {

	cin >> A >> B >> N;

	long long int x;

	if (N < B) { x = N; }
	else { x = B*(N / B) - 1; }

	cout << (A*x) / B - A*(x / B) << endl;

	return 0;
}

Measured memory_bytes: 3160
let rec solve s k i =
  if i = String.length s - 1 then
    s.[i] <- Char.chr @@
      (Char.code s.[i] - Char.code 'a' + k) mod 26 + Char.code 'a'
  else if s.[i] = 'a' || Char.code s.[i] + k < Char.code 'z' + 1 then
    solve s k (i + 1)
  else begin
    let c = s.[i] in
    s.[i] <- 'a';
    solve s (k - Char.code 'z' - 1 + Char.code c) (i + 1)
  end

let () = Scanf.scanf "%s\n%d\n" @@ fun s k ->
  solve s k 0;
  print_endline s



Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	int A=read(),B=read();
	cout<<A*B-A-B+1<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007
//#define MOD 7

using namespace std;

int main(void){
    // Your code here!
    long long count = 0;
    string s;
    
    cin >> s;
    for(int i = 0; i < 4; i++){
        if(s[i] == '+')
            count++;
        else
            count--;
    }
    
    cout << count << endl;
    
    return 0;
}

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

using namespace std;

int main(){
  int n;
  int k;
  cin >> n >> k;
  k--;
  vector<int64_t> h;
  int64_t ans=1000000000000;
  for(int i=0;i<n;i++){
    int64_t tmp=0;
    cin >> tmp;
    h.push_back(tmp);
  }
  sort(h.begin(), h.end());
  // for(auto a: h){
  //   cout << a << " ";
  // }
  // cout << endl;
  for(int i=0;i<n-k;i++){
    ans = min( ans, abs(h.at(i)-h.at(i+k)) );
    // cout << i << " " << i+k << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
import sys

read = sys.stdin.buffer.read


def main():
    N, K, *AF = map(int, read().split())
    A = AF[:N]
    F = AF[N:]

    A.sort()
    F.sort(reverse=True)

    def is_ok(cost):
        k = 0
        for i in range(N):
            if A[i] * F[i] > cost:
                k += A[i] - cost // F[i]
        return k <= K

    ok = pow(10, 12)
    ng = -1
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid

    print(ok)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 125108
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using std::cout;
using std::endl;
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::multiset;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a - b < b) { return comb(a, a - b); }
	static unordered_map<ll, ll> memo;

	ll c = 1;
	FOR(i, a - b + 1, a + 1) {
		c *= i;
		c %= MOD;
	}
	if (memo.find(b) == memo.end()) {
		ll k = 1;
		FOR(i, 2, b + 1) {
			k *= i;
			k %= MOD;
		}
		memo[b] = pow(k, MOD - 2);
	}
	c *= memo[b];
	return c % MOD;
}
multiset<ll> prime_decomposition(ll n) {
	ll i = 2;
	multiset<ll> table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace(n);
		return table;
	}
	return table;
}
/*
-- bit --
REP(i, (1 << n)) {
	REP(j, n) {
		cout << (1 & (i >> j));
	}
	cout << endl;
}
*/

ll dsum(ll a) {
	ll s = 0;
	while (a != 0) {
		s += a % 10;
		a /= 10;
	}
	return s;
}

int main() {
	ll n;
	cin >> n;
	ll min = 1e10;
	FOR(i, 1, n) {
		ll l = i;
		ll r = n - i;

		min = std::min(dsum(l) + dsum(r), min);
	}
	cout << min << endl;
}

Measured memory_bytes: 256
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll maxn = 1000005;
const ll mm = 1e+18;
int f[maxn];
void solve()
{
    int n;
    cin>>n;
    map<int,int>mp;
    rep0(i,n){
        int x;
        cin>>x;
        mp[x]++;
        f[x]++;
    }
    int ans=0;
    for(auto p:mp){
        if(p.s>1) continue;
        bool pp=true;
        for(int i=1;i<=sqrt(p.f);i++){
            if((p.f)%i==0){
                if(i==p.f) f[i]--;
                if(f[i]){
                    pp=false;
                    break;
                }
                if(i==p.f) f[i]++;
                if(p.f/i==p.f) f[p.f/i]--;
                if(f[p.f/i]){
                    pp=false;
                    break;
                }
                if(p.f/i==p.f) f[p.f/i]++;
            }
        }
        if(pp) ans++;
    }
    pr(ans);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 22648