akhauriyash/Code-Regression huggingface dataset:
/**
 *	author:   fractal
 *	timus:    288481RF
 *	created: 08/15/20 18:08:54
**/

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

#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define szc(x) (int)strlen(x)
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound 
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 1e6 + 2;
const int M = 1e5;
const int mod = 998244353;
const int inf = 2e9 + 3;
const ll INF = 1e16;

/*
	BIN POISK EBANA V ROT
	DP EBANA V ROT
	DO EBANA V ROT
*/

int n, l[N];

int main() {
	scanf("%d", &n);
	for (int i= 1; i <= n; ++i) {
		scanf("%d", &l[i]);
		//~ cerr << l[i] << " ";
	}
	int ans = 0;
	for (int i=  1; i <= n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			for (int k = j + 1; k <= n; ++k) {
				if (l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[k] + l[j] > l[i] && l[i] != l[j] && l[j] != l[k] && l[i] != l[k]) {
					ans++;
					//~ cerr << l[i] << " " << l[j] << " " << l[k] << '\n';
				}
			}
		}
	}
	printf("%d", ans);
}


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


vector<int> V = { 1,2,4,8,16,32,64 };

int main() {
	int N;
	cin >> N;
	
	if (N >= 64) {
		cout << 64 << endl;
		return 0;
	}


	for (int i = 0; i < 7; i++) {
		if (V[i] <= N && V[i + 1] > N) {
			cout << V[i] << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

const int MAXN = 4e05 + 10;
const int MAXL = 20 + 5;

int N, V, lgv = 0;
int a[MAXN];
int sec[MAXN]= {0};

int extl[MAXN][MAXL]= {0}, extr[MAXN][MAXL]= {0};
int f[2][MAXN]= {0};
bool answer[MAXN]= {false};
void work (int p, int l, int r) {
	int n = lgv - 1;
	int limit = (1 << n) - 1;
	f[p][0] = l - 1;
	for (int state = 1; state <= limit; state ++) {
		f[p][state] = l - 1;
		for (int j = 1; j <= n; j ++)
			if (state & (1 << (j - 1))) {
				int pre = f[p][state ^ (1 << (j - 1))];
				f[p][state] = max (f[p][state], f[p][state ^ (1 << (j - 1))]);
				f[p][state] = max (f[p][state], extr[pre + 1][j]);
			}
	}
}
void solve () {
	int n = lgv - 1;
	int cnt = 0;
	for (int i = 1; i <= N; i ++) {
		if (extl[i][lgv] == extl[i - 1][lgv] && extr[i][lgv] == extr[i - 1][lgv]) {
			answer[i] = answer[i - 1];
			continue;
		}
		cnt ++;
		if (cnt > lgv) {
			for (int j = 1; j <= N; j ++) answer[j] = false;
			return ;
		}
		int pl = extl[i][lgv], pr = extr[i][lgv];
		if (pl != 1) work (0, 1, pl - 1);
		if (pr != N) work (1, pr + 1, N);
		int limit = (1 << n) - 1;
		if (pl == 1 && pr == N) answer[i] = true;
		else if (pl == 1) answer[i] = f[1][limit] >= N;
		else if (pr == N) answer[i] = f[0][limit] >= pl - 1;
		else {
			for (int state = 1; state <= limit; state ++)
				if (f[0][state] >= pl - 1 && f[1][limit ^ state] >= N) {
					answer[i] = true;
					break;
				}
		}
	}
}

int getnum () {
	int num = 0;
	char ch = getchar ();
	bool isneg = false;

	while (! isdigit (ch)) {
		if (ch == '-') isneg = true;
		ch = getchar ();
	}
	while (isdigit (ch))
		num = (num << 3) + (num << 1) + ch - '0', ch = getchar ();

	return isneg ? - num : num;
}

int main () {
	// freopen ("Input.txt", "r", stdin);
	// freopen ("Output.txt", "w", stdout);

	N = getnum (), V = getnum ();
	for (int i = 1; i <= N; i ++)
		a[i] = getnum ();
	for (int s = V; s > 0; s >>= 1)
		sec[++ lgv] = s;
	sec[++ lgv] = 0;
	reverse (sec + 1, sec + lgv + 1);
	for (int l = 1; l <= lgv; l ++) {
		for (int i = 1; i <= N; i ++) {
			if (i == 1) extl[i][l] = 1;
			else extl[i][l] = a[i] - a[i - 1] <= sec[l] ? extl[i - 1][l] : i;
		}
		for (int i = N; i >= 1; i --) {
			if (i == N) extr[i][l] = N;
			else extr[i][l] = a[i + 1] - a[i] <= sec[l] ? extr[i + 1][l] : i;
		}
	}
	/*for (int l = 1; l <= lgv; l ++) {
		cout << "now: " << sec[l] << endl;
		for (int i = 1; i <= N; i ++)
			cout << extl[i][l] << ' ' << extr[i][l] << endl;
	}*/
	solve ();
	for (int i = 1; i <= N; i ++)
		answer[i] ? puts ("Possible") : puts ("Impossible");

	return 0;
}

/*
3 2
1 3 6
*/

/*
7 2
-10 -4 -2 0 2 4 10
*/

/*
16 19
-49 -48 -33 -30 -21 -14 0 15 19 23 44 52 80 81 82 84
*/

Measured memory_bytes: 52864
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    string s; cin >> s;
    set<char> set;
    rfor(c, s) set.insert(c);

    rep(i, 26) {
        if(set.count('a' + i) == 0) {
            print((char)('a' + i));
            return 0;
        }
    }
    print("None");

    return 0;
}



Measured memory_bytes: 512
/*
[agc028] D - Chords
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 300;
const int MAX_K = 300;
const ll MOD = 1e9 + 7;

int N, K;
int to[2 * MAX_N];
ll fac[2 * MAX_N + 1];
ll dp[2 * MAX_N][2 * MAX_N], dp2[2 * MAX_N][2 * MAX_N];

ll solve() {
    fac[0] = 1;
    for (int i = 1; i <= 2 * MAX_N; i++) {
        fac[i] = (fac[i - 1] * (2 * i - 1)) % MOD;
    }

    ll ans = 0;
    for (int L = 2; L <= 2 * N; L += 2) {
        for (int s = 0; s + L <= 2 * N; s++) {
            int l = s, r = s + L - 1, cnt = 0;
            bool has_out = false;
            for (int j = l; j <= r; j++) {
                if (to[j] == -1) {
                    cnt++;
                } else {
                    if (to[j] < l || r < to[j]) {
                        has_out = true;
                        break;
                    }
                }
            }
            if (has_out) {
                dp[l][r] = dp2[l][r] = 0;
                continue;
            }
            dp2[l][r] = fac[cnt / 2];
            dp[l][r] = dp2[l][r];
            for (int j = l; j < r; j++) {
                (dp[l][r] += MOD - dp2[l][j] * dp[j + 1][r] % MOD) %= MOD;
            }

            (ans += dp[l][r] * fac[N - K - cnt / 2] % MOD) %= MOD;
        }
    }

    return ans;
}

int main() {
    cin >> N >> K;
    memset(to, -1, sizeof(to));
    for (int i = 0; i < K; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a] = b;
        to[b] = a;
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 5888
#include<iostream>

using namespace std;

int A[100];
int B[100];

int main() {
    while (1) {
        int n, m;
        cin >> n >> m;
        if (n * m == 0) break;
        int sumA = 0;
        for (int i = 0; i < n; ++i) {
            cin >> A[i];
            sumA += A[i];
        }

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

        int delta = sumA - sumB;
        //cout << "sum A " << sumA << endl;
        //cout << "sum B " << sumB << endl;
        //cout << delta;

        int mini, minj, minsum = 1000;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                if ((A[i] - B[j]) * 2 == delta) {
                    if (A[i] + B[j] < minsum) {
                        minsum = A[i] + B[j];
                        mini = A[i];
                        minj = B[j];
                    }
                }
            }
        }

        if (minsum == 1000) {
            cout << -1 << endl;
            continue;
        }
        cout << mini << " " << minj << endl;
    }
}

Measured memory_bytes: 3048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) throws IOException {
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			String W = in.readLine();

			double R= Integer.parseInt(W.split(" ")[0]);


         System.out.println(R*2*3.14159);
	}

}


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

using namespace std;

int main(){
	int K,X,temp,temp1;

	scanf("%d %d",&K,&X);

	for(temp=-1000000;temp<=1000000;temp++){
		if(temp>=X-K+1 && temp<=X+K-1){
			printf("%d ",temp);
		}
	}
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){
  int W, H, N;
  cin >> W >> H >> N;
  vector<int> x(N), y(N), a(N);
  int ans[] = {0, W, 0, H};
  REP(i, N){
    cin >> x[i] >> y[i] >> a[i];
    if(a[i]==1){
      ans[0] = max(ans[0], x[i]);
    }
    else if(a[i]==2){
      ans[1] = min(ans[1], x[i]);
    }
    else if(a[i] ==3){
      ans[2]=max(ans[2], y[i]);
    }
    else{
      ans[3]=min(ans[3], y[i]);
    }
  }

  int X, Y;
  if(ans[1] < ans[0]){
    X = 0;
  }
  else{
    X = ans[1] - ans[0];
  }
  if(ans[3]< ans[2]){
    Y=0;
  }
  else{
    Y=ans[3]-ans[2];
  }
  cout << X*Y << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N =1e3;
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        double ans =0,x;
        for(int i=0;i<n;i++)
        {
            scanf("%lf",&x);
            ans +=1.0/x;
        }
        printf("%f\n",1.0/ans);
    }
    return 0;
}


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

#define LL long long

LL S;

int main()
{
	scanf("%lld", &S);
	int t = 1e9, a = S / t + (S % t == 0 ? 0 : 1), b = 1ll * a * t - S;
	printf("%d %d %d %d %d %d\n", 0, 0, t, b, 1, a);
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
num = gets.strip.split.map(&:to_i)
rec = Array.new(9,0)
for i in 0..n-1
  if num[i] < 3200
    rec[num[i]/400] += 1
  else
    rec[8] += 1
  end
end
cnt = 0
for i in 0..7
  if rec[i] > 0
    cnt += 1
  end
end
if cnt > 0
  puts [cnt,cnt+rec[8]].join(" ")
else
  puts [1,n].join(" ")
end

Measured memory_bytes: 14172
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

class APSPath
{
public:
  int solve();
};

int APSPath::solve()
{
  const int infty = 2147483647;
  
  int vn, en;
  cin >> vn >> en;

  vector<vector<int>> adj (vn, vector<int>(vn, infty));

  for ( auto i = 0; i < en; ++i )
    {
      int u, v;
      cin >> u >> v;
      cin >> adj[u][v];
    }

  for ( auto i = 0; i < vn; ++i )
    adj[i][i] = 0;
  
  for ( auto k = 0; k < vn; ++k )
    {
      for ( auto i = 0; i < vn; ++i )
        {
          for ( auto j = 0; j < vn; ++j )
            {
              if ( adj[i][j] > adj[i][k] + adj[k][j] && adj[i][k] != infty && adj[k][j] != infty )
                adj[i][j] = adj[i][k] + adj[k][j];
            }
        }
    }

  for ( auto i = 0; i < vn; ++i )
    if ( adj[i][i] < 0 )
      {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
      }

  for ( auto i = 0; i < vn; ++i )
    {
      for ( auto j = 0; j < vn; ++j )
        {
          if ( j ) cout << " ";
          if ( adj[i][j] == infty )
            cout << "INF";
          else
            cout << adj[i][j];
        }
      cout << endl;
    }
  
  return 0;
}

int main()
{
  APSPath apsp;

  apsp.solve();

  return 0;
}

Measured memory_bytes: 1260
#include <cstdio>
#include <map>
const long long mod=1e9+7;
std::map<long long,long long>dp;
long long solve(long long x){
	return (dp[x])?dp[x]:dp[x]=((solve(x/2)+solve((x-1)/2)+solve((x-2)/2)))%mod;
}
int main(){
	long long n;
	dp[0]=1,dp[1]=2;
	scanf("%lld",&n);
	printf("%lld\n",solve(n));
	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    n,k,q=map(int,input().split())
    if k-q>0:
        for i in range(n):
            print('Yes')
        sys.exit()

    a=[0 for i in range(n+1)]
    for i in range(q):
        a[int(input())]+=1
    x=k-q
    for i in range(1,n+1):
        print('Yes' if x+a[i]>0 else 'No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 4676
#include <bits/stdc++.h>
#define len(x) (int) (x.size())
using namespace std;
typedef long long ll;

int main(){
    int n, val;
    cin >> n;
    vector<bool> elem(1000001, false);
    unordered_map<int, bool> visited;
    
    for(int i = 0; i < n; i++) {
        cin >> val;
        if(visited[val] == true) {
            elem[val] = false;
            continue;
        }
        for(int j = val; j < 1000001; j += val) {
            visited[j] = true;
            if(j == val) elem[j] = true;
            else elem[j] = false;
        }
    }
    ll ans = 0;
    for(int i = 0; i < 1000001; i++) {
        if(elem[i] == true) ans++;
    }
    cout << ans << '\n';
    
    return 0;
}

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

int main()
{
    int n; cin >> n;
    int be = 1, en = 10, ans = 0;
    while (n >= en) {
        ans += en - be;
        be *= 100; en *= 100;
    }
    if (be <= n && n < en) ans += n - be + 1;
    cout << ans;
}


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

using namespace std;

int main(){
	string S; cin >> S;
	int alphabet[26] = {};
	for(int i = 0; i < S.size(); ++i){
		alphabet[S[i]-97]++;
		if(alphabet[S[i]-97] > 1){
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
}

Measured memory_bytes: 256
import copy

def calc(T):
    res = 0
    L = [0]*26
    for i in range(D):
        res += S[i][T[i]-1]
        L[T[i]-1] = i+1
        for j in range(26):
            res -= C[j]*(i+1-L[j])
    return res
    
D = int(input())
C = [int(c) for c in input().split()]
S = [[int(s) for s in input().split()] for _ in range(D)]

T = [0]*D
L = [0]*26
for i in range(D):
    p = -10**12
    for j in range(26):
        d = S[i][j]
        for k in range(26):
            if k == j:
                continue
            d -= C[k]*(i+1-L[k])
        if p < d:
            p = d
            idx = j+1
    T[i] = idx
        

p = calc(T)

for i in range(D-1, -1, -1):
    for j in range(26):
        temp = copy.deepcopy(T)
        temp[i] = j+1
        newp = calc(temp)
        if p < newp:
            T[i] = j+1
            p = newp
            
for i in range(D):
    for j in range(26):
        temp = copy.deepcopy(T)
        temp[i] = j+1
        newp = calc(temp)
        if p < newp:
            T[i] = j+1
            p = newp

for t in T:
    print(t)

Measured memory_bytes: 75108
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		 double   ld;
typedef		vector<ll>      vll;
#define     fi              first
#define     print(v)        for(ll i:v) cout<<i<<ss
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;





vll v[200010];
ll vis[200010];

ll cnt=0;
void dfs(ll u)
{
    cnt++;
    vis[u]=1;
    for(ll i:v[u])
    {
        if(!vis[i])
            dfs(i);
    }
}


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


    ll n,m;
    cin>>n>>m;
    while(m--)
    {
        ll a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }

    ll ans=-1;

    for(ll i=1; i<=n; i++)
    {
        cnt=0;
        if(!vis[i])
            dfs(i);
        ans=max(ans,cnt);
    }

    cout<<ans<<nn;





}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






Measured memory_bytes: 22336
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef double dd;
const int MOD = 1e9 + 7;

void solve(){
 string s;
 cin >> s;
 if(s.back() == 's')
   s += "es";
 else
   s += "s";
 cout << s << endl;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1, tt = 0;
  //cin >> t;
  while(t--){
    //tt++;
    //cout << "Case #" << t << ": ";
    solve();
  }
  return 0;
}


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

int main()
{
    int A, B, ans;
    cin >> A >> B;
    if (A <= 2 * B)
    {
        ans = 0;
    }
    else
    {
        ans = A - 2 * B;
    }

    cout << ans << endl;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  ll n;cin>>n;
  ll m=n;
  ll i;
  vector<int> prims(1000001,0);
  for(i=2;i*i<=n;i++)
  {
    while(m%i==0)
    {
      m/=i;
      prims[i]++;
    }
  }
  int ans=0;
  rep(i,prims.size())
  {
    int cost=1;
    while(prims[i]>=cost)
    {
      prims[i]-=cost;
      ans++;
      cost++;
    }
  }
  if(m>1)ans++;
  cout<<ans<<endl;
}


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

int main(){
  ll k,a,b,c;
  cin>>k>>a>>b;
  if(b-a<3 || k<=a){
    cout<<k+1<<endl;
    return 0;
  }
  c=k-a+1;
  cout<<a+(c/2)*(b-a)+(c%2)<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

bool isPrime(int n){
  if(n == 1 || n % 2 == 0) return false;
  for(int i = 3;i*i <= n;i+=2){
    if(n % i == 0)return false;
  }
  return true;
}
void solve() {
     int n;
     int count = 0;
     cin >> n;
     for(int i = 3; i <= n;i += 2){
        int a = 3;
        int c = i;
        map<int,int> m;
        while(c >= a*a){
          if(c % a == 0){
            c /= a;
            m[a]++;
          }else{
            a++;
          }
        }
        m[c]++;
        int dc = 1;
        for(auto it = m.begin();it != m.end();it++){
          dc *= it->second + 1;
        }
        if(dc == 8)count++;
     }
     P(count);    
}

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


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

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, m; cin >> n >> m;
	vector<pair<int, int>> v(m);
	rep(i, 0, m - 1)
	{
		int a, b; cin >> a >> b;
		v[i] = { b,a };
	}
	sort(all(v));
	int r = v[0].first - 1;
	int cnt = 1;
	rep(i, 1, m - 1)
	{
		int b = v[i].first, a = v[i].second;
		if (a <= r)continue;
		else
		{
			++cnt;
			r = b - 1;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1024
'use strict'
function main(input) {
    const tmp = input.split(' ');
    const W = parseInt(tmp[0], 10);
    const H = parseInt(tmp[1], 10);
    const x = parseInt(tmp[2], 10);
    const y = parseInt(tmp[3], 10);

    const area = W * H / 2;
    console.log(area);
    if (x === W / 2 && y === H / 2) {
        console.log('1');
    } else {
        console.log('0');
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	vector<pair<int, int>> a(n);
	for (auto &t : a) {
		cin >> t.second >> t.first;
	}
	sort(a.begin(), a.end());
	int c = 0;
	for (auto t : a) {
		c += t.second;
		if (c > t.first) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,h,w,r,c;
long long a,res;
pair<long long,pair<int,int> > es[100100];
int fa[200100],full[200100];
int gf(int x){return ((x==fa[x])?(x):(fa[x]=gf(fa[x])));}
bool join(int x,int y){
	x=gf(x),y=gf(y);
	if(x==y){
		if(full[x]) return false;
		full[x]=1;
		return true;
	} 
	if(full[x]&&full[y]) return false;
	full[x]=full[y]=(full[x]|full[y]);
	fa[x]=y;
	return true;
}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>h>>w;
	for(int i=1;i<=h+w;i++) fa[i]=i;
	for(int i=1;i<=n;i++){
		cin>>r>>c>>a;
		c+=h; 
		es[i]=make_pair(a,make_pair(r,c));
	}
	sort(es+1,es+n+1);
	reverse(es+1,es+n+1);
	for(int i=1;i<=n;i++){
		if(join(es[i].second.first,es[i].second.second)){
			res+=es[i].first;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<PII> v(N);
  rep(i,N){
    int x,y;cin >> x >> y;
    v[i].first = x - y;
    v[i].second = x + y;
  }
  sort(all(v));
  int r = -1e9  - 100;
  int num = 0;
  rep(i,N){
    if(r > v[i].first){
      --num;
      r = min(r,v[i].second);
    }else r = max(r,v[i].second);
  }
  cout << N + num << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());

        int max = M / N;
        int ans = 0;
        for (int n = max ; n >= 0 ; n--) {
            if (M % n == 0) {
                System.out.println(n);
                return;
            }
        }
    }
}


Measured memory_bytes: 25300
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll n;
cin>>n;
string s;
cin>>s;
for(int i=0;i<s.length();i++){
s[i]=s[i]+n;
if(s[i]>90){
s[i]=64+(s[i]-90);}
}
cout<<s<<endl;
}

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

#include <math.h>
#include <stdlib.h>


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

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_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll N, K;
    cin >> N >> K;
    ll ans;

    if(K == 0){
        cout << N * N << endl;
        return 0;
    }

    for(ll b = K+1; b<=N; b++){
        ll cnta = (b - K)*(N/b);
        if(N%b > K-1){
            cnta += (N%b-K+1);
        }
        ans += cnta;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())

Y = [list(map(int, input().split())) for _ in range(n)]

ans = []

for i in range(2**n):
    _x = [0] * (m+1)
    _x[0] = x
    _ans = 0
    for j in range(n):
        if (i >> j) & 1:
            for k in range(m):
                _x[k+1] += Y[j][k+1]
            _ans += Y[j][0]
    if min(_x) == x:
        ans.append(_ans)


if len(ans) == 0:
    print(-1)
else:
    print(min(ans))


Measured memory_bytes: 68496
#include <bits/stdc++.h>
using namespace std;
const int BIT=1<<20;
const int PAY=1e10;

int main(){
  int N, M, X;
  cin>>N>>M>>X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  for(int i=0;i<N;i++){
    cin>>C.at(i);
    for(int j=0;j<M;j++){
      cin>>A.at(i).at(j);
    }
  }
  
  int min_pay=PAY;
  int b=(1<<N);
  for(int mask;mask<b;mask++){
    vector<int> skill(M, 0);
    int pay=0;
    for(int book=0;book<N;book++){
      if(mask>>book&1){
        pay+=C.at(book);
        for(int s=0;s<M;s++){
          skill.at(s)+=A.at(book).at(s);
        }
      }
    }
    
    bool complete=true;
    for(int s=0;s<M;s++){
      if(skill.at(s)<X){
        complete=false;
        break;
      }
    }
    if(complete){
      if(min_pay>pay){
        min_pay=pay;
      }
    }
  }
  if(min_pay==PAY){
    cout<<"-1"<<endl;
  }
  else{
    cout<<min_pay<<endl;
  }
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
	int n,t,a;
	cin >> n >> t >> a;
	int H[n];
	for(int i=1; i<=n; i++)
		cin >> H[i];

	double tem[n], tmp;
	for(int i=1; i<=n; i++)
		tem[i] = t - H[i] * 0.006;
	
	int index=1;
	double min = abs(tem[1] - a);

	//cout << min << endl;

	for(int i=2; i<=n; i++){
		tmp = abs(tem[i] - a);
		if(min > tmp){
			min = tmp;
			index = i;
		}
	}
	cout << index << endl;




}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<random>
#include<stack>
#include<queue>
#include<cassert>
using namespace std;
int inf = 1000000000;

char bef(char c, int n){
  string alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

  for(int i=0; i<alp.size(); i++){
    if( alp[i] == c ){
      if( i - n < 0 ) i += 52;
      return alp[i-n];
    }
  }
  return c;
}

int main(void) {

  int n;
  while(cin >> n){
    if( n == 0 ) break;
    vector<int> k(n);
    for(int i=0; i<n; i++) cin >> k[i];
    string s;
    cin >> s;

    string ans = "";
    for(int i=0; i<s.size(); i++){
      ans += bef(s[i], k[i%n]);
    }
    cout << ans << endl;
  }




  return 0;
}

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

int main(void)
{
    int N, M;
    cin >> N >> M;
    vector<int> v[2];

    for (int i = 0; i < M; i++)
    {
        int s, c;
        cin >> s >> c;
        v[0].push_back(s);
        v[1].push_back(c);
    }

    for (int i = 0; i <= 999; i++)
    {
        bool false_flag = 0;
        string i_str = to_string(i);
        if (i_str.size() != N)
            continue;

        for (int j = 0; j < M; j++)
        {
            int digits = v[0][j] - 1;
            char value = v[1][j] + '0';
            if (i_str[digits] != value)
            {
                false_flag = 1;
                break;
            }
        }

        if (false_flag == 1)
        {
            continue;
        }
        else
        {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

signed main(void){
    int N,K,a;
    vector<int> A;
    cin >> N >> K;
    REP(i,N){
        cin >> a;a--;
        A.push_back(a);
    }
    
    vector<int> history;
    vector<int> visited(N,-1);
    
    int now=0;
    history.push_back(0);
    visited[0]=0;
    
    int c=0;
    while(1){
        c++;
        now = A[now];
        history.push_back(now);
        if(visited[now]==-1){
            visited[now]=c;
        }else{
            break;
        }
    }
    
    #if debug
    REP(i,history.size()){
        cout << history[i]+1 << " ";
    }cout << endl;
    REP(i,visited.size()){
        cout << visited[i] << " ";
    }cout << endl;
    #endif
    
    int H = history.size();
    int p1 = visited[history[H-1]];
    int p2 = c;
    
    //cout << p1 MM p2 << endl;
    
    if(K<=p1){
        cout << history[K]+1;
    }else{
        cout << history[p1+((K-p1)%(p2-p1))]+1 << endl;
    }
    
    return 0;
}




Measured memory_bytes: 9576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		System.out.println((a*b)%2==1 ? "Odd":"Even");
	}

}

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

signed main(){
	int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int> r;
    vector<int> w;
    for(int i=0;i<n;i++){
    	if(s[i]=='W') w.push_back(i);
	}
    for(int i=n-1;i>=0;i--){
    	if(s[i]=='R') r.push_back(i);
	}
	int ans=0;
	int m=min(r.size(),w.size());
	for(int i=0;i<m;i++){
    	if(w[i]<r[i]) ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4520
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int MOD = 1e9 + 7;

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

vector<vector<int>> d(410, vector<int>(410, MOD));

void warshall_floyd(int n) {
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				//cout << d[i][j] << endl;
			}
		}
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(m + 1), b(m + 1), c(m + 1);
	for (int i = 1; i <= m; i++) {
		cin >> a[i] >> b[i] >> c[i];
		d[a[i]][b[i]] = -c[i];
	}

	warshall_floyd(n);
		
	cout << abs(d[0][n - 1]) << endl;
}


Measured memory_bytes: 3568
#include <stdio.h>

int main(int argc, char const *argv[]) {
	char str[101];
	int n, m;

	fgets(str, 100, stdin);
	sscanf(str, "%d\n", &n);

	int i;

	for (i = 0; i <= n; i += 4) {
		if ((n - i) % 7 == 0) {
			printf("Yes\n");
			// printf("%d %d \n", n, i);
			return 0;
		}
	}

	printf("No\n");

	return 0;
}


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

int s[100000];
int t[50000];

bool binary_search(int n_size, int target) {
  int head = 0, tail = n_size;
  while(head < tail) {
    int mid = (head + tail) / 2;
    if(s[mid] == target) {
      return true;
    }
    else if(target < s[mid]) {
      tail = mid;
    }
    else {
      head = mid + 1;
    }
  }
  return false;
}


int main() {
  int n, q;

  // input
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  cin >> q;
  for(int i = 0; i < q; ++i) {
    cin >> t[i];
  }

  int cnt = 0;
  // binary serach
  for(int i = 0; i < q; ++i) {
    if(binary_search(n, t[i])) cnt++;
  }
  cout << cnt << endl;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

    int a, b, n;
    while(cin >> a >> b >> n) {
        int cur = 0;
        rep(i, n) {
            a *= 10;
            cur += (a / b) % 10;
            a %= b;
        }
        cout << cur << endl;
    }
    return 0;
}


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

int main(){
	int max = 0;
	int a;
	int b[20];
	int c[20];
	int d[20];
	cin >> a;
	if(a!=1){
	for(int i = 0;i<a;i++){
		cin >> b[i];
	}
	for(int i = 0;i<a;i++){
		cin >> c[i];
	}
	for(int i = 0;i<a;i++){
		d[i] = b[i]-c[i];
	}
	sort(d,d+a);
	for(int i = 0;i<a;i++){
			if(0 <= d[i]){
				max += d[i];
			}
		}
		cout << max; 
	}

else{
	cout << 0;
}
return 0;
}

Measured memory_bytes: 256
import numpy as np

H, W, M = map(int, input().split())
h = np.zeros(H)
w = np.zeros(W)
m = {}
flag = 0

for _ in range(M):
    tmp_h, tmp_w = map(int, input().split())
    h[tmp_h-1] += 1
    w[tmp_w-1] += 1
    m[(tmp_h-1, tmp_w-1)] = 1.

h_max = np.max(h)
h_max_index = list(zip(*np.where(h == h_max)))
w_max = np.max(w)
w_max_index = list(zip(*np.where(w == w_max)))

for i in h_max_index:
    for j in w_max_index:
        if (i[0], j[0]) not in m.keys():
            flag = 1
            break

if flag == 1:
    print(int(h_max + w_max))
else:
    print(int(h_max + w_max - 1))


Measured memory_bytes: 134376
#include <iostream>
typedef long long ll;
using namespace std;

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

  ll N; cin >> N;

  for(ll n = 1; n <= 3500; ++n)  {
    for(ll w = 1; w <= 3500; ++w) {
      ll numer = N*n*w;
      ll denom = 4*n*w - N*n - N*w;
      if(numer > denom && denom > 0 && numer%denom == 0) {
        cout << numer/denom << " " <<  n << " " <<  w << '\n';
        return 0;
      }
    }
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int v, e;
vector<int> G[10000];
int in[10000];
vector<int> ans;

int main() {
  cin >> v >> e;
  REP(i, e) {
    int s, t;
    cin >> s >> t;
    G[s].push_back(t);  // s -> t
    in[t]++;
  }
  queue<int> que;
  REP(i, v) {
    if (in[i] == 0) que.push(i);
  }
  while (que.size()) {
    int p = que.front();
    que.pop();
    ans.push_back(p);
    REP(i, G[p].size()) {
      int q = G[p][i];
      in[q]--;
      if (in[q] == 0) que.push(q);
    }
  }
  REP(i, ans.size()) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 3940
/*
    Author : Ritesh Singh
*/
 
#include <bits/stdc++.h>
using namespace std;
#define lct long long int t;cin>>t;while(t--)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define el '\n'
#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL)
const int mod = 1e9+7;
typedef long long ll;


int32_t main()
{
    IOS;
    int n, x, t;
  	cin >> n >> x >> t;
  	if(n%x == 0)
      t*=(n/x);
  	else
      t *= (n/x+1);
  	cout<<t<<endl;
}



Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	static long mod = 1_000_000_007;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt(), K = in.nextInt();
		
		long dp[][] = new long[N + 1][K + 1];
		for ( int n = 0; n <= N; n++ ) {
			dp[n][0] = 1;
		}
		
		int a[] = new int[N + 1];
		for ( int n = 1; n <= N; n++ ) {
			a[n] = in.nextInt();
			for ( int k = 1; k <= K; k++ ) {

				dp[n][k] = (dp[n][k - 1] + dp[n - 1][k]);
				if ( a[n] < k ) {
					dp[n][k] -= dp[n - 1][k - a[n] - 1];
				}
				dp[n][k] %= mod;
			}
		}
		System.out.println((dp[N][K] + mod) % mod);
		in.close();
	}
}

Measured memory_bytes: 125268
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 200009
//<<fixed << setprecision(9)
int fen[2][space]; // 0H,1V // MIN
int n;

int get(int f,int pos)
{
    int d = (n-1)-pos;
    pos = 1+d;
    int mn=1e9;
    for(int i=pos;i>0;i-=i&(-i)) mn=min(mn,fen[f][i]);

    return mn;
}
void update(int f, int pos, int val)
{
    int d = (n-1)-pos;
    pos = 1+d;
    for(int i=pos;i<=n-2;i+=i&(-i)) fen[f][i]=min(fen[f][i],val);
}

int main()
{
    int i,j,t;
    boost;

    cin>>n>>t;
    rep(i,0,n+1) fen[0][i]=fen[1][i]=n;

    ll black = (n-2ll)*(n-2ll);
    while(t--)
    {
        int type,x;
        cin>>type>>x;
        if(type==1)
        {
            int till = get(0,x);
            black-= till-2;
            update(1,till-1,x);
            // db<<till<<'\n';
        }
        else
        {
            int till = get(1,x);
            black-= till-2;
            update(0,till-1,x);
            // db<<till<<'\n';
        }
    }

    cout<<black;

    return 0;
}

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

using namespace std;

struct Union_Find {
	int par[100000], rank[100000];
	void init(int n) {
		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}

	int find(int n) {
		if (par[n] == n) return n;
		return par[n] = find(par[n]);
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}

	void unite(int x, int y) {
		if (same(x, y)) return;
		x = find(x);
		y = find(y);
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			rank[x] += rank[x] == rank[y];
		}
	}
};

int point[100000];

void hawawa()
{
	int n, m, num = 0;
	cin >> n >> m;
	vector<int> p(n);
	for (auto&& i : p) {
		cin >> i;
		i--;
		point[i] = num;
		num++;
	}
	Union_Find uf;
	uf.init(n);
	while (m--) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		uf.unite(a, b);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (uf.same(i, point[i])) {
			ans++;
		}
	}
	cout << ans << "\n";
}

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


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10000)
dp = {}
def lucas(n):
    if n in dp:
        return dp[n]
    if n == 0:
        dp[n] = 2
        return dp[n]
    if n == 1:
        dp[n] = 1
        return dp[n]
    dp[n] =  lucas(n-1)+lucas(n-2)
    return dp[n]
N = int(input())
print(lucas(N))

Measured memory_bytes: 3060
using System;

namespace Solution
{
    class Problem
    {
        internal class Rearrange
        {
        
        internal void Execute()
        {
        int rowCount = 0, columnCount = 0;

            while (true)
            {
                //Console.WriteLine("Pease enter the rows and columns seperated by a space: ");
                string[] line = Console.ReadLine().Split(' ');

                if (line.Length > 1 && int.TryParse(line[0], out rowCount) && int.TryParse(line[1], out columnCount))
                {
                    if (rowCount == 0 && columnCount == 0)
                        break;

                    // We can only re-arrange if their are even number of students because swapping requires pairs
                    // If row*column is even that means number of students are even
                    Console.WriteLine((rowCount * columnCount % 2 == 0) ? "yes" : "no");
                }
            }
        }
        }
        
        static void Main(string[] args)
        {
            new Rearrange().Execute();
        }
    }
}


Measured memory_bytes: 15968
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int n,m; cin>>n>>m;
  vector<int> d(n,-1);
  bool f=0;
  rep(i,m){
    int s,c; cin>>s>>c;
    s--;
    if(d[s]==-1)
    d[s]=c;
    else if(d[s]!=c)
    f=1;
  }
  if(f||(d[0]==0&&n>1))
  cout<<-1<<endl;
  else{
    if(d[0]==-1&&n!=1) d[0]=1;
    rep(i,n){
      if(d[i]==-1) d[i]=0;
      cout<<d[i];
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 100005
#define pb push_back
#define mp make_pair
#define pii pair<long long,long long>
#define read(a) scanf("%d",&a)
#define p1(a) cout<<"Check "<<a<<endl;
#define p2(a,b) cout<<"Check "<<a<<' '<<b<<endl;
#define p3(a,b,c) cout<<"Check "<<a<<' '<<b<<' '<<c<<endl;
#define fo(i,n) for(i=0;i<n;i++)
#define ll long long
#define clr(a) memset(a,0,sizeof(a))
#define MOD 10000000000
#define INF 10000000000000;

using namespace std;

int main()
{
    int n,m;
    cin>>n;
    int ar[n+5][4];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            scanf("%d",&ar[i][j]);
        }
    }
    for(int i=1;i<n;i++){
        ar[i][0]+=max(ar[i-1][1],ar[i-1][2]);
        ar[i][1]+=max(ar[i-1][0],ar[i-1][2]);
        ar[i][2]+=max(ar[i-1][0],ar[i-1][1]);
    }
    cout<<max(ar[n-1][0],max(ar[n-1][1],ar[n-1][2]));

    return 0;
}



Measured memory_bytes: 1792
#include <iostream>

//2つの円の状態を調べる関数
int check_two_circles(const double xa, const double ya, const double ra,
					  const double xb, const double yb, const double rb);

int main(){
	
	int count;
	std::cin >> count;
	
	for(int i = 0; i < count; ++i){
		double xa, ya, ra, xb, yb, rb;
		std::cin >> xa >> ya >> ra
				 >> xb >> yb >> rb;
		
		std::cout << check_two_circles(xa, ya, ra, xb, yb, rb) << std::endl;
	}
	
	return 0;
}

int check_two_circles(const double xa, const double ya, const double ra,
					  const double xb, const double yb, const double rb){
	
	const double square_dist = (xa-xb)*(xa-xb)+(ya-yb)*(ya-yb);
	
	//(xa-xb)^2 + (ya-yb)^2 > (ra+rb)^2 ならば2つの円は重ならず離れている
	if(square_dist > (ra+rb)*(ra+rb)) return 0;
	//(xa-xb)^2 + (ya-yb)^2 < (ra-rb)^2 ならば片方の円がもう片方の中にある
	else if(square_dist < (ra-rb)*(ra-rb)){
		if(ra > rb) return 2;
		else return -2;
	}
	//いずれでもない場合，AとBは交わっている
	else return 1;
	
}

Measured memory_bytes: 1232
#include <cstdio>
using namespace std; 
int main() {
  short a, b, c; 
  scanf("%hd %hd %hd", &a, &b, &c); 
  printf("%hd", c); 
  printf("%s", " "); 
  printf("%hd", a); 
  printf("%s", " "); 
  printf("%hd\n", b); 
}

Measured memory_bytes: 1728
//InTheNameOfGod
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn =1e5+5;
int n,a[maxn],s=0,cnt,p,re=0;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    rep(i,0,n)
    {
        cin>>a[i];
    }
    while(true)
    {
        cnt=0;
        s=0;
        p=0;
        rep(i,0,n)
        {
            if(a[i]&1)
            {
                cnt++;
                p=a[i];
            }
            else
            {
                s^=1;
            }
        }
        if(s)
        {
            break;
        }
        else if(cnt>1||p==1)
        {
            re^=1;
            break;
        }
        else
        {
            int g=0;
            rep(i,0,n)
            {
                if(a[i]&1)
                {
                    g=__gcd(a[i]-1,g);
                    a[i]--;
                }
                else g=__gcd(a[i],g);
            }
            rep(i,0,n)
            {
                a[i]/=g;
            }
            re^=1;
        }
    }
    if(re)
    {
        cout<<"Second";
    }
    else cout<<"First";
    return 0;
}


Measured memory_bytes: 640