akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define bash push_back
#define alles(x) x.begin(),x.end()
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
const int INF=1 << 30;
bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vit;
typedef map<string,int> mstit;
typedef priority_queue<int> pqit;

ll n,a[1000005];
int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  cin >>n;
  FOR(i,n*3){
    cin >>a[i];
  }
  sort(a,a+n*3,greater<int>());
  ll ans=0;
  for(int i=1;i<=n*2;i+=2){
    ans+=a[i];
  }
  cout <<ans fin;
  return 0;
}



Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  rep(i, n) rep(j, m) {
    cin >> a[i][m-1-j];
    a[i][m-1-j]--;
  }
  vector<int> num(m);
  rep(i, n) num[a[i].back()]++;
  int mx = 0, idx;
  rep(i, m) {
    if (chmax(mx, num[i]))
      idx = i;
  }
  vector<bool> exist(m, true);
  int ans = mx;
  rep(i, m-1) {
    num[idx] = 0;
    exist[idx] = false;
    rep(j, n) {
      if (!exist[a[j].back()]) {
        while (!exist[a[j].back()])
          a[j].pop_back();
        num[a[j].back()]++;
      }
    }
    mx = 0;
    rep(j, m) {
      if (chmax(mx, num[j]))
        idx = j;
    }
    chmin(ans, mx);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  if ((n - 1) % (k - 1) == 0) cout << (n - 1) / (k - 1) << endl;
  else cout << (n - 1) / (k - 1) + 1 << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
x = I()
ans = 2*(x//11)+1
x %= 11
if x == 0:
    ans -= 1
if x > 6:
    ans += 1
print(ans)
"""

#D
n = I()
a = LI()
d = defaultdict(int)
for i in a:
    d[i] += 1
l = list(d.values())
k = len(l)+sum(l)
for i in d.keys():
    d[i] = 1
ans = sum(list(d.values()))
ans -= 1 if k%2 else 0
print(ans)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 18848
#include <cstdio>
#include <cstring> 
#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a
#define N 200006
int n,a[N];char s[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)a[i]=1;
	for(int i=1;i<=n;i++){
		int x=i;
		for(int j=2;j<=n;j++)if(x%j==0){
			while(x%j==0)x/=j,a[j]++;
		}
	}
	for(int i=2;i<=n;i++)a[i]=1LL*a[i]*a[i-1]%1000000007;
	printf("%d",a[n]);
}

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

const double EPS = 1e-8;
const int N = 105;
const int M = 55;

int n, m, l, t[N], v[N];
double dp[N][M];
double sum[N][M];

void gao(double p, double dp[], double sum[]) {
	double q = 1-p, f[2][M] = {};
	f[0][0] = 1;
	for (int i = 1, x = 1; i <= m; ++i, x^=1) {
		f[x][0] = f[!x][0] * q;
		for (int j = 1; j <= i; ++j) {
			f[x][j] = f[!x][j-1] * p + f[!x][j] * q;
		}
	}
	dp[m+1] = sum[m+1] = 0;
	for (int i = m, x = m & 1; i >= 0; --i) {
		sum[i] = sum[i+1] + (dp[i] = f[x][i]);
	}
}

// return true if (i,j) < (x,y)
bool faster(int i, int j, int x, int y) {
	return l*v[x] + t[i]*j*v[i]*v[x] < l*v[i] + t[x]*y*v[i]*v[x];
}

int binsearch(int i, int j, int k) {
	int l = -1, r = m+1, mid;
	while (l + 1 < r) {
		mid = (l+r)>>1;
		faster(i,j,k,mid) ? r=mid : l=mid;
	}
	return r;
}

void debug(double a[], int s, int t) {
	for(int i=s;i<t;++i)printf("%f ", a[i]);puts("");
}

int main() {
	while (3==scanf("%d%d%d", &n, &m, &l)) {
		for (int p,i = 0; i < n; ++i) {
			scanf("%d%d%d", &p, &t[i], &v[i]);
			gao(p/100., dp[i], sum[i]);
//			debug(dp[i], 0, m+2);
//			debug(sum[i], 0, m+2); 
		}
		for (int i = 0; i < n; ++i) {
			double ans = 0;
			for (int j = 0; j <= m; ++j) {
				double p = dp[i][j];
				for (int r,k = 0; k < n; ++k) {
					if (i == k) continue;
					r = binsearch(i, j, k);
					p *= sum[k][r];
				}
				ans += p;
			}
			printf("%.10f\n", ans);
		}
	}
}

Measured memory_bytes: 1156
#include<stdio.h>
int main(void)
{
	double max=0,min=10000,temp,ans;
	while(scanf("%lf",&temp)!=EOF){
		if(temp>max){
			max=temp;
		}
		if(temp<min){
			min=temp;
		}
	}
	printf("%lf",max-min);
	return 0;
}

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

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

  int count = 0;
  for (int i = 0; i < n; i++) {
    while (i + 1 < n && a.at(i) == a.at(i + 1)) ++i;

    if (i + 1 < n && a.at(i) < a.at(i + 1)) {
      while (i + 1 < n && a.at(i) <= a.at(i + 1)) ++i;
    } else if (i + 1 < n && a.at(i) > a.at(i + 1)) {
      while (i + 1 < n && a.at(i) >= a.at(i + 1)) ++i;
    }
    count++;
  }

  cout << count << endl;
}

Measured memory_bytes: 3752
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    long long n, k;
    cin >> n >> k;

    vector<long long> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    long long res = 0;
    for (int i = 0; i < n; i++) {
        if ((k | a[i]) <= k) {
            res += b[i];
        }
    }

    for (int i = 0; i <= 31; i++) {
        if ((k & (1LL << i)) > 0) {
            long long r = 0, s = ((k | ((1LL << i) - 1)) ^ (1LL << i));
            for (int j = 0; j < n; j++) {
                if ((s | a[j]) <= s) {
                    r += b[j];
                }
            }
            res = max(res, r);
        }
    }

    cout << res << '\n';
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main() {
  int n; cin >> n;
  vector<int> a(n);
  vector<vector<int>> cnt(2, vector<int>(1e5+1, 0));

  vector<int> m(2, 0), p(2, 0);
  REP(i, n){
    cin >> a[i];
    cnt[i & 1][a[i]]++;

    if(cnt[i & 1][a[i]] > m[i & 1]){
      m[i & 1] = cnt[i & 1][a[i]];
      p[i & 1] = a[i];
    }
  }

  if(p[0] == p[1]){
    if(m[0] == m[1]){
      vector<int> s(2, 0);
      REP(i, n){
        if(a[i] == p[0]) continue;
        s[i & 1] = max(s[i & 1], cnt[i & 1][a[i]]);
      }
  
      if(s[0] > s[1]) m[0] = s[0];
      else m[1] = s[1];
    } else if(m[0] > m[1]){
      int sum = 0;
      REP(i, n){
        if(i & 1 && a[i] != p[1]){
          sum = max(cnt[i & 1][a[i]], sum);
        }
      }
      m[1] = sum;
    } else {
      int sum = 0;
      REP(i, n){
        if((i & 1) == 0 && a[i] != p[0]){
          sum = max(cnt[i & 1][a[i]], sum);
        }
      }
      m[0] = sum;

    }
  }

  cout << n - m[0] - m[1] << endl;

  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = round(1e9+7);

int main() {
    vi col(3);
    rep(i,3) cin >> col[i];
    int N;
    cin >> N;

    ll ans = 0;
    sort(col.begin(), col.end());
    rep(i,N/col[2]+1){
       int tmp = N-i*col[2];
       if(tmp < 0) break;
       rep(j,tmp/col[1]+1){
           if(tmp-col[1]*j < 0) break;
           if((tmp-col[1]*j)%col[0] == 0) ans++;
       } 
    }


    cout << ans << endl;
    return 0;
}


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

int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++) cin >> a.at(i).at(j);
  }
  
  vector<int> cuth(0);
  vector<int> cutw(0);
  for(int i = 0; i < h; i++){
    bool ok = false;
    for(int j = 0; j < w; j++){
      if(a.at(i).at(j) == '#') ok =true;
    }
    if(!ok) cuth.push_back(i);
  }
  for(int i = 0; i < w; i++){
    bool ok = false;
    for(int j = 0; j < h; j++){
      if(a.at(j).at(i) == '#') ok = true;
    }
    if(!ok) cutw.push_back(i);
  }
  if((int)cuth.size()){
    reverse(cuth.begin(), cuth.end());
    for(int i = 0; i < h; i++){
      int k = cuth.back();
      if(k != i) continue;
      cuth.pop_back();
      for(int j = 0; j < w; j++) a.at(i).at(j) = '*';
    }
  }
  
  if((int)cutw.size()){
    reverse(cutw.begin(), cutw.end());
    for(int i = 0; i < w; i++){
      int k = cutw.back();
      if(k != i) continue;
      cutw.pop_back();
      for(int j = 0; j < h; j++) a.at(j).at(i) = '*';
    }
  }
  
  for(int i = 0; i < h; i++){
    bool ok = false;
    for(int j = 0; j < w; j++){
      char c = a.at(i).at(j);
      if(c == '*') continue;
      cout << c;
      ok = true;
    }
    if(ok) cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int T[200005]={0};

int main(){
  int n;
  cin>>n;
  int k=1;
  for(int i=1;i<=n;i++){
    cin>>T[i];
    if(k==T[i])k++;
  }
  if(k==1)cout<<-1<<endl;
  else cout<<n-k+1<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc=new Scanner(System.in);
		
		int r=sc.nextInt();
		double d=2*r*Math.PI;
		
		System.out.println(d);
		
	}

}

Measured memory_bytes: 27132
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int i=1;
do{
  int x=i;
  if(x%3==0){
	  System.out.print(" "+i);
  } else{
 do{
  if(x%10==3){
  System.out.print(" "+i);
  break;
}
x/=10;
 }while(x!=0);
 }
} while (++i <= n);
System.out.println();
}
}

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

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		sum += v[i];
	}
	sort(v.rbegin(),v.rend());
	cout << sum - v[0] / 2;
}


Measured memory_bytes: 256
L, R = map(int, input().split())
ans = 2019
    
if L//2019 != R//2019:
    print(0)
    exit(0)
else:
    L = L%2019
    R = R%2019

    for i in range(L,R+1):
        for j in range(i+1,R+1):
            ans = min(ans,(i*j)%2019)

print(ans)

Measured memory_bytes: 9072
n = int(input())
a_L = list(map(int,input().split()))

start = min(a_L)
end = max(a_L)

ans = float("inf")
for i in range(start,end+1):
    cost = 0
    for val in a_L:
        cost += (val-i)**2
    
    ans = min(ans,cost)

print(ans)

Measured memory_bytes: 39732
#include<iostream>
long long int m,r=-1,s=-1,i,d,c;
int main() {
    std::cin>>m;
    for(i=0;i<m;i++){
        std::cin>>d>>c;
        r+=d*c;
        s+=c;
    }
  std::cout<<s+r/9;
} 


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

int main(){
  int N, D;
  cin >> N >> D;
  vector<vector<int>> X(N,vector<int>(D));

  for(int i=0; i<N; i++){
    for(int j=0; j<D; j++){
      cin >> X.at(i).at(j);
    }
  }
  
  int S=0, count=0;
  double sq;
  for(int i=0; i<N-1; i++){
    for(int j=1; j<N-i; j++){
      S=0;
      for(int k=0; k<D; k++){
        S += (X.at(i).at(k) - X.at(i+j).at(k))*(X.at(i).at(k) - X.at(i+j).at(k));
      }
      sq = sqrt((double)S);
      
      if(sq - floor(sq) == 0){
        count += 1;
      }
    }
  }

  cout << count << endl;
}

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

int main(){
	ll n;
	cin>>n;
	char s[n];
	int r=0,l=0;
	for(int i=0;i<n;i++){
		cin>>s[i];
		if(s[i]=='R'){
			r++;
		}else{
			l++;
		}
	}
	if(r>l){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

#define int long long
#define double long double

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }

int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define REP(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	REP(i,0,n)
#define PER(i,a,b)	for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n)	PER(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define dump(val) 	cerr << #val " = " << val << endl;
#define dum(val)	cerr << #val " = " << val;
#define FILL(a,v)	fill(a,a+sizeof(a)/sizeof(*a),v)

const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e17 + 9;

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

	string s;
	cin >> s;

	bool start_od = s.size() % 2;
	bool end_od = s.front() == s.back();
	
	if (start_od == end_od) {
		cout << "Second" << endl;
	}
	else {
		cout << "First" << endl;
	}

	return 0; 
}

Measured memory_bytes: 512
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int a=0;
    int n; cin >> n;
    for(int i = 0; i < 1000; ++i) {
        a += 1000;
        if(a >= n) {
            cout << a - n << endl;
            return 0;
        }
    }
}

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

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans = -1e18;
  ans = max(ans, a * c);
  ans = max(ans, b * c);
  ans = max(ans, a * d);
  ans = max(ans, b * d);
  cout << ans;
}

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

using namespace std;

int main() {
  	int n, m;
  	cin >> n;
  	int t[n];
  	for (int& x : t)
      	cin >> x;
  	cin >> m;
  	int p[m], x[m];
 	for (int i = 0; i < m; i++)
      	cin >> p[i] >> x[i];
  	for (int k = 0; k < m; k++) {
    	int sum = 0;
      	for (int i = 0; i < n; i++)
          	sum += (i + 1 == p[k] ? x[k] : t[i]);
      	cout << sum << endl;
    }
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, p;
    cin >> n >> p;
    vector<ll> A(n);
    for(auto &x : A) {
        cin >> x;
    }
    ll dp[100 * 50 + 1] = {};
    dp[0] = 1;
    for(int i = 0; i < n; i++) {
        for(int j = 100 * 50 - A[i]; j >= 0; j--) {
            dp[j + A[i]] += dp[j];
        }
    }
    ll ret = 0;
    for(int i = 0; i <= 100 * 50; i++) {
        if(i % 2 == p) ret+=dp[i];
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, a) for (int i = 0; i < (int)(a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) {
  cerr << head;
  dump();
}
template <typename Head, typename... Tail>
void dump(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  dump(forward<Tail>(tail)...);
}
#define debug(...)                                                               \
  do {                                                                         \
    cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = ";                        \
    dump(__VA_ARGS__);                                                         \
  } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

const ll LINF = 1LL << 60;
const int INF = 1001001001;

/////////////////////////////////////////////////////////////////////


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

  int n; cin >> n;
  int q; cin >> q;

  dsu d(n);
  vector<int> ans;
  for (int i=0; i<q; i++){
    int t,u,v; cin>>t>>u>>v;
    if (t==0) d.merge(u, v);
    else ans.push_back(d.same(u, v));
  }
  for (auto v:ans) cout << v << endl;

  return 0;
}


Measured memory_bytes: 4428
#include <bits/stdc++.h>
#define pi acos(-1)
#define pb push_back
using namespace std;
typedef long long ll;
string text="abcdefghijklmnopqrstuvwxyz";
const int mx=1e5+7;
const ll m=1e9+7;
ll n,q;
ll lazy[4*mx];
int a[mx];
ll tree[4*mx];
//void init(int node,int b,int e)
//{
//    if(b==e){
//        tree[node]=a[b];
//        return;
//    }
//    int l=node*2;
//    int r=node*2+1;
//    int m=(b+e)/2;
//    init(l,b,m);
//    init(r,m+1,e);
//    tree[node]=tree[l]*tree[r];
//}
//int query(int node,int b,int e,int i,int j)
//{
//    if(i>e || j<b)return 1;
//    if(b>=i && e<=j){
//        return tree[node];
//    }
//    int l=node*2;
//    int r=node*2+1;
//    int m=(b+e)/2;
//    int p1=query(l,b,m,i,j);
//    int p2=query(r,m+1,e,i,j);
//    return p1*p2;
//}
//void update(ll node, ll b, ll e, ll i, ll j, ll x)
//{
//    if (i > e || j < b)
//        return;
//    if (b >= i && e <= j)
//    {
//        tree[node].sum += ((e - b + 1) * x);
//        tree[node].prop += x;
//        return;
//    }
//    ll Left = node * 2;
//    ll Right = (node * 2) + 1;
//    ll mid = (b + e) / 2;
//    update(Left, b, mid, i, j, x);
//    update(Right, mid + 1, e, i, j, x);
//    tree[node].sum = (tree[Left].sum+ tree[Right].sum + ((e - b + 1) * tree[node].prop));
//}
//void update(int node, int b, int e, int i, int newvalue)
//{
//    if (i > e || i < b)
//        return;
//    if (b >= i && e <= i) {
//        tree[node] = newvalue;
//        return;
//    }
//    int l = node * 2;
//    int r = node * 2 + 1;
//    int m = (b + e) / 2;
//    update(l, b, m, i, newvalue);
//    update(r, m + 1, e, i, newvalue);
//    tree[node] = (tree[l] * tree[r]);
//}
//void update(int node,int b,int e,int l,int r,int val)
//{
//    if(lazy[node]!=0){
//        tree[node]+=(e-b+1)*lazy[node];
//        if(b!=e){
//            lazy[node*2]+=lazy[node];
//            lazy[node*2+1]+=lazy[node];
//        }
//        lazy[node]=0;
//    }
//    if(b>e || b>r || e<l)return;
//    if(b>=l && e<=r){
//        tree[node]+=(e-b+1)*val;
//        if(b!=e){
//            lazy[node*2]+=val;
//            lazy[node*2+1]+=val;
//        }
//        return;
//    }
//    int mid=(b+e)/2;
//    update(node*2,b,mid,l,r,val);
//    update(node*2+1,mid+1,e,l,r,val);
//    tree[node]=tree[node*2]+tree[node*2+1];
//}
//int query(ll node,ll b,ll e,ll l,ll r)
//{
//     if(b>e || b>r || e<l)return 0;
//     if(lazy[node]!=0){
//        tree[node]+=(e-b+1)*lazy[node];
//        if(b!=e){
//            lazy[node*2]+=lazy[node];
//            lazy[node*2+1]+=lazy[node];
//        }
//        lazy[node]=0;
//    }
//    if(b>=l && e<=r){
//        return tree[node];
//    }
//    ll mid=(b+e)/2;
//    ll p1=query(node*2,b,mid,l,r);
//    ll p2=query(node*2+1,mid+1,e,l,r);
//    return p1+p2;
//}
int main()
{
    ll n,k;
    cin>>n>>k;
    ll x=n%k;
    ll y=k-x;
    cout<<min(x,y)<<endl;
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,i,s=0;
    cin>>n>>k;
    int a[n+2];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;i<k;i++)
    {
        s+=a[i];
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next(); //Input String
    int N = s.length(); //Size of the input string    
    //Case 1: 101010101010
    int caseoneanswer = 0;
    for(int i = 1; i<=N; i++){
      if(i%2 == 1 && s.charAt(i-1) == '0'){
        caseoneanswer++; 
      } 
      if(i%2 == 0 && s.charAt(i-1) == '1'){
        caseoneanswer++; 
      }
    }
    //Case 2: 01010101010
    int casetwoanswer = 0;
    for(int i = 1; i<=N; i++){
      if(i%2 == 1 && s.charAt(i-1) == '1'){
        casetwoanswer++;
      }
      if(i%2 == 0 && s.charAt(i-1) == '0'){
        casetwoanswer++; 
      }
    }
    System.out.println(Math.min(caseoneanswer, casetwoanswer));
  }
}

Measured memory_bytes: 39572
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int k,n;
    cin>>k>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    int ans=k-a[n-1]+a[0];
    rep(i,n-1){
        ans=max(ans,a[i+1]-a[i]);
    }
    ans=k-ans;
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define sz(x) ((int)(x).size())
using namespace std;
typedef long long ll;
const int n = 1e6 + 5;

int N, M, K, T;
int A[n];
int F[n], TC[n];

bool bc(int n, int k){
	int r = F[n] - F[k] - F[n-k];
	//if(!(r >= 0)){
//		cerr << "n: " << n << " k:"
//	}
	return r == 0;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	F[0] = 0;
	for(int i = 0; i <= N; ++i){
		int z = i;
		while(z > 0 && (z % 2) == 0){
			TC[i]++;
			z = z >> 1;
		}
	}

	for(int i = 1; i <= N; ++i){
		F[i] = F[i-1] + TC[i];
	}
	/*
	for(int i = 0; i < 10; ++i){
		for(int j = 0; j <= i; ++j){
			cout << bc(i, j) << " ";
		}
		cout <<endl;
	}
*/
	string s; cin >> s;
	bool has1 = false;
	vector<int> Ones;

	for(int i = 0; i < N; ++i){
		A[i] = s[i] - '1';
		has1 |= A[i] == 1;
	}
	for(int i = 0; i < N; ++i){
		if(has1){
			if(A[i] == 2) A[i] = 0;
		}else{
			if(A[i] == 2) A[i] = 1;
		}
		if(A[i] == 1)
			Ones.push_back(i);
	}

	int o = 0;
	for(int i : Ones){
		o += bc(N-1, i);
	}
	o %= 2;
	int r = 0;
	if(has1 && o) r = 1;
	if(!has1 && o) r = 2;
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 20120
(* O(n log n) *)
Scanf.scanf "%d" @@ fun n ->
  let a_s = Array.init (3 * n) @@ fun _ -> Scanf.scanf " %d" @@ (+) 0 in
  Array.sort (fun x y -> y - x) a_s;
  let f (i, acc) a = i + 1, acc + if i <= 2 * n && i mod 2 = 0 then a else 0 in
  Array.fold_left f (1, 0) a_s |> snd |> Printf.printf "%d\n"

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

struct UnionFind {
  vector<int> par;
  UnionFind(int n) : par(n, -1) { }
  
  void init(int n) { par.assign(n, -1); }
  
  int root(int x) {
    if (par[x] < 0) return x;
    else return par[x]=root(par[x]);
  }

  bool issame(int x, int y) {
    return root(x)==root(y);
  }

  bool merge(int x, int y) {
    x=root(x);
    y=root(y);
    if (x==y) return false;
    if (par[x]>par[y]) swap(x, y);
    par[x]+=par[y];
    par[y]=x;
    return true;
  }
  
  int size(int x) {
    return -par[root(x)];
  }
};

int main() {
  ll n,m; cin>>n>>m;
  vector<int> A(m),B(m);
  rep(i, m) {
    cin>>A[i]>>B[i];
    --A[i], --B[i];
  }
  
  UnionFind uf(n);
  ll tmp=n*(n-1)/2;
  vector<ll> res;
  rep(i, m) {
    res.push_back(tmp);
    int a=A[m-1-i];
    int b=B[m-1-i];
    if (uf.issame(a, b)) continue;
    ll sa=uf.size(a);
    ll sb=uf.size(b);
    tmp-=sa*sb;
    uf.merge(a, b);
  }
  reverse(res.begin(), res.end());
  rep(i, res.size()) cout<<res[i]<<endl;
  return 0;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n,ans=0;
  cin >> n;
  int arr[n];
  for (int i=0; i < n; i++) {
    cin >> arr[i];
    if ((i+1) % 2 != 0 && arr[i] % 2 != 0) {
      ans++;
    }
  }
  cout << ans << '\n';
 return 0; 
}

Measured memory_bytes: 3628
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	set<int> nums = {n};
	int counter = 0;
	while(true) {
		if(n%2) {
			n = 3*n+1;
			if(nums.count(n)) { println(counter+2); return 0; }
		}
		else {
			n /= 2;
			if(nums.count(n)) { println(counter+2); return 0; }
		}
		nums.insert(n);
		counter++;
	}
}


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

int N;
int M;

int main() 
{
	cin >> N >> M;
	if(abs(N - M) > 1)
		cout << 0;
	else
	{
		long long inu = 1, saru = 1;
		for(int i = 1; i <= N; i++)
		{	
			inu *= i;
			inu %= 1000000007;
		}
		for(int i = 1; i <= M; i++)
		{
			saru *= i;
			saru %= 1000000007;
		}
		
		if(N - M == 0)
			cout << inu * saru * 2 % 1000000007;
		else
			cout << inu * saru % 1000000007;
	}
}

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

int main() 
{
    string s,t;
    cin >> s >> t;
    
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            cout<<"No\n";
            return 0;
        }
    }
    
    cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 3596
/*
We will not return to the countless mistakes of the past
I will not relive the failures of the man I once was

Only through dedication will I destroy all preconception

No longer will I let myself be truly satisfied with the standard
We will not return to the countless mistakes of the past

Only through dedication will I destroy all preconception

Let this be
Be the day
Day of my
My declaration
Let this be the day of my declaration

Join me,
Walk with me

Shatter the bonds that tie us
To what we strive to never be

Join me,
Walk with me
*/
#include<bits/stdc++.h>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn=1000001;

bool cmp(pii a,pii b){
if(a.se==b.se) return a.fi<b.fi;
return a.se<b.se;
}

int main(){

int n,m;
cin>>n>>m;
int x,y;
vpi v;
while(m--){
    cin>>x>>y;
    v.pb(mp(x,y));
}
sort(all(v),cmp);
int ans=0;
int endd=0;
forn(i,v.size()){
if(v[i].fi<endd) continue;
endd=v[i].se;
ans++;
}
cout<<ans;
return 0;
}


Measured memory_bytes: 2420
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long MOD = 1'000'000'007LL;
const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

template< typename G >
struct StronglyConnectedComponents {
	const G &g;
	vector<vector<int>> gg, rg;
	vector< int > comp, order, used;

	StronglyConnectedComponents(G &g) : g(g), gg(g.size()), rg(g.size()), comp(g.size(), -1), used(g.size()) {
		for (int i = 0; i < g.size(); i++) {
			for (auto e : g[i]) {
				gg[i].emplace_back((int)e);
				rg[(int)e].emplace_back(i);
			}
		}
	}

	int operator[](int k) {
		return comp[k];
	}

	void dfs(int idx) {
		if (used[idx]) return;
		used[idx] = true;
		for (int to : gg[idx]) dfs(to);
		order.push_back(idx);
	}

	void rdfs(int idx, int cnt) {
		if (comp[idx] != -1) return;
		comp[idx] = cnt;
		for (int to : rg[idx]) rdfs(to, cnt);
	}

	void build(vector<vector<int>> &t) {
		for (int i = 0; i < gg.size(); i++) dfs(i);
		reverse(begin(order), end(order));
		int ptr = 0;
		for (int i : order) if (comp[i] == -1) rdfs(i, ptr), ptr++;

		t.resize(ptr);
		for (int i = 0; i < g.size(); i++) {
			for (auto &to : g[i]) {
				int x = comp[i], y = comp[to];
				if (x == y) continue;
				t[x].push_back(y);
			}
		}
	}
};


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

	ll N, M; scanf("%lld %lld", &N, &M);
	vector<vector<int>> g(N);
	for (ll i = 0; i < M; i++) {
		ll a, b; scanf("%lld %lld", &a, &b);
		g[a].push_back(b);
	}

	StronglyConnectedComponents<vector<vector<int>>> scc(g);
	vector<vector<int>> t;
	scc.build(t);
	ll Q;
	scanf("%lld", &Q);
	while (Q--) {
		ll a, b; scanf("%lld %lld", &a, &b);
		if (scc[a] == scc[b]) puts("1");
		else puts("0");
	}
	return 0;


}


Measured memory_bytes: 5092
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
int n; 
  cin>>n;
  ll l;
  cin>>l;
  ll len[n+1];
  len[0]=0;
  rep1(i, n){
    cin>>len[i];}
  bool pos=false;
  int d=0;
  rep1(i, n-1){
    if(len[i]+len[i+1]>=l){
      d=i;
      pos=true;
    break;}
  }
  if(!pos){
    cout<<"Impossible"<<endl;
  return 0;}
  
  cout<<"Possible"<<endl;
  
  int turn[n+1];
  int num=1;
  for(int i=d;i>=1;i--){
    turn[num]=i;
  num++;}
  for(int i=d+1;i<=n-1;i++){
    turn[num]=i;
  num++;}
  
  for(int i=n-1;i>=1;i--){
    cout<<turn[i]<<endl;}
  
  return 0;

}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

mint calcNumOfCombination_mint(mint n, mint r){
  mint num = 1;
  for(mint i = 1; i.x <= r.x; i.x++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = 2;
  ans = ans.pow(n);
  ans -= calcNumOfCombination_mint(n, a);
  ans -= calcNumOfCombination_mint(n, b);
  ans -= 1;
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# input
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0
for i in range(n):
    if a[i] > b[i]:
        res -= a[i] - b[i]
    else:
        res += (b[i] - a[i]) // 2
if res >= 0:
    print("Yes")
else:
    print("No")


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

class AizuOnlineJudge {
    static void Main() {
        Console.ReadLine();
        var m = Console.ReadLine()
            .Aggregate(new[] { 0, 0 }, (p, c) => {
                p[c <= 'Z' ? 0 : 1] += char.ToUpper(c) <= 'M' ? 1 : -1;
                return p;
            });

        Console.WriteLine(Math.Abs(m[0]) + Math.Abs(m[1]));
        Console.WriteLine(
            new String(m[0] > 0 ? 'A' : 'N', Math.Abs(m[0])) + new String(m[1] > 0 ? 'a' : 'n', Math.Abs(m[1]))
        );
    }
}



Measured memory_bytes: 18176
fun main(args : Array<String>) {
    val x = readLine()!!.toInt()

    for (a in -1000..1000) {
        for (b in -1000..1000) {
            val a5 = Math.pow(a.toDouble(), 5.0).toLong()
            val b5 = Math.pow(b.toDouble(), 5.0).toLong()

            if (a5 - b5 == x.toLong()) {
                println("$a $b")
                return
            }
        }
    }
}


Measured memory_bytes: 34592
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let x = get!(usize);
    let a = x / 11 * 2;
    let d = x % 11;
    println!("{}", a + (match d { 0 => 0, _ if d <= 6 => 1, _ => 2 }));
}

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

int main()
{
    int N; cin >> N;
    int a[200005] = {};
    bool one_exists = false;
    for (int i = 1; i <= N; i++)
    {
        cin >> a[i];
    }

    int num = 0;
    for (int i = 1; i <= N; i++)
    {
        if (a[i] == num + 1)
        {
            num++;
        }
    }

    int ans;
    if (num == 0) ans = -1;
    else ans = N - num;

    cout << ans << endl;
    return 0;
}

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

int main() {
    ll n, ans = 0;
    vector<ll> a, b;
    cin >> n;
    a.resize(n+1);
    for(int i=0;i<n+1;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        ll b;
        cin >> b;
        ans += min(a[i], b);
        b -= min(a[i], b);
        ans += min(a[i+1], b);
        a[i+1] -= min(a[i+1], b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read() {
	int x(0),neg(1);char ch(getchar());
	while(ch<'0'||ch>'9') {
		if (ch=='-') neg=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*neg;
}
int n;
signed main() {
	n=read();
	printf("%lld\n",(n-1)*n/2);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;
const ull finf = 1e18;

int countDeg(ll a){
    int cnt = 0;
    while(a >= 10 ){
        a /= 10;
        cnt++;
    }
    return ++cnt;
}

int main() {
    int N;
    cin >> N;
    vector<ull> nums(N);
    
    rep(i, N){
        cin >> nums[i];
        if(nums[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans;
    ans = 1;
    rep(i, N){
        ll d = finf / ans;
        ll a = nums[i];
        if(a > d){
            cout << -1 << endl;
            return 0;
        }
        ans *= a;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4052
#include <string>
#include <cstdio>
#include <cstdlib>
char S[9];
int main(){
	int q,n,r,i;
	for(scanf("%d",&q);q--;printf("%d\n",r))
		for(r=0,scanf("%d",&n);n>9;r++){
			sprintf(S,"%d",n);n=0;
			std::string s=S;
			for(i=1;i<s.length();i++)n=std::max(n,atoi(s.substr(0,i).c_str())*atoi(s.substr(i).c_str()));
		}
}

Measured memory_bytes: 1072
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
using P = pair<int,int>;
using node = pair<string,ll>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;

int main(void) {
  map<int,int> m;
  for (int i = 0;i < 3;++i){
    int a,b;
    cin >> a >> b;
    ++m[a];++m[b];
  }
  int cnt1 = 0,cnt2 = 0;
  for (auto p : m){
    if (p.second == 1) {
      ++cnt1;
    } else if (p.second == 2) {
      ++cnt2;
    }
  }
  cout << (cnt1 == 2 && cnt2 == 2 ? "YES" : "NO") << endl;
  return 0;
}


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

using namespace std;

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

	int x[N];
	int y[N];
	int h[N];
	int H;

	for (int n=0; n<N; n++){
		cin >> x[n] >> y[n] >> h[n];
	}

	for (int cx=0; cx<=100; cx++){
		for (int cy=0; cy<=100; cy++){
			int flag = true;

			for (int n=0; n<N; n++){
				if (h[n] > 0){
					H = abs(x[n]-cx) + abs(y[n]-cy) + h[n];
					break;
				}
			}

			for (int n=0; n<N; n++){
				if (max(H - abs(x[n]-cx) - abs(y[n]-cy), 0) != h[n]){
					flag = false;
					break;
				}
			}

			if (flag){
				cout << cx << " " << cy << " "<< H << endl;
				return 0;
			}

		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll t1,t2,a,b,c,d;

int main(){
	cin>>t1>>t2>>a>>b>>c>>d;
	ll tmp1=t1*a+t2*b,tmp2=t1*c+t2*d;
	if(tmp1==tmp2){
		cout<<"infinity"<<endl;
		return 0;
	}
	if(tmp1>tmp2){
		swap(a,c);
		swap(b,d);
		swap(tmp1,tmp2);
	}
	ll d=tmp2-tmp1;
	ll m=t1*a-t1*c;
	if(m<0){
		cout<<0<<endl;
	}
	else{
		ll res=1;
		m-=d;
		if(m>=0){
			ll t=m/d;
			res+=t*2;
			m-=t*d;
			if(m==0) res++;
			if(m>0) res+=2;
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    int s=0,t=0;
    cin>>a;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]=='S')
            s++;
        if(s && a[i]=='T')
        {
            s--;
            t+=2;
        }
    }
    cout<<a.size()-t<<endl;
    return 0;
}

Measured memory_bytes: 640
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))

n = int(input())
ans = 0
for i in range(1,n+1):
    if len(str(i))%2 != 0:
        ans += 1
print(ans)


Measured memory_bytes: 9084
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

ll n,a[100010];
ll l[100010],r[100010];
ll gcd(int x,int y){return y?gcd(y,x%y):x;}
int main(){
    scanf("%lld",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    l[1]=a[1]; r[n] = a[n];
    for(int i=2;i<=n;i++) l[i]=gcd(l[i-1],a[i]);
    for(int i=n-1;i>=1;i--) r[i]=gcd(r[i+1],a[i]);
    ll ans = max(r[2],l[n-1]);
    for(int i=1;i<n-1;i++){
        ans = max(ans,gcd(l[i],r[i+2]));
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    int a, b;
    cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,count=0;
    cin>>n;
    string s;cin>>s;
    for(i=0;i+2<n;i++)
    {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
        {
            count++;
        }
    }
    cout<<count;
}


Measured memory_bytes: 256