akhauriyash/Code-Regression huggingface dataset:
data class Point(val x: Int, val y: Int) {
    fun distanceTo(p :Point) = Math.sqrt((this.x.toDouble() - p.x) * (this.x - p.x) + (this.y - p.y) * (this.y - p.y))
}

fun main(args: Array<String>) {
    val n = readInteger()
    val pointArray = Array<Point>(n) {
        val (x, y) = readIntegerList()
        Point(x, y)
    }

    val permutationList =  permutationListFrom(Array(n) { it })
    var distanceSum = 0.0
    for (permutation in permutationList) {
        var prev = pointArray[permutation[0]]
        for (nextIndex in permutation.drop(1)) {
            val next = pointArray[nextIndex]
            distanceSum += prev.distanceTo(next)

            prev = next
        }
    }

    println(distanceSum / permutationList.size)
}

fun <T : Comparable<T>> permutationListFrom(array: Array<T>): List<Array<T>> {
    val current = array.copyOf()
    val permutationList = mutableListOf<Array<T>>()
    do {
        permutationList += current.copyOf()
    } while (nextPermutation(current))

    return permutationList
}

fun <T : Comparable<T>> nextPermutation(currentPermutation: Array<T>): Boolean {
    fun <T> Array<T>.reverse(start: Int, end: Int) {
        val midPoint = ((start + end) / 2) - 1
        if (midPoint < 0) return
        var reverseIndex = end - 1
        for (index in start..midPoint) {
            val tmp = this[index]
            this[index] = this[reverseIndex]
            this[reverseIndex] = tmp
            reverseIndex--
        }
    }

    val n = currentPermutation.size

    var i = n - 2
    while (i >= 0) {
        if (currentPermutation[i] < currentPermutation[i + 1]) break
        i--
    }

    if (i < 0) return false

    var j = n
    do {
        j--
    } while (currentPermutation[i] > currentPermutation[j])

    if (currentPermutation[i] < currentPermutation[j]) {
        val tmp = currentPermutation[i]
        currentPermutation[i] = currentPermutation[j]
        currentPermutation[j] = tmp
        currentPermutation.reverse(i + 1, n)
        return true
    }

    return false
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 43328
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int Y1,m1,d1,y2,m2,d2,m[]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
	while(cin>>Y1>>m1>>d1>>y2>>m2>>d2){
		if(Y1<0||m1<0||d1<0||y2<0||m2<0||d2<0)return 0;
		int a=0;
		while(Y1!=y2||m1!=m2||d1!=d2){
			d1++;
			if(d1==m[m1]+1+(m1==2&&(Y1%4==0&&Y1%100!=0||Y1%400==0)))m1++,d1=1;
			if(m1==13)Y1++,m1=1;
			a++;
		}
		cout<<a<<endl;
	}
}

Measured memory_bytes: 0
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");

const [a, b]: number[] = input[0].split(' ').map((x: string): number => +x);

if(a >= 13){
    console.log(b);
}else if (a >= 6){
    console.log(b/2);
}else{
    console.log(0);
}

Measured memory_bytes: 7372
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;

ll solve() {
    ll res = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0)
            res += i;
    }
    return res;
}

void input() {
    cin >> n;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

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


Measured memory_bytes: 3156
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <list>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int main(void){
    ll x;
    cin>>x;
    ll cnt=0;
    cnt=(x/11);
    x=x-11*cnt;
    cnt*=2;
    bool turn=true;
    while(x>0){
        if(turn)x-=6;
        else x-=5;
        turn^=1;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}
 

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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    vector<int> values(n);
    for (int i = 0; i < n; ++i) cin >> values[i];
	int result = INT_MAX/2;
	int a = *min_element(values.begin(), values.end());
	int b = *max_element(values.begin(), values.end());
    for (int i = a; i <= b; ++i) {
    	int cur = 0;
    	for (int j = 0; j < n; ++j) {
    		cur += (values[j] - i) *  (values[j] - i);
    	}
    	result = min(result, cur);
    }
    cout << result << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring> 
using namespace std;
string a[101];int n,i;
int main(){
    scanf("%d%*d",&n);
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;i++)
        cout<<a[i];
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int MOD=1e9+7;
const int N=2e6+3;

int jc[N],inv[N];
int r1,c1,r2,c2;
LL ans[N],Ans;

inline LL C(int n,int m) {
	return (LL)jc[n]*inv[m]%MOD*inv[n-m]%MOD;
}
inline LL f(int r,int c) {
	return C(r+c,r);
}
LL Pow(LL x,int p) {
	if(p==0) return 1;
	if(!(p&1)) return Pow(x*x%MOD,p>>1);
	return x*Pow(x*x%MOD,p>>1)%MOD;
}
void Init() {
	jc[0]=1;
	for(int i=1;i<N;i++)
		jc[i]=1ll*i*jc[i-1]%MOD;
	inv[N-1]=Pow(jc[N-1],MOD-2);
	for(int i=N-2;i>=0;i--)
		inv[i]=(i+1ll)*inv[i+1]%MOD;
}
int main() {
	Init();
	scanf("%d %d %d %d",&r1,&c1,&r2,&c2);
	if(r2-r1<c2-c1)
		swap(r1,c1),swap(r2,c2);
	Ans=ans[0]=C(r1+c1,r1);
	for(int s=r1+c1+1;s<=r1+c2;s++) {
		int i=s-r1-c1;
		ans[i]=(2*ans[i-1]+f(r1-1,s-r1)+f(s-c1,c1-1))%MOD;
		Ans=(Ans+ans[i]+MOD)%MOD;
	}
	for(int s=r1+c2+1;s<=r2+c1;s++) {
		int i=s-r1-c1;
		ans[i]=(2*ans[i-1]-f(s-1-c2,c2)+f(s-c1,c1-1))%MOD;
		Ans=(Ans+ans[i]+MOD)%MOD;
	}
	for(int s=r2+c1+1;s<=r2+c2;s++) {
		int i=s-r1-c1;
		ans[i]=(2*ans[i-1]-f(s-1-c2,c2)-f(r2,s-1-r2))%MOD;
		Ans=(Ans+ans[i]+MOD)%MOD;
	}
	printf("%d\n",(Ans+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 31488
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  int n,m;
  cin >> n >> m;
  vector <P> p(n);
  
  REP(i,n){
    cin >> p[i].first >> p[i].second;
  }
  sort(p.begin(),p.end());
  REP(i,m){
    int x1,x2,y1,y2;
    int sum = 0;
    cin >> x1 >> y1 >> x2 >> y2;
    REP(j,n){
      if(p[j].first >= x1 && p[j].first <= x2 && p[j].second >= y1 && p[j].second <= y2){
	sum++;
      }
    }
    cout << sum << endl;
  }
  return 0;
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, W;
    cin >> N >> W;
    vector<vector<long long>> val(N+1, vector<long long>(W+1, 0));

    for (int i = 0; i < N; i++) {
        int w, v;
        cin >> w >> v;
        for (int j = 0; j <= W; j++) {
            if (j-w >= 0) val[i+1][j] = max(val[i][j], val[i][j-w] + v);
            else val[i+1][j] = val[i][j];
        }
    }
    cout << val[N][W] << endl;
    return 0;
}



Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <stdio.h>

using namespace std;

int main()
{
	unsigned long m=100000,n;

	cin>>n;
	for(int i=0;i<n;i++){
		m*=1.05;
		if(m%1000!=0){
			m/=1000;m++;m*=1000;
		}
	}

	cout<<m<<endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long


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

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++) cin >> a.at(i);

    int b = 0,c = 0;
    for(int i = 0;i < n;i ++){
        if(a.at(i) % 4 == 0) b ++;
        if(a.at(i) % 2 == 1) c ++;
    }

    if(n % 2 == 1 && b == (n-1) / 2){
        cout << "Yes" << endl;
        return 0;
    }

    if(b >= c) cout << "Yes" << endl;
    else cout << "No" <<endl;
}



Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> hoge(n);
    map<int,int> num;
    
    for(int i=0;i<n;i++){
        cin>>hoge.at(i);
        
        num[hoge.at(i)-1]++;
        num[hoge.at(i)]++;
        num[hoge.at(i)+1]++;
    }
    
    int ans=0;
    
    for(auto a:hoge){
        ans=max(ans,max(num[a-1],max(num[a],num[a+1])));
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 5120
import sys
from bisect import bisect_right as bi_r, bisect_left as bi_l

n, s = sys.stdin.read().split()
n = int(n)
s = s.replace('R', '0')
s = s.replace('G', '1')
s = s.replace('B', '2')
s = [int(x) for x in s]

def main():
    res = [[] for _ in range(3)]
    for i in range(n):
        res[s[i]].append(i)
    tot = 0
    for j in range(1, n - 1):
        cnt = 0
        m = s[j]
        if m == 0:
            lr = [(1, 2), (2, 1)]
        elif m == 1:
            lr = [(0, 2), (2, 0)]
        else:
            lr = [(0, 1), (1, 0)]
        for l, r in lr:
            cnt += bi_r(res[l], j) * (len(res[r]) - bi_l(res[r], j))
        i = j - 1
        k = j + 1
        while True:
            if i < 0 or k >= n:
                break
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                cnt -= 1
            i -= 1
            k += 1
        tot += cnt
    print(tot)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 9240
n = int(input())
hi = list(map(int, input().split()))

for i in range(n-2, -1, -1):
    if hi[i] > hi[i+1]:
        if hi[i] - hi[i+1] != 1:
            print('No')
            exit()
        else:
            hi[i] -= 1
print('Yes')


Measured memory_bytes: 14396
#include <iostream>

using namespace std;

long long N;


void dfs(long long n, int use, long long &cnt){
    if (n > N){
        return ;
    }

    if (use == 0b111){
        cnt++;
    }

    dfs(n * 10 + 7, use | 0b001, cnt);

    dfs(n * 10 + 5, use | 0b010, cnt);

    dfs(n * 10 + 3, use | 0b100, cnt);
}


int main() {
    cin >> N;

    long long ans = 0;
    dfs(0, 0, ans);
    cout << ans << endl;


    return 0;
}

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

const int dx[24] = {-3,-3,-3,-2,-2,-2,-1,-1,-1,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3};
const int dy[24] = {1,2,3,1,2,3,1,2,3,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
const int H = 4;
const int W = 4;
const int N = H*W;
int dp[2][1<<N];

int main() {
  int dx[4], dy[4];
  while(cin >> dx[0] && dx[0] <= 4) {
    cin >> dy[0];
    for(int i = 1; i < 4; ++i) cin >> dx[i] >> dy[i];

    fill(dp[0], dp[2], 0);
    dp[0][0] = 1;
    for(int t = 0; t < N; ++t) {
      int i = t / W; 
      int j = t % W;
      int p = t % 2;
      int q = 1 - p;
      for(int k = 0; k < (1<<N); ++k) dp[q][k] = 0;
      for(int k = 0; k < (1<<N); ++k) {
        if(k & (1<<t)) {
          dp[q][k] += dp[p][k];
        } else {
          for(int m = 0; m < 4; ++m) {
            int ni = i + dy[m];
            int nj = j + dx[m];
            int nt = ni * W + nj;
            if(ni < 0 || ni >= H) continue;
            if(nj < 0 || nj >= W) continue;
            if(k & (1<<nt)) continue;
            dp[q][k|(1<<t)|(1<<nt)] += dp[p][k];
          }
        }
      }
    }
    cout << dp[N%2][(1<<N)-1] << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<int> B(N, 0);
  for (int i = 0; i < N; i++) {
    B[0] = B[0] * (-1) + A[i];
  }
  for (int i = 0; i < N - 1; i++) {
    B[i + 1] = 2 * A[i] - B[i];
  }
  for (int i = 0; i < N; i++) {
    cout << B[i] << ' ';
  }
  return 0;
}


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

using namespace std;


#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000009
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl			'\n'
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

const int maxn = 1e5 + 5;
void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}


bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

set<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	set<int> primes;

	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.insert(i);
	}
	return primes;
}
set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		// int count = 0;
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}

int power(int x, unsigned int y, int p)
{
	int res = 1;

	x = x % p;

	if (x == 0) return 0;
	;
	while (y > 0)
	{

		if (y & 1)
			res = (res * x) % p;

		y = y >> 1; // y = y/2
		x = (x * x) % p;
	}
	return res;

}

// Graph------------------------------------------------------------------------


int32_t main()
{
	FIO;
	// c_p_c();
	// --------------------------------------------------
	// Never GIVE UP !!!!
	int n;
	cin >> n;
	vi arr(n);
	for (int &x : arr)
		cin >> x;
	int sum = 0;
	for (int i = 1; i < n; i++)
	{
		if (arr[i - 1] > arr[i])
		{
			sum += arr[i - 1] - arr[i];
			arr[i] = arr[i - 1];
		}
	}
	cout << sum << endl;

}

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

using namespace std;
typedef long long ll ;
typedef long double ld ;
#define FAST(IO) ios_base::sync_with_stdio(false);cin.tie(NULL);
#define r return
/*fixed << setprecision(9) useful float shit*/
#define e "\n"
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define loop(n) for(ll i=0;i<n;i++)
#define gcd __gcd
#define mod 1000000007
ll n , a[100010][4] , dp[100010][4] , mn = 1e9 ;
ll solve(ll i , ll j , ll sum){
    if(i==n)return 0 ;
    if(dp[i][j]!=-1)return dp[i][j] ;
    if(j==2)return dp[i][j] = sum+max(solve(i+1,j-1,a[i+1][j-1]),solve(i+1,j-2,a[i+1][j-2]));
    if(j==0)return dp[i][j] =  sum+max(solve(i+1,j+1,a[i+1][j+1]),solve(i+1,j+2,a[i+1][j+2])) ;
    if(j!=0&&j!=2)return dp[i][j] = max(sum+solve(i+1 , j-1 , a[i+1][j-1]),sum+solve(i+1,j+1,a[i+1][j+1])) ;

}
int main(){
    FAST(IO)
    memset(dp , -1 , sizeof(dp)) ;
    cin >> n ;
    loop(n)
        for(ll j = 0 ; j < 3 ; j++)cin >> a[i][j];
        ll q = solve(0,0,a[0][0]);
        ll w = solve(0,1,a[0][1]);
        ll t = solve(0,2,a[0][2]);
        mn = max(q,w) ;
        cout << max(mn,t) ;
     r 0 ;
}


Measured memory_bytes: 12800
def main():
    n,m = map(int,input().split())
    flag = [False for i in range(n+5)]
    AC = 0
    WA = [0 for i in range(n+5)]
    _WA = 0
    for i in range(m):
        input_line = input().split()
        p,s = int(input_line[0]), input_line[1]
        if flag[p] == False:
            if s == "AC":
                AC += 1
                _WA += WA[p]
                flag[p] = True
            else:
                WA[p] += 1
    print(AC,_WA)
    return


if __name__ == "__main__":
    main()

Measured memory_bytes: 47920
#include <bits/stdc++.h>
using namespace std;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 
typedef long long ll;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define DBGV(v,n) forn(i,n) cout << v[i] << " "; cout << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
#define MAXN 2005
#define INF 1000000007

vector <int> divisores(int n)
{
	vector <int> ans;
	forr(i,1,sqrt(n)+1)
	{
		if(n%i == 0) 
		{
			ans.pb(i);
			if(i*i != n) ans.pb(n/i);
		}
		
	}
	sort(all(ans));
	return ans;
}

int main()
{ 
	FIN;
	
	#ifdef input
		//freopen("test1.txt", "r", stdin);
	#endif
	
	vector <int> visto(1000005,0);
	int n;
	cin >> n;
	vector <int> v(n);
	forn(i,n) cin >> v[i];
	forn(i,n) visto[v[i]]++;
	int ans = 0;
	forn(i,n)
	{
		vector <int> div = divisores(v[i]);
		bool d=false;
		visto[v[i]]--;
		for(auto u : div)
		{
			if(visto[u]>0) d=true;
		}
		if(d==true) ans++;
		visto[v[i]]++;
	}
	cout << n-ans << endl;
	return 0;
}


Measured memory_bytes: 7960
from functools import lru_cache


def solve(N, A, B, C, D):

    @lru_cache(None)
    def dfs(n):  # n -> 0 になるまでのコスト
        if n == 0:
            return 0
        if n == 1:
            return D

        cost = n * D
        for div, c in zip((2, 3, 5), (A, B, C)):
            q, r = divmod(n, div)

            if r == 0:
                cost = min(cost, dfs(q) + c)
            else:
                cost = min(cost, dfs(q) + c + D * r)
                cost = min(cost, dfs(q+1) + c + D * (div - r))
        return cost

    return dfs(N)


def main():
    T = int(input())

    for _ in range(T):
        N, A, B, C, D = map(int, input().split())
        print(solve(N, A, B, C, D))


if __name__ == "__main__":
    main()


Measured memory_bytes: 20752
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

mod = 10**9 + 7
k = int(input())
s = input()
n = len(s)

def make_tables(n, mod = 10 ** 9 + 7):
    fac = [1, 1] # 階乗テーブル
    finv = [1, 1] #逆元の階乗テーブル
    inv = [0, 1] #逆元テーブル

    for i in range(2, n + 1):
        fac.append((fac[-1] * i) % mod)
        inv.append((mod -inv[mod % i] * (mod // i)) % mod)
        finv.append((finv[-1] * inv[-1]) % mod)
    return fac, finv

def nCk(n, k, mod = 10 ** 9 + 7):
    k = min(k, n-k)
    return fac[n] * finv[k] * finv[n-k] % mod

##########################
fac, finv = make_tables(2*10**6 + 1)
ans = 0
for i in range(k + 1):
    temp = 1
    temp *= pow(26, i, mod)
    temp %= mod
    j = k - i
    if j == 0:
        ans += temp
        continue
    temp *= pow(25, j, mod)
    temp %= mod
    temp *= nCk(n + j - 1, n - 1)
    ans += temp
    ans %= mod
print(ans % mod)





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

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var NX = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int out1 = 0;

        int a = NX.Max();
        int b = NX.Min();
        out1 = a - b;

        Console.WriteLine(out1);
    }
}

Measured memory_bytes: 13396
N = int(input())
max_1st = -1
max_1st_index = -1
max_2nd = -1
only_max = False
for i in range(0, N):
  if i == 0:
    max_1st = int(input())
    max_1st_index = 0
  elif i == 1:
    tmp = int(input())
    if (tmp > max_1st):
      max_1st, max_2nd = tmp, max_1st
      max_1st_index = 1
    else:
      max_2nd = tmp
  else:
    tmp = int(input())
    if (max_2nd < tmp) and (tmp < max_1st):
      max_2nd = tmp
    elif (max_1st < tmp):
      max_1st, max_1st_index = tmp, i
      only_max = False
    elif (max_1st == tmp):
      only_max = True

for j in range(0, N):
  if only_max:
    print(max_1st)
  else:
    if j == max_1st_index:
      print(max_2nd)
    else:
      print(max_1st)


Measured memory_bytes: 4540
# include <iostream>
# include <string>
using namespace std;
int main()
{
	int a,b;
	string s;
	cin>>a>>b>>s;
	int n=s.size();
	if(a+b+1!=n)
	{
		cout<<"No";
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		if(i!=a)
		{
			if(s[i]<'0'||s[i]>'9')
			{
				cout<<"No";
				return 0;
			}
		}
	}
	if(s[a]!='-')
	{
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char num[200003];
int main(){
	for(int i=1;i<200003;i++)num[i]=0;
	int a=0,b=0,c=0,x=0,y=0,z=0;
	scanf("%s",&num);
	a=0;
//	printf("%d\n",num[i]); 
	for(int i=0;i<=strlen(num);i++)	{
		a+=num[i];
		a-=48;
	//	printf("%c\n",num[i]);
	//	printf("%d\n",a);
	}
	a+=48;
	if(a%9==0)printf("Yes");
	if(a%9!=0)printf("No");
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <unistd.h>

typedef long long ll;
using namespace std;

int main(){
  ll n,m,ans=0;
  cin >> n>>m;
  if(n>2){
  	if(m>1){
  		ans+=(n-2)*(m-2);
  	}
  	else{
  		ans+=(n-2);
  	}
  }
  else if(n==1){
  	if(m>1){
  	    ans+=(m-2);
  	}
  	else{
  		ans++;
  	}
  }
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class BComparingStrings {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int a, b; cin >> a >> b;
      if (a > b) {
        swap(a, b);
      }
      rep(i, b) {
        cout << a;
      }
      cout << endl;
    }
};

signed main() {
  BComparingStrings solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

int main() {
	int x;
	cin >> x;
	int res = 1;
	int deg = x;
	while (deg % 360 != 0) {
		deg += x;
		res++;
	}
	pv(res)
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string.h>

typedef long long ll;

using namespace std;

int main()
{
    ll n,d,x[10][10]={},i,j,k,ans=0,count=0;
    cin >> n >> d;
    for(i=0;i<n;i++)
    {
        for(j=0;j<d;j++)
        {
            cin >> x[i][j];
        }
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
                    ans=0;
            for(k=0;k<d;k++)
            {
                ans += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
              
            }
            for(k=1;k<500;k++)
            {
                if(ans == k*k)
                {
                    count++;
                    break;
                }
            }
 
        }
    }
    cout << count;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

struct edge{
    ll to;
    ll cost;
    edge(ll t, ll c){
        to = t;
        cost = c;
    }
};

struct fulledge{ //* u->v with cost
    ll u, v, cost;
    fulledge(){}
    fulledge(ll _u, ll _v, ll _c){
        u = _u; v = _v; cost = _c;
    }

    bool operator< ( fulledge const &e) const {
        return cost < e.cost;
    }
};

struct edgeGreater{
    bool operator()(const fulledge &e1, const fulledge &e2){
        return e1.cost > e2.cost;
    }
};

//* simplest bellman-ford shortest path calculator
bool BellmanFord(vector<fulledge> &es, vector<ll> &dist, vector<bool> &neg, ll s){
    ll N = dist.size();
    ll M = es.size();
    fill(dist.begin(), dist.end(), INF);
    dist[s] = 0;
    bool update;
    rep(loop, N){
        update = false;
        rep(i, M){
            fulledge e = es[i];
            if(dist[e.u]!=INF && dist[e.v] > dist[e.u]+e.cost) {
                dist[e.v] = dist[e.u] + e.cost;
                update = true;
            }
        }
        if(!update) 
            break;
    }
    //* check which node can be affected by negative cycles
    fill(neg.begin(), neg.end(), false);
    rep(loop, N){
        rep(i, M){
            fulledge e = es[i];
            if(dist[e.u]!=INF && dist[e.v] > dist[e.u]+e.cost) {
                dist[e.v] = dist[e.u] + e.cost;
                neg[e.v] = true;
            }
            if(neg[e.u] == true)
                neg[e.v] = true;
        }
    }

    return update;
}


void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c){
    vector<fulledge> es;
    rep(i, M){
        es.push_back(fulledge(a[i]-1, b[i]-1, -c[i]));
    }
    vector<ll> dist(N);
    vector<bool> neg(N);
    ll isBad = BellmanFord(es, dist, neg, 0LL);
    if(neg[N-1]==true)
        cout << "inf" << endl;
    else
        cout << -dist[N-1] << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
    }
    solve(N, M, std::move(a), std::move(b), std::move(c));
    return 0;
}


Measured memory_bytes: 384
from collections import deque

N = int(input().rstrip())

dll = deque()

for n in range(N):
    command = input().rstrip()
    if command.endswith(("First", "Last")):
        if command == "deleteFirst":
            dll.popleft()
        else:
            dll.pop()
    else:
        command, x = command.split(" ")
        if command =="insert":
            dll.appendleft(x)
        else:
            try:
                dll.remove(x)
            except Exception as e:
                pass
            
print(" ".join(dll))


Measured memory_bytes: 69740
#include <stdio.h>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))

int n, k;
char str[100005];

struct {
	int len;
	char ch;
} cp[100005];
int cp_n;

int main()
{
	scanf("%d %d", &n, &k);
	scanf("%s", str);

	//??
	cp_n = 0;
	cp[0].len = 0;
	cp[0].ch = 0;
	for (int i = 0; i < n; i++) {

		if (cp[cp_n].ch != str[i]) {
			cp_n++;
			cp[cp_n].ch = str[i];
			cp[cp_n].len = 1;
		} 
		else {
			cp[cp_n].len++;
		}
	}

	int len_sum = 0;
	int z_sum = 0;
	int l, r;
	int ans = 0;

	l = r = 1;
	len_sum = cp[1].len;
	if (cp[l].ch == '0') {
		z_sum = 1;
	}

	while (l <= cp_n && r <= cp_n) {
		if (z_sum > k) {
			if (cp[l].ch == '0') {
				z_sum--;
			}

			len_sum -= cp[l].len;
			l++;
		}
		else {
			ans = max(ans, len_sum);

			r++;

			if (cp[r].ch == '0') {
				z_sum++;
			}
			len_sum += cp[r].len;
		}
	}

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

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    ll N,ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    ll a,b;
    if(N==0)ans=2;
    else if(N==1)ans=1;
    else{
        b=2,a=1;
        REP(i,N-1){
            ans=a+b;
            b=a;
            a=ans;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	for(int i=1;i<=b;i++){
		if((a*i)%b==c){
			cout << "YES\n";
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int l[200000],r[200000],p[100000],qq[100000];
int main(void)
{
	int n,m,i,j,k,q,a[501][501],sum,b[501][501];
	scanf("%d %d %d",&n,&m,&q);
	for(i=0;i<m;i++)	scanf("%d %d",&l[i],&r[i]);
	for(i=0;i<q;i++)	scanf("%d %d",&p[i],&qq[i]);
	for(i=0;i<=n;i++)	{
		for(j=0;j<=n;j++)	{
			a[i][j]=0;
		}
	}
	for(i=0;i<m;i++)	a[l[i]][r[i]]++;
	for(i=1;i<=n;i++)	{
		b[i][0]=0;
		for(j=1;j<=n;j++)	{
			b[i][j]=b[i][j-1]+a[i][j];
		}
	}	
//	for(i=1;i<=n;i++)	{
//		for(j=1;j<=n;j++)	{
//			printf("%d ",b[i][j]);
//		}
//		printf("\n");
//	}	
	
	
	for(i=0;i<q;i++)	{
		sum=0;
		for(j=p[i];j<=qq[i];j++)	{
			sum+=b[j][qq[i]]-b[j][j-1];
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 5120
n = int(input())
ans = 0

for i in range(1,n+1):
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        ans += i

print(ans)


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

using namespace std;
using ll = long long;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N,0);
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        A.at(a - 1)++;
        A.at(b - 1)++;
    }
    for(int i = 0; i < N; i++) {
        cout << A.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 3556
K,S=input().split()
k=int(K)
s=int(S)
L=0
for i in range(0,k+1):
    X=i
    if 0<int(S)-X<k*2:
        for j in range(0,k+1):
            Y=j
            Z=s-(X+Y)
            if 0<=Z<=k:
                L=L+1
            else:
                L=L
    if s-X==0 or s-X==k*2:
        L=L+1
    else:
        L=L
print(L)        

Measured memory_bytes: 3064
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 120;
int a[N];
int main() {
	fio;
	int n, x, ans = 0;
	cin >> n;
	cin >> x;
	for (int i = 1; i <= n; i++) cin >> a[i];
	sort(a+1, a+1+n);
	bool f = false;
	for (int i = 1; i <= n; i++) {
		if(x >= a[i]) {
			x -= a[i];
			ans++;
		}
		else f = true;
	}
	if(!f && x && ans) ans--; 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define rep(x, n) for (int x = 1; x <= n; ++x)
#define FOR(x, l, r) for (int x = l; x <= r; ++x)
const int maxN = 55;
int n, m;
char s[maxN][maxN];
int dx[9] = {0, -1, 0, 1, 1, 1, 0, -1, -1};
int dy[9] = {0, -1, -1, -1, 0, 1, 1, 1, 0};

int main()
{
	scanf("%d%d", &n, &m);
	rep(i, n) scanf("%s", s[i] + 1);
	rep(i, n) rep(j, m) if (s[i][j]  == '.')
	{
		int x, y, tmp = 0;
		rep(k, 8)
		{
			x = dx[k] + i;
			y = dy[k] + j;
			if (s[x][y] == '#')
				++tmp;
		}
		s[i][j] = tmp + '0';
	}
	rep(i, n) puts(s[i] + 1);
	return 0;
}

Measured memory_bytes: 256
n = int(raw_input())
a = map(int, raw_input().split())
def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

x = partition(a, 0, n-1)
for i in range(n):
    if i == x:
        print '[%d]' % a[i],
    elif i == n-1:
        print a[i]
    else:
        print a[i],
            

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

int main(){
  int N;
  cin >> N ;
  
  vector<int> A(N-1); //自分の上司番号
  for(int i=0;i<N-1;i++){
    cin >> A.at(i);
    A.at(i)--;
  }
  
  vector<int> B(N); //自分の部下人数
  for(int i=0;i<N-1;i++){
    B.at(A.at(i))++;
  }
  
  for(int i=0;i<N;i++){
    cout << B.at(i) << endl;
  }

}

Measured memory_bytes: 4816
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         char[] arr = st.nextToken().toCharArray();
         int N = arr.length;
         for(int i=0; i < N-1; i++)
            if(arr[i] == arr[i+1])
            {
               System.out.println((i+1)+" "+(i+2));
               return;
            }
         for(int i=0; i < N-2; i++)
            if(arr[i] == arr[i+2])
            {
               System.out.println((i+1)+" "+(i+3));
               return;
            }
         System.out.println("-1 -1");
      }
   }

Measured memory_bytes: 37236
s = input()
k = int(input())
r = []
for c in s:
    n = ord('z') - ord(c) + 1
    if k >= n and c != 'a':
        r.append('a')
        k -= n
    else:
        r.append(c)
if k > 0:
    r[-1] = chr(ord('a') + (ord(r[-1]) - ord('a') + k) % 26)
print(''.join(r))


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

using namespace std;

int main() {


    stack<int> st;
    while (true) {
        string s;
        cin >> s;
        if (cin.eof()) break;
        //オペランドが出てくる時点であ２つのStacが溜まっているのは絶対である
        if (s[0] == '+') {
            int b = st.top(); st.pop();
            int a = st.top(); st.pop();
            st.push(a + b);
        }
        else if (s[0] == '-') {
            int b = st.top(); st.pop();
            int a = st.top(); st.pop();
            st.push(a - b);
        }
        else if (s[0] == '*') {
            int b = st.top(); st.pop();
            int a = st.top(); st.pop();
            st.push(a * b);
        }
        else
            st.push(atoi(s.c_str()));//std::string::c_str ()とは、std::stringの文字列のC言語形式のchar*型のポインタを返します
        
    }
    
    printf("%d\n", st.top());
    return 0;
}



Measured memory_bytes: 3268
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

vector<pair<int,int> > a;
int ans[220000];

int main()
{
  int i,j,n,x;
  scanf("%d",&n);
  for (i=0;i<n;i++)
  {
    scanf("%d",&x);
    a.push_back(make_pair(x,i));
  }
  sort(a.begin(),a.end());
  for (i=0;i<n;i++)
  {
    if (i<n/2)
    {
      ans[a[i].second]=a[n/2].first;
    }
    else
    {
      ans[a[i].second]=a[n/2-1].first;
    }
  }
  for (i=0;i<n;i++)
    printf("%d\n",ans[i]);
  return 0;
}

Measured memory_bytes: 4720
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, k, x, y, ans=0;
  cin >> n >> k >> x >> y;
  for (int i=0; i<n; i++) {
    if (i<k) {
      ans += x;
    } else {
      ans += y;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
xs = []

n.times do
  x, l = gets.chomp.split.map(&:to_i)
  xs << [3 * (x - l) + 1, 3 * (x + l) - 1]
end

xs.sort_by! {|lb, _| lb }
lb, ub = xs.pop
lx = [lb]
ux = [ub]

while !xs.empty?
  lb, ub = xs.pop
  j = ux.bsearch_index {|y| y >= lb } || ux.size
  i = lx.bsearch_index {|y| y >= ub } || lx.size
  if i == 0 && j == 0
    lx.unshift(lb)
    ux.unshift(ub)
  end
end
puts ux.size

Measured memory_bytes: 24128
w = list(map(str,input()))
w.sort()
w = "".join(w)

flag = 0
w = [w[i*2:i*2+2] for i in range(-(-len(w)//2))]
for i in w:
  if len(i)==1 or not i[0] == i[1]:
    flag = 1
    break

print("Yes") if not flag else print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

#define endl ("\n")
#define pi (3.141592653589)
#define mod 1000000007
#define int int64_t
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

int32_t main() 
{
    fast;
	int A, B, N;
    cin >> A >> B >> N;

    int res = A*min(N, B-1)/B;
    cout << res << endl;
    return 0;
}




Measured memory_bytes: 3532
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;

int main() {
    int n,d;
    cin >> n >> d;
    int see=1+2*d;
    for (int i = 0;; i++)
    {
        if (see*i>=n)
        {
            cout << i << endl;
            return 0;
        }
        
    }
}


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

#define ll 					long long
#define db					double
#define ull 				unsigned long long
#define pii 				pair<int,int>
#define fi 					first
#define se 					second
#define vi 					vector<int>
#define vl					vector<ll>
#define psb 				push_back
#define ppb 				pop_back
#define all(x)			 	(x).begin(),(x).end()
#define sz(x)				(int)(x).size()
#define endln 				printf("\n")
#define gc					getchar_unlocked
#define setmin(x)			memset((x), -1, sizeof((x)))
#define setnul(x)			memset((x), 0, sizeof((x)))
#ifndef getchar_unlocked
#define getchar_unlocked 	getchar
#endif
const int inf = 1e9 + 5;
const ll infll = 1e18+5;
const int mod = 1e9 + 7;

template <typename T>
void gi(T &ret) {
	ret = 0; char inp=gc(); int kl=1;
	while (inp<'0' || inp>'9') {if (inp=='-') kl=-1; inp=gc();}
	while ('0'<=inp && inp<='9') ret=(ret<<3)+(ret<<1)+(inp-'0'), inp=gc();
	if (kl<1) ret=-ret;
}

const int MAXN = 2e5+5;
int n, val[MAXN];

int main() {
	gi(n);
	for (int i=1; i<=n; i++) gi(val[i]);
	int piv = 0, sum = 0;
	ll ans = 0ll;
	for (int i=1; i<=n; i++) {
		sum ^= val[i-1];
		if (piv<i) {
			piv = i;
			sum = val[i];
		}
		while (piv<n && (sum^val[piv+1])==(sum|val[piv+1])) {
			piv++;
			sum |= val[piv];
		}
		ans += (ll)(piv-i+1);
	}
	printf ("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
N, M = input().split(' ')
N = int(N)
M = int(M)
citys = []
for i in range(M):
  a, b = input().split(' ')
  a = int(a)
  b = int(b)
  citys.append(a)
  citys.append(b)
for i in range(1, N+1):
  print(citys.count(i))

Measured memory_bytes: 8988
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    int ans=0;
    REP1(i,1,n)  {
        int a;
        cin >> a;
        if ( i%2&&a%2 ) ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3532
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x, y;
	cin >> x >> y;
	cout << x + y / 2 << endl;
	return 0;
}

Measured memory_bytes: 256