akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)

vector<size_t> primeNum(){
    const size_t n = (123456 + 1)*2;
    vector<bool> is_prime(n,true);
    vector<size_t> primeCnt(n,0);

    is_prime[0] = is_prime[1] = false;
    for(int i=0;i*i<n;i++){
        if(is_prime[i] == false) continue;
        for(int j=i*2;j<n;j+=i){
            is_prime[j] = false;
        }
    }

    for(int i=0;i<n;i++){
        if(is_prime[i]) primeCnt[i]++;
    }
    for(int i=1;i<n;i++){
        primeCnt[i] += primeCnt[i-1];
    }

    return primeCnt;
}

int main(){
    vector<size_t> primeCnt = primeNum();
    size_t n;
    while(cin >> n, n != 0){
        cout << primeCnt[2*n] - primeCnt[n] << endl;
    }
}


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

bool f(int n) {
  if (n == 0) return true;
  else if (n < 0) return false;
  return f(n-4) | f(n-7);
}

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

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int N,A[300001],num[300001]={};
ll maxlen[300001];//maxlen[X]:X個の列を取り出すときの最大の長さ
ll kDksum[300001]={};
ll Dkbacksum[300001]={};
int main(){

	scan(N);
	rep(i,N){
		scan(A[i]);
		num[A[i]]++;
	}
	vint kazu;
	rep1(i,N) if(num[i]>0) kazu.push_back(num[i]);
	sort(ALL(kazu));
	map<ll,ll> kazukazu;
	ll kazusum=0;
	rep(j,kazu.size()){
		kazusum+=kazu[j];
		kazukazu[kazu[j]]++;
	}

	rep(j,N+1){
		kDksum[j+1]=kDksum[j]+j*kazukazu[j];
	}

	brep(j,N){
		Dkbacksum[j]=Dkbacksum[j+1]+kazukazu[j+1];
	}
	rep1(i,N){
		maxlen[i]=-((kDksum[i+1]+i*Dkbacksum[i])/i);//後でupperboundするので負にしてる
	}
	rep1(K,N){
		int ans=upper_bound(maxlen+1,maxlen+N+1,-K)-maxlen-1;
		prin(ans);
	}
	return 0;
}


Measured memory_bytes: 29684
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int a, b;
int main() {
	scanf("%d %d", &a, &b);
	if (a <= 12)
		b /= 2;
	if (a <= 5)
		b = 0;
	printf("%d\n", b);
}

Measured memory_bytes: 128
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define endl '\n'
#define forci(p,q) for(int i=p;i<q;i++)
ll power(ll a, ll b) {a %= mod;  ll res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll fact[8999997]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<8999997;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
using namespace std;
int solve()
{
	facto();
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n=s.length();
	int ans=0;
	for(int i=0;i<=k;i++){
		int x=power(26,i);
		int y=power(25,k-i);
		int z=ncr(n+k-i-1,n-1);
		int temp=(x*y)%mod;
		temp=(temp*z)%mod;
		ans=(ans+temp)%mod;
	}	
	cout<<ans;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}

Measured memory_bytes: 74552
#include <stdio.h>

int map[10][10] = {0};

void fill(int x,int y){
    if(x>=0 && x<10 && y>=0 && y<10){
        map[x][y]++;
    }
}
void fills(int x,int y,int s){
    fill(x,y);
    fill(x+1,y);
    fill(x-1,y);
    fill(x,y+1);
    fill(x,y-1);
    if(s >= 2){
        fill(x+1,y+1);
        fill(x-1,y+1);
        fill(x+1,y-1);
        fill(x-1,y-1);
    }
    if(s >= 3){
        fill(x+2,y);
        fill(x-2,y);
        fill(x,y+2);
        fill(x,y-2);
    }
}
int main(){
    int x,y,size;
    while(scanf("%d,%d,%d\n",&x,&y,&size) > 0){
        fills(x,y,size);
    }
    int i,j;
    int ans = 0;
    int max = 0;
    for(i=0;i<10;i++){
        for(j=0;j<10;j++){
            if(map[i][j] == 0)
                ans++;
            if(max < map[i][j]){
                max = map[i][j];
            }
        }
    }
    printf("%d\n%d\n",ans,max);
    return 0;
}

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int dp[5005][5005];

signed main() {
	int n, ans = 0;
	string s;
	cin >> n >> s;
	for (int i = n - 1; i >= 0; i--) {
		for (int j = n - 1; j >= 0; j--) {
			if (s[i] == s[j]) {
				dp[i][j] = dp[i + 1][j + 1] + 1;
			}
			else dp[i][j] = 0;
		}
	}
	rep(i, n) {
		rep(j, n) {
			ans = max(ans, min(dp[i][j], abs(i - j)));
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 195712
#include<bits/stdc++.h>
using namespace std;
int n,k,val[100005];
vector<int> g[100005];
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq;
int main()
{
	cin>>n;
	for(int i=1;i<=n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	memset(val,-1,sizeof(val));
	cin>>k;
	for(int i=1;i<=k;i++)
	{
		int v,p;
		cin>>v>>p;
		val[v]=p;
		pq.push(make_pair(p,v));
	}
	while(!pq.empty())
	{
		pair<int,int> p=pq.top();
		pq.pop();
		for(int i=0;i<g[p.second].size();i++)
			if(val[g[p.second][i]]==-1)
			{
				val[g[p.second][i]]=val[p.second]+1;
				pq.push(make_pair(val[g[p.second][i]],g[p.second][i]));
			}
	}
	for(int i=1;i<=n;i++)
		for(int j=0;j<g[i].size();j++)
			if(abs(val[g[i][j]]-val[i])!=1)
			{
				cout<<"No"<<endl;
				return 0;
			}
	cout<<"Yes"<<endl;
	for(int i=1;i<=n;i++)
		cout<<val[i]<<endl;
	return 0;
}


Measured memory_bytes: 7924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

typedef tuple<int, int, int> T;

int main(){
    int N, Q; cin >> N >> Q;
    vector<T> xlr(N);
    for(int i=0; i<N; ++i){
        int l, r, x; cin >> l >> r >> x;
        l -= x; r -= x;
        xlr[i] = make_tuple(x, l, r);
    }
    sort(xlr.begin(), xlr.end());

    set<pair<int, int>> se;
    vector<int> ans(Q, -1);

    for(int i=0; i<Q; ++i){
        int d; cin >> d;
        se.insert(make_pair(d, i));
    }

    for(int i=0; i<N; ++i){
        int x, l, r;
        tie(x, l, r) = xlr[i];
        auto itr = se.lower_bound(make_pair(l, -1));
        while(itr != se.end()){
            if(itr->first >= r) break;
            ans[itr->second] = x;
            se.erase(itr++);
        }
    }

    for(auto e:ans) cout << e << endl;


    return 0;
}

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

int main()
{
    int N, L;
    cin >> N >> L;

    int sum = 0;
    int diff = 200000;

    rep(i, N) {
        int a = L + i + 1 - 1;
        sum += a;
        if (abs(a) < abs(diff)) {
            diff = a;
        }
    }

    cout << sum - diff << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    private static int type = 26;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int d = Integer.parseInt(scan.next());
        int[] c = new int[type];
        for (int i = 0; i < type; i++) {
            c[i] = Integer.parseInt(scan.next());
        }
        int[][] s = new int[d][type];
        for (int i = 0; i < d; i++) {
            for (int j = 0; j < type; j++) {
                s[i][j] = Integer.parseInt(scan.next());
            }
        }
        int[] t = new int[d];
        for (int i = 0; i < d; i++) {
            t[i] = Integer.parseInt(scan.next());
        }
        scan.close();

        for (int i = 0; i < d; i++) {
            t[i]--;
        }
        // 前のコンテスト開催日
        int[] prevContest = new int[type];
        Arrays.fill(prevContest, -1);
        long score = 0;

        for (int i = 0; i < d; i++) {
            score += s[i][t[i]];
            prevContest[t[i]] = i;
            for (int j = 0; j < type; j++) {
                score -= c[j] * (i - prevContest[j]);
            }
            System.out.println(score);
        }
    }

}

Measured memory_bytes: 42060
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=1e6+5,MAX=3e7,MOD=1e9+7;
 
using namespace std;
 
int n,S;
pair<int,int>a[N];
ll memo[105][100005];
ll solve(int indx ,int rem){

	 if(indx == n){

	 	 if(rem == 0)return 0;
	 	 return 1e15;
	 }

	 ll &ret = memo[indx][rem];

	 if(ret !=-1 )return ret;


	 ret =  a[indx].first + solve(indx+1,rem - a[indx].second);

	 ret = min(ret , solve(indx+1,rem) );

	 return ret;
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //#ifndef ONLINE_JUDGE
      //freopen("test.txt","r",stdin);
    //#endif

      scanf("%d %d",&n,&S);


      for(int i=0;i<n;i++)scanf("%d %d",&a[i].first,&a[i].second);

       memset(memo,-1,sizeof(memo));
       
      for(int i=1e5;i>=0;i--){

      	 if(solve(0,i)<=S)return !printf("%d\n",i );
      }
     
}

Measured memory_bytes: 84224
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define PI 3.1415926535897932384626433832795
#define pii pair <int, int>
#define pb push_back
#define ll long long
#define ss second
#define ff first
#define N 200010

using namespace std;

int n;
int v[N];
int s[N];

int main()
{
	cin >> n;
	
	for(int i = 1; i <= n; i++)
		cin >> v[i], s[i] = v[i];
	
	sort(s+1, s+n+1);
	
	for(int i = 1; i <= n; i++) {
		if(v[i] <= s[n/2])
			cout << s[n/2+1] << "\n";
		else
			cout << s[n/2] << "\n";
	}
}

Measured memory_bytes: 3712
#include <iostream>

using namespace std;
int n;
int main(){
    cin >> n;
    int cnt = 1;
    if (n % 2 == 0) cout << -1;
    else{
        int sum = 7;
        while (cnt <= 1e7 && sum % n > 0){
            cnt++;
            sum = (sum * 10 + 7) % n;
        }
        if (cnt > 1e7) cout << -1; else cout << cnt;
    }
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' ) {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }

  
}

Measured memory_bytes: 3632
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
point = 0
for i in range(N):
    point += B[A[i]-1]
    if i+1 < N and A[i]+1 == A[i+1]:
        point += C[A[i]-1]
print(point)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const int dy[4] = {0, 0, -1, 1};
const int dx[4] = {-1, 1, 0, 0};
int main(void) {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }
  queue<pair<int, int> > q;
  vector<vector<int> > dist(h, vector<int>(w, -1));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == '#') {
        q.push(make_pair(i, j));
        dist[i][j] = 0;
      }
    }
  }
  int ans;
  while (!q.empty()) {
    pair<int, int> pos = q.front();
    int cur_y = pos.first;
    int cur_x = pos.second;
    q.pop();
    ans = dist[cur_y][cur_x];
    for (int dir = 0; dir < 4; dir++) {
      int next_y = cur_y + dy[dir];
      int next_x = cur_x + dx[dir];
      if (next_y < 0 || next_y >= h || next_x < 0 || next_x >= w) continue;
      if (dist[next_y][next_x] >= 0) continue;
      q.push(make_pair(next_y, next_x));
      dist[next_y][next_x] = dist[cur_y][cur_x] + 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 13456
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, a[222222], b[222222];

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

  std::cin >> N;

  for (int i = 1; i <= N; i ++)
    std::cin >> a[i];

  std::vector<int> c;

  for (int i = N; i >= 1; i --) {
    if (i + i > N) {
      if ((b[i] = a[i]))
        c.push_back(i);
    }
    else {
      int x = 0;
      
      for (int j = i + i; j <= N; j += i) {
        assert(b[j] >= 0);

        x ^= b[j];
      }

      if ((b[i] = (x ^ a[i])))
        c.push_back(i);
    }
  }

  std::sort(ALL(c));

  std::cout << c.size() << std::endl;

  if (! c.empty()) {
    for (const auto& i : c)
      std::cout << i << ' ';
    std::cout << std::endl;
  }

  return 0;
}


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


int main(){
	string right("yuiophjklnm");
	string input;
	while(cin >> input, input != "#"){
		int count = 0;
		int shefting = 0;

		for(int i=0; i < input.length(); i++){
			bool isRight = false;
			for(int j=0; j < right.length(); j++){
				if(input[i] == right[j]){
					isRight = true;
					break;
				}
			}
			if(isRight && shefting != 1){
				isRight = false;
				shefting = 1;
				count++;
			}
			else if(!isRight && shefting != 2){
				shefting = 2;
				count++;
			}
		}
		cout << count-1 << endl;
	}
}

Measured memory_bytes: 1188
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	int n;
	int P[105][105]={};

	cin>>n;

	for(int i=0;i<n;i++){
		int x;cin>>x;
		
		int y;cin>>y;
		for(int j=0;j<y;j++){
			int Y;
			cin>>Y;
			Y;
			P[x][Y]=1;
		}

	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)
			{if(j>1)cout<<" ";
				cout<<P[i][j];
		}
		cout<<endl;
	}

	return 0;
}
				

Measured memory_bytes: 1212
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<stdlib.h>
#include<queue>
#include<vector>
#include<list>
using namespace std;
int mp[111][111];
int main ()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<111;i++)
        for(int j=0;j<111;j++)
            mp[i][j]=0;
    for(int i=1;i<=n;i++)
    {
        int u,v;
        scanf("%d %d",&u,&v);
        for(int j=1;j<=v;j++)
        {
            int w;
            scanf("%d",&w);
            mp[u][w]=1;
        }
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
    {
        if(j==n)
            printf("%d\n",mp[i][j]);
        else
            printf("%d ",mp[i][j]);
    }
    return 0;
}




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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int A = nextInt();
  int B = nextInt();
  if (A <= 5) B = 0;
  else if (A <= 12) B /= 2;
  cout << B << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
A,B,C,D;main(i){scanf("%1d%1d%1d%1d",&A,&B,&C,&D);i=8;while(i--)if(A+(i/4?-B:B)+(i/2%2?-C:C)+(i%2?-D:D)==7){char p[]={'+','-'};printf("%d%c%d%c%d%c%d=7\n",A,p[i/4],B,p[i/2%2],C,p[i%2],D);break;}}


Measured memory_bytes: 128
module Main where

import Control.Applicative
import Numeric
import Data.List

type House = [Floor]
type Floor = [Room]
type Room  = Int

officialHouseInit :: [House]
officialHouseInit = replicate 4 houseInit

houseInit :: House
houseInit = replicate 3 floorInit

floorInit :: Floor
floorInit = replicate 10 roomInit

roomInit :: Room
roomInit = 0

showofficialHouse :: [House] -> String
showofficialHouse = intercalate (replicate 20 '#' ++ "\n" ) . map showHouse

showHouse :: House -> String
showHouse = unlines . map showFloor

showFloor :: Floor -> String
showFloor = concatMap ((' ' : ) . showRoom)

showRoom :: Room -> String
showRoom = show 

main :: IO ()
main = do
  { [n] <- getInts
  ; hs <- loop n officialHouseInit
  ; putStr $  showofficialHouse hs
  }

loop :: Int -> [House] -> IO [House]
loop 0 hs = return hs
loop n hs = do
  {[b,f,r,v] <- getInts
  ; let (fronts, ho:ends) = splitAt (b - 1) hs
  ; let (lows, fl: ups)   = splitAt (f - 1) ho
  ; let (xs, rm :ys)      = splitAt (r - 1) fl
  ; let fl' = xs ++ (rm + v) : ys
  ; let ho' = lows ++ fl' : ups
  ; let hs' = fronts ++ ho' : ends
  ; loop (n-1) hs'
  }
  
--

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn .  unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""



Measured memory_bytes: 4684
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    if (n % 2 == 0) {
        cout << 0.5 << endl;
    } else {
        printf("%.6lf\n", 1.0 * ((n+1)/2) / n);
    }
}

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

Measured memory_bytes: 256
import numpy as np
N,M=map(int, input().split())
tabelist = np.zeros(M)
for i in range(N):
  c=list(map(int, input().split()))
  for k in range(1,c[0]+1):
    tabelist[c[k]-1] = tabelist[c[k]-1] + 1
#    print(i,k,tabelist)
print(len([1 for x in tabelist if x==N]))

Measured memory_bytes: 12408
#include<cstdio>
using namespace std;
int main()
{
	int n,a,b,x;
	scanf("%d %d %d",&n,&a,&b);
	x=n*a;
	if(b>x)	printf("%d\n",x);
	else	printf("%d\n",b);
	return 0;
}


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

string letter;
int conta;
int contb;
int contc;

int main(){
  	cin >> letter;
  	conta=0;
  	contb=0;
  	contc=0;
	for(int i =0;i<3;i++){
    	if(letter[i]=='a') conta++;
    }
  	if(conta != 1){
      cout <<"No"<<endl;
      return(0);
    }
  
	for(int i =0;i<3;i++){
    	if(letter[i]=='b') contb++;
    }
  	if(contb != 1){
      cout <<"No"<<endl;
      return(0);
    }
  
	for(int i =0;i<3;i++){
    	if(letter[i]=='c') contc++;
    }
  	if(contc != 1){
      cout <<"No"<<endl;
      return(0);
    }
  	
  	cout <<"Yes"<<endl;
    return(0);
}

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

int main(){
  int N;
  cin >> N;
  vector<double>u(N+1);
  for(int i=1;i<N+1;i++){
    cin >> u[i];
  }
  sort(u.begin(),u.end());
  double ans;
  for(int i=2;i<N+1;i++){
    if(i==2){
      ans=(u[1]+u[2])/2;
    }
    else{
      ans=(ans+u[i])/2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  string s,t;
  cin>>s>>t;
  int a=s.size(),b=t.size();
  int ans=100005;
  rep(i,a-b+1){
    int p=0;
    rep(j,b){
      if(s[i+j]!=t[j]) p++;
    }
    chmin(ans,p);
  }
  out(ans);
}

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


Measured memory_bytes: 3644
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]

use std::{cmp, fmt};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};

fn main() {
    let (a, b, k): (i64, i64, i64) = {
        let mut sc = InputScanOnce::new(io::stdin(), 1024);
        (sc.next(), sc.next(), sc.next())
    };
    let s = a + k - 1;
    let t = b - k + 1;
    if s < t {
        for i in a..s + 1 {
            println!("{}", i);
        }
        for i in t..b + 1 {
            println!("{}", i);
        }
    } else {
        for i in a..b + 1 {
            println!("{}", i);
        }
    }
}

struct InputScanOnce {
    buf: Vec<u8>,
    pos: usize,
}

#[allow(dead_code)]
impl InputScanOnce {
    fn new<R: Read>(mut reader: R, estimated: usize) -> Self {
        let mut buf = Vec::with_capacity(estimated);
        let _ = io::copy(&mut reader, &mut buf).unwrap();
        if buf.last() != Some(&b'\n') {
            panic!("Input must end with '\\n'");
        }
        InputScanOnce { buf: buf, pos: 0 }
    }

    #[inline]
    fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: fmt::Debug,
    {
        let mut start = None;
        loop {
            match (self.buf[self.pos], start.is_some()) {
                (b' ', true) | (b'\n', true) => break,
                (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                (_, false) => start = Some(self.pos),
            }
        }
        let target = &self.buf[start.unwrap()..self.pos];
        unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
        T3::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        T::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                let l = self.next::<String>();
                l.as_bytes().iter().cloned().map(&mut f).collect()
            })
            .collect()
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
using namespace std;
int N;
int D[10][10];
int a,b,c;
int M[10];
bool F[10];
int town;
int main()
{
	while(true){
		scanf("%d",&N);
		if(N==0)break;
		for(int i=0;i<10;i++)for(int j=0;j<10;j++)D[i][j]=10000001;
		
		town=0;
		for(int i=0;i<N;i++){
			scanf("%d%d%d",&a,&b,&c);
			D[a][b]=c;
			D[b][a]=c;
			town=max(town,max(a,b));
		}
		int ans=100000001;
		int ansm;
		town++;
		for(int s=0;s<town;s++){
			for(int i=0;i<town;i++)F[i]=false;
			for(int i=0;i<town;i++)M[i]=10000001;
			M[s]=0;
			while(true){
				for(int i=0;i<town;i++){
					if(!F[i])goto a;
				}
				break;
a:;
				int v=-1;
				int mi=10000001;
				for(int i=0;i<town;i++){
					if(!F[i]){
						if(mi>=M[i]){
							mi=M[i];
							v=i;
						}
					}
				}
				F[v]=true;
				
				for(int i=0;i<town;i++){
					M[i]=min(M[i],M[v]+D[v][i]);
				}
			}
			int sum=0;
			for(int i=0;i<town;i++){
				sum+=M[i];
			}
			if(ans>sum){
				ans=sum;
				ansm=s;
			}
		}
		printf("%d %d\n",ansm,ans);
	}
	return 0;
}

Measured memory_bytes: 1188
X = int(input())
Acount = 0
Bcount = 0
di= {}
def func(i):
    return i**5
for i in range(5000):
    di[str(func(i))] = str(i)
preA = int(X **(1/5))-1000
while True:
    funcA = preA**5
    if funcA-X>=0 and str(funcA-X) in di.keys():
        print(str(preA)+" "+di[str(funcA-X)])
        break
    elif X-funcA>= 0 and str(X-funcA) in di.keys():
        print(str(preA)+" -"+di[str(X-funcA)])
        break
    preA += 1

Measured memory_bytes: 68812
package main

import "fmt"

func solve() {
	var X, t int
	fmt.Scan(&X, &t)
	fmt.Println(max(X-t, 0))
}

func main() {
	solve()
}

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

int main() {
  int k;
  string s;
  cin >> k >> s;
  
  int u = s.size();
  
  if(u <= k){
    cout << s << endl;
  }
  
  else {
    for(int i=0; i<k; i++){
      if(i!=k-1){
      cout << s.at(i);
      }
      else {
        cout << s.at(i) << "..." << endl;
      }
    }
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <chrono>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <deque>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdarg.h>
#include <utility>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unisgned long long
#define ld long double
#define all(a) a.begin(), a.end()
#define SORT(a) sort(all(a))
#define pii pair<int, int>
#define tii triple<int, int, int>
#define e 1e-7
#define PI acos(-1)
#define sz(a) (int)(a.size())
#define inf 1e17
#define vi vector<int>
#define F first
#define S second
#define rng(x) for(int _ = 0; _ < (x); _++)
#define rngi(i, x) for(int i = 0; i < (x); i++)
#define rngsi(s, i, x) for(int i = (s); i <(x); i++)
#define int long long
#define problem ""

template<typename A, typename B, typename C>
struct triple{
    A X;
    B Y;
    C Z;
    triple(A a = 0, B b = 0, C c = 0) :X(a), Y(b), Z(c) {}
};
template<typename A, typename B, typename C>
triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0){
    return triple<A, B, C>(a, b, c);
}
template<typename A, typename B, typename C>
bool operator<(const triple<A, B, C>& a, const triple<A, B, C>& b){
    if (a.X != b.X)
        return a.X < b.X;
    if (a.Y != b.Y)
        return a.Y < b.Y;
    return a.Z < b.Z;
}
template<typename T, typename SS>
ostream& operator<<(ostream& ofs, const pair<T, SS>& p){
    ofs << "( " << p.F << " , " << p.S << " )";
    return ofs;
}
template<typename T>
void print(T a){
    for (auto i : a)
        cout << i << ' ';
    cout << '\n';
}
template<typename T>
T max(T a, T b, T c){
    return max(a, max(b, c));
}
template<typename T>
T min(T a, T b, T c){
    return min(a, min(b, c));
}
template<typename T, typename D>
D min(T a){
    return *min_element(all(a));
}
template<typename T, typename D>
D max(T a){
    return *max_element(all(a));
}
struct custom_hash{
    static uint64_t splitmix64(uint64_t x){
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void solve(){
    int n; cin >> n;
    string s; cin >> s;
    char p = -1;
    int ans = 0;
    rngi(i, n) {
        if(s[i] != p) ans++;
        p = s[i];
    }
    cout << ans << '\n';
}

signed main()
{
    if(0){
        freopen(problem".in", "r", stdin);
        freopen(problem".out", "w", stdout);
    }
    srand(time(NULL));
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    int t = 1; //cin >> t;
    rng(t) solve();
}


Measured memory_bytes: 3728
a = []
b = []
numbers_s = []
numbers_g = []

w = int(input())
n = int(input())

for i in range(0, n):
    temp_a, temp_b = input().split(',')
    a.append(int(temp_a))
    b.append(int(temp_b))

for i in range(0, w):
    numbers_s.append(i+1)
    numbers_g.append(0)

for i in range(0, w):

    temp_idx = i+1

    for j in range(0, n):
        if temp_idx == a[j]: temp_idx = b[j]
        elif temp_idx == b[j]: temp_idx = a[j]

    numbers_g[temp_idx - 1] = i+1

for i in range(0, len(numbers_g)):
    print(numbers_g[i])



Measured memory_bytes: 5596
#!/usr/bin/env python
import sys

f = sys.stdin
x, y = map(int, f.readline().split(' '))

moneyx = (x==1) * 300000 + (x==2) * 200000 + (x==3) * 100000
moneyy = (y==1) * 300000 + (y==2) * 200000 + (y==3) * 100000
moneyz = (x==1 and y==1) * 400000
moneyall = moneyx + moneyy + moneyz
print(moneyall)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
 
 
int main()
{
    int n;
    int card[4][14] = { {0} };
    cin >> n;
    for (int i = 0; i < n; i++){
        char c;
        int num, mark;
        cin >> c >> num;
        if (c == 'S'){
            mark = 0;
        }
        else if (c == 'H'){
            mark = 1;
        }
        else if (c == 'C'){
            mark = 2;
        }
        else{
            mark = 3;
        }
        card[mark][num] = 1;
    }
    for (int i = 0; i < 4; i++){
        for (int j = 1; j < 14; j++){
            char c;
            if (card[i][j] == 0){
                if (i == 0){
                    c = 'S';
                }
                else if (i == 1){
                    c = 'H';
                }
                else if (i == 2){
                    c = 'C';
                }
                else{
                    c = 'D';
                }
                cout << c << " " << j << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;


int W, H;
char Map[25][25];
int d[4][2]={{0,1},{1,0},{0,-1},{-1,0}};

int dfs(int x, int y){
	if(Map[y][x] == '#') return 0;
	Map[y][x] = '#';
	int ret = 1;
	for(int i=0;i<4;i++){
		ret += dfs(x+d[i][1],y+d[i][0]);
	}
	return ret;
}
main(){
	int i,j;
	while(cin >> W >> H, W){
		int sx, sy;
		for(i=0;i<=H+1;i++)
			for(j=0;j<=W+1;j++)
				Map[i][j] = '#';
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				cin >> Map[i][j];
				if(Map[i][j] == '@'){
					sx = j;sy = i;
				}
			}
		}
		cout << dfs(sx, sy) << endl;
	}
	return 0;
}

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

int main() {
  long long X;
  long long r;
  long long r500 = 500;
  long long y500 = 1000;
  long long r5 = 5;
  long long y5 = 5;
  long long a = 0;
  cin >> X;
  r = X;
  while (r >= r500){
    r -= r500;
    a += y500;
  }
  while (r >= r5){
    r -= r5;
    a += y5;
  }
  cout << a << endl;
}

Measured memory_bytes: 256
def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return list(map(int, read_line().split()[:n]))


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    buf = list(a)
    count = 0
    while True:
        if all(map(lambda x: x % 2 == 0, buf)):
            count += 1
            buf = list(map(lambda x: x // 2, buf))
        else:
            break
    return count
        

def write(result):
    print(result)


if __name__ == '__main__':
    solve()

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

struct Motion{
	int xi, yi, xf, yf;
	Motion(int xi_, int yi_, int xf_, int yf_): xi(xi_), yi(yi_), xf(xf_), yf(yf_){}
};

int h, w, a[510][510], x, y;
vector<Motion> ans;

int main(){
	cin >> h >> w;
	for (int i = 0; i < h; ++i){
		for (int j = 0; j < w; ++j){
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < h; ++i){
		for (int j = 0; j < w; ++j){
			if (a[i][j] % 2 == 1){
				if (j < w - 1){
					ans.emplace_back(i+1, j+1, i+1, j+2);
					a[i][j+1]++;
					a[i][j]--;
				}
				else{
					if (i < h - 1){
						ans.emplace_back(i+1, j+1, i+2, j+1);
						a[i+1][j]++;
						a[i][j]--;
					}
				}
			}
		}
	}
	cout << ans.size() << endl;
	for (auto &o: ans) printf("%d %d %d %d\n", o.xi, o.yi, o.xf, o.yf);
}

Measured memory_bytes: 5232
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func solve(lev, num int, nums, p []int) int {
	if lev == 0 {
		if num == 1 {
			return 1
		} else {
			return 0
		}
	} else {
		if num == 1 {
			return 0
		} else if num <= nums[lev-1]+1 {
			return solve(lev-1, num-1, nums, p)
		} else if num == nums[lev-1]+2 {
			return p[lev-1] + 1
		} else if num <= nums[lev-1]*2+2 {
			return solve(lev-1, num-(nums[lev-1]+2), nums, p) + p[lev-1] + 1
		} else {
			return p[lev-1]*2 + 1
		}
	}
}

func rec(N, X int, t, p []int) int {
	if N == 0 {
		if X == 1 {
			return 1
		}
		return 0
	} else {
		if X == 1 {
			return 0
		} else if X <= t[N-1]+1 {
			return rec(N-1, X-1, t, p)
		} else if X == t[N-1]+2 {
			return p[N-1] + 1
		} else if X <= t[N-1]*2+2 {
			return rec(N-1, X-(t[N-1]+2), t, p) + p[N-1] + 1
		} else {
			return p[N-1]*2 + 1
		}
	}
	return 0
}

func main() {
	sc.Split(bufio.ScanWords)

	N, X := getInt(), getInt()

	p := make([]int, 51)
	t := make([]int, 51)

	p[0] = 1
	t[0] = 1

	for i := 1; i <= N; i++ {
		t[i] = t[i-1]*2 + 3
		p[i] = p[i-1]*2 + 1
	}

	ans := rec(N, X, t, p)
	out(ans)
}


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

int main(void){
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    
    int ans = 0;
    for (int i = 0; i <= 3000; i++) {
        for (int j = 0; j <= 3000; j++) {
            if ((n - i * r - j * g) % b == 0 && i * r + j * g <= n) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

lint sgm(lint n) {
	//0からの総和を返す
	return n * (n + 1) / 2;
}

lint fact(lint n) {
	//n!を返す
	if (n == 0) return 1;
	else return n * fact(n - 1);
}

lint power(lint x, lint n, lint m) {
	//(x^n)%mを返す
	lint res = 1;
	x %= m;
	while (n > 0) {
		if (n % 2 == 1) {
			res = res * x % m;
		}
		x = x * x % m;
		n /= 2;
	}
	return res;
}

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	int N;
	cin >> N;
	vector<vector<int>>A(N,vector<int>(2));
	rep(i, N) {
		cin >> A[i][0];
	}
	rep(i, N) {
		A[i][1] = i + 1;
	}
	rep(i, N) {
		sort(A[i]);
	}
	sort(A);
	int cnt = 0;
	rep(i, N - 1) {
		if (A[i] == A[i + 1]) {
			cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<string,int>;

int main() {
    int n;
    cin >> n;
    vector<pair<int,P>> re(n);
    rep(i,n) re[i].first = i+1;
    rep(i,n) cin >> re[i].second.first >> re[i].second.second;
    auto cmp = [](auto a,auto b) {
        P ap = a.second;
        P bp = b.second;
        if(ap.first == bp.first) return ap.second > bp.second;
        return ap.first < bp.first;
    };
    sort(all(re),cmp);
    rep(i,n) cout << re[i].first << endl;
}

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

using namespace std;

int n,k,i;
bool flag[10];

bool ok(int s){
	int tmp = s;
	while(tmp){
		int d = tmp % 10;
		tmp /= 10;
		if(flag[d])
		return 0;
	}
	return 1;
}

int main(){
	scanf("%d%d", &n, &k);
	for(i = 0; i < k; i++){
		int x;
		scanf("%d", &x);
		flag[x] = 1;
	}
	for(i = n; ; i++){
		if(ok(i))
		return 0 * printf("%d\n", i);
	}	
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    string g; int y, m, d;
    while(cin >> g, g != "#") {
        cin >> y >> m >> d;

        string f = "";
        if(y >= 31) {
            if(y > 31) f = "?";
            else {
                if(m >= 5) f = "?";
                else f = "HEISEI";
            }
        }
        else {
            f = "HEISEI";
        }

        if(f == "?") y -= 30;
        cout << f << " " << y << " " << m << " " << d << endl;
    }
    return 0;
}



Measured memory_bytes: 3136
#include<iostream>
 
using namespace std;
 
int main()
{
  int A, B;
  cin >> A >> B;
  if ((A >= 10) || (B >= 10))
  {
    cout << -1 << "\n";
  }
  else
  {
    cout << A*B << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int t,a,b,c;
    scanf("%d",&t);
    for(int cas=0;cas<t;cas++)
    {
        scanf("%d%d%d",&a,&b,&c);
        a*=a;b*=b;c*=c;
        if(a==b+c||b==a+c||c==a+b)
        printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 1008
import sys
n,k = map(int,input().split())
h = map(int,input().split())
h = list(h)

dp = [sys.maxsize]*n
dp[0]=0

for i in range(n):
    for j in range(i+1,i+k+1):
        if j<n:
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]))

print(dp[n-1])

Measured memory_bytes: 52448
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	string s; cin>>s;
	int n = s.size();
	int num[n][2]={};
	int pre0=-1, pre1=-1;
	for(int i=0;i<n;i++){
		if(i>0){
			if(s[i-1]=='L' and s[i]=='L'){
				num[pre1][0]++;
				// cerr<<pre0<<endl;
				swap(pre0, pre1);
				continue;
			}
			if(s[i-1]=='R' and s[i]=='R'){
				num[pre1][0]++;
				// cerr<<pre0<<endl;
				swap(pre0, pre1);
				continue;

			}
		}
		int now=i;
		int cnt=0;
		while(true){
			cnt++;
			if(s[now]=='R'){
				if(s[now+1]=='L'){
					num[now+1][cnt%2]++;
					num[now][(cnt+1)%2]++;
					pre0=(cnt%2==1?now:now+1);
					pre1=(cnt%2==0?now:now+1);
					// cerr<<pre0<<endl;
					break;
				}
				now++;
			}else{
				if(s[now-1]=='R'){
					num[now-1][cnt%2]++;
					num[now][(cnt+1)%2]++;
					pre0=(cnt%2==1?now:now-1);
					pre1=(cnt%2==0?now:now-1);
					// cerr<<pre0<<endl;
					break;
				}
				now--;
			}
		}
	}
	for(int i=0;i<n;i++){
		cout << num[i][0] << (i==n-1?"\n":" ");
	}
	return 0;
}

Measured memory_bytes: 1408
n=int(input())
l=[(i,j) for i in range(1,n+1) for j in range(i+1,n+1)]
if n%2==1:

    for i in range(1,int((n+1)/2)):
        l.remove((i,n-i))
else:
    for i in range(1,int(n/2)+1):
        l.remove((i,n-i+1))
print(len(l))
for i,j in l:
    print(i,j)


Measured memory_bytes: 3956
require 'set'
n = gets.to_i

rot = -> a, i1, i2, i3, i4, i5, i6, i7, i8, x, y do
    a[i1], a[i2], a[i3], a[i4], a[i5], a[i6], a[i7], a[i8] = a[i5], a[i6], a[i7], a[i8], a[i1], a[i2], a[i3], a[i4]
    a[x], a[y] = a[y], a[x]
end

check = -> a do
    a[1..9].uniq.size == 1 &&
    a[10..12].uniq.size == 1 &&
    a[13..15].uniq.size == 1 &&
    a[16..18].uniq.size == 1 &&
    a[19..21].uniq.size == 1
end

n.times do
    queue = [[nil] + gets.split.map(&:to_i)]
    step = 0
    reached = Set[*queue]
    until queue.empty?
        new_queue = []
        add = -> x do
            if !reached.include?(x)
                reached << x
                new_queue << x
            end
        end

        queue.each do |a|
            if check[a]
                puts step
                new_queue = []
                break
            end
            b = a.dup
            rot[b, 16, 1, 2, 3, 15, 28, 29, 30, 19, 21]
            add[b]
            b = a.dup
            rot[b, 18, 7, 8, 9, 13, 22, 23, 24, 10, 12]
            add[b]
            b = a.dup
            rot[b, 21, 1, 4, 7, 10, 24, 27, 30, 16, 18]
            add[b]
            b = a.dup
            rot[b, 19, 3, 6, 9, 12, 22, 25, 28, 13, 15]
            add[b]
        end
        queue = new_queue
        step += 1
    end
end



Measured memory_bytes: 8436
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var s = Console.ReadLine();
            int result = 700;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'o') result += 100;
            }


            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define INF 999999999
using namespace std;

int main(){
    int a, b; cin >> a >> b;
    cout << (a-1) * (b-1) << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
a = 1

if 0 in A:
    a = 0
else:
    A = sorted(A)
    for i in A:
        if 10**18 <i*a:
            a = -1
            break 
        else:
            a = i*a
print(a)

Measured memory_bytes: 21476