akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define all(c) begin(c), end(c)
#define range(i,a,b) for(int i = a; i < (int)(b); i++)
#define rep(i,b) range(i,0,b)

struct Dinic {
public:
    using Cap = int;
    Dinic(int n_) : n(n_), g(n_) {}
    Cap maximumFlow(int s_, int t_) {
        s = s_;
        t = t_;
        Cap res = 0;
        while (levelize()) {
            prog.assign(n, 0);
            res += augment(s, numeric_limits<Cap>::max());
        }
        return res;
    }
    void addEdge(int u, int v, Cap c) {
        g[u].push_back({ u,v,c,0,(int)g[v].size() });
        g[v].push_back({ v,u,c,c,(int)g[u].size() - 1 });
    }

private:
    struct Edge {
        int s, d;
        Cap c, f;
        int r;
    };
    vector<vector<Edge>> g;
    int n, s, t;
    vector<int> level, prog;
    bool levelize() {
        queue<int> q;
        q.push(s);
        level.assign(n, -1); 
        level[s] = 0; 
        while (q.size()) {
            int v = q.front();
            q.pop();
            if (v == t) break;
            for (auto &e : g[v]) {
                if (level[e.d] == -1 && residue(e) != 0) {
                    level[e.d] = level[v] + 1;
                    q.push(e.d);
                }
            }
        }
        return level[t] != -1;
    }
    Cap augment(int v, Cap lim) {
        Cap res = 0;
        if (v == t) return lim;
        for (int &i = prog[v]; i < (int)g[v].size(); i++) {
            if (lim == 0) break;
            auto &e = g[v][i];
            if (level[v] < level[e.d] && residue(e) != 0) {
                Cap aug = augment(e.d, min(lim, residue(e)));
                e.f += aug;
                reverse(e).f -= aug;
                res += aug;
                lim -= aug;
            }
        }
        return res;
    }
    Cap residue(const Edge& e) { return e.c - e.f; }
    Edge &reverse(const Edge &e) { return g[e.d][e.r]; }
};

int main() {
    int N, M;
    cin >> N >> M;
    Dinic g(N);
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        g.addEdge(a, b, c);
    }
    Dinic d(g);
    cout << d.maximumFlow(0, N - 1) << endl;
}

Measured memory_bytes: 3248
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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


vector<string> Week={"SUN","MON","TUE","WED","THU","FRI","SAT"};
string s;

void input(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    cin >> s;
    
    
    
}





void solve(){
    int ans=-1;
    for(int i = 0;i < 7;i++){
        if(Week[i]==s) ans = 7-i;
    }
    
    cout << ans << endl;
    
    
    
    
    
    
    
    

}



signed main() {
    
    input();
    solve();
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    long int a,c;
    char s;
    
    scanf("%ld %c %ld",&a,&s,&c);
   

    switch(s)
    {
    case '+':
        printf("%ld",a+c);
        break;
    default :
        printf("%ld",a-c);
    }

    return 0;

}


Measured memory_bytes: 128
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] d = new int[n];
		for(int i = 0; i < n; i++){
		    d[i] = sc.nextInt();
		}
		Arrays.sort(d);
		
		// 計算
		int result = d[n/2] - d[n/2 - 1];
		
		// 出力
		System.out.println(result);
		
	}
}


Measured memory_bytes: 50720
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

bool v_inc(vector<int>& v){
    if(v[8]==3){
        v[8] = 5;
    }else if(v[8]==5){
        v[8] = 7;
    }else if(v[8]==7){
        v[8] = 3;
        for (int i = 7; i >= 0;i--){
            if(v[i]==5){
                v[i] = 7;
                return 0;
            }else if(v[i]==3){
                v[i] = 5;
                return 0;
            }else if(v[i]==0){
                v[i] = 3;
                return 0;
            }else{
                
                if(i==0){
                    return 1;
                }
                v[i] = 3;
            }

        }
    }
    return 0;
}

int main(){
    long long int n;
    cin >> n;
    vector<int> v(9, 0);
    v[6] = 3;
    v[7] = 5;
    v[8] = 7;
    int result = 0;

    bool three_f = 0, five_f = 0, seven_f = 0;
    int j;
    while(100000000*v[0]+10000000*v[1]+1000000*v[2]+100000*v[3]+10000*v[4]+1000*v[5]+100*v[6]+10*v[7]+v[8]<=n){
        for (j = 0; j < 9;j++){
            if(v[j]==3){
                three_f = true;
            }else if(v[j]==5){
                five_f = true;
            }else if(v[j]==7){
                seven_f = true;
            }
        }
        if(three_f ==true&& five_f == true&& seven_f == true){
            result++;
        }
       
        if(v_inc(v)){
            break;
        }
        three_f = 0;
        five_f = 0;
        seven_f = 0;
    }
          cout << result << endl;
        
          
          return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

void solve() {
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);

    ll md = x / d;
    ll ans = x - min(md, k) * d;
    if (k > md) {
        k -= md;
        if (k % 2) {
            ans = abs(ans - d);
        }
    }

    cout << ans << endl;
}

int main() {
    // For fast I/O
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int T;
    T = 1;
    // cin >> T;
    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

ll pow(ll a, ll b) {
	if (b == 0) return 1;
	ll d = pow(a, b / 2);
	ll z = 1;
	if (b % 2) z = a;
	return (((d * d) % MOD) * z) % MOD;
}

ll n, b, r;

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> b >> r;
	ll a = n / (b + r) * b;
	ll p = n % (b + r);
	cout << a + min(p, b) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
    string s;
    cin >> s;
    char m, n;
    int count=0;
    m = s[0];
    while (n != m){
        n = m;
        for (int i=0; i<s.length(); i++){
            if (s[i] != m){
                m = s[i];
                s = s.substr(i);
                count++;
                break;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3780
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        int i,j;
        
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int A[][]=new int[n][m];
        int B[]=new int[m];
        for(i=0;i<n;i++){
            for(j=0;j<m;j++){
                A[i][j]=sc.nextInt();
            }
        }
        for(i=0;i<m;i++)B[i]=sc.nextInt();
        
        int C[]=new int[n];
        for(i=0;i<n;i++){
            C[i]=0;
            for(j=0;j<m;j++){
                C[i]+=A[i][j]*B[j];
            }
        }
        
        for(i=0;i<n;i++)System.out.println(C[i]);
    }
}


Measured memory_bytes: 40996
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get { () => ( get().parse().unwrap() ) }
    
    let n = get!();
    let k: usize = get!();
    let mut vs = vec![0; 200001];
    for i in 0..n {
    	let a: usize = get!();
        vs[a] += 1;
    }
    let mut c = 0;
    for &v in &vs  {
    	if v > 0 {
        	c += 1;
        }
    }
    if k >= c {
    	println!("0");
        return;
    }
    vs.sort();
    let mut ans = 0;
    for &v in &vs {
    	if v > 0 {
        	ans += v;
            c -= 1;
            if c == k {
            	break;
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 6524
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	String s=sc.nextLine();
	char c[]=s.toCharArray();
int a=0;
int b=0;
	for(int i=0;i<s.length();i++){
		if(c[i]=='A'){
			a=i;
			break;
		}
	}
	for(int i=s.length()-1;i>0;i--){
		if(c[i]=='Z'){
			b=i;
			break;
		}
	}
System.out.println(b-a+1);
	}}

Measured memory_bytes: 25236
N = int(input())
S = []
for i in range (N):
    s = input()
    S.append(s[0:1])

m = S.count('M')
a = S.count('A')
r = S.count('R')
c = S.count('C')
h = S.count('H')

total = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h
print(total)

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>

int main(){
    int N,M; cin>>N>>M;
    map<int,int> mp;
    REP(i,M){
        int a,b; cin>>a>>b;
        ++mp[a];
        ++mp[b];
    }
    bool ok = true;
    for(int i=1;i<=N;++i){
        if(mp[i]%2==1){ ok =false; break;}
    }
    cout << (ok?LINY:LINN);
}

Measured memory_bytes: 4992
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	int N = sc.nextInt();


    	ArrayList<String> result = new ArrayList<>();
    	result.add(sc.next());
//    	for(int i=1;i<N;i++) {
//    		System.out.println(i);
//    		String next = sc.next();
//    		boolean chk = true;
//    		for(String j:result) {
//    			if(next.equals(j)) {
//    				chk = false;
//    				break;
//    			}
//    		}
//    		if(chk) {
//    			result.add(next);
//    			Collections.sort(result);
//    		}
//    	}
    	for(int i=1;i<N;i++) {
    		result.add(sc.next());
    	}
		Collections.sort(result);
		ArrayList<String> ans = new ArrayList<String>(new HashSet<>(result));
    	System.out.println(ans.size());
    }

}


Measured memory_bytes: 67932
fun main(args: Array<String>) {
    val (n, k) = readIntegerList()
    val (r, s, p) = readIntegerList()
    val t = readLine()!!
    val dp = Array(n + 1) { LongArray(3) }
    for (i in 1..n) {
        val pre = Math.max(i - k, 0)
        dp[i][0] = Math.max(dp[pre][1], dp[pre][2]) + if (t[i - 1] == 's') r else 0
        dp[i][1] = Math.max(dp[pre][2], dp[pre][0]) + if (t[i - 1] == 'p') s else 0
        dp[i][2] = Math.max(dp[pre][0], dp[pre][1]) + if (t[i - 1] == 'r') p else 0
    }
    var ans = 0L
    for (i in n downTo (n - k + 1)) {
        ans += dp[i].max()!!
    }
    println(ans)
}

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


Measured memory_bytes: 41916
#include <iostream>

using namespace std;

int main() {
	string N;
	cin >> N;

	long long sum = 0;
	for (int i = 0; i < N.size(); ++i) {
		char ch[2];
		ch[0] = N[i];
		ch[1] = '\0';
		sum += (atoi(ch));
	}

	string result = sum % 9 == 0 ? "Yes" : "No";
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cstdint>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	cout << (n == m ? "Yes" : "No") << endl;
	return 0;
}


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

using namespace std;
using ll = long long;

const int mod = 1e9 + 7;

void add_self(int& a, int b) {
    a += b;
    if (a >= mod) {
        a -= mod;
    }
}

void sub_self(int& a, int b) {
    a -= b;
    if (a < 0) {
        a += mod;
    }
}

signed main() {
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> dp(k + 1);
    // dp[i] - the number of ways such that we used i candies so far
    dp[0] = 1;
    for (int child = 0; child < n; child++) {
        int up_to;
        scanf("%d", &up_to);
        vector<int> fake(k + 1);
        for (int used = k; used >= 0; used--) {
            int tmp = dp[used];
            int L = used + 1;
            int R = used + min(up_to, k - used);
            if (L <= R) {
                add_self(fake[L], tmp);
                if (R + 1 <= k) {
                    sub_self(fake[R + 1], tmp);
                }
            }
            //~ for(int i = L; i <= R; ++i) {
                //~ add_self(dp[i], tmp);
            //~ }
        }
        int prefix_sum = 0;
        for(int i = 0; i <= k; i++) {
            add_self(prefix_sum, fake[i]);
            add_self(dp[i], prefix_sum);
        }
    }
    printf("%d\n", dp[k]);     
    return false;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int N;
    cin>>N;
    vector<int> L;

    for(int i = 0;i < N;i++) {
        int l;
        cin>>l;
        L.push_back(l);
    }

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

    int ans =0;
    for(int i = 0;i < N-2;i++) {
        for(int j = i+1;j < N-1;j++) {
            int a = L[i];
            int b = L[j];

            auto it1 = upper_bound(L.begin()+j+1,L.end(),b-a);
            auto it2 = lower_bound(L.begin()+j+1,L.end(),a+b);

            auto l1 = (L.end()-it1);
            auto l2 = (L.end()-it2);
            ans += (l1-l2);
            
            
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        //mod 4 == 0
        int a = 0;
        //mod 4 == 2
        int b = 0;
        //mod 4 == 1, 3
        int c = 0;
        for (int i = 0 ; i < n ; i++) {
            int m = sc.nextInt();
            if (m % 4 == 0) {
                a++;
            } else if (m % 4 == 2) {
                b++;
            } else {
                c++;
            }
        }
        if (b == 0) {
            if (c > a + 1) {
                System.out.println("No");
            } else {
                System.out.println("Yes");
            }
        } else {
            if (c > a) {
                System.out.println("No");
            } else {
                System.out.println("Yes");
            }
        }

    }

}

Measured memory_bytes: 50032
while (ary = gets.split) != ["EndOfInput", "X"]
  str_ary = []
  tmp_str = ary[0][0]
  for num in (1..(ary[0].size - 1))
    tmp_char = ary[0][num]
    unless tmp_char == "_" or tmp_char.ord.between?(65, 90)
      tmp_str += tmp_char
      next
    else
      str_ary << tmp_str
      if tmp_char == "_"
        tmp_str = ""
      else
        tmp_str = tmp_char
      end
    end
  end
  str_ary << tmp_str

  case ary[1]
  when "L"
    for num in (0..(str_ary.size - 1))
      str_ary[num].downcase! if num == 0
      str_ary[num].capitalize! if num != 0
    end
    puts str_ary.join
  when "U"
    str_ary.each {|s| s.capitalize!}
    puts str_ary.join
  when "D"
    str_ary.each {|s| s.downcase!}
    puts str_ary.join("_")
  end
end

Measured memory_bytes: 8672
s = gets.chomp

gets.to_i.times do
  o, b, e, r = gets.split
  b, e = b.to_i, e.to_i
  case o
  when 'print' then puts s[b..e]  
  when 'reverse' then s[b..e] = s[b..e].reverse
  when 'replace' then s[b..e] = r
  end
end

Measured memory_bytes: 8700
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define puts(i) cout<<i<<endl
int main(){
	ll n;
	cin>>n;
	ll l[n+1];
	l[0]=2;
	l[1]=1;
	for(int i=2;i<=n;i++)l[i]=l[i-1]+l[i-2];
	puts(l[n]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n;cin>>n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) {
		cin>>a[i];
	}
	multiset<ll> s;
	for(int i = 0; i < n; i++) {
		auto ite = s.lower_bound(a[i]);
		if (ite != s.begin()){
			s.erase(--ite);
		}
		s.insert(a[i]);
	}
	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;



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

	ll N;
	cin >> N;
	vector<ll> A(1<<N);
	FOR(i,0,(1<<N)){
		cin >> A[i];
	}
	FOR(i,0,N){
		vector<ll> B;
		for(ll j=0;j<A.size();j+=2){
			ll x,y;
			x=A[j];
			y=A[j+1];
			if(x<y)swap(x,y);
			if(x==y)x+=y;
			B.push_back(x-y);
		}
		A = B;
	}
	cout << A[0] << endl;
}

Measured memory_bytes: 3448
#include<stdio.h>
#include<math.h>
int main(){
  double x1,x2,y1,y2,r1,r2,d;
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&r1,&x2,&y2,&r2);
    d=hypot(x1-x2,y1-y2);
    if     (d+r1<r2)printf("-2\n");
    else if(d+r2<r1)printf("2\n");
    else if(r1+r2<d)printf("0\n");
    else            printf("1\n");
  }
  return 0;
}

Measured memory_bytes: 632
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Product and GCD
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

ll powll(ll a, ll b) {
  ll p = 1;
  while (b > 0) {
    if (b & 1LL) p *= a;
    a *= a;
    b >>= 1;
  }
  return p;
}

/* main */

int main() {
  ll n, p;
  scanf("%lld%lld", &n, &p);

  if (n == 1) printf("%lld\n", p);
  else if (n >= 40) puts("1");
  else {
    ll gcd = 1;
    for (ll k = 2;; k++) {
      ll e = powll(k, n);
      if (p < e) break;
      if (p % e == 0) gcd = k;
    }
    printf("%lld\n", gcd);
  }

  return 0;
}


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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

const int N = 3e3+1;
int dp[N][N];
pii path[N][N];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    string s,t; cin >> s >> t;
    int ss = si(s), st = si(t);
    dforn(i,ss) dforn(j,st){
        int &x = dp[i][j];
        pii &y = path[i][j];
        x = dp[i+1][j+1] + (s[i] == t[j]);
        y = s[i] == t[j] ? mp(i,j) : mp(i+1,j+1);
        if(dp[i+1][j] > x) x = dp[i+1][j], y = {i+1,j};
        if(dp[i][j+1] > x) x = dp[i][j+1], y = {i,j+1};
    }
    string r;    
    int lcs = dp[0][0],x=0,y=0,u,v;
    while(lcs){
        tie(u,v) = path[x][y];
        if(x == u && y == v) r += s[x], lcs--, u++, v++;
        x = u, y = v;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 105856
let rec read f n =
  if n <= 0 then []
  else
    let x = f () in
    x :: read f (n - 1)

let () =
  let n = read_int () in
  let xs = read read_int n in
  let tbl = Array.of_list (0 :: xs) in
  let vt = Array.make (n+1) false in
  let rec iter c i =
    if vt.(i) then (-1)
    else if tbl.(i) = 2 then c
    else begin
        vt.(i) <- true;
        iter (c+1) tbl.(i)
      end
  in iter 1 1 |> string_of_int |> print_endline


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

int size;
vector<long long> dat,lazy;
void init(int n){
  size = 1;
  while(size<n) size *= 2;
  dat.assign(2*size-1,0);
  lazy.assign(2*size-1,0);
}
void lazy_evaluate(int k,int l,int r){
  dat[k] += lazy[k] * (r-l);
  if(k<size-1){
    lazy[2*k+1] += lazy[k];
    lazy[2*k+2] += lazy[k];
  }
  lazy[k] = 0;
}
void update(int a,int b,int x,int k,int l,int r){
  lazy_evaluate(k,l,r);
  if(b<=l||r<=a) return;
  else if(a<=l&&r<=b){
    lazy[k] += x;
    lazy_evaluate(k,l,r);
  }else{
    update(a,b,x,2*k+1,l,(l+r)/2);
    update(a,b,x,2*k+2,(l+r)/2,r);
    dat[k] = dat[2*k+1] + dat[2*k+2];
  }
}
long long query(int a,int b,int k,int l,int r){
  lazy_evaluate(k,l,r);
  if(b<=l||r<=a) return 0;
  else if(a<=l&&r<=b){
    return dat[k];
  }else{
    return query(a,b,2*k+1,l,(l+r)/2) + query(a,b,2*k+2,(l+r)/2,r);
  }
}

int main(){
  int n,q;
  scanf("%d %d",&n,&q);
  init(n);
  for(int i=0;i<q;i++){
    int cmd;
    scanf("%d",&cmd);
    if(cmd==0){
      int s,t,x;
      scanf("%d %d %d",&s,&t,&x);
      update(s-1,t,x,0,0,size);
    }else if(cmd==1){
      int s,t;
      scanf("%d %d",&s,&t);
      printf("%lld\n",query(s-1,t,0,0,size));
    }
  }
  return 0;
}

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

using namespace std;

#define int long long

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

	int n;
	cin >> n;
	vector<int> a(n + 1);
	vector<int> b(n);
	for (auto &t : a) {
		cin >> t;
	}
	for (auto &t : b) {
		cin >> t;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int tk = min(b[i], a[i]);
		ans += tk;
		a[i] -= tk;
		b[i] -= tk;
		tk = min(b[i], a[i + 1]);
		a[i + 1] -= tk;
		b[i] -= tk;
		ans += tk;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


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

    ll n,l;
    cin >> n >> l;
    ll minV = INF;
    ll indexV = -1;
    ll sum = 0;
    F0R(i,n){
      sum += l+i;
      if(minV > abs(l+i)){
        minV = abs(l+i);
        indexV = i;
      }
    }
    cout << sum - (l+indexV) << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int h,w,c[11][11],res=0;
std::vector<int> a;
int main(){
  std::cin >> h >> w;
  for(int i = 0; i<=9; i++)for(int j = 0; j<=9; j++)cin >> c[i][j];
  for(int i = 0; i<h; i++)
    for(int j = 0; j<w; j++){
      int x;
      std::cin >> x;
      if(abs(x)!=1) a.push_back(x);
    }
  for(int k = 0; k<=9; k++)
    for(int i = 0; i<=9; i++)
      for(int j = 0; j<=9; j++)
          c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
  for(int e : a) res+=c[e][1];
  std::cout << res << '\n';
}


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

int main(void) {
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<int> diff(N);
  diff[0] = A[0] + (K - A[N - 1]);
  for (int i = 1; i < N; i++) {
    diff[i] = A[i] - A[i - 1];
  }
  cout << K - (*max_element(diff.begin(), diff.end())) << endl;
  return 0;
}

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

#define ll long long
#define lli long long int
#define loop(i,x,n) for(lli i=x; i<=n; i++)
#define rloop(i,n,x) for(lli i=n; i>=x; i--)
#define inf INT_MAX

typedef vector<lli> v64;
typedef vector<pair<lli,lli>> vp64;
typedef vector<bool> vbo;
typedef set<lli> s64;
typedef set<bool> sbo;
typedef unordered_set<lli> us64;
typedef map<lli,lli> m64;
typedef unordered_map<lli,lli> um64;

int main(){
    int n,c;
    cin>>n>>c;
    int w[n],v[n];
    int H = 0;
    for(int i=0; i<n ;i++) cin>>w[i]>>v[i], H+=v[i];
    ll dp[n][H+1];
    dp[0][0] = 0;
    for(int i=1; i<=H; i++){
        dp[0][i] = inf;
    }
    dp[0][v[0]] = w[0];
    for(int i=1; i<n; i++){
        for(int j=0; j<=H; j++){
            dp[i][j] = dp[i-1][j];
            if(j>=v[i]){
                dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]]+w[i]);
            }
        }
    }
    int ans = 0;
    for(int i=0; i<=H; i++){
        if(dp[n-1][i]<=c) ans = max(ans,i);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 78464
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)

# lis_of_lis = [[] for _ in range(N)]


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


K = z()
if K == 7:
    print(1)
    exit()

t = 7 % K
for i in range(1, K+1):
    if t == 0:
        print(i)
        exit()

    t = (t * 10 + 7) % K

print(-1)


Measured memory_bytes: 42392
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    string S;
    in(S);

    int s = 0;
    int l = 0;

    rep(i, S.size())
    {
        int tmps = i;
        int tmpl = 0;
        reps(j, i, S.size())
        {
            if (S[j] != 'A' && S[j] != 'T' && S[j] != 'C' && S[j] != 'G')
            {
                break;
            }

            tmpl++;
        }
        chmax(l, tmpl);
    }

    outl(l);

    return 0;
}

Measured memory_bytes: 3652
// **** WHEN THE GOING GETS TOUGH, THE TOUGH GETS GOING. ****
#include<bits/stdc++.h>
using namespace std;
#define fi              first
#define se              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pll             pair<ll,ll>
#define vll              vector<int>
#define mll             map<ll,ll>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define md             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
void hi()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
void bye()
{
    #ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
    #endif
}
ll ans=md,c=0,o=0,e=0,a[123456];
void printArray(ll arr[], ll size) 
{ 
    for(ll i = 0; i < size; i++) 
        cout<<arr[i]<<" "; 
    printf("\n"); 
    return; 
} 
void printSequencesRecur(ll arr[], ll n, ll k, ll index) 
{ 
   ll i; 
   if (k == 0) 
   {
       ans=min(ans,o);
       ans=min(ans,e);
       o=0,e=0;

    printArray(arr, index); 
   } 
   if (k > 0) 
   { 
      for(i = 1; i<=n; ++i) 
      { 
        arr[index] = a[i-1];
        c++;c%=2;
        if(c==0) o=max(o,arr[index]);
        else e=max(o,arr[index]); 
        printSequencesRecur(arr, n, k-1, index+1); 
      } 
   }
}
void printSequences(ll n, ll k) 
{ 
    ll *arr = new ll[k]; 
    printSequencesRecur(arr, n, k, 0); 
  
    delete(arr); // free dynamically allocated array 
    return; 
}  
void solve()
{
    ll n; cin>>n;
    ll a[n],b[n]={0};
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n-1;i++)  b[n-1]^=a[i];
    for(int i=0;i<n-1;i++)  b[i]=(a[i]^a[n-1])^b[n-1];
    for(int i=0;i<n;i++) cout<<b[i]<<" ";
}

int main()
{
    hi();
    ll test_cases=1; //cin>>test_cases;
    for(ll t=1;t<=test_cases;t++)
    {
        solve();
    }
    bye();
    return 0;
}

Measured memory_bytes: 6752
n, k = map(int, input().split())

def Base_10_to_n(X, n):
  X_dumy = X
  out = ''
  while X_dumy>0:
    out = str(X_dumy%n)+out
    X_dumy = int(X_dumy/n)
  return out

print(len(str(Base_10_to_n(n, k))))


Measured memory_bytes: 2940
#include<cstdio>
#include<set>
#include<iostream>
#include <iterator>
#include <utility>
#include<map>
#define max 100005
using namespace std;
struct tree
{
	int parent;
	int left;
	int  right;
};
struct tree T[max];
int dep(int i)
{
	int d=0;
	while(T[i].parent!=-1)
	{
		i=T[i].parent;
		d++;
	}
	return d;
}
void print(int i)
{
	printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,dep(i));
	if(T[i].parent==-1)
	printf("root, ");
	else if(T[i].left==-1)
	printf("leaf, ");
	else
	printf("internal node, ");
	printf("[");
	for(int j=0,c=T[i].left;c!=-1;c=T[c].right,j++)
	{
		if(j)
		printf(", ");
		printf("%d",c);
	}
	printf("]\n");
}
int main()
{
	int n,id,k,c,p,r,l;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		T[i].left=-1;
		T[i].parent=-1;
		T[i].right=-1;
	}
	for(int i=0;i<n;i++)
	{
		cin>>id>>k;
		for(int j=0;j<k;j++)
		{
			cin>>c;
			if(j==0)
			T[id].left=c;
			else
			T[l].right=c;
			l=c;
			T[c].parent=id;
		}
	}
	for(int i=0;i<n;i++)
	print(i);
	return 0;
}


Measured memory_bytes: 4396
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int n = sc.nextInt(), m = sc.nextInt();
        UnionFind uf = new UnionFind(n + 1);
        for (int i = 0; i < m; i++) {
            uf.unite(sc.nextInt(), sc.nextInt());
        }

        int ans = 1;
        for (int i = 1; i <= n; i++) {
            ans = Math.max(ans, uf.size(i));
        }

        out.println(ans);

        out.flush();
    }

    public class UnionFind {
        int[] parents, sizes;

        UnionFind(int n) {
            parents = new int[n];
            sizes = new int[n];
            for(int i = 0; i < n; i++) {
                parents[i] = i;
                sizes[i] = 1;
            }
        }

        public int find(int x) {
            if (x == parents[x]) return x;
            return parents[x] = find(parents[x]);
        }

        public void unite(int x, int y) {
            x = find(x);
            y = find(y);
            if (x == y) return;
            if (sizes[x] < sizes[y]) {
                int temp = x;
                x = y;
                y = temp;
            }
            parents[y] = x;
            sizes[x] += sizes[y];
        }

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

        public int size(int x) {
            return sizes[find(x)];
        }
    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

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

int solve(int x) {
	int d = 0;
	for (int i = 1; i <= x; ++i) {
		if (x % i == 0) d++;
	}
	return d == 8 ? 1 : 0;
}

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	int cnt = 0;
	for (int i = 1; i <= n; ++i) {
		if (i % 2 == 0) continue;
		cnt += solve(i);
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)
const int N = 1e6  + 4;
int v[N];
int main() {
#ifndef ONLINE_JUDGE
#endif
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   int n;
   cin >> n;
   vector<int> a(n);
   for(int &x : a)
      cin >> x , v[x]++;

   int rs = 0;
   for(int x : a){
      v[x]--;
      bool good = true;
      for(int i = 1 ; 1ll * i * i <= x ; ++i){
         if(x % i == 0){
            if(v[i] || v[x/i]){
               good = false;
               break;
            }
         }
      }
      rs += good;
      v[x]++;
   }
   cout << rs << "\n";
}


Measured memory_bytes: 7728
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional> 

#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define REP(i,n) FOR(i,0,n)
 
int main()
{
  int n;
  std::vector<int> d;
  REP(i,10) {
      scanf("%d", &n);;
      d.push_back(n);
  }
  std::sort(d.begin(), d.end(), std::greater<int>() );
  printf("%d\n",d[0]);
  printf("%d\n",d[1]);
  printf("%d\n",d[2]);
   
  return 0;
}


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

#define rep(i,s,n) for (int i = (ll)s; i < (ll)n; i++)
#define rrep(i,n,e) for (int i = (ll)n-1; i >= (ll)e; i--)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) cout << fixed << setprecision(10) << x << endl;
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;

constexpr ll LINF = 1001002003004005006ll;
constexpr int INF = 1001001001;
constexpr int n_max = 2e5+10;

int powint(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x; n >>= 1;
  }
  return ret;
};

ll powll(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x; n >>= 1;
  }
  return ret;
};

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; };

void print() { cout << endl; };
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
};
template <class T>
void print(vector<T> &vec, ll k){
   ll n = vec.size();
   k = min(k, n);
   rep(i, 0, k-1) cout << vec[i] << " ";
   cout << vec[k-1] << endl;
};
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
    print(vec);
  }
};
template<class T, class U>
void print(pair<T,U> &p){
  cout << p.first << " " << p.second << "\n";
};

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

  int h1, m1, h2, m2; cin >> h1 >> m1 >> h2 >> m2;
  int k; cin >> k;
  int h = k / 60;
  int m = k % 60;
  int h3, m3;
  if (m > m2) {
    m3 = 60 + m2 - m;
    h2--;
    h3 = h2 - h;
  } else {
    m3 = m2 - m;
    h3 = h2 - h;
  }

  int ah, am;
  if (m1 > m3) {
    am = 60 + m3 - m1;
    h3--;
    ah = h3 - h1;
  } else {
    am = m3 - m1;
    ah = h3 - h1;
  }

  cout << ah * 60 + am << endl;



  return 0;
};


Measured memory_bytes: 3640
<?php 
    fscanf(STDIN, "%d %d %d", $a, $b, $c);  //a2 b4 c2

    $num = [$a,$b,$c];

    if(count(array_unique($num)) == 1){
        echo "No";
    } elseif(count(array_unique($num)) == 2){
        echo "Yes";
    } else {
        echo "No";
    };

Measured memory_bytes: 4604
var a,b:byte;
begin
readln(a, b);
if (a=1) and (b=2)  then write('3');
if (a=2) and (b=1)  then write('3');
if (a=2) and (b=3)  then write('1');
if (a=3) and (b=2) then write('1');
if (a=1) and (b=3) then write('2');
if (a=3) and (b=1)  then write('2');
end.






Measured memory_bytes: 128
#include<bits/stdc++.h>
#define  INF 1100000000
#define	 MOD 1000000007
using namespace std;

int main(){
	int N;
	while(cin >> N, N != 0){
		string w;
		int size[1000];
		for(int i=0;i<N;i++){
			cin >> w;
			size[i+1] = w.size();
		}
		
		for(int i=1;i<=N;i++){
			int count=0, j=i;
			while(count < 5){
				count += size[j];
				j++;
			}
			if(count != 5){
				continue;
			}
			count = 0;
			while(count < 7){
				count += size[j];
				j++;
			}
			if(count != 7){
				continue;
			}
			count = 0;
			while(count < 5){
				count += size[j];
				j++;
			}
			if(count != 5){
				continue;
			}
			count = 0;
			while(count < 7){
				count += size[j];
				j++;
			}
			if(count != 7){
				continue;
			}
			count = 0;
			while(count < 7){
				count += size[j];
				j++;
			}
			if(count != 7){
				continue;
			}
			cout << i << endl;
			break;
		}
	}
	return 0;
	
}


Measured memory_bytes: 3176
#include <iostream>
#include <string>

using namespace std;
int main(){
	string s;
	cin >> s;
	int c = 0;
	for(int i=0;i<s.size()-1;i++){
		if(s[i]!=s[i+1])c++;
	}
	// cout << c << endl;
	if(c%2)cout << 'o' << endl;
	else cout << s[0] << endl;
}

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

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

int main() {
    vector<int> d(4);
    rep(i, 3) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        d[x]++; d[y]++;
    }
    rep(u, 4) if (d[u] >= 3) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
}


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

int main()
{
  int count=0;
  string T, W;
  cin >> W;
  transform(T.begin(), T.end(), T.begin(), ::tolower);

  while(1)
    {
      cin >> T;
      if(T=="END_OF_TEXT")
	break;
      transform(T.begin(), T.end(), T.begin(), ::tolower);
      if(W==T)
	count += 1;
    }
  cout << count << endl;
}

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

int main(){
	int N, T, A, H; cin >> N >> T >> A;
	double closest_diff = 1000; // init
	int closest_index = 0;
	
	for (int i=0; i<N; ++i){
		cin >> H;
		if (closest_diff <  abs(A - (T - H*0.006))){
			// do nothing
		} else {
			closest_diff = abs(A - (T - H*0.006));
			closest_index = i; 
		}
	}
	cout << closest_index + 1 << endl;  // start from 1
	return 0;
}


Measured memory_bytes: 256