akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	string s;
	cin >> s;
	int n=s.length();

	string t=s.substr(0, n-1), rt=t;
	reverse(rt.begin(), rt.end());
	if(s[n-1]!='0' || s[0]!='1' || s[n-2]!='1' || t!=rt){
		cout << -1 << endl;
		return 0;
	}

	int curr=1;
	for(int i=0; i<n-1; i++){
		cout << curr << " " << i+2 << endl;
		if(s[i]=='1') curr=i+2;
	}
	return 0;
}

Measured memory_bytes: 1664
def f_max(X, digit):
    if X == 0:
        return sum([Ad[i] * (2**i) for i in range(digit)])
    elif X == 2**digit - 1:
        return sum([max(Ad[i], N - Ad[i]) * (2**i) for i in range(digit)])
    elif X >= 2**(digit-1):
        return max((N - Ad[digit-1]) * (2**(digit-1)) + f_max(X-2**(digit-1), digit-1), Ad[digit-1] * (2**(digit-1)) + f_max(2**(digit-1)-1, digit-1))
    else:
        return Ad[digit-1] * (2**(digit-1)) + f_max(X, digit-1)

N, K = map(int, input().split())
K_max, digits = 2*10**12, 0
while K_max > 0:
    K_max >>= 1
    digits += 1

Ad = [0]*digits
for a in list(map(int, input().split())):
    for i in range(digits):
        Ad[i] += a % 2
        a >>= 1

print(f_max(K, digits))

Measured memory_bytes: 14840
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char a = sc.next().charAt(0); 
      	char b = sc.next().charAt(0); 
      if((int)a<(int)b){System.out.println("<");}
      else if((int)a>(int)b){System.out.println(">");}
      else if((int)a==(int)b){System.out.println("=");}

    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,K;
    cin >> N >> K;
    if(K <= (N + 1) / 2)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
def main():
  n,l = list(map(int,input().split()))
  ans=0
  if l>=0:
    for i in range(2,n+1):
      ans+= l+i-1
  elif n+l-1<0:
    for i in range(1,n):
      ans+=l+i-1
  else:
    for i in range(1,n+1):
      ans+=l+i-1
  print(ans)  
main()

Measured memory_bytes: 9056
#include <iostream>
using namespace std;
int main() {
    int x, y;
    while(1) {
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        if (x < y) {
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  int n,k,a,x=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a>=abs(k-a)){
      x+=(abs(k-a))*2;
    }
    else
      x+=a*2;
  }
  cout<<x<<endl;
}

Measured memory_bytes: 256
s=input()
a=int(s[0]+s[1])
b=int(s[2]+s[3])

if 1<=a<=12:
  if  1<=b<=12:
    print('AMBIGUOUS')
    exit()
  else:
    print('MMYY')
    exit()
elif 1<=b<=12:
  print('YYMM')
  exit()
else:
  print('NA')

Measured memory_bytes: 3060
import itertools
x=[0.]*100;y=[0.]*100
for e in iter(input,'0'):
    a=0
    n=int(e)
    for i in range(n):x[i],y[i]=map(float,input().split(','))
    for i,j in itertools.product(range(100),range(100)):
            c=0
            for k in range(n):
                if pow(x[k]-(i/10),2)+pow(y[k]-(j/10),2)<=1.01:c+=1
            if c>a:a=c
    print(a)


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

using namespace std;
struct node
{
    int t;
    int x,y;
};
const int maxn = 100000;
const int INF = 1e5+10;

int N;
int main()
{
    node T0 = {0,0,0},T1;
    scanf("%d",&N);
    int flag = 0;
    for(int i = 0; i < N; i++)
    {
        scanf("%d%d%d",&T1.t,&T1.x,&T1.y);
        if(flag == 1) continue;
        int t0 = T0.t+abs(T1.x-T0.x)+abs(T1.y-T0.y);
        if(t0>T1.t || (T1.t-t0)%2 != 0)
        {
            flag = 1;
            continue;
        }
        T0.t = T1.t;
        T0.x = T1.x;
        T0.y = T1.y;
    }
    if(flag == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
mini=min(a)
dp1=[-1 for i in range(k+1)]
dp2=[-1 for i in range(k+1)]
for x in range(k+1):
	if x == 0 or mini > x:
		dp1[x]=False
		dp2[x]=False
		continue
	dp1[x]=False
	dp2[x]=False
	for v in a:
		if v>x:
			continue
		dp1[x]=dp1[x] or not dp2[x-v]
		dp2[x]=dp2[x] or not dp1[x-v]

if dp1[k]:
	print("First")
else:
	print("Second")

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

int main(){
    int n,x;
    int ans =0;
    cin >> n >>x;
    vector <int> a(n);
    for (int i =0;i<n;i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    for (int i=0;i<n;i++){
        if(a.at(i)<=x){
            x-=a.at(i);
            ans++;
        }
    }
    if(x>0 && n == ans){
        ans--;
    }
        cout << ans << endl;
}    


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b,c,k=3;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b && b==c && c==a){
		printf("1");
		return 0;
	}
    if(a==b) k--;
	if(b==c) k--;
	if(a==c)
		k--;
	printf("%d",k);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 2e9;
const int mod = 1e9 + 7;

int a[10][10];

int f(const vi& v) {
    int t = 0;
    rep(i, v.size()) {
        t = a[t][v[i]];
    }
    return t;
}

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

    rep(i, 10) rep(j, 10) cin >> a[i][j];

    int ans = 0;
    rep(i, 10000) {
        vi b(4);
        int p = i;
        rep(j, 4) {
            b[j] = p % 10;
            p /= 10;
        }
        reverse(all(b));
        b.emplace_back(f(b));

        ans += [&](){
            rep(j, 5) {
                rep(k, 10) {
                    if (b[j] == k) continue;
                    vi c = b;
                    c[j] = k;
                    if (!f(c)) return 1;
                }
            }

            rep(j, 4) {
                if (b[j] == b[j + 1]) continue;
                vi c = b;
                swap(c[j], c[j + 1]);
                if (!f(c)) return 1;
            }
            return 0;
        }();
    }

    cout << ans << endl;
}

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

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    cout << A[N/2] - A[N/2-1] << endl;
}

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

using namespace std;

const int N = 2e5 + 5;
vector<int> adj[N];
int vis[N] , n , m;

int opp (int node) {
    if (node > n)
        return node - n;
    return node + n;
}

void dfs (int node) {
    if (vis[node])
        return;

    vis[node] = 1;

    dfs(opp(node));
    for (int child : adj[node])
        dfs(child);
}

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

    cin >> n >> m;

    for (int i = 0 ;i < m ;i++) {
        int x , y , z;
        cin >> x >> y >> z;

        if (z&1) {
            adj[opp(x)].push_back(y);
            adj[opp(y)].push_back(x);
        } else {
            adj[x].push_back(y);
            adj[y].push_back(x);
        }
    }

    int ans = 0;
    for (int i = 1 ;i <= n ;i++) {
        if (!vis[i]) {
            ans++;
            dfs(i);
            dfs(opp(i));
        }
    }

    cout << ans;
}


Measured memory_bytes: 18412
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
const double PI = acos(-1);  // PI = 3.141593...

int main() {
    int n;
    double d1=0, d2=0, d3=0, d4=0;
    cin >> n;
    vector<int> x(n,0), y(n,0);
    for(int i=0; i<n; ++i) cin >> x[i];
    for(int i=0; i<n; ++i) cin >> y[i];
    for(int i=0; i<n; ++i) {
        int d = abs(x[i]-y[i]);
        d1 += d;
        d2 += d*d;
        d3 += d*d*d;
        d4 = (d4 < d) ? d : d4;
    }
    d2 = pow(d2, 1.0/2);
    d3 = pow(d3, 1.0/3);
    printf("%.6lf\n", d1);
    printf("%.6lf\n", d2);
    printf("%.6lf\n", d3);
    printf("%.6lf\n", d4);
    return 0;
}


Measured memory_bytes: 3348
# -*- coding: utf-8 -*-
fibs = {0: 1, 1: 1}


def fib(n):
    if n not in fibs:
        fibs[n] = fib(n - 1) + fib(n - 2)

    return fibs[n]


if __name__ == '__main__':
    n = int(input())
    print(fib(n))



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;


int main(){
int n,k; cin>>n>>k;
int d[k]; REP(i,k)cin>>d[i];
ll res =1000001;

for(ll i=n;i<=1000000;i++){
 bool  flag=1;
 
 if(i>=0)REP(l,k){
    if(i%10==d[l])flag=0;
  }
 if(i>=10)REP(l,k){
    if((i%100)/10==d[l])flag=0;
  }
  if(i>=100)REP(l,k){
    if((i%1000)/100==d[l])flag=0;
  }
  if(i>=1000)REP(l,k){
    if((i%10000)/1000==d[l])flag=0;
  }
  if(i>=10000)REP(l,k){
    if((i%100000)/10000==d[l])flag=0;
  }

  if(flag&&i<res){
    res=i;
    break;
  }
}
  cout<<res<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
typedef long long ll;

int main()
{
    int n;
    scanf("%d",&n);
    int tmp=0;
    for(int i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        if(x%2)tmp++;
    }
    if(tmp%2)printf("NO\n");
    else printf("YES\n");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll h;
	cin>>h;
	h=log2(h);
	ll ans=1;
	for(ll i=1;i<=h+1;i++) ans*=2;
	cout<<ans-1<<"\n";
	return 0;	
}

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


int main() {
    int N;
    cin >> N;
    map<int,int> A;
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        A.insert(make_pair(tmp,i+1));
    }

    for(int i=0;i<N;i++){
        cout << A[i+1];
        if(i==N-1) cout << endl;
        else cout << " ";
    }

    return 0;
}

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

signed main(){
	string S;
	cin >> S;
	if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3]){
		printf("Bad\n");
	}
	else{
		printf("Good\n");
	}
	return 0;
}

Measured memory_bytes: 3584
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    B = tuple(map(int, input().split()))

    surplus_scores = []
    sum_lack_score = 0
    ans = 0
    for a, b in zip(A, B):
        if a > b:
            surplus_scores.append(a - b)
        elif a < b:
            sum_lack_score += b - a
            ans += 1

    if sum_lack_score > 0:
        surplus_scores.sort(reverse=True)
        pass_exam = False
        for i, score in enumerate(surplus_scores):
            sum_lack_score -= score
            if sum_lack_score <= 0:
                ans += (i + 1)
                pass_exam = True
                break
        if not pass_exam:
            ans = -1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 18992
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
int main()
{
   char S[6];
   gets (S);
   if(!strcmp(S,"Sunny"))
      printf("Cloudy");
   else if (!strcmp(S,"Cloudy"))
    printf("Rainy");
   else if (!strcmp(S,"Rainy"))
     printf("Sunny");
   else printf("invalid");


    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define lp(i, x, n) for (int i = x; i < (int)n; ++i)
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define ll long long
#define N 123451
bool s[11];

bool ck(int n) {
        while (n) {
                int rem = n % 10;
                if (s[rem])
                        return 1;
                n /= 10;
        }
        return 0;
}

int main(){
        int a, b;
        cin >> a>> b;
        lp (i, 0, b) { int r; cin >> r; s[r] = 1;}
        while (1) {
                if (ck(a)) a++;
                else
                        break;
        }
        printf("%d\n", a);
        return 0;
}


Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int k, s;
	cin >> k >> s;
	REP(x, k+1){
		REP(y, k+1){
			if(s-x-y>=0 && s-x-y<=k) ans ++;
		}
	}
	cout << ans << endl;
	
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int n, a[100000];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	sort(a, a+n);
	int c = a[0];
	for(int i = 1; i < n-1; i++){
		if(abs(a[n-1]/2 - a[i]) < abs(a[n-1]/2 - c) || abs(a[n-1]/2+a[n-1]%2 - a[i]) < abs(a[n-1]/2+a[n-1]%2 - c))
			c = a[i];
	}
	
	cout << a[n-1] << " " << c << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back


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

    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    rep(i, N) cin >> H[i];
    sort(all(H), greater<int>());

    if(N<=K){
        cout << 0 << endl;
        return 0;
    }

    ll sum=0;
    for(ll i=K; i<N; i++) sum += H[i];
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1792
import math
A, B = map(int, input().split())
XA=list(i for i in range (math.ceil(A/0.08), math.floor((A+1)/0.08)) )
XB=list(i for i in range (math.ceil(B/0.1), math.floor((B+1)/0.1)) )
X=list( set(XA) & set(XB)  )
if(len(X)>0):
    print(min(X))
else:
    print("-1")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define l long 
#define ll long long 
#define ld long double 
#define INF 1000000000000
#define MOD 1000000007
#define MAX_N 1000006
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    l n,k;
    cin>>n>>k;
    vector<l> a;
    l x;
    for(l i=0;i<n;i++)
    {
        cin>>x;
        a.push_back(x);
    }
    vector<ll> dp(k+1),prf(k+1);
    dp[0]=1;
    l lo,hi;
    for(l i=0;i<n;i++)
    {
        for(l s=0;s<=k;s++)
            prf[s]=0;
        for(l s=0;s<=k;s++)
        {
            lo=s+1;
            hi=s+min(a[i],k-s);
            if(lo<=hi)
            {
                prf[lo]=(prf[lo]+dp[s])%MOD;
                if(hi<k)
                prf[hi+1]=(prf[hi+1]-dp[s])%MOD;
            }
        }
        dp[0]=(dp[0]+prf[0])%MOD;
        for(l s=1;s<=k;s++)
        {
            prf[s]=(prf[s-1]+prf[s])%MOD;
            dp[s]=(dp[s]+prf[s])%MOD;
        }
    }    
    if(dp[k]<0)
    dp[k]+=MOD;
    cout<<dp[k]<<endl;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
#define int long long
struct NODE{
	int pos;
	int which;
	int eid;
	int cost;
	int cut;
};
bool operator < (const NODE &a,const NODE &b){
	return a.cost > b.cost;
}
 
namespace std {
    template <>
    class hash<std::pair<int, int>> {
    public:
        size_t operator()(const std::pair<int, int>& x) const{
            return hash<int>()(x.first) ^ hash<int>()(x.second);
        }
    };
}
vector<NODE> g[300010];
 
map<int,vector<NODE>> g2[300010];
int done[300010][2][2];
int memo[300010] = {};

unordered_map< pair<int,int> , int> done2;
 
int& table(const NODE &b){
	if( b.cut == 1 ) return done[b.pos][0][1];
	return done[b.eid][b.which][0];
}double start ;
 
void solve(long long N, long long M, vector<long long> p, vector<long long> q, vector<long long> c){
	
	deque<NODE> Q;
	

	for(int i = 0 ; i < 300010 ; i++){
		for(int j = 0 ; j < 2 ; j++)
			done[i][j][0] = done[i][j][1] = 1e18;
		memo[i] = 1e9;
	}
			
	for(int i = 0 ; i < M ; i++){
		p[i]--;
		q[i]--;
		g[p[i]].push_back({q[i],1,i,1});
		g[q[i]].push_back({p[i],0,i,1});
		g2[p[i]][c[i]].push_back({q[i],1,i,1});
		g2[q[i]][c[i]].push_back({p[i],0,i,1});
	}
	int counter = 0;
	for( auto &&e : g[N-1] ){
		for(int cut = 0 ; cut < 2 ; cut++){
			NODE nd = {e.pos,e.which,e.eid,1,cut};
			Q.push_back(nd);
			table(nd) = 1;
			memo[nd.pos] = min(nd.cost,memo[nd.pos]);
			counter = max(nd.cost,counter);
		}
	}
	
	while( Q.size() ){
		double end = clock();
		auto q = Q.front(); Q.pop_front();
		if( (double)(end - start) / CLOCKS_PER_SEC > 2.5 ){
			cout << counter + 5 << endl;
			return;
		}
		if( memo[q.pos] + 1 <= q.cost ) continue;
		memo[q.pos] = min(memo[q.pos],q.cost);
 		if( table(q) != q.cost ) continue;
		if( q.cut == 0 ){
			if( done2.count({q.pos,c[q.eid]}) ) continue;
			else done2[{q.pos,c[q.eid]}] = true;
		}
		if( q.pos == 0  ){
			cout << q.cost << endl;
			return;
		}
		if( q.cut ){
			for( auto &&e : g[q.pos] ){
				for(int cut = 0 ; cut < 2 ; cut++){					
					int cc = (c[q.eid]!=c[e.eid]);
					NODE nd = {e.pos,e.which,e.eid,q.cost+cc,cut};
					memo[nd.pos] = min(nd.cost,memo[nd.pos]);
					counter = max(nd.cost,counter);
					if( table(nd) > nd.cost ){
						table(nd) = nd.cost;
						if( cc == 1 ){
							Q.push_back(nd);
						}else{
							Q.push_front(nd);
						}
					}
				}
			}
		}else{
			for( auto &&e : g2[q.pos][c[q.eid]] ){
				for(int cut = 0 ; cut < 2 ; cut++){					
					int cc = (c[q.eid]!=c[e.eid]);
					assert(cc==0);
					NODE nd = {e.pos,e.which,e.eid,q.cost+cc,cut};
					memo[nd.pos] = min(nd.cost,memo[nd.pos]);
					counter = max(nd.cost,counter);
					if( table(nd) > nd.cost ){
						table(nd) = nd.cost;
						if( cc == 1 ){
							Q.push_back(nd);
						}else{
							Q.push_front(nd);
						}
					}
				}
			}
		}
	}
	cout << -1 << endl;
}
 
 
 
signed main(){
	start = clock();
	ios::sync_with_stdio(false);
	long long N;
	long long M;
	cin >> N;
	cin >> M;
	vector<long long> p(M-1+1);
	vector<long long> c(M-1+1);
	vector<long long> q(M-1+1);
	for(int i = 0 ; i <= M-1 ; i++){
		cin >> p[i];
		cin >> q[i];
		cin >> c[i];
	}
	solve(N, M, p, q, c);
	return 0;
}

Measured memory_bytes: 128268
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

typedef unsigned long long LL;

const int N=200005;

int n;
LL a[N],val[N],m;

int main()
{
	scanf("%d%llu",&n,&m);
	for (int i=1;i<=n;i++) scanf("%llu",&a[i]);
	for (int i=1;i<=n;i++) val[i]=val[i-1]+a[i];
	LL ans=0;
	for (int i=1;i<=n;i++) ans+=a[i]+(LL)a[i]*4+m;
	for (int i=1;i<=n;i++)
	{
		LL w=(val[n]-val[n-i])*2;
		for (int j=n,s=0;j>0;j-=i,s++)
		{
			w+=(LL)(val[j]-val[std::max(0,j-i)])*(s*2+3);
		}
		ans=std::min(ans,w+(LL)m*i);
	} 
	printf("%llu\n",ans+(LL)m*n);
	return 0;
}

Measured memory_bytes: 3328
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;

void print_vector(vector<int> vec){
    for (int item : vec){
        cout << item << flush;
    }
    cout << endl << flush;
}

void print_mat(vector<vector<int>> mat){
    for (vector<int> vec : mat){
        print_vector(vec);
    }
}

void Main(){
    bool test = false;
    int h, w;
    cin >> h >> w;
    vector<vector<int>> s(h, vector<int>(w));
    vector<vector<int>> t(h, vector<int>(w));
    for (int i=0; i<h; i++){
        string tmp;
        cin >> tmp;
        for (int j=0; j<w; j++){
            if (tmp[j]=='.') s[i][j] = 0;
            else s[i][j] = 1;
        }
    }

    if (s[0][0]) t[0][0] = 1;
    else t[0][0] = 0;

    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            if (i==0 && j==0) continue;
            int m = 1 << 30;
            if (i>0) {
                int tmp = t[i-1][j];
                if (s[i][j] && !s[i-1][j]) tmp++;
                m = min(m, tmp);
            }
            if (j>0) {
                int tmp = t[i][j-1];
                if (s[i][j] && !s[i][j-1]) tmp++;
                m = min(m, tmp);
            }
            t[i][j] = m;
        }
    }
    cout << t[h-1][w-1];
}

int main(void){
    std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
    Main();
}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
int abs(int n){
    if(n > 0){
        return n;
    } else {
        return -n;
    }
}


int main(){
  int n;
  scanf("%d", &n);
  int x[n];
  for(int i = 0; i < n; i++){
        scanf("%d", &x[i]);
  }
  
  int count = 0;
  for(int i = 1; i < n-1; i++){
      if((x[i-1] < x[i] && x[i] < x[i+1])||(x[i-1] > x[i] && x[i] > x[i+1])){
        count+=1;
      }
  }
  
  printf("%d", count);
  return 0;
}


Measured memory_bytes: 128
n = int(input())

if n == 3:
    print(2, 5, 63)
    exit()

n -= 4
a, b = 2, 2

k = min(n // 3, 4999)
a += k * 3
n -= k * 3

if n % 2 == 1:
    a += 1
    n -= 1
b += n

for i, j in enumerate(range(2, 30001, 2)):
    if i == a:
        break
    print(j)

for i, j in enumerate(range(3, 30001, 6)):
    if i == b:
        break
    print(j)

"""
A : 2, 4, 6, ...,  30000 の 15000個
B : 3, 9, 15, ..., 29997 の 5000個
和が6の倍数になるように構成する
Aは, [2, 4] [6] [8, 10] [12]のように, [2, 1, 2, 1, ...]の組みで6の倍数
Bは, [3, 9] [15, 21]のように, [2, 2, 2, 2, ...]の組みで6の倍数
[2, 4, 3, 9]は確定で選ぶ必要がある(全体のGCDは1なので)
そこは7,8行目で確定で選ぶようにして, まずはAから取れるだけ取る
[1, 2, 1, 2, ...]を[3, 3, ...]と解釈する
このとき, Bには2しかないので, 奇数ならば最後の1を必ずAからとる(14行目)
あとは残った数だけBからとる
"""

Measured memory_bytes: 3424
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int K,N;
	int t[100001];
	ll d[100001];
	vll pt[100001];
	vpll dttop,dtless;
	int tnum=0;
	scan(N);scan(K);
	rep(i,N){
		scan(t[i]);scan(d[i]);
		pt[t[i]].push_back(d[i]);
	}
	rep1(i,N) if(pt[i].size()) sort(pt[i].rbegin(),pt[i].rend());
	rep1(i,N){
		if(pt[i].size()){
			dttop.push_back(mp(pt[i][0],i));
			rep1(j,pt[i].size()-1){
				dtless.push_back(mp(pt[i][j],i));
			}
		}
	}
	sort(dttop.rbegin(),dttop.rend());
	sort(dtless.rbegin(),dtless.rend());
	ll dtlesssum[100001]={},dttopsum[100001]={};
	bool alre[100001]={};
	int alrenum[100001]={};
	rep(i,K){
		if(i<dtless.size()){
			dtlesssum[i+1]=dtlesssum[i]+dtless[i].first;
			alrenum[i+1]=alrenum[i]+(alre[dtless[i].second]==0);
			alre[dtless[i].second]=1;
		}
		if(i<dttop.size()) dttopsum[i+1]=dttopsum[i]+dttop[i].first;
	}
	ll ans=0;
	for(ll i=1;i<=dttop.size();i++){
		//if(0<=K-i&&K-i<=dtless.size()&&alrenum[K-i]<=i) ans=max(ans,dttopsum[i]+dtlesssum[K-i]+i*i);
		if(0<=K-i&&K-i<=dtless.size()) ans=max(ans,dttopsum[i]+dtlesssum[K-i]+i*i);
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 10096
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
	int n,m=0,sum=0;
    cin >> n;
    vector<int> p(n);
    for(int i;i<n;i++){
        cin >> p.at(i);
        if(m<p.at(i)) m=p.at(i);
    }
    for(int i;i<n;i++){
        sum += p.at(i);
    }
    cout << sum-m/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
const ll MOD = 1e9 + 7;

void mainsolve(){
	ll n;
	cin >> n;

	vector<vector<ll>> memo(10, vector<ll>(10));
	rep(i,n+1){
		if(i==0) continue;
		string s = to_string(i);
		memo[s[0] - '0'][s.back() - '0']++;
	}

	ll res = 0;
	rep(i,10){
		rep(j,10){
			res += memo[i][j] * memo[j][i];
		}
		//res -= memo[i][i];
	}

	cout << res << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int x,y,z,a,b;
    scanf("%d %d %d",&x,&y,&z);
    if(x>=y)
        a=x-y;
    else
        a=y-x;
    if(x>=z)
        b=x-z;
    else
        b=z-x;
    if(a>b)
        printf("B");
    else
        printf("A");
 return 0;
}


Measured memory_bytes: 128
fn main() {
    let s: String = read();
    println!(
        "{}",
        String::from_utf8(s.chars().map(|c| c as u8 + 1).collect()).unwrap()
    );
}

use std::io::stdin;
use std::io::Read;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let token: String = cin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


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

using namespace std;

const int N = 1234567;

int n;
int a[N];
int have[N];
int b[3];
int cnt[N];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    have[a[i]]++;
  }
  int ans = 0;
  vector<int> odd, even;
  for (int i = 0; i < N; i++) {
    if (have[i] % 2) {
      ans++;
      odd.push_back(i);
    } else if (have[i] > 0) {
      even.push_back(i);
    }
  }
  for (auto it : odd) cnt[it] = 1;
  for (int i = 1; i < N; i++) cnt[i] += cnt[i - 1];
/*  for (int i = 0, j = 0; i + 1 < (int) even.size() && j < (int) odd.size(); i += 2, j++) {
    while (j < (int) odd.size() && odd[j] < even[i]) j++;
    while (i + 1 < (int) even.size() && odd[j] > even[i + 1]) i++;
    if (j < (int) odd.size() && i + 1 < (int) even.size()) {
      ans += 2;
    }
  }
*/
  int len = (int) even.size();
  for (int i = 0; i < len / 2; i++) {
    int j = i + len / 2 + len % 2;
    int res = cnt[even[j]] - cnt[even[i] - 1];
    if (res > 0) ans += 2;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 8952
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)

int main(void){
    int h,w;
    cin >> h >> w;
    int coin[h][w];
    vector<int> ans1;
    vector<int> ans2;
    vector<int> ans3;
    vector<int> ans4;
    rep(i,h)rep(j,w)cin >> coin[i][j];
    rep(i,h)rep(j,w){
        if(coin[i][j] % 2 == 1){
            coin[i][j]--;
            ans1.push_back(i+1);
            ans2.push_back(j+1);
            if(j != w-1 &&coin[i][j+1] % 2 == 1){
                coin[i][j+1]++;
                ans3.push_back(i+1);
                ans4.push_back(j+2);
            }
            else if(i != h-1 &&coin[i+1][j] % 2 == 1){
                coin[i+1][j]++;
                ans3.push_back(i+2);
                ans4.push_back(j+1);
            }
            else if(j != w-1){
                coin[i][j+1]++;
                ans3.push_back(i+1);
                ans4.push_back(j+2);
            }
            else if(i != h-1){
                coin[i+1][j]++;
                ans3.push_back(i+2);
                ans4.push_back(j+1);
            }
        }
    }
    int n = ans4.size();
    cout << n << endl;
    rep(i,n){
        cout << ans1[i] << " " << ans2[i] << " " << ans3[i] << " " << ans4[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5220
n = int(input())

prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
dic = {}
for num in prime:
    dic[num] = 0
for i in range(1, n + 1):
    j = i
    for num in dic:
        if j == 1:
            break
        while j % num == 0:
            j //= num
            dic[num] += 1
        
        
more_2 = 0
more_4 = 0
more_14 = 0
more_24 = 0
more_74 = 0
for _, j in dic.items():
    if j >= 2:
        more_2 += 1
    if j >= 4:
        more_4 += 1
    if j >= 14:
        more_14 += 1
    if j >= 24:
        more_24 += 1
    if j >= 74:
        more_74 += 1
ans = 0
if more_24 >= 1:
    ans += more_24 * (more_2 - 1)
if more_14 >= 1:
    ans += more_14 * (more_4 - 1)
if more_4 >= 2:
    ans += (more_4 * (more_4 - 1) * (more_2 - 2)) // 2
if more_74 >= 1:
    ans += more_74
print(ans)


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

int main() {
  string A;
  cin >> A;
  
  if (A[0] == A[1] && A[0] ==  A[2]){
  
    cout << "Yes" << endl;
  
  }
  
  else if ( A[3] == A[1] && A[1] ==  A[2]){
  
    cout << "Yes" << endl;
    
  }
  
  else {
    cout << "No" << endl;
  }

  }

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

int main() {
	long n,j=0,k=0;
	cin>>n;
	long a[n],b[n],c[200010];
	for(long i=0;i<n;i++)cin>>a[i]>>b[i];
	for(long i=0;i<n;i++)k+=a[i];
	for(long i=0;i<200010;i++)c[i]=1000000001;
	for(long i=0;i<n;i++){
		if(a[i]>b[i]){
			c[j]=b[i];
			j++;
		}
	}
	sort(c,c +n);
	if(j>0){
	cout<<k-c[0]<<endl;
	}
	else{
		cout<<0<<endl;
	}
	return 0;
}

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

namespace Dynamic_Programming
{
    class Optimal_Binary_Search_Tree
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var p = Console.ReadLine().Split(' ').Select(s => double.Parse(s)).ToArray();
            var q = Console.ReadLine().Split(' ').Select(s => double.Parse(s)).ToArray();

            var cost = new double[n + 1, n];

            for (int i = 0; i < n; i++)
            {
                cost[i, i] = 2 * q[i] + p[i] + 2 * q[i + 1];
                if (0 <= i - 1) cost[i, i - 1] = q[i];
                cost[i + 1, i] = q[i + 1];
            }

            for (int j = 1; j < n; j++)
            {
                for (int i = j - 1; 0 <= i; i--)
                {
                    var f = p.Skip(i).Take(j - i + 1).Sum() + q.Skip(i).Take(j + 1 - i + 1).Sum();

                    var res = double.MaxValue;
                    for (int r = i; r <= j; r++)
                    {
                        var tmp = (r > 0 ? cost[i, r - 1] : q[0]) + cost[r + 1, j];
                        res = Math.Min(res, tmp);
                    }

                    cost[i, j] = res + f;
                }
            }

            Console.WriteLine(cost[0, n - 1]);
        }
    }
}



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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}; 
constexpr int dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    cout << (input() + 1) / 2 << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


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

using namespace std;

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<bool> firstIslandConnections(n, false);
  std::vector<bool> lastIslandConnections(n, false);
  for (int i = 0; i < m; i++) {
    int a, b;
    std::cin >> a >> b;
    if (a == 1) {
      firstIslandConnections[b] = true;
    } else if (b == n) {
      lastIslandConnections[a] = true;
    }
  }
  for (int i = 0; i < n; i++) {
    if (firstIslandConnections[i] && lastIslandConnections[i]) {
      std::cout << "POSSIBLE" << std::endl;
      return 0;
    }
  }
  std::cout << "IMPOSSIBLE" << std::endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2500)
 
def erase(x, y):
    c[y][x] = '0'
    for dx, dy in ((1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)):
        nx, ny = x + dx, y + dy
        if 0 <= nx < w and 0 <= ny < h and c[ny][nx] == '1':
            erase(nx, ny)
 
while True:
    w, h = map(int, input().split())
    if w == h == 0:
        break
    c = [input().split() for _ in range(h)]
    ans = 0
    for y in range(h):
        for x in range(w):
            if c[y][x] == '1':
                ans += 1
                erase(x, y)
    print(ans)

Measured memory_bytes: 9472
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <tuple>
using namespace std;
const int inf = 1e9;
const int dx[5] = {1, 0, -1, 0, 0};
const int dy[5] = {0, 1, 0, -1, 0};
int mindist[256][256][256];
void init(){
	for(int i=0; i<256; i++){
		for(int j=0; j<256; j++){
			for(int k=0; k<256; k++){
				mindist[i][j][k] = inf;
			}
		}
	}
}

struct info{
	int p[3];
	int dist;
	info(int a, int b, int c, int d):p{a,b,c},dist(d){}
	info(){}
};

int main(){
	while(1){
		int w,h,n;
		cin >> w >> h >> n;
		if(w == 0) break;

		//input
		bool wall[16][16] = {};
		vector<pair<int, int> > s, g;
		cin.ignore();
		for(int i=0; i<h; i++){
			string str;
			getline(cin, str);
			for(int j=0; j<w; j++){
				if('a'<=str[j] && str[j]<='z'){
					s.emplace_back(str[j], (i<<4) +j);
				}
				if('A'<=str[j] && str[j]<='Z'){
					g.emplace_back(str[j], (i<<4) +j);
				}
				if(str[j] == '#') wall[i][j] = true;
			}
		}
		while((int)s.size() < 3){
			s.emplace_back(0, s.size());
			g.emplace_back(0, g.size());
		}
		sort(s.begin(), s.end());
		sort(g.begin(), g.end());

		//bfs
		init();
		mindist[s[0].second][s[1].second][s[2].second] = 0;
		queue<info> wait;
		info start(s[0].second, s[1].second, s[2].second, 0);
		info goal(g[0].second, g[1].second, g[2].second, 0);
		wait.push(start);
		while(!wait.empty()){
			info curr = wait.front();
			wait.pop();
			int p[3] = {curr.p[0], curr.p[1], curr.p[2]};
			int py[3] = {p[0]>>4, p[1]>>4, p[2]>>4};
			int px[3] = {p[0]&0b1111, p[1]&0b1111, p[2]&0b1111};
			int dist = curr.dist;
			if(p[0]==goal.p[0] && p[1]==goal.p[1] && p[2]==goal.p[2]) break;

			int np[3];
			int y,x;
			for(int i=0; i<5; i++){
				if(py[0]==0 && i<4) continue;
				y = py[0] +dy[i];
				x = px[0] +dx[i];
				if(py[0]!=0 && wall[y][x]) continue;
				np[0] = y*16 +x;
				for(int j=0; j<5; j++){
					if(py[1]==0 && j<4) continue;
					y = py[1] +dy[j];
					x = px[1] +dx[j];
					if(py[1]!=0 && wall[y][x]) continue;
					np[1] = y*16 +x;
					if(np[0] == np[1] || (np[0]==p[1] && np[1]==p[0])) continue;
					for(int k=0; k<5; k++){
						y = py[2] +dy[k];
						x = px[2] +dx[k];
						if(wall[y][x]) continue;
						np[2] = y*16 +x;
						if(np[1] == np[2] || (np[1]==p[2] && np[2]==p[1])) continue;
						if(np[2] == np[0] || (np[2]==p[0] && np[0]==p[2])) continue;
						if(dist +1 < mindist[np[0]][np[1]][np[2]]){
							mindist[np[0]][np[1]][np[2]] = dist +1;
							wait.push(info(np[0], np[1], np[2], dist +1));
						}
					}
				}
			}
		}
		cout << mindist[g[0].second][g[1].second][g[2].second] << endl;
	}	
	return 0;
}


Measured memory_bytes: 72468
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  int n, m;
  while (scanf("%d %d", &n, &m) != EOF)
  {
    printf("%d\n", m*(m-1)/2 + n*(n-1)/2);
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
	os << "[ "; for(auto v : V) os << v << " "; return os << "]";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os << "(" << P.first << "," << P.second << ")";
}
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1> void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << endl;
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1<<" | ";
	__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define mems(x, y) memset(x, y, sizeof(x))
#define rep(i, n) for (int i = 0; i < n; ++i)
#define irep(i, n) for (int i = 1; i <= n; ++i)
#define print(x) cout << x << '\n'
#define err(x) clog << x << '\n'
typedef long long ll;
#define int ll
typedef long double ld;
#define double ld
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;
const int mod = (119<<23)+1;
const int M = 1e9+7;
const int N = 1e5+5;

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cout << fixed << setprecision(15);
	
	int n; cin >> n;
	int a[n]; rep(i, n) cin >> a[i];
	int c = 1;
	int ans = 0;
	rep(i, n) {
		if (a[i] == c) {
			c++;
		} else {
			ans++;
		}
	}
	if (c == 1) print(-1);
	else print(ans);
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	string s;
	int ans=0;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='1') ans++;
	}
	cout<<ans<<endl;
}

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

#define N 100005
#define num 100
typedef struct aa
{
  char name[num];
  int t;
} A;

A data[N];
int head,tail,n;

void enqueue(A x){
data[tail]=x;
tail=(tail+1)%N;
}

A dequeue(){
A x=data[head];
head=(head+1)%N;
return x;
}

int min(int a,int b){return a<b?a:b;}

int main(){
int elaps=0,c;
int i,q;
A u;
scanf("%d %d",&n,&q);
for(i=1;i<=n;i++){
scanf("%s",data[i].name);
scanf("%d",&data[i].t);
}
head=1;
tail=n+1;

while(head!=tail){
u=dequeue();
c=min(q,u.t);
u.t-=c;
elaps+=c;

if(u.t>0){
enqueue(u);
}

else{
  printf("%s %d\n",u.name,elaps);
}
}

return 0;
}


Measured memory_bytes: 11844
from collections import Counter

N=int(input())
n=list(map(int,input().split()))
#Divide it into even and odd
n1=[]
n2=[]
for i in range(N//2):
    n1.append(n[i*2])
    n2.append(n[i*2-1])
#end

#make lile {key,value}             tabunn kokoga ikenai
cm1=Counter(n1).most_common(2)
cm2=Counter(n2).most_common(2)
#end

#for example(4,1 1 1 1)
cm1.append([0,0])
cm2.append([0,0])
#end


#answer
if cm1[0][0] != cm2[0][0]:
    ans=N-cm1[0][1]-cm2[0][1]
elif cm1[0][1]-cm1[1][1] > cm2[0][1]-cm2[1][1]:#prefer large disadvantage  
    ans=N-cm1[0][1]-cm2[1][1]
else:
    ans=N-cm1[1][1]-cm2[0][1]
print(ans)
#end

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

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

  int n;
  cin >> n;

  double x = (n + 1) / 2;
  cout << x / n << endl;

  return (0);
}


Measured memory_bytes: 3768
from heapq import *
n, m = map(int, input().split())
A = list(map(int, input().split()))
h = []
for a in A:
  heappush(h, ((-1) * a, 1))
for _ in range(m):
  b, c = map(int, input().split())
  heappush(h, ((-1) * c, b))

ans = 0
for _ in range(len(A)):
  c, b = heappop(h)
  ans += (-1) * c
  if b > 1:
    heappush(h, (c, b - 1))
print(ans)

                

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}


// end of Template
int n;
ll ans = 1;
priority_queue <ll> q;
map <int,int> f;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        int temp; cin>>temp;
        f[temp]++;
        if(f[temp]%2==0){
            q.push(temp);
        }
    }

    if(q.size()<=1) ans=0;
    else{
        ans *= q.top();
        q.pop(); ans*= q.top();
    }
    cout<<ans<<newl;

}


Measured memory_bytes: 4992
import java.util.*;


public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long x = Long.parseLong(sc.next());
		Long L=(x-1)/11;
		int r = ((x-1)%11<6)?1:2;
			System.out.println(2*L+r);
			
		sc.close();
	}
}

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

using namespace std;

#define LL long long
#define ULL unsigned LL
#define LD long double

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	if(s[2] == s[3] && s[4] == s[5])
		cout<<"Yes";
	else
		cout<<"No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10],x;//x是计数器
char c;
int main(void)
{
    while(cin>>c&&c!='\0')//每次输入一个字符
    {
        if(c=='0') a[x++]=0;//如果c为'0'a数组就存下0
        else if(c=='1') a[x++]=1;//如果c为'1'a数组就存下1
        else//如果c为'B'a数组就计数器退一位
        {
            if(x) x--;
        }
    }
    if(x)
    {
        for(int i=0;i<x;i++) printf("%d",a[i]);//输出
        printf("\n"); 
    }
}

Measured memory_bytes: 256