akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<62)-1
#define MAX 1000000000
signed main(){
    int N; cin>>N;
    vii A(N);
    rep(i,1,N){
        int X,Y; cin>>X>>Y;
        A[X-1].pb(Y-1);
        A[Y-1].pb(X-1);
    }
    vi F(N,-1);
    F[0]=0;
    queue<int> Q;
    Q.push(0);
    Q.push(-1);
    int cnt=1;
    while(Q.size()>1){
        int X=Q.front(); Q.pop();
        if(X==-1){
            cnt++;
            Q.push(-1);
        }
        else{
            rep(i,0,A[X].size()){
                int Y=A[X][i];
                if(F[Y]==-1){
                    F[Y]=cnt;
                    Q.push(Y);
                }
            }
        }
    }
    int mem=0,sum=0;
    int ans=0;
    rep(i,0,N){
        if(F[i]>sum){
            sum=F[i];
            mem=i;
        }
    }
    Q.pop();
    Q.push(mem);
    Q.push(-1);
    vector<bool> G(N,1);
    G[mem]=0;
    cnt=1;
    while(Q.size()>1){
        int X=Q.front(); Q.pop();
        if(X==-1){
            cnt++;
            Q.push(-1);
        }
        else{
            rep(i,0,A[X].size()){
                int Y=A[X][i];
                if(G[Y]){
                    G[Y]=0;
                    Q.push(Y);
                    ans=max(ans,cnt);
                }
            }
        }
    }
    if(ans%3==1) cout<<"Second"<<endl;
    else cout<<"First"<<endl;
}



Measured memory_bytes: 15984
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<cstdio>
#include<cmath>
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
	int n;
	cin>>n;
	rep(i,n){
		vector<int>in(3);
		rep(j,3)cin>>in[j];
		sort(all(in));
		if(in[0]*in[0]+in[1]*in[1]==in[2]*in[2])cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

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

using namespace std;

int main() {
	int n, m, l, r, L = -1, R = 1e5 + 5;
	scanf("%d %d", &n, &m);
	for(int i = 0; i < m; ++i){
		cin >> l >> r;
		L = max(L, l);
		R = min(R, r);
	}
	if (R - L + 1 >= 0)
		printf("%d", R - L + 1);
	else
		printf("0");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll k;
  cin >> k;
  vl a(k);
  rep(i, k) cin >> a[i];
  reverse(all(a));
  ll nl = 2, nr = 2, l, r;
  rep(i, k) {
    l = nl;
    r = nr;
    nl = (l + a[i] - 1) / a[i] * a[i];
    nr = (r / a[i] + 1) * a[i] - 1;
    if(nl > r || nr < l) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << nl << ' ' << nr << endl;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	long long H, W;
	cin >> H >> W;

	if (H % 3 == 0 || W % 3 == 0) {
		cout << 0 << endl;
		return 0;
	}

	long long buf1 = W;
	long long buf2 = H;
	long long ans = INT_MAX;
	{
		long long areaMax;
		long long areaMin;
		buf1 = max(H, W);
		buf2 = min(H, W);
		if (0 < (int)ceil(buf1 / 3.0)) {
			areaMax = max({ buf2 * ceil(buf1 / 3.0), buf2 * floor(buf1 / 3.0) });
			areaMin = min({ buf2 * ceil(buf1 / 3.0), buf2 * floor(buf1 / 3.0) });
			ans = areaMax - areaMin;
		}

		buf1 = min(H, W);
		buf2 = max(H, W);
		if (0 < (int)ceil(buf1 / 3.0)) {
			areaMax = max({ buf2 * ceil(buf1 / 3.0), buf2 * floor(buf1 / 3.0) });
			areaMin = min({ buf2 * ceil(buf1 / 3.0), buf2 * floor(buf1 / 3.0) });
			ans = min(ans, areaMax - areaMin);
		}
	}
	{
		buf1 = H;
		buf2 = W;
		for (long long i = 1; i <= buf1; ++i) {
			long long areaMax = max({ i * buf2, (buf1 - i) * (int)ceil(buf2 / 2.0), (buf1 - i) * (int)floor(buf2 / 2.0) });
			long long areaMin = min({ i * buf2, (buf1 - i) * (int)ceil(buf2 / 2.0), (buf1 - i) * (int)floor(buf2 / 2.0) });

			if (areaMax < areaMin) {
				continue;
			}

			ans = min(ans, areaMax - areaMin);
		}
	}
	{
		buf1 = W;
		buf2 = H;
		for (long long i = 1; i <= buf1; ++i) {
			long long areaMax = max({ i * buf2, (buf1 - i) * (int)ceil(buf2 / 2.0), (buf1 - i) * (int)floor(buf2 / 2.0) });
			long long areaMin = min({ i * buf2, (buf1 - i) * (int)ceil(buf2 / 2.0), (buf1 - i) * (int)floor(buf2 / 2.0) });

			if (areaMax < areaMin) {
				continue;
			}

			ans = min(ans, areaMax - areaMin);
		}
	}




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

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string S, T;
  cin >> S >> T;
  const int n = S.size();
  for(int i = 0; i < n; i++){
  	if(S.substr(i,n-i)+S.substr(0,i)==T){return (cout << "Yes" << endl),0;}
  }
  cout << "No" << endl;
return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
const int MAX_N=3e3+5;
const ll inf=1e18;
inline int qi(){
    int f=0,fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline ll ql(){
	ll f=0;int fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
ll dp[MAX_N][MAX_N][4];
int v[MAX_N][MAX_N];
int main()
{
	ll r=qi(),c=qi(),k=qi(); ms(v);
	repi(i,1,k){
		int x=qi(),y=qi(),val=qi();
		v[x][y]=val;
	}
	repi(i,1,r)repi(j,1,c){
		dp[i][j][0]=max(max(dp[i-1][j][0],max(dp[i-1][j][1],max(dp[i-1][j][2],dp[i-1][j][3]))),dp[i][j-1][0]);
		dp[i][j][1]=max(dp[i][j][1],max(dp[i-1][j][0],max(dp[i-1][j][1],max(dp[i-1][j][2],dp[i-1][j][3])))+v[i][j]);
		dp[i][j][1]=max(dp[i][j][1],max(dp[i][j-1][1],dp[i][j-1][0]+v[i][j]));
		dp[i][j][2]=max(dp[i][j-1][2],dp[i][j-1][1]+v[i][j]);
		dp[i][j][3]=max(dp[i][j-1][3],dp[i][j-1][2]+v[i][j]);
	}
	printf("%lld\n",max(max(dp[r][c][0],dp[r][c][1]),max(dp[r][c][2],dp[r][c][3])));
	return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;
const ll INF = 1LL << 60;

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

vector<pair<ll, ll> > prime_factorize(ll n){
    vector<pair<ll, ll> > res;
    for(ll i = 2; i * i <= n; i++){
        if(n % i != 0) continue;
        ll ex = 0;
        while(n % i == 0){
            ex++;
            n /= i;
        }
        res.push_back({i, ex});
    }
    if(n != 1) res.push_back({n, 1});
    return res;
}

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

    V<P<ll, ll> > pf = prime_factorize(p);
    ll ans = 1;
    for(auto p : pf){
        for(int i = 0; i < p.second / n; i++){
            ans *= p.first;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3592
//#include "SaveFuncs.cpp"

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
//#define int long long
constexpr int INF = 2000000100;
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
string strMulti(string t, int n) { string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }

/*****/

int Main()
{
	int N;
	cin >> N;
	vector<int> P(N);
	rep(i, N)	cin >> P.at(i);

	int diff = 0;
	rep(i, N)
	{
		if (P.at(i) != i + 1)
		{
			diff++;
		}
	}


	if (diff == 0 || diff == 2)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;
}

/*****/

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

	Main();

	return 0;
}


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

int *tmp;

int merge(int *a, int low, int mid, int high){
        for(int i=low;i<high;i++) tmp[i]=a[i];
        int i=low, j=mid, k=low, c=0;
        while(i<mid||j<high){
                c++;
                if(i==mid) a[k++] = tmp[j++];
                else if(j==high) a[k++] = tmp[i++];
                else{
                        if(tmp[i]<tmp[j]) a[k++] = tmp[i++];
                        else a[k++] = tmp[j++];
                }
        }
        return c;
}

int mergesort(int *a, int low, int high){
        if(low>=high-1) return 0;
        int mid = low+(high-low)/2;
        int c1 = mergesort(a, low, mid);
        int c2 = mergesort(a, mid, high);
        int c3 = merge(a, low, mid, high);
        return c1+c2+c3;
}

int main(){
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++) cin>>a[i];
        tmp = new int[n];
        int c = mergesort(a,0,n);
        for(int i=0;i<n;i++) {
                cout<<a[i];
                if(i<n-1) cout<<" ";
                else cout<<endl;
        }
        cout<<c<<endl;
        delete tmp;
        return 0;
}


Measured memory_bytes: 6724
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <queue>
#include <cmath>
#include <iomanip>
#include <cstdlib>
// #include <fstream>

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

const long long INF = 1LL<<60;
const int MAX_N = 110;
const int MAX_V = 100010;
long long int dp[MAX_N][MAX_V];


int main()
{
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    int N;
    long long int W;
    
    std::cin >> N >> W;
    std::vector<long long int> w(MAX_N, 0), v(MAX_N, 0);
    
    for(int i=0; i<N; i++) std::cin >> w[i] >> v[i];
    
    for(int i=0; i<MAX_N; i++)
    {
        for(int j=0; j<MAX_V; j++) dp[i][j] = INF;
    }

    dp[0][0] = 0;

    for(int i=0; i<N; i++)
    {
        for(int sum_v=0; sum_v<MAX_V; ++sum_v)
        {
            if(sum_v-v[i]>=0)
                chmin(dp[i+1][sum_v], dp[i][sum_v-v[i]]+w[i]);
            
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }
    
    long long ans = 0;
    for(int sum_v = 0; sum_v < MAX_V; ++sum_v)
    {
        if(dp[N][sum_v] <= W) ans = sum_v;
    }
    
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 86272
#include <stdio.h>
#include <stdlib.h>

int main(){
  int n,i,x,j,r,t;
  int *a;
  scanf("%d",&n);
   a = malloc(sizeof(int)*n+1);

   for(i = 0; i < n; i++){
     scanf("%d",&a[i]);
   }
   x = a[i-1];
   r = i-1;
   i = 0 - 1;
   for(j = 0; j < r; j++){
     if( a[j] <= x){
       i = i + 1;
       t = a[j];
       a[j] = a[i];
       a[i] = t;
     }
   }
     t = a[i+1];
     a[i+1] = a[r];
     a[r] = t;
   

   for ( j = 0; j < n; j++){
     if( j == i+1){
       printf("[");
     }
     printf("%d",a[j]);
     if(j == i+1){
       printf("]");
     }
     if(j < n-1){
       printf(" ");
     }
   }
   printf("\n");
   return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
    ll ans = 0;
    ll t = 0;
    ll cand = 0;
    for (int i = 30; i >= 1; i--) {
        if (((K >> i) & 1) == 0) continue;
        t += (1 << i) - 1;
        cand = 0;
        for (int j = 0; j < N; j++) {
            if ((A[j] | t) == t) cand += B[j];
        }
        ans = max(ans, cand);
        t += 1;
    }
    cand = 0;
    for (int j = 0; j < N; j++) {
        if ((A[j] | K) == K) cand += B[j];
    }
    ans = max(ans, cand);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
def examA():
    N = SI()
    ans = "No"
    for s in N:
        if s=="7":
            ans = "Yes"
    print(ans)
    return

def examB():
    N = I()
    ans = 0
    for i in range(1,N+1):
        if i%3==0:
            continue
        if i%5==0:
            continue
        ans += i
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 10104
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    bool a = true;
    for(int i=0;i<s.size();i=i+2)
    {//奇数
    if(s[i]=='R'||s[i]=='U'||s[i]=='D')
    continue;
    a=false;
    }
    for(int i=1;i<s.size();i=i+2){//偶数
    if(s[i]=='L'||s[i]=='U'||s[i]=='D')
    continue;
    a=false;
    }
    if(a)
    cout << "Yes" << endl;
    else 
    cout << "No" << endl;

}

Measured memory_bytes: 256
n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)
b = gets.chop.split.map(&:to_i)
c = gets.chop.split.map(&:to_i)
 
index = 0
score = 0
before_food_index = nil
n.times do
  food = a[index]
  food_index = food - 1
  food_score = b[food_index]
  if !before_food_index.nil? && before_food_index + 1 == food_index
    score += c[before_food_index]
  end
  score += food_score
  index += 1
  before_food_index = food_index
end
 
puts score

Measured memory_bytes: 1788
#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T,typename U>
using gmap = cc_hash_table<T, U, hash<T> >;
//END CUT HERE
#ifndef call_from_test
//INSERT ABOVE HERE
signed AGC023_A(){
  using ll = long long;
  int n;
  scanf("%d",&n);
  vector<ll> as(n);
  for(int i=0;i<n;i++) scanf("%lld",&as[i]);

  gmap<ll, ll> mp;
  ll ans=0,sum=0;
  mp[sum]++;
  for(int i=0;i<n;i++){
    sum+=as[i];
    ans+=mp[sum];
    mp[sum]++;
  }

  printf("%lld\n",ans);
  return 0;
}
/*
  verified on 2019/12/09
  https://atcoder.jp/contests/agc023/tasks/agc023_a
*/

signed main(){
  AGC023_A();
  return 0;
}
#endif


Measured memory_bytes: 12140
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()
b = na()
c = na()

t = -2
ans = 0
for i in a:
    ans += b[i-1]
    if t+1 == i:
        ans += c[i-2]
    t = i

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001
#define MOD 1000000007

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    reverse(A.begin(), A.end());
    vector<ll> dp(N,INF);
    for(int i = 0; i < N; i++){
        auto iter = upper_bound(dp.begin(), dp.end(), A[i]);
        ll idx = iter - dp.begin();
        dp[idx] = A[i];
    }
    cout << lower_bound(dp.begin(), dp.end(), INF) - dp.begin() << endl;
}

Measured memory_bytes: 4828
program main
    implicit none
    integer(8) X, i, j, ans
	read(*, *) X
	ans = 0
	do i = 1, 40
	    do j = 2, 10
			if(i**j < 1 .or. i**j > 1000) then
				exit
		    else if(i**j <= X) then
			    ans = max(i**j, ans)
			end if
		end do
	end do
	write(*, *) ans
end program main

Measured memory_bytes: 768
N, M = map(int, input().split())
H = list(map(int, input().split()))
ans = [0 for _ in range(N)]
for _ in range(M):
  a, b = map(int, input().split())
  if H[a-1] < H[b-1]:
    ans[a-1] -= 1
  elif H[a-1] > H[b-1]:
    ans[b-1] -= 1
  elif H[a-1] == H[b-1]:
    ans[b-1] -= 1
    ans[a-1] -= 1
print(ans.count(0))

Measured memory_bytes: 20000
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define FOR(i,a,b) for(int i=a; i<b; i++)
#define For(i,a,b) for(int i=a; i>b ;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define endl "\n"
#define mod 1000000007

void solve()
{
	
}

int main()
{
	IOS;
	ll int t=0;
	string str;
	cin>>str;
	FOR(i,0,str.length())
	{
		string x="";
		x+=str[i];
		t+=stoi(x);
	}
	if(t%9==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 2; i * i <= n; ++i) {
        ll num = 1;
        ll cnt = 0;
        while(1) {
            if (n % i != 0) break;
            n /= i;
            ++cnt;
            if (cnt >= num) {
                ++ans;
                ++num;
                cnt = 0;
            }
        }
    }
    if (n != 1) ++ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>

using namespace std;

long long n_divide(long long y, long long x) {
    if(y == -1) {
        return 0;
    } else {
        return y/x + 1;
    }
}

int main() {
    long long a, b, x;

    cin >> a >> b >> x;

    cout << n_divide(b, x) - n_divide(a-1, x) << endl;

    return 0;
}


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

int main() {
  string S;
  cin >> S;
  bool n, w, s, e;
  n = false, w = false, s = false, e = false;
  int N = S.size();
  rep(i, N){
    if(S[i] == 'N')n=true;
    if(S[i] == 'W')w=true;
    if(S[i] == 'S')s=true;
    if(S[i] == 'E')e=true;
  }
  int cn = 0;
  if(n)cn++;
  if(w)cn++;
  if(s)cn++;
  if(e)cn++;
  if(cn == 4){
    cout << "Yes" << endl;
    return 0;
  }else if(cn == 3 || cn == 1){
    cout << "No" << endl;
    return 0;
  }else if (cn == 2){
    if(n){
      if(s){
        cout << "Yes" << endl;
        return 0;
      }else{
        cout << "No" << endl;
        return 0;
      }
    }
    if(w){
      if(e){
        cout << "Yes" << endl;
        return 0;
      }else{
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "No" << endl;
    return 0;
  }

}

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

#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int32_t main()
{

 
  string s;
  cin >> s;
  if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}

Measured memory_bytes: 256
d = gets.to_i
c = gets.split.map &:to_i
s = d.times.map { gets.split.map &:to_i }

last = [0] * 26
s.each_with_index do |row, day|
  down_sum = last.each_with_index.sum { |day_last, i| c[i] * (day - day_last) }
  i = (0...26).max { |i| s[day][i] - down_sum + c[i] }
  p 1 + i
end


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

int main(){ 
  int sx, sy, tx , ty;
   cin >> sx >> sy>> tx >> ty;
  string S = "";
  
  for(int i = 0; i < ty - sy; i++){ S = S + "U";}
  for(int i = 0; i <  tx - sx; i++){ S = S + "R";}
  for(int i = 0; i < ty - sy; i++){ S = S + "D";}
  for(int i = 0; i < tx - sx; i++){ S = S + "L";}
  S = S + "L";
  for(int i = 0;  i < ty- sy + 1; i++){ S = S + "U";}
  for(int i = 0; i < tx - sx + 1; i++){ S = S + "R";}
  S = S + "D"; S = S + "R";
  for(int i = 0; i < ty - sy + 1; i++){ S = S + "D";}
  for(int i = 0; i < tx - sx + 1; i++){ S = S + "L";}
  S = S + "U";
  
  cout << S << endl; return 0;}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define maxn 100005
using namespace std;
char s[maxn];
int st[maxn];
int ed[maxn];
int vis[200];

int flag=0;
int main()
{
   scanf("%s",s);
    memset(vis,0,sizeof(vis));
memset(st,0,sizeof(st));
memset(ed,0,sizeof(ed));
for(int i=0;i<strlen(s)-1;i++)
    if(s[i]==s[i+1])
{flag=1;
    printf("%d %d\n",i+1,i+1+1);
break;
}
if(!flag)
{for(int i=0;i<strlen(s)-2;i++)
    if(s[i]==s[i+2])
{
    flag=1;
    printf("%d %d\n",i+1,i+1+2);
    break;
}
}
if(!flag)
    printf("-1 -1\n");


return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  string S;
  cin >> S;
  if (S[2] == S[3] && S[4] == S[5])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950


bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}

//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////

void solve(){

    ll x,n;
    cin>>x>>n;

    vec a;
    if(n==0){
        cout<<x; return;
    }
    inpvec(a,n);
    map<ll,ll> m;
    sort(all(a));
    loop(i,0,n){
        m[a[i]]++;
    }

    ll r = x;
    ll p=1e5;
    ll ans1,ans2;

    while(p--){
        if(m.count(r)==0){
            ans1=r;
            break;
        }
        r++;
    }
    r=x;
    p=1e5;
    while(p--){
        if(m.count(r)==0){
            ans2=r;
            break;
        }
        r--;
    }

    // if(ans2<a[0] and ans1>a[n-1]){
    //      cout<<min(ans1 , ans2); return;
    // }
    // if(ans2<a[0]){
    //      cout<<ans1; return;
    // }
    // if(ans1>a[n-1]){
    //     cout<<ans2; return;
    // }
    ll a1 = abs(ans1-x);
    ll a2 = abs(ans2-x);
    if(a1<a2){
        cout<<ans1;
    }
    else{
        cout<<ans2;
    }

    return;
} 
 
int main()
{
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

Measured memory_bytes: 3688
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;
#define MV 10001
#define INF 1e9

struct edge{int to,cost;};
vector <edge> G[MV];
bool used[MV];
int V,E;
int d[MV];

int prim(){  
    for(int i=0;i<V;i++){
        d[i] = INF;
        used[i]=false;
    }
    d[0]=0;
    used[0]=true;
  
    for(int i=0;i<G[0].size();i++){
        d[G[0][i].to]=G[0][i].cost;
    }
    int num=0;

    for(int j=0;j<V;j++){
        int m=-1;
        for(int i=0;i<V;i++){
            if(used[i]==false && (m==-1 || d[m]>d[i])) m=i;
        }
        if (m==-1) break;
        used[m]=true;
        num+=d[m];
        for(int i=0;i<G[m].size();i++){
            d[G[m][i].to]=min(d[G[m][i].to],G[m][i].cost);
        }
    }
    return num;
}

int main(){
  int first;
  cin>>V>>E;
  for(int i=0;i<E;i++){
    int f,t;
    edge e;
    cin>>f>>e.to>>e.cost;
    G[f].push_back(e);
    t=e.to;
    e.to=f;
    G[t].push_back(e);
  }

  int fl = prim();
  cout << fl << endl;
}



Measured memory_bytes: 5944
void main()
{
    long n, s;
    rdVals(n, s);
    long[] a = rdRow;

    long[][] dp = new long[][](n+1, s+1);
    foreach (i; 0 .. n+1) dp[i][0] = 1;
    long result;
    foreach (i, x; a)
    {
        foreach (j; 0 .. s+1)
        {
            dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % mod;
            if (j - x < 0) continue;
            dp[i+1][j] = (dp[i+1][j] + dp[i][j-x]) % mod;
        }
        result = (result + dp[i+1][s]) % mod;
    }

    result.writeln;
}


enum long mod = 998244353;
//enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 74492
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
using Graph = vector<vector<pair<ll, ll>>>;


int main()
{
    ll A, B, C, D; cin >> A >> B >> C >> D;
    while (true) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int main(void)
{
    int N;
    cin >> N;
    int a[N];
    int count[100010] = {};
    rep(i ,N){
        cin >> a[i];
        a[i]++;
    }
    for (int i = 0; i < N; i++) {
        count[a[i]-1]++;
        count[a[i]]++;
        count[a[i]+1]++;
    }
    int max = 1;
    for (int i = 0; i < N; i++) {
        if (max < count[i]) max = count[i];
    }
    cout << max;
    return 0;
}

Measured memory_bytes: 1024
"""
N = int(input())
A, B = map(int,input().split())
lst = [list(map(int,input().split())) for i in range(M)]
A = list(map(int,input().split()))
"""

S = input()
T = input()

ans = 0
for i in range(3):
  if S[i] == T[i]:
    ans += 1
    
print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<int>().max()

int main() {
	int n, k;
	cin >> n >> k;
	int s = 0;
	for(int i=1; i<=k; i++) {
		int x;
		cin >> x;
		s += x;
	}
	if (s >= n) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
import Text.Printf
import Control.Monad

len :: Int
len = 8

grid :: Int -> Int -> [Bool] -> Bool
grid x y dat = (dat!!((x-1)+(y-1)*len))

getfalse :: Int -> Int -> [Bool] -> [Bool]
getfalse x y dat = map edit [0..((length dat)-1)]
    where edit i = if i==((x-1)+(y-1)*len) then False 
                   else (dat!!i)

explode :: Int -> Int -> [Bool] -> [Bool]
explode x y dat
    | (x<1 || y<1 || x>len || y>len)  = dat --out of grid
    | grid x y dat                    =     --has bomb
        (explode (x+1) y) $ (explode (x+2) y) $  (explode (x+3) y) $ 
        (explode (x-1) y) $ (explode (x-2) y) $  (explode (x-3) y) $ 
        (explode x (y+1)) $ (explode x (y+2)) $  (explode x (y+3)) $
        (explode x (y-1)) $ (explode x (y-2)) $  (explode x (y-3)) $
        getfalse x y dat
    | otherwise                       = dat --no bomb

printres :: Int -> [Bool] -> IO ()
printres i res = do
    printf "Data %d:\n" i
    let s = map (\x->if x then '1' else '0') res
    let s' = map (\i -> drop (i*len) $ take ((i+1)*len) s) [0..(len-1)]
    mapM_ putStrLn s'

solve :: Int -> IO ()
solve i = do
    dummy<-getLine
    str<-replicateM len getLine 
    x<-readLn::IO Int
    y<-readLn::IO Int
    let dat = map (\x->(x=='1')) $ foldr (++) "" str
    printres i $ explode x y dat

main :: IO ()
main = do
    n_data<-readLn::IO Int
    mapM_ solve [1..n_data]

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

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

int main(int argc, char *argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n, m;
    cin >> n >> m;

    string s, t;
    cin >> s >> t;

    ll lcm = (n*m) / gcd(max(n, m), min(n, m));

    int i = 0;
    while(i < n || i < m) {
        ll idx1 = i*(lcm/n);
        ll idx2 = i*(lcm/m);

        bool valid = true;

        if(idx1 % (lcm/m) == 0) {
            int j = idx1 / (lcm/m);
            if(i < n && j < m && s[i] != t[j]) valid = false;
        }

        if(idx2 % (lcm/n) == 0) {
            int j = idx2 / (lcm/n);
            if(i < m && j < n && t[i] != s[j]) valid = false;
        }

        if(!valid) {
            cout << -1 << '\n';
            return 0;
        }

        ++i;
    }

    cout << lcm << '\n';
}


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

int a[200010];
int b[200010];

int main() {
	long long n;
	long long x,m;
	long long ans;
	long long  p,p_max,p_round;
	long long ansm;
	long long mm,mn;

	cin >> n >> x >> m ;
	rep(i, m) b[i]=-1;

	p=x;
	rep(i, m){
		b[p]=i;
		p=p*p;
		p%=m;
		if (b[p]>=0){
			p_max=i+1;
			p_round=i+1-b[p];
            break;
		}
	}
	if (n<2*p_max){
		p=x;
		ans=0;
		rep(i, n){
			ans+=p;
			p=p*p;
			p%=m;
		}
		cout << ans << endl;
		return 0;
	}
	ansm=0;
	rep(i,p_round){
      	ansm+=p;
		p=p*p;
		p%=m;
	}
	mm=n-2*p_max;
	mm/=p_round;
	mn=n-mm*p_round;
 	ans=mm*ansm;
	p=x;
	rep(i,mn){
      	ans+=p;
		p=p*p;
		p%=m;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3936
import math
import sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from functools import lru_cache, reduce
from heapq import heapify, heappop, heappush
from itertools import chain, combinations, permutations, product
from typing import List, Dict

# import numpy as np

sys.setrecursionlimit(10**6 + 1)
input = sys.stdin.readline
write = sys.stdout.write


def read_item(cls=int):
    return cls(input())


def read_n_item(cls=int) -> list:
    return [cls(s) for s in input().split()]


def list2d(row, col, init_val=0) -> List[list]:
    return [[init_val] * col for _ in range(row)]


MOD = 10**9 + 7

n, k = read_n_item()
teleporter = [0] + read_n_item()

pos = 1
cycle = []
visited = [False] * (n+1)

for _ in range(k):
    cycle.append(pos)
    visited[pos] = True
    pos = teleporter[pos]
    if visited[pos]:
        break

if not visited[pos]:
    print(pos)
else:
    start = cycle.index(pos)
    cycle_len = len(cycle) - start
    end = (k - start) % cycle_len
    print(cycle[start + end])



Measured memory_bytes: 33024
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n, m;
	cin >> n >> m;
	
	vector<ll> a(n);
	ll sum = 0LL;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	
	vector< pair<ll, int> > p;
	for(int i = 0; i < m; ++i) {
		int b;
		ll c;
		cin >> b >> c;
		p.push_back( {c, b} );
	}
	
	sort(a.begin(), a.end());
	sort(p.begin(), p.end());
	
	ll ans = 0LL;
	for(int i = 0; i < n; ++i) {
		if( p.back().first <= a[i] || p.empty() ) {
			ans += a[i];
		} else {
			ans += p.back().first;
			p.back().second--;
			
			if( p.back().second == 0 ) p.pop_back();
		}
	}

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


Measured memory_bytes: 6072
function Main(input) {
	input = input.split("\n");
	input[0] = input[0].split("");
	input[1] = input[1].split("");
	input[2] = input[2].split("");
  input[0].push("#");
    input[1].push("#");
    input[2].push("#");
	var now = 0;
	var ans = "C";
  //console.log(input[now])
	while(input[now].length>0){
		switch(input[now][0]){
			case "a":
			input[now].shift();
			now = 0;
			break;
         	case "b":
			input[now].shift();
			now = 1;
			break;
			case "c":
			input[now].shift();
			now = 2;
			break;
          case "#":
            switch(now){
              case 0:
                console.log("A");
                break;
              case 1:
                console.log("B");
                break;
              case 2:
                console.log("C");
                break;
                      }
            input[now].shift();
            break;
		}
	}
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}



void smain();

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

#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


void smain() {

    ll a, b;
    cin >> a >> b;
    if (b == 1) {
        cout << "0";
        return;
    }
    ll mn = 1;
    ll mx = a - b + 1;
    cout << mx - mn;

}


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

#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define ll long long
using namespace std;

int inf = 1e18;
const int N = 5e5+5;
int mod = 1e9+7;
/*void dfs(int u,int par,int maxx)
{


    for(int v:adj[u])
    {
        if(v==par)
            continue;
        dfs(v,u,maxx);
    }
}


int ncr(int n , int r ){
	r = min(r,n-r);
	int res = 1 ;
	for(int i = 1 ; i <= r ; i++ ){
		( res *= n-i+1 )%= mod;
		res /= i ;
	}
	return res ;
}
*/
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}

ll arr[N];
ll help(int n)
{
    ll ans = 0;
    for(int i=0;i<64;++i)
    {
        int ct = 0;
        ll k = (1ll<<i);
        for(int j=0;j<n;++j)
        {
            if(arr[j]&k)
                ct++;
        }
        ans+= k%mod*ct%mod*(n-ct)%mod;
        ans%=mod;
    }
    return ans;
}
int32_t main()
{
    io
    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        int n;
        cin>>n;
        rep(i,0,n)
        cin>>arr[i];
        ll ans = help(n);
        cout<<ans%mod<<el;


    }



    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  int a[A], b[B];
  rep(i,0,A-1) cin >> a[i];
  rep(i,0,B-1) cin >> b[i];
  int mina = *min_element(a, a+A);
  int minb = *min_element(b, b+B);
  int ans = mina + minb;
  rep(i,0,M-1) {
    int x, y, c;
    cin >> x >> y >> c; x--; y--;
    ans = min(ans, a[x] + b[y] - c);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>

int main()
{
  int n, m;
  scanf("%d %d", &n, &m);
  int l = 1, r = 10e8;
  int a, b;
  for (int i = 0; i < m; ++i)
  {
    scanf("%d %d", &a, &b);
    if (l <= b && a <= r)
    {
      if (l < a) l = a;
      if (b < r) r = b;
    }
    else
    {
      puts("0");
      return 0;
    }
  }
  printf("%d\n", r - l + 1);
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(void){
	int N,score[102]={},max=0;
	string S;

	cin>>N>>S;

	REP(i,N){
		if(S[i]=='I'){
			score[i+1]=score[i]+1;
			chmax(max,score[i+1]);
		}else score[i+1]=score[i]-1;
	}

	cout<<max<<endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  bool no=true;
  if((abs(b-a)<=d&&abs(c-b)<=d)||(abs(c-a)<=d))
  { 
    no=false;
  }
  if(no){
    cout<<"No\n";
  }
  else{
    cout<<"Yes";
  }
}

Measured memory_bytes: 3572
/*
    Author - Param Kothari
    Ah shit, here we go again
*/
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    int h, a, res = 0;
    cin >> h >> a;
    if(h % a == 0){
        res = h / a;
    }
    else{
        res = h / a;
        res++;
    }
    cout << res << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Project
{
	class Card
	{
		public char mark;
		public int num;
		public Card() { }
		public Card(char mark, int num)
		{
			this.mark = mark;
			this.num = num;
		}
	}

	class MainClass
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			Card[] cards = new Card[n];
			Card[] ccards = new Card[n];
			for (int i = 0; i < n; i++)
			{
				string[] s = Console.ReadLine().Split(' ');
				cards[i] = new Card(s[0][0], int.Parse(s[1]));
				ccards[i] = new Card(s[0][0], int.Parse(s[1]));
			}
			MergeSort(ccards, 0, n);
			var sb = new StringBuilder();
			for (int i = 0; i < n; i++)
			{
				sb.Append(ccards[i].mark);
				sb.Append(":");
				sb.Append(ccards[i].num);
				if (i != n - 1)
					sb.Append(" ");
			}
			string s1 = sb.ToString();
			QuickSort(cards, 0, n - 1);
			sb = new StringBuilder();
			for (int i = 0; i < n; i++)
			{
				sb.Append(cards[i].mark);
				sb.Append(":");
				sb.Append(cards[i].num);
				if (i != n - 1)
					sb.Append(" ");
			}
			string s2 = sb.ToString();
			if (s1 == s2)
				Console.WriteLine("Stable");
			else
				Console.WriteLine("Not stable");
			foreach (Card x in cards)
			{
				Console.WriteLine("{0} {1}", x.mark, x.num);
			}
		}

		public static int Partition(Card[] c, int p, int r)
		{
			Card tmp = new Card();
			int x = c[r].num;
			int i = p - 1;
			for (int j = p; j < r; j++)
			{
				if (c[j].num <= x)
				{
					i++;
					tmp.mark = c[i].mark;
					tmp.num = c[i].num;
					c[i].mark = c[j].mark;
					c[i].num = c[j].num;
					c[j].mark = tmp.mark;
					c[j].num = tmp.num;
				}
			}
			tmp.mark = c[i + 1].mark;
			tmp.num = c[i + 1].num;
			c[i + 1].mark = c[r].mark;
			c[i + 1].num = c[r].num;
			c[r].mark = tmp.mark;
			c[r].num = tmp.num;
			return i + 1;
		}

		public static void QuickSort(Card[] c, int p, int r)
		{
			if (p < r)
			{
				int q = Partition(c, p, r);
				QuickSort(c, p, q - 1);
				QuickSort(c, q + 1, r);
			}
		}

		public static void MergeSort(Card[] a, int left, int right)
		{
			if (left + 1 < right)
			{
				int mid = (left + right) / 2;
				MergeSort(a, left, mid);
				MergeSort(a, mid, right);
				Merge(a, left, mid, right);
			}
		}
		public static void Merge(Card[] a, int left, int mid, int right)
		{
			int n1 = mid - left;
			int n2 = right - mid;
			Card[] L = new Card[n1 + 1];
			Card[] R = new Card[n2 + 1];
			for (int l = 0; l < n1; l++)
			{
				L[l] = new Card(a[left + l].mark, a[left + l].num);
			}
			for (int l = 0; l < n2; l++)
			{
				R[l] = new Card(a[mid + l].mark, a[mid + l].num);
			}
			L[n1] = new Card(' ', int.MaxValue);
			R[n2] = new Card(' ', int.MaxValue);
			int i = 0, j = 0;
			for (int k = left; k < right; k++)
			{
				if (L[i].num <= R[j].num)
				{
					a[k].mark = L[i].mark;
					a[k].num = L[i].num;
					i++;
				}
				else
				{
					a[k].mark = R[j].mark;
					a[k].num = R[j].num;
					j++;
				}
			}
		}
	}
}

Measured memory_bytes: 27844