akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int H,W;
vector<string> A;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> H >> W;
    for (int i = 0; i < H; i++)
    {
        string a;
        cin >> a;
        A.push_back(a);
    }
    
}

bool isIn(pii now){
    return (0<=now.first and now.first<H and now.second<W and 0<=now.second);
}

int bfs(vector<pii> init){
    queue<pair<int,pii>> q;
    vector<vector<bool>> visited(H,vector<bool>(W,false));
    for(auto s:init) {q.push({0,s}); visited[s.first][s.second]=true;}
    int dist;
    int ans=0;
    pii now;
    while(!q.empty()){
        tie(dist,now) = q.front();
        ans = max(ans,dist);
        q.pop();
        // if(visited[now.first][now.second]) continue;
        visited[now.first][now.second] = true;
        for (int k = 0; k < 4; k++)
        {
            pii next=now;
            next.first+=dx[k];
            next.second+=dy[k];
            if(!isIn(next)) continue;
            if(visited[next.first][next.second]) continue;
            visited[next.first][next.second] = true;
            q.push({dist+1,next});
        }
    }
    return ans;
}

int solve(){
    vector<pii> init;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if(A[i][j]=='#') init.push_back({i,j});
        }
        
    }
    cout << bfs(init) << endl;
    return 0;
}   

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


Measured memory_bytes: 29288
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){

	int n;
	cin>>n;
	int h1[n],m1[n];
	for(int i=0;i<n;i++){
		cin>>h1[i]>>m1[i];
	}
	int k;
	cin>>k;
	int h2[k],m2[k];
	for(int i=0;i<k;i++){
		cin>>h2[i]>>m2[i];
	}

	int f=n+k;
	int h[f],m[f],c=0;
	for(int i=0;i<n;i++){
		h[i]=h1[i];
		m[i]=m1[i];
		c++;
	}
	for(int i=0;i<k;i++){
		h[c+i]=h2[i];
		m[c+i]=m2[i];
	}
	
	int g[f],hm[f];
	for(int i=0;i<f;i++){
		g[i]=h[i]*60;
		hm[i]=g[i]+m[i];
	}
	sort(hm,hm+f);
	int c2=0;
	for(int i=0;i<f;i++){
		if(hm[i]==hm[i+1]){
			hm[i]=10000;
			c2++;
		}
	}
	sort(hm,hm+f);
	for(int i=0;i<f;i++){
		h[i]=hm[i]/60;
		m[i]=hm[i]%60;
	}
	for(int i=0;i<f-c2;i++){
		if(i!=f-1-c2){
			if(m[i]<10){
				cout<<h[i]<<":"<<0<<m[i]<<" ";
			}
			else{
				cout<<h[i]<<":"<<m[i]<<" ";
			}
		}
		else{
			if(m[i]<10){
				cout<<h[i]<<":"<<0<<m[i]<<endl;
			}
			else{
				cout<<h[i]<<":"<<m[i]<<endl;
			}
		}
	}

return 0;
}

Measured memory_bytes: 1184
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
using namespace std;
int n;
double p[2999], dp[2999][3000];
bool vis[2999][3000];
double calc(int i, int head) {
	if (i == n) return (head > n - head) ? 1.0 : 0.0;
	if (vis[i][head]) return dp[i][head];
	double res = 0.0;
	res += calc(i + 1, head + 1) * p[i];
	res += calc(i + 1, head) * (1.0 - p[i]);
	vis[i][head] = 1;
	return dp[i][head] = res;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%lf", &p[i]);
	memset(vis, 0, sizeof(vis));
	double res = calc(0, 0);
	printf("%.12lf\n", res);
	return 0;
}

Measured memory_bytes: 79616
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

template <class T>
struct Union_find {
    /*
  T: integer(int, long longなど)
  n個の整数に対してunion find森を生成
  par: 親の配列 ex)par[x]はxの親
  rank: ランクの配列で、root以外は意味はない
  size_of: サイズの配列で、root以外は意味がない
  root(x): xの根を返す
  same(x, y): boolでxとyが連結かを返す
  size(x): xが含まれる木の要素数を返す
  unite(x, y): xが含まれる木とyが含まれる木を連結させる
  */
    vector<int> par;
    vector<int> rank;
    vector<int> size_of;

    Union_find(T n) : par(n), rank(n) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
            size_of.push_back(1);
        }
    }

    int root(T x) {
        return par[x] == x ? x : par[x] = root(par[x]);
    }

    bool same(T x, T y) {
        return root(x) == root(y);
    }

    int size(T x) {
        return size_of[root(x)];
    }

    void unite(T x, T y) {
        x = root(x);
        y = root(y);
        if (x == y) {
            return;
        }
        if (rank[x] < rank[y]) {
            size_of[y] += size_of[x];
            par[x] = y;
        }
        else {
            size_of[x] += size_of[y];
            par[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
        return;
    }
};

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<set<int>> cannot_make_friends_with(n);
    int a, b;
    Union_find<int> uf(n);
    rep(i, m) {
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a, b);
        cannot_make_friends_with[a].insert(b);
        cannot_make_friends_with[b].insert(a);
    }
    int c, d;
    rep(i, k) {
        cin >> c >> d;
        c--;
        d--;
        if (uf.same(c, d)) {
            cannot_make_friends_with[c].insert(d);
            cannot_make_friends_with[d].insert(c);
        }
    }
    rep(i, n) {
        cout << uf.size(i) - cannot_make_friends_with[i].size() - 1;
        if (i != n - 1)
            cout << " ";
        else
            cout << endl;
    }
    return 0;
}

Measured memory_bytes: 25464
#include<bits/stdc++.h>
using namespace  std ;
typedef long long  ll;
typedef pair<ll, ll> Pll;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define rad(X) cout << (X) << endl
#define ASH(X) cout << (X) << " "
#define debug(x) cout << #x << " " << x << endl;
#define debug2(x,y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define FOR(I,A,B) for(ll I = (A); I <= (B); I++)
#define cir(I,B,A) for(ll I = (A); I >=(B); I--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define SORT(c) (sort(c.begin(),c.end()))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASES int ___T; cin >> ___T; for(int cs=1;cs<=___T;cs++)
#define FAST()  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll fx[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll fy[] = {0, 1, 1, 1, 0, -1, -1, -1};
vector<ll>a,b,c;
map<ll,ll>m1,m2,m3;

/************************************************/

void Execute()
{
      ll x;
      ll p;
      cin >> x;
      ll point = 100;
      ll cnt =0;

      while(x>point)
      {
        point+=(point/100LL);
        cnt++;
      }
      cout<<cnt<<endl;


}

int main()
{
    //freopen("atomm.txt", "r", stdin);
    FAST();
    //CASES

        Execute();

}


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


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }
 

void solve()
{
	ll a,b;
	cin>>a>>b;
	cout<<a*b;
	
	return;	
}
	

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

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

using namespace std;

int main(){
    string s;
    int n;
    cin>>n;
    cin>>s;
    if(n%2==0){
        string s1;
        string s2;
        s1=s.substr(0,n/2);
        s2=s.substr(n/2,n/2);
        // cout<<s1<<" "<<s2;
        if(s1==s2){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
	return 0;
}

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

using namespace std;
typedef long long ll;
int main() {
    ll n,k,q;
    cin >> n >> k >> q;
    vector<ll> a(n + 1, 0);
    for(ll i = 0; i < q;i++){
        ll x;
        cin >> x;
        a[x]++;
    }
    for(ll i = 1; i <= n;i++){
        if(q-a[i]>=k){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }
        return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int64_t n;
  cin >> n;
  cout << (n+1)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

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

    int ssize = s.size() - 2;
    cout << s[0] << ssize << s[s.size() - 1] << endl;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <complex>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0;i<(n);i++)
typedef unsigned long long ull;
using namespace std;
typedef complex<double> xy_t;

double dot_product(xy_t a, xy_t b){return (conj(a)*b).real();}
double cross_product(xy_t a, xy_t b){return (conj(a)*b).imag();}
xy_t projection(xy_t p,xy_t b){ return b*dot_product(p, b)/norm(b);}
const double eps = 1e-11;
int main (){
    int N;
    cin >> N;
    rep(_N,N){
        double x[4],y[4];
        rep(i,4){
            cin >> x[i] >> y[i];
        }
        xy_t a[2] = {
            xy_t(x[0],y[0]) - xy_t(x[1],y[1]),
            xy_t(x[2],y[2]) - xy_t(x[3],y[3])
        };
        bool p = abs(cross_product(a[0], a[1])) < eps;
        cout << (p ? "YES" : "NO") << endl;
    }
	return 0;
}

Measured memory_bytes: 1228
def gcd(m,n) :
    x = max(m,n)
    y = min(m,n)
    if x%y == 0 :
        return y
    else :
        while x%y != 0 :
            z = x%y
            x = y
            y = z
        else :
            return z

def lcm(m,n) :
    return int(m*n/gcd(m,n))

N,M = map(int,input().split())
S = list(input())
T = list(input())
L = lcm(N,M)
A = []
B = []
flag = 0
counter = 0
if N >= M :
    for i in range(N) :
        A.append(i*L//N+1)
    for j in range(M) :
        b = j*L//M+1
        if j*N % M == 0 :
            index = N*j//M
            if S[index] == T[j] :
                counter += 1
            else :
                flag = 1
                break
        else :
            counter += 1
    if flag == 1 :
        print(-1)
    else :
        if counter == M :
            print(L)
else :
    for i in range(M) :
        A.append(i*L//M+1)
    for j in range(N) :
        b = j*L//N+1
        if j*M % N == 0 :
            index = M*j//N
            if T[index] == S[j] :
                counter += 1
            else :
                flag = 1
                break
        else :
            counter += 1
    if flag == 1 :
        print(-1)
    else :
        if counter == N :
            print(L)

        

Measured memory_bytes: 8664
import collections

def main():
    n = int(input())
    s = []
    for i in range(n):
        s_ = input()
        s.append(s_)
    
    c = collections.Counter(s)
    print("AC x " + str(c["AC"]))
    print("WA x " + str(c["WA"]))
    print("TLE x " + str(c["TLE"]))
    print("RE x " + str(c["RE"]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 16616
#include<iostream>
#include<cmath>
#define M 1000000007
using namespace std;

long long int pos(unsigned long long int x, unsigned long long int n)
{
	unsigned long long int res=1;
	while(n>0)
	{
		if(n&1)res=res*x%M;
		x=x*x%M;
		n>>=1;
	}
	return res;
}

int main()
{
	unsigned long long int m, n;
	cin >> m >> n;
	cout << pos(m, n) << endl;
	return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];
  ll ans1=0,ans2=0,sum=0;
  rep(i,N){
    sum+=A[i];
    if(i%2==0&&sum<=0){
      ans1+=1-sum;
      sum=1;
    }
    else if(i%2!=0&&sum>=0){
      ans1+=sum+1;
      sum=-1;
    }
  }
  sum=0;
  rep(i,N){
    sum+=A[i];
    if(i%2==0&&sum>=0){
      ans2+=sum+1;
      sum=-1;
    }
    else if(i%2!=0&&sum<=0){
      ans2+=1-sum;
      sum=1;
    }
  }
  cout<<min(ans1,ans2)<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000

long long gcd(long long a, long long b){
	if (b == 0) return a;
	return gcd(b, a % b);
}


int main(){
	
	long long A,B;
	cin>>A>>B;
	
	long long G = gcd(A,B);
	//cout<<G<<endl;
	long long ans = 1;
		
	for(long long i=2;i*i<=G;i++){
		if(G%i==0){
			//cout<<i<<endl;
			ans++;
			while(G%i==0){
				G/=i;
			}
		}
	}
	
	if(G!=1)ans++;
	
	cout<<ans<<endl;
	
	return 0;
}



Measured memory_bytes: 256
n,k,s = map(int,input().split())
x = [0]*n
for i in range(n):
    if i < k:
        x[i] = s
    else:
        if s != 10**9:
            x[i] = s+1
        else:
            x[i] = 1

for i in range(n-1):
    print(x[i],end=" ")
else:
    print(x[n-1])


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

int main()
{
    int n;
    cin >> n;
    int sen = n / 1000;
    sen *= 1000;
    if (sen != n)
        sen += 1000;
    cout << sen - n << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
string s;
string t;

int main() {
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  if(a<b){
    cout << "a < b" << endl;
  }
  if(a>b){
    cout << "a > b" << endl;
  }
  if(a==b){
    cout << "a == b" << endl;
  }

  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
    ll n, ans = 0;
    cin >> n;
    vector<ll> m(n + 1);
    vector<ll> h(n);

    for (int i = 0; i < n + 1; i++)
    {
        cin >> m[i];
    }

    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }

    for (int i = 0; i < n; i++)
    {
        if (h[i] <= m[i])
        {
            ans += h[i];
        }
        else
        {
            ans += m[i];
            h[i] = h[i] - m[i];
            if (m[i + 1] >= h[i])
            {
                ans += h[i];
                m[i + 1] -= h[i];
            }
            else
            {
                ans += m[i + 1];
                m[i + 1] = 0;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

int n,k,x,y;

int main(){
  double ans=0.0;
  cin >> n;
  vi v(n);
  REP(i,n){
    cin>>v[i];
  }


  sort(v.begin(), v.end());
  ans=v[0]*1.0;
  for(int i=1;i<n;i++){
    ans*=0.5;
    ans+=v[i]*0.5;
  }

  cout<<setprecision(10)<<(ans)<<endl;
  
  
  return 0;
}

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

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

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

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n,m;
    cin >> n >> m;
    if (n==m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

































Measured memory_bytes: 256
#include<stdio.h>
 
#define MAXLEN 20000
 
int garea,gareas[(MAXLEN/2)+1],gcnt;
 
 
int getArea( char *inputs, int start, int end )
{
    int i;
    int ravine,water;
    
    gareas[gcnt]=ravine=water=0;
    for( i=start; i<=end; i++ ) {
        if( '\\'== *(inputs+i) ) {
            water+=(ravine*2);
            ravine++;
            water++;
        } else if( 0 < ravine && '/' == *(inputs+i) ) {
        	ravine--;
        } else {
	     	gareas[gcnt]+=ravine;
        }       
    }
	gareas[gcnt]+=water;
    
    return gareas[gcnt];
}
  
int checkRavine( char *inputs, int start )
{
    int i;
    int ravine;
    
    ravine=0;
    for( i=start; '\0'!=*(inputs+i); i++ ) {
        if( '\\'== *(inputs+i) ) {
            ravine++;
        } else if( 0 < ravine && '/' == *(inputs+i) ) {   
            ravine--;
            if( 0 == ravine ) {
            	garea+=getArea( inputs, start, i );
            	gcnt++;
                return i-start;
            }           
        }
    }
    return 0;
}
 
 
void getAreas( char *inputs )
{
    int i,next;
     
    next=0;
    for( i=0; '\0'!=inputs[i]; i++ ) {
        next=checkRavine( inputs, i );
        i+=next;
    }
 
    return;
}
 
int main( void ) 
{
    char inputs[MAXLEN+1];
    int i;
 
    scanf( "%s", inputs );
    garea=gcnt=0;
    getAreas( inputs );
     
    printf( "%d\n", garea );
    
    if( gcnt ) {
        printf( "%d ", gcnt );
        gcnt--;
        for( i=0; i<=gcnt; i++ ) {
            printf( "%d", gareas[i] );
            if( i < gcnt ) {
                printf( " " );  
            } else {
            	printf( "\n" ); 
            }
        }
    } else {
        printf( "0\n" );
    }
     
    return 0;
}

Measured memory_bytes: 568
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 100000000
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)

int main(){
    double N,M,allNum;
    cin >> N >> M;
    vector<double>A(N,0);
    rep(i,0,N) cin >> A[i];
    sort(A.begin(),A.end(),greater<double>());
    allNum = accumulate(A.begin(),A.end(),0.0);
    if(A[M-1] < allNum/(4*M)){
        cout  << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <stdlib.h>
using namespace std;

int top, S[1000];

void initialize() {
	top = 0;
}

bool isEmpty() {
	return (top == 0)? true : false;
}

void push(int x) {
	S[++top] = x;
}

int pop() {
	return S[top--];
}

int main()
{
	int a, b;
	char s[200];
	initialize();

	while( scanf("%s", s) != EOF ) {
		if( s[0] == '+' ) {
			a = pop();
			b = pop();
			push(a + b);
		}

		else if( s[0] == '-' ) {
			b = pop();
			a = pop();
			push(a - b);
		}

		else if( s[0] == '*' ) {
			a = pop();
			b = pop();
			push(a * b);
		}

		else push(atoi(s));
	}

	printf("%d\n", pop());

	return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
int n;
class Point{
  public:
  double x;
  double y;
  Point(){}
  Point(double _x, double _y){
    x = _x;
    y = _y;
  }
  Point operator+(const Point &p)const{
    Point res;
    res.x = x + p.x; res.y = y + p.y;
    return res;
  }
  double length(){
    return sqrt(x*x+y*y);
  }
};

void func(int i, Point l, Point r){
  if(i == n) return;
  Point s, t, u;
  Point sum = r+l;
  s = Point((l.x * 2.0 + r.x)/3.0, (2*l.y + r.y)/3.0);
  t = Point((l.x + 2*r.x)/3.0, (l.y + 2*r.y)/3.0);
  u = Point(cos(M_PI/3)*(t.x - s.x) - sin(M_PI/3)*(t.y - s.y) + s.x,
            sin(M_PI/3)*(t.x - s.x) + cos(M_PI/3)*(t.y - s.y) + s.y
           );
  func(i+1, l, s);
  printf("%.10f %.10f\n", s.x, s.y);
  func(i+1, s, u);
  printf("%.10f %.10f\n", u.x, u.y);
  func(i+1, u, t);
  printf("%.10f %.10f\n", t.x, t.y);
  func(i+1, t, r);
  return;
}

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  Point p1(0, 0), p2(100, 0);
  printf("%.10f %.10f\n", p1.x, p1.y);
  func(0, p1, p2);
  printf("%.10f %.10f\n", p2.x, p2.y);

  return 0;
}

Measured memory_bytes: 1248
#include <stdio.h>

int main(void) {
	// your code goes here
	int h,w,i,j,a[501][501],n=0,y[250001],x[250001],yd[250001],xd[250001];
	scanf("%d %d",&h,&w);
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(i=1;i<h;i++){
		for(j=1;j<=w;j++){
			if(a[i][j]%2==1){
				n++;
				y[n]=i;
				x[n]=j;
				yd[n]=i+1;
				xd[n]=j;
				a[i+1][j]++;
			}
		}
		
	}
	for(j=1;j<w;j++){
		if(a[h][j]%2==1){
			n++;
			y[n]=h;
			x[n]=j;
			yd[n]=h;
			xd[n]=j+1;
			a[h][j+1]++;
		}
	}
	printf("%d\n",n);
	for(i=1;i<=n;i++){
		printf("%d %d %d %d\n",y[i],x[i],yd[i],xd[i]);
	}
	return 0;
}


Measured memory_bytes: 6912
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
long long gcd(long long a, long long b) { return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b) { return a/gcd(a,b)*b;}

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

int main() {
  int h, n;
  cin >> h >> n;
  int sum, tmp;
  sum = 0;
  rep (i, n) {
    cin >> tmp;
    sum += tmp;
  }
  if (h <= sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    long long n,x;
    scanf("%lld%lld",&n,&x);
    long long ans=LLONG_MAX,a[n],b[n];
    for (int i=0; i<n; i++){
        scanf("%lld",&a[i]);
        b[i]=a[i];
    }
    for (int i=0; i<n; i++){
        long long tmp=x*i;
        for(int j=0; j<n; j++){
            if (j-i>=0){
                if (b[j]>a[j-i]){
                    b[j]=a[j-i];
                }
            } else {
                if (b[j]>a[n+j-i]){
                    b[j]=a[n+j-i];
                }
            }
            tmp+=b[j];
        }
        if (ans>tmp){
            ans=tmp;
        }
    }
    printf("%lld\n",ans);
	return 0 ;
}

Measured memory_bytes: 256
while (m,f,r = gets.split.map(&:to_i))!= [-1,-1,-1] do
    if (m == -1)||(f == -1)||(m+f < 30)
        puts "F"
    elsif(m+f >= 80) 
        puts "A"
    elsif (m+f >=65)
        puts "B"
    elsif (m+f >=50)|| (r>=50)
        puts "C"
    else (m+f >=30) 
        puts "D"
    end
end



Measured memory_bytes: 6868
import java.io.*;
import java.util.*;
public class Main
{
	
	public void solve()
	{
		int L = nextInt();
		int N = nextInt();
		int left = 0;
		int right = 0;
		for(int i = 0;i < N;i++)
		{
			int x = nextInt();
			int w = nextInt();
			if(x > 0)
			{
				right += Math.abs(x) * w;
			}else if(x < 0)
			{
				left += Math.abs(x) * w;
			}
		}

		if(right == left)
		{
			out.println(0);
		}else if(right < left)
		{
			out.println(1);
			out.println(1 + " " + (left - right));
		}else
		{
			out.println(1);
			out.println(-1 + " " + (right - left));
		}
	}
	public static void main(String[] args)
	{
		out.flush();
		new Main().solve();
		out.close();
	}
	/*Input*/
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;
 
	private boolean hasNextByte()
	{
		if(p < buflen)return true;
		p = 0;
		try
		{
			buflen = in.read(buffer);
		}catch(IOException e)
		{
			e.printStackTrace();
		}
		if(buflen <= 0)return false;
		return true;
	}
	public boolean hasNext()
	{
		while(hasNextByte() && !isPrint(buffer[p]))
		{
			p++;
		}
		return hasNextByte();
	}
 
	private boolean isPrint(int ch)
	{
		if(ch >= '!' && ch <= '~')return true;
		return false;
	}
 
	private int nextByte()
	{
		if(!hasNextByte())return -1;
		return buffer[p++];
	}
 
	public String next()
	{
		if(!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while(isPrint((b = nextByte())))
		{
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}
 
	public int nextInt()
	{
		return Integer.parseInt(next());
	}
 
	public long nextLong()
	{
		return Long.parseLong(next());
	}
 
	public double nextDouble()
	{
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24364
L, R = map(int, input().split())
min = 2100
for i in range(L, R):
    j = i + 1
    while(j < R + 1):
        if(min > i * j % 2019):
            min =  i * j % 2019
        if(min == 0):
            break
        j += 1
    if(min == 0):
        break
print(min)

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(){
	int n , i , a , b , c;
	cin >> n;
	for(i=0 ; i<n ; i++){
		cin >> a >> b >> c;
		if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

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


int main(void) {
    int N;
    cin >> N;
    double p[N];
    rep(i, N) cin >> p[i];



    double dp[N+1][N+1];
    rep(i,N+1){
        rep(j,N+1){
            dp[i][j] = 0.0;
        }
    }

    dp[0][0] = 1.0;
    for(int i = 1; i <= N; i++) {
        for(int j = 0; j <= i; j++) {
            if(j >= 1){
                dp[i][j] = dp[i-1][j-1] * p[i-1] + dp[i-1][j] * (1.0 - p[i-1]);
            } else {
                dp[i][j] = dp[i-1][j] * (1.0 - p[i-1]);
            }
        }
    }

    // rep(i,N+1){
    //     rep(j,N+1){
    //         cout << dp[i][j] << endl;
    //     }
    // }

    double ans = 0.0;
    for(int i = (N/2)+1; i <= N; i++) {
        // cout << dp[N][i] << endl;
        ans += dp[N][i];
    }
    cout << setprecision(10) << scientific << ans << endl;

    return 0;
}


Measured memory_bytes: 70528
#include<bits/stdc++.h>
using namespace std;
const int wx[4]={0,0,1,-1},wy[4]={1,-1,0,0};
int n,mm;
bool m[21][21];
bool walk[21][21];
int max(int x,int y)
{
    if(x>y) return x;
    return y;
}
struct Node {
    int x,y,deep;
}
q[100000];
int dfs(int x,int y)
{
    memset(walk,0,sizeof(walk));
    q[1].x=x,q[1].y=y,q[1].deep=0;
    walk[x][y]=1;
    int l=1,r=1;
    while(l<=r)
    {
        for(int i=0;i<4;++i)
        {
            int tx=q[l].x+wx[i],ty=q[l].y+wy[i];
            if(m[tx][ty]==1||walk[tx][ty]==1||tx<=0||ty<=0||tx>n||ty>mm) continue;
            q[++r].x=tx,q[r].y=ty;
            q[r].deep=q[l].deep+1;
            walk[tx][ty]=1;
        }
        ++l;
    }
   
    return q[r].deep;
}
int main()
{
	//#ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  //#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
    cin>>n>>mm;
    char ch;
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=mm;++j)
        {
            cin>>ch;
            if(ch=='#') m[i][j]=1;
        }
    }
    int res=0;
    for(int a=1;a<=n;++a)
    {
        for(int j=1;j<=mm;++j)
        {
            if(m[a][j]==0) res=max(res,dfs(a,j));
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int fiv[31];
  fiv[0]=1;
  fiv[1]=1;
  fiv[2]=2;
  for(int i=3;i<=30;i++){
    fiv[i]=fiv[i-1]+fiv[i-2]+fiv[i-3];
  }
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    
    if(fiv[n]<=3650){
      cout<<'1'<<endl;
    }else{
      if(fiv[n]%3650==0){
	cout<<fiv[n]/3650<<endl;
      }else if(fiv[n]%3650!=0){
	cout<<(fiv[n]/3650) +1<<endl;
      }
    }
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
 string s;
 cin>>s;
 int n = s.length();
 int sum=0;
 for(int i=0;i<n;i++)
 {
     sum+= s[i]-'0';
 }
 if(sum%9==0)
 cout<<"Yes";
 else
 cout<<"No";
}

Measured memory_bytes: 3712
from collections import deque
N,M=map(int,input().split())
tree=[[] for _ in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    tree[a-1].append(b-1)
    tree[b - 1].append(a - 1)
col=[-1]*N
d=deque()
for i in range(N):
    if col[i]==-1:
        d.append(i)
        col[i]=i
    while len(d)>0:
        v=d.popleft()
        for j in tree[v]:
            if col[j]==-1:
                col[j]=i
                d.append(j)
#print(col)
print(len(set(col))-1)

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

int main() {
  
  string S, T;
  cin >> S >> T;
  int a = S.size();
  int b = 0;
  
  for( int i = 0; i < a; i++ ){
    if (S.at(i) == T.at(i))
      b++;
  }
  
  if ( b == a)
    cout << "Yes" <<endl;
  
  else
    cout << "No" <<endl;
}

Measured memory_bytes: 3628
<?php

$k = trim(fgets(STDIN));

$dp = [];
$d = [1, 6, 9, 6**2, 6**3, 6**4, 6**5, 6**6, 6**7, 9, 9**1, 9**2, 9**3, 9**4, 9**5, 9**6];

$dp[0] = 0;

for ($i = 1;$i <= 1000000; $i++) $dp[$i] = 100000;

for ($i = 0;$i <= 100000; $i++) {
    foreach ($d as $v) {
        $dp[$i + $v] = $dp[$i] + 1 < $dp[$i + $v] ? $dp[$i] + 1 : $dp[$i + $v];
    }
}

echo $dp[$k].PHP_EOL;


Measured memory_bytes: 146932
#include <iostream>

#define pi 3.14159265358979323846 
using namespace std;


int main(void) {
	int A, B, H, M;

	cin >> A >> B >> H >> M;
	//double theta_a = pi / 2 - pi * H / 6.0 + M * pi / 360.0;
	//double theta_a = pi / 2 - pi * H / 6.0 - M * pi / 360.0;
	//double theta_b = pi / 2 - pi * M / 30.0;

	/*double theta_a = pi * H / 6.0 - M * pi / 360.0;*/
	double theta_a = (pi * H + M * pi / 60.0000000) / 6.0000000;
	double theta_b = pi * M / 30.0000000;

	double x_a, y_a, x_b, y_b;

	x_a = (double)A * cos(theta_a);
	y_a = (double)A * sin(theta_a);
	x_b = (double)B * cos(theta_b);
	y_b = (double)B * sin(theta_b);

	//cout << x_a << endl;
	//cout << y_a << endl;
	//cout << x_b << endl;
	//cout << y_b << endl;
	//if (x_a < 0) x_a *= -1;
	//if (x_b < 0) x_b *= -1;
	//if (y_a < 0) y_a *= -1;
	//if (y_b < 0) y_b *= -1;
	double dis = sqrt(pow((x_a - x_b), 2.000000) + pow((y_a - y_b), 2.000000));
	printf("%.20lf\n", dis);
	//cout << dis << endl;

	return 0;
}

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

b = []
if n % 2 == 0:
    for i in reversed(range(1, n, 2)):
        b.append(str(a[i]))
    for i in range(0, n, 2):
        b.append(str(a[i]))
else:
    for i in reversed(range(0, n + 1, 2)):
        b.append(str(a[i]))
    for i in range(1, n, 2):
        b.append(str(a[i]))

ans = ' '.join(b)
print(ans)

Measured memory_bytes: 31944
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const OUT: usize = 0;
const IN: usize = 1;

fn main() {
    let _n = read::<usize>();
    let m = read::<usize>();
    let mut events = vec![];
    for i in 0..m {
        let from = read::<usize>() - 1;
        let to = read::<usize>() - 1;
        events.push((from, IN, i));
        events.push((to, OUT, i));
    }
    events.sort();
    let mut ans = 0;
    let mut current = vec![];
    let mut oks = vec![false; m];
    for &(_pos, t, index) in events.iter() {
        if t == IN {
            current.push(index);
        } else {
            if oks[index] {
                continue;
            }
            ans += 1;
            for &c in current.iter() {
                oks[c] = true;
            }
            current.clear();
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 13432
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 200005

using namespace std;

long long n, m, v, p;
long long a[N];

bool check(int pos) {
	long long tmp = (v - p - pos + 1) * m, mx = a[pos] + m;
	for (int i = pos + 1; i <= n - p + 1; ++i) {
		if (a[i] > mx) return false;
		tmp -= mx - a[i];
	}

	if (tmp <= 0) return true;
	else return false;
}

int main() {

	cin >> n >> m >> v >> p;
	for (int i = 1; i <= n; ++i) scanf("%lld", a + i);
	sort(a + 1, a + n + 1);

	int l = 1, r = n - p + 1, mid, ans;
	while (l <= r) {
		mid = l + r >> 1;
		if (check(mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}

	cout << n - ans + 1 << endl;
	return 0;
}



Measured memory_bytes: 1024
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

func solve(sc *scanner, wr *bufio.Writer) {
	n, m := sc.getInt2()
	pq := newIntPriorityQueue()
	for i := 0; i < n; i++ {
		a := sc.getInt()
		heap.Push(pq, a)
	}

	for i := 0; i < m; i++ {
		(*pq)[0] /= 2
		heap.Fix(pq, 0)
	}

	ans := sum(*pq...)
	fmt.Fprintln(wr, ans)
}

type intPriorityQueue []int

func newIntPriorityQueue() *intPriorityQueue {
	pq := new(intPriorityQueue)
	heap.Init(pq)
	return pq
}

func (pq intPriorityQueue) Len() int           { return len(pq) }
func (pq intPriorityQueue) Less(i, j int) bool { return pq[i] > pq[j] }
func (pq intPriorityQueue) Swap(i, j int)      { pq[i], pq[j] = pq[j], pq[i] }
func (pq *intPriorityQueue) Push(x interface{}) {
	*pq = append(*pq, x.(int))
}
func (pq *intPriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	ret := old[n-1]
	*pq = old[0 : n-1]
	return ret
}

func main() {
	sc := newScanner()
	wr := bufio.NewWriter(os.Stdout)
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)

	solve(sc, wr)
	wr.Flush()
}

// input ------------------------
type scanner struct {
	*bufio.Scanner
}

func newScanner() *scanner {
	sc := bufio.NewScanner(os.Stdin)
	return &scanner{sc}
}
func (sc *scanner) getInt() int {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getInt2() (int, int) {
	return sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt3() (int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt4() (int, int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInts(n int) []int {
	ret := make([]int, n)
	for i := range ret {
		ret[i] = sc.getInt()
	}
	return ret
}
func (sc *scanner) getString() string {
	sc.Scan()
	return sc.Text()
}
func (sc *scanner) getRunes() []rune {
	return []rune(sc.getString())
}
func (sc *scanner) getFloat() float64 {
	sc.Scan()
	ret, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := range ret {
		ret[i] = sc.getFloat()
	}
	return ret
}

// math ----------------------------
func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func pow(a, b int) int {
	ret := 1
	for b > 0 {
		if b&1 > 0 {
			ret = ret * a
		}
		a = a * a
		b >>= 1
	}
	return ret
}


Measured memory_bytes: 6772
#include <iostream>
#include <string>
#include <vector>

using namespace std;

class point {
public:
	int x, y;
	point() {}
	point(int _x, int _y) {
		x = _x;
		y = _y;
	}
};

class list_node {
public:
	list_node *prev, *next;
	point data;
	list_node(list_node *_prev, list_node *_next, point _data) {
		prev = _prev;
		next = _next;
		data = _data;
	}
};

class list {
public:
	list_node *front, *back;
	list() {
		front = new list_node(0, 0, point());
		back = new list_node(front, 0, point());
		front->next = back;
	}
	~list() {
		list_node *node = front;
		while (node) {
			list_node *next = node->next;
			delete node;
			node = next;
		}
	}
	list_node* insert_next(list_node *node, point data) {
		list_node *pre_next = node->next;
		node->next = new list_node(node, pre_next, data);
		pre_next->prev = node->next;
		return node->next;
	}
	list_node* push_front(point data) {
		return insert_next(front, data);
	}
	list_node* push_back(point data) {
		return insert_next(back->prev, data);
	}
	list_node* get_first() {
		return front->next;
	}
	list_node* get_last() {
		return back->prev;
	}
	void remove(list_node *node) {
		list_node *prev = node->prev;
		list_node *next = node->next;
		prev->next = next;
		next->prev = prev;
		delete node;
	}
};

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

int bfs(vector<string> &cell) {
	int h = cell.size(), w = cell[0].size();
	list q;
	vector<vector<int>> d(h, vector<int>(w, -1));
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (cell[i][j] == '#') {
				q.push_back(point(i, j));
				d[i][j] = 0;
			}
		}
	}
	int max_d = 0;
	while (q.get_first() != q.back) {
		point p = q.get_first()->data;
		q.remove(q.get_first());
		max_d = d[p.x][p.y];
		for (int i = 0; i < 4; ++i) {
			point to(p.x + dx[i], p.y + dy[i]);
			if (to.x < 0 || to.y < 0 || to.x >= h || to.y >= w) continue;
			if (d[to.x][to.y] != -1) continue;
			d[to.x][to.y] = d[p.x][p.y] + 1;
			q.push_back(to);
		}
	}
	return max_d;
}

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> cell(h, string());
	for (int i = 0; i < h; ++i) cin >> cell[i];
	cout << bfs(cell) << endl;
	return 0;
}

Measured memory_bytes: 40412
N, Q = list(map(int, input().split()))
S = input()
cum = [0] * N
for i in range(1, N):
    if S[i-1]=='A' and S[i]=='C':
        cum[i] = cum[i-1] + 1
    else:
        cum[i] = cum[i-1]

for _ in range(Q):
    l, r = list(map(int, input().split()))
    print(cum[r-1] - cum[l-1])


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  int N; ll K; cin >> N >> K;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  ll ng = 0; ll ok = *max_element(all(A));
  while(abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    ll tmp = 0;
    REP(i, N) {
      tmp += (A[i] - 1) / mid;
    }
    if(K >= tmp) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}

Measured memory_bytes: 4776
package main
import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
 
func nextInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

type Item struct {
  Price int
}

type PriorityQueue []*Item

func (pq PriorityQueue) Len() int {
  return len(pq)
}

func (pq PriorityQueue) Less(i, j int) bool {
  return pq[j].Price < pq[i].Price
}

func (pq PriorityQueue) Swap(i, j int) {
  pq[i], pq[j] = pq[j], pq[i]
}

func (pq *PriorityQueue) Pop() interface{} {
  old := *pq
  n := len(old)
  item := old[n-1]
  *pq = old[0:n-1]
  return item
}

func (pq *PriorityQueue) Push(x interface{}) {
  item := x.(*Item)
  *pq = append(*pq, item)
}

func main() {
  sc.Buffer(make([]byte, 500000), 500000)
  sc.Split(bufio.ScanWords)
 
  n := nextInt()
  m := nextInt()
  
  as := make([]int, n)
  for i := 0; i < n; i++ {
    as[i] = nextInt()
  }
  priorityQueue := make(PriorityQueue, n)
  for i, a := range as {
    item := Item{}
    item.Price = a
    priorityQueue[i] = &item 
  }
  heap.Init(&priorityQueue)
  
  for i := 0; i < m; i++ {
    item := heap.Pop(&priorityQueue).(*Item)
    newPrice := item.Price/2
    newItem := Item{}
    newItem.Price = newPrice
    heap.Push(&priorityQueue, &newItem)
  }
  result := int64(0)
  for i := 0; i < n; i++ {
    item := heap.Pop(&priorityQueue).(*Item)
    result += int64(item.Price)
  }
  fmt.Println(result)
  
  
}

Measured memory_bytes: 4736
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


long int gcd(long int a, long int b){
  long int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


int main(void){
  int n;
  scanf("%d",&n);
  int ans=0;
  for(int i=1;i<n;i++){
    ans+=(n-1)/i;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1732
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long a = in.nextInt();
            long b = in.nextInt();
            if (a > b) {
                out.println(0);
                return;
            }
            if (n == 1 && a < b) {
                out.println(0);
                return;
            }
            out.println((a + b * (n - 1)) - (a * (n - 1) + b) + 1);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 23252