akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(void) {
    int n;
    cin >> n;
    int t,x,y,now=0,nx=0,ny=0;
    int d,dt;
    rep(i,n){
        cin >> t >> x >> y;
        d = abs(nx-x)+abs(ny-y);
        dt = t-now;
        if(!(d<=dt&&(dt-d)%2==0)){
            cout << "No" << endl;
            return 0;
        }
        nx=x;ny=y;now=t;
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
	int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
	if(a<c&&b>c){
      printf("Yes\n");
    }
  else if(a>c&&b<c){
  	printf("Yes\n");
  }
  else{
  	printf("No\n");
  }
}

Measured memory_bytes: 128
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

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




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int jrr[100000];
long long int jump(long long int i,long long int n,long long int arr[],long long int k)
{
	if(i>n-1)
	return 99999999999999;
	if(i == n-1)
		return 0;
	else if(jrr[i]!=-1)
	return jrr[i];
	else
    {   // cout<<arr[i]<<" i"<<endl;
    long long int o=99999999999999,j;
    for(j=i+1;j<=i+k;j++)
   {  o= min(o,jump(j,n,arr,k)+abs(arr[j]-arr[i]));
   	// if(j<n)
		// {	//	dp[i]=min(dp[i],abs(arr[i]-arr[i+j])+dp[i+j]);)
  //  	o=abs(arr[j]-arr[i])+jump(j,n,arr,k);
  //  	if(o<min)
  //  	min=o;
		// }
    }
    //cout<<o<<"r";
    jrr[i]=o;
    return jrr[i];
    }
	
}

int main() {
	// your code goes here

	long long int n,k;
	cin>>n>>k;
	long long int arr[n];
	for(int i=0;i<n;i++)
	cin>>arr[i];
	memset(jrr,-1,sizeof(jrr));

	cout<<jump(0,n,arr,k);
	return 0;
}


Measured memory_bytes: 9600
using System;
using System.Linq;

    class Program1
    {
        static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            Console.WriteLine(input[0]*input[1]<=input[2]?input[0]*input[1]:input[2]);
        }
    }

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.nextLine());
    String[] W = new String[N];
    for (int i=0; i<N; i++) {
      W[i] = sc.nextLine();
    }


    for (int i=1; i<N; i++) {
      for (int j=0; j<i; j++) {
        if (W[i].equals(W[j])) {
          System.out.println("No");
          return;
        }
      }

      char lastChar = W[i-1].charAt(W[i-1].length()-1);
      if (!W[i].startsWith(String.valueOf(lastChar))) {
        System.out.println("No");
        return;
      }
    }

    System.out.println("Yes");

  }
}

Measured memory_bytes: 21716
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
typedef long long int ll;
typedef std::pair<int, int> PA;
#define rep(i,n) for(int i=0;i<(int)n;i++)

bool my_compare(pair<pair<string, int>,int> a, pair<pair<string, int>,int> b) {
	//first優先比較
	if (a.first.first != b.first.first) {
		return a.first.first < b.first.first; // 昇順
		//return a.first.first > b.first,first; // 降順
	}

	// それ以外はsecondで比較
	if (a.first.second != b.first.second) {
		//return a.first.second < b.first.second;//昇順
		return a.first.second > b.first.second;//降順
	}
	else {
		// どちらも同じ
		return true;
	}
}

int main(void) {
	int n; cin >> n;
	vector<ll> v(n-1);
	for (int i = 0; i < n - 1; i++) {
		cin >> v[i];
	}
	ll sum = 0;
	sum += v[0]+v[n-2];
	for (int i = 1; i < n - 1; i++) {
		sum += min(v[i - 1],v[i]);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
function MainB(input){
    const [S, T] = input.split('\n');
    const Sarr = S.split('');
    const Tarr = T.split('');
    const box = [];
    // Tの文字列がSに含むか検索
    for(let i=0; i<Sarr.length-Tarr.length+1; i++){
        let findNum = 0;
        for(let j=0; j<Tarr.length; j++){
            // 文字が見つかったら
            if(Sarr[i+j] === Tarr[j]){
                findNum++;
            }
        }
        box.push(findNum);
    }
    console.log(Tarr.length-Math.max.apply(null, box));
}
MainB(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 32480
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

using namespace std;

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

    int n,h[100005],k;
    cin>>n>>k;
    reps(i,n){
	cin>>h[i];
    }
    h[0]=INF;

    int sum[100005];
    memset(sum,INF,sizeof(sum));
    sum[1]=0;
    for(int i=2;i<=n;i++){
	for(int j=1;j<=min(k,i-1);j++){
	sum[i]=min(sum[i-j]+abs(h[i]-h[i-j]),sum[i]);
	}
    }

    cout<<sum[n]<<'\n';
    return 0;
}


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


void solve(long long N, long long A, long long B){
    // cerr << (N/(A+B)) * A << endl;
    // cerr << N%(A+B) << endl;
    cout << (N/(A+B))*A + min(A,N%(A+B)) << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


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

int main(){
  int N;
  vector<int> V(20), C(20);

  cin >> N;
  for(int i=0; i<N; i++) cin >> V[i];
  for(int i=0; i<N; i++) cin >> C[i];

  int ans = 0;
  for(int i=0; i<N; i++){
    ans += max(0, V[i]-C[i]);
  }

  cout << ans << endl;
} 

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

int main(){
  long long n, d, x, y;
  cin >> n >> d;
  d = d*d;
  int count = 0;
  for (int i = 0; i < n; i++){
    cin >> x >> y;
    if((x*x + y*y) <= d) count++;
  }
  cout << count << endl;
  return 0;
}

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

int main(){
 int N,M,A[1000],B[1000],ok=0,temp,ans=0;
 cin>>N>>M;
 for(int i=0;i<M;i++){
 	cin>>A[i]>>B[i];
	if(A[i]>=N)ok++;
 }
 for(int i=0;i<M-1;i++){
 	for(int j=0;j<M-1;j++){
		if(B[i]>B[i+1]){
			temp=B[i+1];
			B[i+1]=B[i];
			B[i]=temp;
			temp=A[i+1];
			A[i+1]=A[i];
			A[i]=temp;
		}
	}
 }
 for(int i=0;ok<M-1;i++){
 	if(A[i]>=N)continue;
	ok++;
 	ans=ans+B[i]-N;
 }
 cout<<ans<<endl;
}


Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int main(void)
{
 int A,B;
  int ans;
  cin >> A >> B;
  for(int i=1 ;i <=3;i++)
  {
    if(A != i && B != i)
    {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int a[105];
bool dp[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, K;
    cin >> n >> K;
    rep(i,n){
        cin >> a[i];
    }
    dp[0] = false;
    srep(i,1,K+1){
        bool flag = false;
        rep(j,n){
            if(i >= a[j]){
                if(!dp[i-a[j]]){
                    flag = true;
                    break;
                }
            }
        }
        dp[i] = flag;
    }
    if(dp[K]){
        cout << "First\n";
    }else{
        cout << "Second\n";
    }
    return 0;
}

Measured memory_bytes: 384
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def is_closer(s, orig, insp):
    return abs(s - orig * 2) > abs(s - insp * 2)

def main():
    N = get_ln_int_inputs()[0]
    a = get_ln_int_inputs()

    s = sum(a)

    minimum_v = a[0]
    p_s = minimum_v
    for i in range(1, N - 2):
        p_s += a[i]
        if is_closer(s, minimum_v, p_s):
            minimum_v = p_s

    print(abs(s - minimum_v * 2))


main()

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

#define IL __inline__ __attribute__((always_inline))

#define For(i, a, b) for (int i = a, i##end = b; i <= i##end; ++ i)
#define FOR(i, a, b) for (int i = a, i##end = b; i < i##end; ++ i)
#define Rep(i, a, b) for (int i = a, i##end = b; i >= i##end; -- i)
#define REP(i, a, b) for (int i = (a) - 1, i##end = b; i >= i##end; -- i)

typedef long long LL;

template <class T>
IL bool chkmax(T &a, const T &b) {
  return a < b ? ((a = b), 1) : 0;
}

template <class T>
IL bool chkmin(T &a, const T &b) {
  return a > b ? ((a = b), 1) : 0;
}

template <class T>
IL T mymax(const T &a, const T &b) {
  return a > b ? a : b;
}

template <class T>
IL T mymin(const T &a, const T &b) {
  return a < b ? a : b;
}

template <class T>
IL T myabs(const T &a) {
  return a > 0 ? a : -a;
}

const int INF = 0X3F3F3F3F;
const double EPS = 1E-10, PI = acos(-1.0);

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define OK DEBUG("Passing [%s] in LINE %d...\n", __FUNCTION__, __LINE__)
/*------------------------------header------------------------------*/

const int MAXN = 200000 + 5;

int pos[MAXN], dpos[MAXN];
LL pre[MAXN], suf[MAXN];

int main() {
  int L, n;
  scanf("%d%d", &L, &n);
  For(i, 1, n) {
    scanf("%d", &pos[i]);
    dpos[i] = L - pos[i];
  }
  For(i, 1, n) {
    pre[i] = pre[i - 1] + pos[i];
  }
  Rep(i, n, 1) {
    suf[i] = suf[i + 1] + dpos[i];
  }
  LL answer = pos[n];
  REP(i, n, 1) {
    if (i < n - i) {
      break;
    }
    LL cur = ((pre[i] - pre[(i << 1) - n]) << 1) + (suf[i + 1] << 1) - dpos[i + 1];
    chkmax(answer, cur);
    if (i != n - i) {
      chkmax(answer, cur + (pos[(i << 1) - n] << 1) - pos[i] + dpos[i + 1]);
    }
  }
  chkmax<LL>(answer, dpos[1]);
  For(i, 2, n) {
    if (n - i + 1 < i - 1) {
      break;
    }
    LL cur = ((suf[i] - suf[(i << 1) - 1]) << 1) + (pre[i - 1] << 1) - pos[i - 1];
    chkmax(answer, cur);
    if (n - i + 1 != i - 1) {
      chkmax(answer, cur + (dpos[(i << 1) - 1] << 1) - dpos[i] + pos[i - 1]);
    }
  }
  printf("%lld\n", answer);
  return 0;
}


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

int main()
{
	long long K;
	char S[101];
	scanf("%s", S);
	scanf("%lld", &K);
	
	int l, flag = 1;
	for (l = 0; S[l+1] != 0; l++) if (S[l] != S[l+1]) flag = 0;
	if (flag == 1) {
		printf("%lld\n", K * (l + 1) / 2);
		fflush(stdout);
		return 0;
	}
	
	int i, count = 0, tmp = 1;
	if (S[0] == S[l++]) flag = 1;
	for (i = 1; i < l; i++) {
		if (S[i] == S[i-1]) tmp++;
		else {
			count += tmp / 2;
			tmp = 1;
		}
	}
	count += tmp / 2;
	for (i = 1; S[i] == S[i-1]; i++);
	if (i % 2 == 0) flag = 0;
	for (i = l - 2; S[i] == S[i+1]; i--);
	if ((l - i - 1) % 2 == 0) flag = 0;
	
	if (flag == 1) printf("%lld\n", K * count + (K - 1));
	else printf("%lld\n", K * count);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e9+7;
const ll N = 101;
ll n,t,kobaisu;

ll kbs(ll a,ll b){
	ll m=a,n=b;
	if(a<b){
		ll w=a;
		a=b;
		b=w;
	}
	ll w=1;
	while(w!=0){
		w=a%b;
		a=b;
		b=w;
	}
	m/=a;
	n/=a;
	return m*n*a;
}

int main(){
	cin>>n;
	cin>>kobaisu;
	FOR(i,1,n){
		cin>>t;
		kobaisu=kbs(kobaisu,t);
	}
	cout<<kobaisu<<endl;
	return 0;
}


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

int L, a[21];

int int_sort( const void * a , const void * b ) {
  if( *( int * )a < *( int * )b ) {
    return -1;
  }
  else
  if( *( int * )a == *( int * )b ) {
    return 0;
  }
  return 1;
}


int get_dec(int a, int L, int flag){// flag = 0 -> min flag = 1 -> max
	int res = 0, b[] = {0,0,0,0,0,0};
	int i = 0;
	while(a > 0){
		b[i] = a%10;
		a /= 10;
		i++;
	}
	qsort(b, L, sizeof(int), int_sort);
	if(flag == 0){
		for (i = 0; i < L; i++)
		{
			res += b[i];
			res *= 10;
		}
	}else{
		for (i = 0; i < L; i++)
		{
			res += b[L-1-i];
			res *= 10;
		}
	}
	res /= 10;
	return res;
}

int main()
{
	int i, j;
	int min = 100, ans;
	while(1){
		scanf("%d %d", &a[0], &L);
		if(a[0] == 0 && L == 0) break;
		for (i = 0; i < 20; i++)
		{
			a[i+1] = get_dec(a[i], L, 1) - get_dec(a[i], L, 0);
		}
		for (j = 0; j <= 20; j++)
		{
			for (i = j+1; i <= 20; i++)
			{
				if(a[i] == a[j] && min > i){
					min = i;
					ans = j;
				}
			}
		}
		printf("%d %d %d\n", ans, a[min], min-ans);
		min = 100;
	}
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
	int A, B;
	cin >> A >> B;
	string S;
	cin >> S;
	
	bool is_ok(true);
	if (S[A] != '-') {
		is_ok = false;
	} else {
		string S0 = S.substr(0, A);
		string S1 = S.substr(A + 1);

		if (S0.size() != A || S1.size() != B) {
			is_ok = false;
		} else {
			for (int i = 0; i < A; i++) {
				int is_int = S[i] - '0';
				if (is_int >= 0 && is_int <= 9) {
				} else {
					is_ok = false;
				}
			}
		
			for (int j = 0; j < B; j++) {
				int is_int = S1[j] - '0';
				if (is_int >= 0 && is_int <= 9) {
				} else {
					is_ok = false;
				}
			}
		}
	}

	cout << ((is_ok) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#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字くらい使った方がいいかも
*/

const int inf = 1<<30;

int H, W;
int dist[55][55];
char field[55][55];

void bfs(){
    dist[1][1] = 1;

    queue<pair<int, int>> q;
    q.push({1, 1});

    int d1[4] = {0, -1, 0, 1};
    int d2[4] = {1, 0, -1, 0};

    while(!q.empty()){
        pair<int, int> u = q.front(); q.pop();
        int uh = u.first, uw = u.second;
        for(int i=0; i<4; i++){
            int nxth = uh+d1[i], nxtw = uw+d2[i];
            if(field[nxth][nxtw] == '.' && dist[nxth][nxtw] > dist[uh][uw]+1){
                dist[nxth][nxtw] = dist[uh][uw]+1;
                q.push({nxth, nxtw});
            }
        }
    }
}

int main(){
    cin >> H >> W;
    int black = 0, white = 0;

    for(int i=0; i<55; i++) for(int j=0; j<55; j++) { dist[i][j] = inf; field[i][j] = '#'; }

    for(int i=1; i<=H; i++){
        for(int j=1; j<=W; j++){
            char c; cin >> c;
            if(c == '#') black++;
            else white++;

            field[i][j] = c;
        }
    }

    bfs();

    if(dist[H][W] == inf) cout << -1 << endl;
    else cout << white-dist[H][W] << endl;

}

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

 
 
//----------------------------MACROS-------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 1e5 + 1;//                                                             |
//----------------------------------------------------------------------------------


void solve()
{   
    ll n;cin>>n;
    multiset<ld> m;
    for(int i=0;i<n;i++){
        ld k;cin>>k;
        m.pb(k);
    }
    while(m.size()>1){
        ld a=*m.begin();
        m.erase(m.begin());
        a+=*m.begin();
        m.erase(m.begin());
        m.pb(a/2.0);
    }
    cout<<*m.begin()<<"\n";
    
}
 
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll t; t=1;
    //cin>>t;
    while(t--) solve(); return 0;
}

Measured memory_bytes: 3832
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];

		long sum = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}

		long min = Long.MAX_VALUE;
		long tmp = sum;
		for (int i = 0; i < n - 1; i++) {
			sum -= a[i];
			min = Math.min(min, Math.abs(tmp - sum - sum));
		}

		System.out.println(min);

		sc.close();

	}

}

Measured memory_bytes: 60408
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int MOD = (int)1e9 + 7;
const double PI = acos(-1.0);

const int N = 1e6 + 100;
vector<int> v[N];

void pre(){
	for(int i = 1; i < N; i++){
		for(int j = i; j < N; j += i){
			v[j].push_back(i);
		}
	}
}

int m[N];

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
		m[a[i]]++;
	}
	sort(a,a+n);
	pre();
	int ans = 0;
	for(int i = 0; i < n; i++){
		m[a[i]]--;
		bool ok = true;
		for(auto x : v[a[i]]){
			if(m[x] > 0){
				ok = false;
				break;
			}
		}
		if(ok)
			ans++;
		m[a[i]]++;
	}
	cout << ans << endl;
	
	
	return 0;
}


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

int n, num,ti[105], vi[105];
double mx, s, Y, d[105][105];
int f(int p) {return p > 0 ? p : -p;}
int main()
{
	int i, j, k;
	cin >> n;
	for (i = 1; i <= n; i++) {
		scanf ("%d", &ti[i]);
	}
	for (i = 1; i <= n; i++) {
		scanf ("%d", &vi[i]);
	}
	for (i = 1; i <= n; i++) {
		for (j = 0; j <= vi[i]; j++) {
			mx = -2e9;
			for (k = 0; k <= vi[i - 1]; k++) {
				if (k > vi[i]) continue;
				if (f(j - k) > ti[i]) continue;
				num = vi[i] - k + vi[i] - j;
				if (num <= ti[i]) s =vi[i] * ti[i] - (double)(vi[i] - k) * (vi[i] - k) / 2 - (double)(vi[i] - j) * (vi[i] - j) / 2;
				else {
					Y = (double)(ti[i] + j + k) / 2;
					s = Y * ti[i] - (double)(Y - k) * (Y - k) / 2 - (double)(Y - j) * (Y - j) / 2;
				}
				s += d[i - 1][k];
				if (mx == -2e9 || s > mx) mx = s;
			}
			d[i][j] = mx;
		}
	}
	printf("%.7f", d[n][0]);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#define MAXN 100010

using namespace std;

int n,a[MAXN];
long long ans = 0;
int p = 2;

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

    ans += a[0] - 1;
    for (int i = 1; i < n; i++) {
        if (a[i] == p) {
            p++;
        } else {
            ans += (a[i]-1) / p;
        }
    }

    cout << ans << '\n';
}


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

int main(){
    int n;
    cin>>n;

    vector<pair<pair<string,int>,int>> a(n);
    for(int i=0;i<n;i++){
        string s;
        int p;
        cin>>s>>p;
        a.at(i)=make_pair(make_pair(s,-1*p),i+1);
    }

    sort(a.begin(), a.end());

    for(int i=0;i<n;i++){
        cout<<a.at(i).second<<endl;
    }

}


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

void chmin(int &a, int b) {
     a = min(a, b);
}

const int INF = 1 << 25;
int N, M, R;
int dl[210][210], ds[210][210], dist[1010][210], op[1010];

int main() {
    while(scanf("%d%d", &N, &M)) {
        if(N == M && M == 0) break;
        for(int i=0; i<N; i++) {
            fill(dl[i], dl[i] + N, INF);
            fill(ds[i], ds[i] + N, INF);
            dl[i][i] = ds[i][i] = 0;
        }

        for(int i=0; i<M; i++) {
            int x, y, t; char s;
            scanf(" %d%d%d %c", &x, &y, &t, &s);
            x--; y--;
            if(s == 'L') {
                chmin(dl[x][y], t);
                chmin(dl[y][x], t);
            }
            else {
                chmin(ds[x][y], t);
                chmin(ds[y][x], t);
            }
        }

        for(int k=0; k<N; k++) {
            for(int i=0; i<N; i++) {
                for(int j=0; j<N; j++) {
                    chmin(dl[i][j], dl[i][k] + dl[k][j]);
                    chmin(ds[i][j], ds[i][k] + ds[k][j]);
                }
            }
        }

        scanf("%d", &R);
        for(int i=0; i<R; i++) {
            scanf("%d", &op[i]); op[i]--;
            fill(dist[i], dist[i] + N, INF);
        }

        dist[0][op[0]] = 0;
        for(int i=0; i<R-1; i++) {
            for(int j=0; j<N; j++) {
                if(dist[i][j] == INF) continue;
                int cur = op[i], nxt = op[i+1];

                // land only
                chmin(dist[i+1][j], dist[i][j] + dl[cur][nxt]);

                // land + sea
                for(int k=0; k<N; k++) {
                    chmin(dist[i+1][k], dist[i][j] + dl[cur][j] + ds[j][k] + dl[k][nxt]);
                }
            }
        }

        printf("%d\n", *min_element(dist[R-1], dist[R-1] + N));
    }
    return 0;
}


Measured memory_bytes: 3876
n, h = map(int, input().split())
arr = []
for _ in range(n) :
    a,b = map(int, input().split())
    arr.append((a,-1))
    arr.append((b,1))

cnt = 0
ans = 10**9 + 100
for p in sorted(arr)[::-1] :
    if p[1] == -1 :
        # a
        ans = min(ans, cnt + (h+p[0]-1)//p[0])
        break
    elif p[1] == 1 and h>0 :
        # b
        h -= p[0]
        cnt += 1
        if h <= 0 :
            h = 0
            ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 26836
#include <stdio.h>

int main(void) {
	int A, B;
	int i, x;
	scanf("%d%d", &A, &B);
	while (A!=0 || B!=0)
	{
		x=0;
		for (i=A; i<=B; i++)
		{
			if (i%4==0 && (i%100!=0 || i%400==0))
			{
				printf("%d\n", i);
				x=1;
			}
		}
		if (x==0)
		{
			printf("NA\n");
		}
		scanf("%d%d", &A, &B);
		if (A!=0 || B!=0)
		{
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
  return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
  mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }


  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> p, m;
  rep(i,n) {
    ll x; cin >> x;
    if(x>=0) p.push_back(x);
    else m.push_back(-1*x);
  }
  sort(p.rbegin(),p.rend());
  sort(m.rbegin(),m.rend());
  p.push_back(-1);
  m.push_back(-1);
  ll pp = 0, mm = 0;//ppは正の数で使う個数
  while(k>0) {
    if(p[pp]>=m[mm]) pp++;
    else mm++;
    k--;
  }
  mint ans = 1;
  if(p.size()==1&&mm%2==1) {//答えは必ず負になる
    m.pop_back();
    sort(m.begin(),m.end());
  }
  else if(pp>0 && mm%2==1) {
    if(p[pp-1]*p[pp] >= m[mm-1]*m[mm] && pp < (ll)p.size()-1) {
      pp++; mm--;
    }
    else if(p[pp-1]*p[pp] <= m[mm-1]*m[mm] && mm < (ll)m.size()-1) {
      pp--; mm++;
    }
  }
  else if(pp==0 && mm%2==1 && pp < (ll)p.size()-1) {
    pp++; mm--;
  }
  rep(i,pp) ans *= p[i];
  rep(i,mm) ans *= -1*m[i];
  cout << ans << endl;
  return 0;
}


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

int main() { 
    int a[3][3], n, ans = 0;

    for(int i = 0; i < 3; ++i) {
        for(int j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }
    cin >> n;
    int b;
    for(int ii = 0; ii < n; ++ii) {
        cin >> b;
        for(int i = 0; i < 3; ++i) {
            for(int j = 0; j < 3; ++j) {
                if(a[i][j] == b) {
                    a[i][j] = 0;
                }
            }
        }
    }
    
    if(a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0) {
        ans = 1;
    }
    if(a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0) {
        ans = 1;
    }
    if(a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0) {
        ans = 1;
    }

    if(a[0][0] == 0 && a[1][0] == 0 && a[2][0] == 0) {
        ans = 1;
    }
    if(a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0) {
        ans = 1;
    }
    if(a[0][2] == 0 && a[1][2] == 0 && a[2][2] == 0) {
        ans = 1;
    }

    if(a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) {
        ans = 1;
    }
    if(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) {
        ans = 1;
    }

    if(ans) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
s = input()
t = input()
m = len(s)
n = len(t)
did = m -n
li = []
for i in range(did+1):
  su = 0
  for j in range(n):
    if t[j] ==s[i+j]:
      su +=0
    else:
      su +=1
  li.append(su)
print(min(li))

Measured memory_bytes: 9112
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define MAX (1 << 29)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s)
    ret += to_string(x);
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N), ans(N);
  FOR(i, N) cin >> A[i], ans[A[i] - 1] = i + 1;
  FOR(i, N) cout << ans[i] << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 1664
N = int(input())

#N = int(input())
#N, M = map(int, input().split())
#A = list(map(lambda x: int(x)*(-1), input().split()))
#A = [int(input()) for i in range(N)]
#C = [list(map(int, input().split())) for i in range()]

sum = 0
for i in range(N):
    if (i+1) % 3 != 0 and (i+1) % 5 != 0:
        sum += (i+1)
print(sum)

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

int n, m, q, ans;
int a[55], b[55], c[55], d[55], e[15];

void dfs(int i){
    if (i == n + 1){
        int tmp = 0;
        for (int j = 1; j <= q; ++j){
            if (e[b[j]] - e[a[j]] == c[j]) tmp += d[j];
        }
        ans = max(ans, tmp);
        return;
    }
    for (int j = e[i]; j <= m; ++j){
        e[i+1] = j; dfs(i+1);
    }
}

int main(){
    scanf("%d %d %d", &n, &m, &q);
    for (int i = 1; i <= q; ++i){
        scanf("%d %d %d %d", a+i, b+i, c+i, d+i);
    }
    e[0] = 1; dfs(0);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3796
#include<iostream>
using namespace std;
  int main(){
  int A,B,C;
  cin>>A>>B>>C;
  int temp=B;
  B=A;
  A=temp;
  int temp2=C;
  C=A;
  A=temp2;
  cout<<A<<" "<<B<<" "<<C<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()



int main() {
    ll h, w;
    cin >> h >> w;
    if (h % 3 == 0 || w % 3 == 0) {
        cout << 0 << endl;
        exit(0);
    }
    ll u = h / 2;
    ll d = (h + 1) / 2;
    ll ans = 1e11;
    if (h > 3) {
        chmin(ans, w);
    }
    if (w > 3) {
        chmin(ans, h);
    }
    rep (i, 1, w) {
        vector<ll> p = {h * i, (w - i) * u, (w - i) * d};
        sort(all(p));
        chmin(ans, p[2] - p[0]);
    }
    ll l = w / 2;
    ll r = (w + 1) / 2;
    rep (i, 1, h) {
        vector<ll> p = {w * i, (h - i) * l, (h - i) * r};
        sort(all(p));
        chmin(ans, p[2] - p[0]);
    }
    cout << ans << endl;
}




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

int main(){
    ll n ; cin >> n;
    ll ans = 0;
    for(int i=1;i<(int)(sqrt(n)+1);i++){
        if(n%i != 0) continue;
        ll m = (n/i) - 1;
        if(1<=i && i<=m-1) ans+= m;       
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int i, answer = 700;
  char str[4];
  scanf("%s", str);
  for(i = 0; i < 3; i++) {
    if(str[i] == 'o') answer += 100;
  }
  printf("%d\n", answer);
  return 0;
}


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

namespace AtCoder_Cs
{
    public class Program
    {
        public static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var lst = new HashSet<int>();

            for (int i = 0; i < N; i++)
            {
                lst.Add(int.Parse(Console.ReadLine()));
            }

            Console.WriteLine($"{lst.Count()}");
        }
    }
}


Measured memory_bytes: 13396
A = sum([list(map(int,input().split()))for _ in range(3)],[])
N = int(input())
b = [int(input()) for _ in range(N)]

f=sum(1<<i for i in range(9)if A[i]in b)
print('Yes'if[v for v in[7,56,73,84,146,273,292,448]if f&v==v]else'No')


Measured memory_bytes: 8876
#include <iostream>
#include <vector>
#include <map>
#include <cmath>

using namespace std;
using ll = long long int;
int main(){
  ll n;
  cin >> n;
  map<ll, ll> ANS;
  vector<ll> SUM(n, 0LL);
  
  for(ll i=0;i<n;i++){
    ll vi;
    cin >> vi;
    if(i!=0)
      SUM[i] = SUM[i-1];
    SUM[i] += vi;
  }
  
  for(auto e: SUM){
    {
      ANS[e]++;
    }
  }
  
  ll ans=0;
ANS[0]+=1;
  for(auto e:ANS){
      ans += e.second*(e.second-1)/2;
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 14336
use std::io;
use std::str::FromStr;
use std::collections::HashSet;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| u64::from_str(n).unwrap());
    let (a, b, c) = (it.next().unwrap(), it.next().unwrap(), it.next().unwrap());

    let mut col = HashSet::new();
    col.insert(a);
    col.insert(b);
    col.insert(c);

    println!("{}", col.len());
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) {
        int h;
        cin >> h;
        h--;
        H[i] = h;
    }
    bool ok = true;
    rep2(i, 1, N) {
        int h = H[i];
        if (H[i - 1] <= h) {
            continue;
        } else if (H[i - 1] == h + 1) {
            H[i]++;
        }else {
            ok = false;
        }
    }
    cout << (ok ? "Yes" : "No") << '\n';
}

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


Measured memory_bytes: 640
#include<stdio.h>

void sharpprint(void){
    printf("####################\n");
}

//構造体を使う
void ridgeprint(int ridge[3][10]){
    int i, j;
    for (i = 0; i < 3;i++){
        for (j = 0; j < 10; j++){
            printf(" %d", ridge[i][j]);
        }
        printf("\n");
    }
}

void move_in(int ridge[4][3][10], int moving[4]){
    ridge[moving[0]][moving[1]][moving[2]] += moving[3];
}

int main(void){
    int ridge[4][3][10];
    int action;
    int i, j, k;
    int moving[5];
    for (i = 0; i < 4;i++){
        for (j = 0; j < 3; j++){
            for (k = 0; k < 10;k++){
                ridge[i][j][k] = 0;
            }
        }
        
    }
    scanf("%d", &action);
    for (i = 0; i < action;i++){
        scanf("%d %d %d %d", &moving[0], &moving[1], &moving[2], &moving[3]);
        moving[0] -= 1;
        moving[1] -= 1;
        moving[2] -= 1;
        move_in(ridge, moving);
    }
    for (i = 0; i < 3; i++){
        ridgeprint(ridge[i]);
        sharpprint();
    }
    ridgeprint(ridge[3]);
    return 0;
}


Measured memory_bytes: 2020
#include <stdio.h>

long long cnt;
int l;
int A[1000000];
int n;
int G[1000000];
int size;

void insertionSort(int *A,int n,int g){
  int i,v,j;

  for(i=g;i<n;i++){
    v=A[i];
    j=i-g;

    while(j>=0&&A[j]>v){
      A[j+g]=A[j];
      j-=g;
      cnt++;
    }

    A[j+g]=v;

  }

}

void shellSort(int *A,int n){
  int h,i;

  for(h=1,i=0;;i++){
    if(h>n) break;

    G[i]=h;
    h=3*h+1;
  }
  size=i;

  for(i=size-1;i>=0;i--){
    insertionSort(A,n,G[i]);
  }

}

int main(){
  int i;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  cnt=0;

  shellSort(A,n);

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

  for(i=size-1;i>=0;i--){
    printf("%d",G[i]);
    if(i!=0) printf(" ");
  }
  printf("\n");
  printf("%lld\n",cnt);

  for(i=0;i<n;i++){
    printf("%d\n",A[i]);
  }

  return 0;
}


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

using namespace std;
using ll = long long;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int L, R, d;
	cin >> L >> R >> d;
	cout << R / d - (L - 1) / d;
}


Measured memory_bytes: 3508
#include <stdio.h>

int S1[1000000],f;

int binary_s(int z){
  int lef_s=0,rig_s=f;
  int o;
  while(lef_s<rig_s){
    o=(lef_s+rig_s)/2;
    if(z==S1[o]) return 1;
    if(z>S1[o]) lef_s=o+1;
    else if(z<S1[o]) rig_s=o;
  }
  return 0;
}

int main(){
  int i,g,z,match=0;
  
  scanf("%d",&f);
  for(i=0;i<f;i++){
    scanf("%d",&S1[i]);
      }
  
  scanf("%d",&g);
  for(i=0;i<g;i++){
    scanf("%d",&z);
    if(binary_s(z)) match++;
  }

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

    return 0;
} 
  



Measured memory_bytes: 2240
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
ll dx[4] = {1,0,0,-1};
ll dy[4] = {0,1,-1,0};

#define ARRAY_MAX 100005

int main(){

    ll n;
    cin >> n;
    vector<int> a(ARRAY_MAX),cnt(ARRAY_MAX,0);
    vector<bool> used(ARRAY_MAX,false);

    REP(i,n+1){
        cin >> a[i+1];
        cnt[i+1] = a[i+1];
    }

    /*REP(i,n+1){
        cout << cnt[i] << " ";
    }
    cout << endl;*/

    ll ans = 0;
    for(int i = 1;i <= n;i++){

        if(i == cnt[cnt[i]] && used[i] == false && used[cnt[i]] == false){
            ans++;
            used[i] = used[cnt[i]] = true;
        }
    }
    cout << ans << endl;






    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using LL=long long;

int main() {
  int N;
  cin >>N;
  
  vector<int> vec(N);
  for(int i=0;i < N; i++){
    cin >>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  long long count=0;
  count += vec.at(0);
  
  vector<int> dvec(2*N);
  for(int i=1;i<N;i++){
    dvec.at(2*i-2)=vec.at(i);
    dvec.at(2*i-1)=vec.at(i);
  }
  
  for(int i=0;i<N-2;i++){
    count += dvec.at(i);
  }
  
  cout <<count <<endl;
  
  
}
    
      


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

int main()
{
    string n;
    cin >> n;
    int d[26];
    rep(i, 26) d[i] = 0;
    for (int i = 0; i < n.length(); i++)
    {
        d[n[i] - 'a']++;
    }

    rep(i, 26)
    {
        if (d[i] % 2 == 1)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
A = []

for i in range(n):
    a = int(input())
    A.append(a)
A.sort()
i = 0
ans = 0
while True:
    cnt = 0
    while A[i + cnt] == A[i]:
        cnt += 1
        if i + cnt == n:
            break
    if cnt%2 == 1:
        ans += 1
    i += cnt
    if i == n:
        break
print(ans)

Measured memory_bytes: 81084
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")

#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;



int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n;
	cin >> n;
	string s;
	cin >> s;
	int res = 0;
	for (int i = 0; i < sz(s); i++)
		if (i == 0 || s[i] != s[i - 1])
			res++;
	cout << res;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
int a[200005];
int main(){
        int n;
        while(~getI(n)){
                F(i,0,n) getI(a[i]);
                int small=a[0],ans=1;
                F(i,1,n){
                        if(small>=a[i]) ans++;
                        small=min(a[i],small);
                }
                printf("%d\n",ans);
        }
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>
#include <thread>
#include <fstream>

using namespace std;

//const bool debug = false;

#ifndef M_PI
    const double M_PI = acos(-1.0);
#endif // M_PI

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
//#define ll long long
const int mod = int(1e9) + 7;
//const int inf = 1e7;
//const long long infLL = 1e16;
//const int MX2 = 10100500; //  e7
//const long long INF = 1e18 + 0.5;
const int MX = 300500; //       e6
const int SZ = 122;

vector<int> a[MX];
int pr[MX];
int e[MX];
int n;

int get_next_val(int u, int to_add){
    int val = 0;
    if(val == to_add) val++;
    sort(a[u].begin(), a[u].end());
    for(int i = 0; i < a[u].size(); i++){
            if(a[u][i] == val || val == to_add) val++;
    }
    if(val == to_add) val++;
    return val;
}

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    cin >> n;
    for(int i = 0; i < n; i++){
        int p;
        cin >> p;
        p--;
        pr[i] = p;
        e[p]++;
    }
    list<int> leafs;
    for(int i = 0; i < n; i++){
        if(e[i] == 0) leafs.push_back(i);
    }
    int cnt = n;
    while(leafs.begin() != leafs.end()){
        int u = leafs.front();
        leafs.pop_front();
        int val = get_next_val(u, -1);
        a[ pr[u] ].push_back(val);
        e[pr[u]]--;
        if(e[ pr[u] ] == 0) leafs.push_back(pr[u]);
        cnt--;
    }
    if(cnt % 2 == 0) {cout << "POSSIBLE" << endl; return 0;}
    int root = 0;
    while(e[root] == 0) root++;
    int prev_root_res = -1;

    for(int i = 0; i < 2; i++){
        int root_res = get_next_val(root, prev_root_res);
        int u = pr[root];
        int to_add = root_res;
        while(pr[u] != root){
            u = pr[u];
            to_add = get_next_val(u, to_add);
        }
        int fin_val = get_next_val(u, to_add);
        bool ok = fin_val != root_res;
        if(prev_root_res != -1 && prev_root_res != fin_val) ok = false;
        if(ok){cout << "POSSIBLE" << endl; return 0;}
        prev_root_res = root_res;
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 13568