akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;

  int n;

  cin >> n;
  
  int d1,d2;
  bool flg = false;
  int cnt = 0;
  for(ii=0;ii<n;ii++){
    cin >> d1 >> d2;
    if(d1 == d2){
      cnt++;
    }
    else{
      cnt = 0;
    }
    if(cnt >= 3){
      flg = true;
    }
  }
  if(flg){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3616
import sys
N, M, K = map(int, input().split())
friends = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, sys.stdin.readline().split())
    friends[a-1].add(b-1)
    friends[b-1].add(a-1)
blocks = [set() for _ in range(N)]
for _ in range(K):
    c, d = map(int, sys.stdin.readline().split())
    blocks[c-1].add(d-1)
    blocks[d-1].add(c-1)

done = set()
chains = []
todo = []
for s in range(N):
    if s in done:
        continue
    chain = set()
    todo.append(s)
    while todo:
        i = todo.pop()
        for ni in friends[i]:
            if ni in done:
                continue
            done.add(ni)
            chain.add(ni)
            todo.append(ni)
    chains.append(chain)

ans = [0] * N
for chain in chains:
    for i in chain:
        blocks[i].intersection_update(chain)
        ans[i] = len(chain) - len(blocks[i]) - len(friends[i]) - 1
print(" ".join(map(str, ans)))

Measured memory_bytes: 127992
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#define SIZE 1000000
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
char str[SIZE];
 
int main()
{
	scanf("%s",&str);
	ll n=strlen(str);
	ll bcount=0;
	ll ichi=0;
	for(ll i=n-1;i>=0;i--){
		if(str[i]=='B'){
			ichi+=n-i;
			bcount++;
		}
	}
	printf("%lld", ichi-bcount*(bcount+1)/2);
}

Measured memory_bytes: 384
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int x;
   cin>>x;
   cout<<(x*x*x)<<endl;
   //while(1);
   return 0;
 }
 

Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
  	int a, b;
  	cin >> a >> b;
  	cout << a * b;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>

using namespace std;

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

    int i, j;
    for (i = 0; i < s.size(); i++) {
        if (s[i] == 'C') break;
    }
    for (j = s.size() - 1; j >= 0; j--) {
        if (s[j] == 'F') break;
    }

    cout << ((i < j)? "Yes" : "No") << endl; 

    return 0;
}

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

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

    vector<int> X(N);
    int x, min, max;
    for (int i = 0; i < N; i++)
    {
        cin >> x;
        X.at(i) = x;
        if (i == 0)
            min = max = x;
        else
        {
            if (x < min)
                min = x;
            if (max < x)
                max = x;
        }
    }

    int res = INT_MAX;
    for (int p = min; p <= max; p++)
    {
        int tmp = 0;
        for (int i = 0; i < N; i++)
        {
            tmp += pow(X.at(i) - p, 2);
        }
        if (tmp < res)
            res = tmp;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
  return *(int*)a - *(int*)b;
}
int main(void){
  int i,j,k;
  int ii[200001];
  int len,lenb,cnt,flg;
  int max,maxi,sum=0;

  scanf("%d %d",&len,&lenb);
  for(i=0;i<len;i++){
    scanf("%d",&k);
    ii[i] = k+1;
  }
  for(i=0;i<lenb;i++){
    sum+=ii[i];
  }
  max =sum;
  maxi = 0;
//      printf("sum %d\n",sum);
  for(i=1;i<=len-lenb;i++){
    sum=sum-ii[i-1]+ii[i+lenb-1];
    if (max < sum){
      max = sum;
      maxi = i;
    }
//      printf("max %d i %d sum %d\n",max,i,sum);
  }

  //  printf("len %d,lenb %d\n",len,lenb);
  for(i=0;i<len;i++){
    //          printf("i%d %d\n",i,iisum[i]);
  }
  //    printf("i %d cnt %d\n",i,cnt);

  //  printf("maxi %d max %d\n",maxi,max);
  printf("%f\n",(float)max/2);
  return 0;
}

Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

#define N_MAX 100000
#define MOD 1000000007

void solv()
{
	int A, B; scanf("%d%d", &A, &B);
	int table[10]; fill(table, table + 10, 0);
	table[A] = 1;
	table[B] = 1;
	for (int i = 1; i <= 3; i++){
		if (0 == table[i]){
			printf("%d", i);
			return;
		}
	}

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

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

int main(){
	int x,a[3]={0,0,0};
	for(int i=0;i<2;i++){
		cin >> x;
		if(x==2){
			a[2]++;
		}else if(x==4||x==6||x==9||x==11){
			a[1]++;
		}else{
			a[0]++;
		}

	}
	for(int i=0;i<3;i++){
		if(a[i]==2){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
program AGC010A
    implicit none
    integer(8)::N,i,ans
    integer(8),allocatable,dimension(:)::A
    read(5,*)N
    allocate(A(N))
    read*,A
    ans=0
    do i=1,N
        ans=ans+mod(A(i),2)
    end do
    if(mod(ans,2)==0)print'(A)',"YES"
    if(mod(ans,2)==1)print'(A)',"NO"
end program AGC010A

Measured memory_bytes: 1536
#include <stdio.h>

int main()
{
    int n, m, h[100010], check[100010]={0}, count = 0;

    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++)
        scanf("%d", &h[i]);

    for (int i = 0; i < m; i++)
    {
        int a, b;
        scanf("%d %d", &a, &b);
        if (h[a] > h[b])
            check[b]=1;
        else if (h[a] < h[b])
            check[a]=1;
        else
        {
            check[a]=1;
            check[b]=1;
        }
    }

    for (int i = 1; i <= n; i++)
    {
        if (check[i] == 0)
            count++;
    }

    printf("%d", count);
    return 0;
}

Measured memory_bytes: 2512
import math
a, b, C = map(int, input().split())
S = a * b * math.sin(math.pi * C / 180) / 2
c = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.pi * C / 180))
L = a + b + c
h = 2 * S / a
print('{:.4f}'.format(S))
print('{:.4f}'.format(L))
print('{:.4f}'.format(h))


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

int main(){
	long long int n,k;
	cin>>n>>k;
	long long int a,b,res=0,p=0,r;
	if(k==0){
		cout<<n*n<<endl;
		return 0;
	}
	for(long long int i=1;i<=n;i++){
		b=i;
		r=n%b;
		p=n/b;
		res+=p*max(b-k,0LL);
		//res+=r;
		res+=max(r-k+1,0LL);
	}
	cout<<res<<endl;
}


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    ll N, K; cin >> N >> K;

    vector<pair<ll,ll>> ab(N);
    ll a, b;
    rep(i, N) {
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }
    sort(all(ab));

    ll ans = -1;
    ll sum = 0;
    rep(i, N) {
        sum += ab[i].second;
        if (sum >= K) {
            ans = ab[i].first;
            break;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1792
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n;
    std::cin >> n;
    
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            if(i*4+j*7==n){
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define assign(x,val) memset(x,val,sizeof(x))
#define motherfucker  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define for0(i,n) for(ll i=0;i<n;++i)
#define for1(i,n) for(ll i=1;i<=n;++i)
#define ford(i,n) for(ll i=n;i>=1;--i)
#define forg(i,a,b) for(ll i=a;i<b;++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpl;
long long mod = 1000000007;
const long double PI = (long double)(3.1415926535897932384626433832795);
inline void yes(){cout<<"Yes\n";}
inline void no(){ cout<<"No\n";}
inline void notposs(){cout<<-1<<endl;}
bool tests = 0;


void solve(){
	ll n;cin>>n;
	ll k = ((ll)log2(n) + 1);
	cout<<(1LL << k) - 1<<endl;
}
 
int main(){
	
	motherfucker
	ll t = 1;
	if(tests) cin>>t;
	for0(i, t){
		solve();
	}
	return 0;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = (1 << 21) + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 21;


int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll m, d;
	cin >> m >> d;
	ll ans = 0;
	for(int i = 4; i <= m; i++){
		for(int j = 2; j < 10; j++){
			if(i % j) continue;
			int k = i / j;
			if(k < 2) continue;
			if(k > 9) continue;
			if(d >= (10*j + k)) ans ++;
		}
	}
	cout << ans;
	return 0;
}

/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/



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

int main(){
    string s;
    cin >> s;
    if(s[5]=='0'&&s[6]-'0'<5)
    {
        cout << "Heisei" << endl;
    }
    else
    {
        cout << "TBD" << endl;
    }
    return 0;
}

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

using namespace std;

int main(void){
    int N,K;
    cin>>N>>K;
    double ans=0;
    double temp=1.0/(double)N;    
    for(int i=1;i<=N;i++){
        int result=i;
        int count=0;
        while(result<K){
            result*=2;
            count++;
        }
        ans+=temp*pow((1.0/2.0),count);
    }
    cout<<fixed;
    cout<<setprecision(10)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int r,c;
    cin>>r;
    cin>>c;
    int ara[r][c];
    int k=r*c;
    int d;
    cin>>d;
    if(r>c){
        int x;
        for(x=1;x<=c;x++){
        if(r*x>=d){
        printf("%d", x);
        break;
        }


    }
    }
    else if(c>r){
        int x;
        for(x=1;x<=r;x++){
        if(c*x>=d){
        printf("%d", x);
        break;
        }

    }
    }
    else if(r==c){
        int x;
        for(x=1;x<=r;x++){
        if(r*x>=d){
        printf("%d", x);
        break;
        }

    }
    }
    return 0;

}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		int ai;
		cin >> ai;
		a.at(i) = ai;
	}
	sort(a.begin(), a.end());
	cout << a.at(a.size()-1) - a.at(0) << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

# ソートを行う
sortList = sorted(A, reverse=True)

# 配列
alice = []
bob = []

# 奇数がAlice
for i in range(len(sortList)):
        if i % 2 == 0:
                alice.append(sortList[i])
        if i % 2 != 0:
                bob.append(sortList[i])

print(sum(alice) - sum(bob))

Measured memory_bytes: 3064
//Code by Mukul Totla
#include<bits/stdc++.h>
using namespace std;
#define ll long long

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

    int n,i;
    cin>>n;
    int arr[n];
    for(i=0; i<n; i++)
        cin>>arr[i];
    int k=1;
    int flag=0;
    int cnt=0;
    for(i=0; i<n; i++)
    {
       if(arr[i]==k)
         {
            flag=1;
           cnt++;
           k++;
         }
    }
    if(flag==0)
        cout<<-1;
    else
        cout<<n-cnt;
    return 0;
}

Measured memory_bytes: 4456
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  ll cnt=0;
  for (ll b = k+1; b <= n; ++b) {
    ll s= n/b;
    cnt += s*(b-k);
    for (int i = 1; i <= n - s * b; ++i) {
      if(i>=k) ++cnt;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

answer = [0] * N
temp = []

for i in range(0, N):
    temp.append([i + 1, A[i]])

temp.sort(key=lambda x: x[1])

for i in range(0, N):
    print(temp[i][0], end=" ")

Measured memory_bytes: 23372
int North(void);
int East(void);
int West(void);
int South(void);
int Right(void);
int Left(void);

int top,front,r,l,back,bottom;

int main(void){
  int n,sum,i;
  char s[7];
  
  while(1){
    scanf("%d",&n);
    if(n==0)break;

    top=1;
    front=2;
    r=3;
    l=4;
    back=5;
    bottom=6;

    sum=top;

    for(i=0;i<n;i++){
      scanf(" %s",s);

      if(strcmp(s,"North")==0)sum+=North();
      else if(strcmp(s,"East")==0)sum+=East();
      else if(strcmp(s,"South")==0)sum+=South();
      else if(strcmp(s,"West")==0)sum+=West();
      else if(strcmp(s,"Left")==0)sum+=Left();
      else if(strcmp(s,"Right")==0)sum+=Right();
    }
    printf("%d\n",sum);
  }
  return 0;
}

int North(void){
  int t;

  t=top;
  top=front;
  front=bottom;
  bottom=back;
  back=t;

  return top;
}

int East(void){
  int t;

  t=top;
  top=l;
  l=bottom;
  bottom=r;
  r=t;

  return top;
}

int West(void){
  int t;

  t=top;
  top=r;
  r=bottom;
  bottom=l;
  l=t;

  return top;
}

int South(void){
  int t;

  t=top;
  top=back;
  back=bottom;
  bottom=front;
  front=t;

  return top;
}

int Right(void){
  int t;

  t=front;
  front=r;
  r=back;
  back=l;
  l=t;

  return top;
}

int Left(void){
  int t;

  t=front;
  front=l;
  l=back;
  back=r;
  r=t;

  return top;
}

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

typedef long long ll;

int main(int argc, char **argv) {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  ll n, p;
  string s;
  cin >> n >> p >> s;
  
  if (p != 2 && p != 5) {
    vector<vector<int>> met(p);
    met[0].push_back(0);
    ll cur_mod = 0;

    vector<ll> tenpowmod(n, 0);
    tenpowmod[0] = 1;
    for (int i = 1; i < n; i++)
      tenpowmod[i] = (tenpowmod[i-1] * 10) % p;
    reverse(tenpowmod.begin(), tenpowmod.end());
    ll ans = 0;
    for (int i = 0; i < n; i++) {
      cur_mod = (cur_mod + ll(s[i] - '0') * tenpowmod[i]) % p;
      ans += (ll)met[cur_mod].size();
      met[cur_mod].push_back(i + 1);
    }
    cout << ans << '\n';
  } else {
    if (p == 2) {
      ll ans = 0;
      for (int i = 0; i < n; i++) {
        int d = s[i] - '0';
        if (d & 1)
          continue;
        ans += i + 1;
      }
      cout << ans << '\n';
    } else {
      ll ans = 0;
      for (int i = 0; i < n; i++) {
        int d = s[i] - '0';
        if (d % 5 != 0)
          continue;
        ans += i + 1;
      }
      cout << ans << '\n';
    }
  }
}

Measured memory_bytes: 3732
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func sort2(x, y int) (int, int) {
	if x < y {
		return x, y
	}
	return y, x
}

func main() {
	scanner.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	c := nextInt()

	smaller, larger := sort2(a, b)
	smallest, _ := sort2(smaller, c)
	_, largest := sort2(larger, c)

	fmt.Println(smallest, largest)
}



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

int main() {
	int N, L;

	cin >> N >> L;

	int sum = 0;
	for( int i = 0; i < N; i++ ) {
		sum += L + i;
	}
	int mi = 10000;
	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		int sum1 = 0;
		for( int j = 0; j < N; j++ ) {
			if( j == i ) {
				continue;
			}
			sum1 += L + j;
		}
		if( abs( sum - sum1 ) < mi ) {
			mi = abs( sum - sum1 );
			ans = sum1;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long
//here begins your code

int solve(int h){

	if(h == 1){
		return 1;
	}
	else{
		return 1 + 2 * solve(h/2);
	}
}


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

  cout << solve(H) << endl;

  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){
    int n,a[110];
    cin >> n;
    rep(i,n) cin >> a[i];

    sort(a,a+n);
    int ans = abs(a[0] - a[n-1]) ;

    cout << ans << endl;





    return 0;
}

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

int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	int ans=1;
	int i=1;
	while(i<n)
	{
	    if(s[i]!=s[i-1])
	    {
	        ans++;
	    }
	    i++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <tuple>
#include <cmath>
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    int ans = 1;
    int d=0;
    for(int i=1;i<N;i++){
        int d2=0;
        if(A[i-1]<A[i])d2=1;
        if(A[i-1]>A[i])d2=-1;
        if(!d){
            d=d2;
        }else{
            if(d*d2<0){
                ans++;
                d=0;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

ll N;

void rec(ll now, int use, ll &ans){
    if(now>N)return;
    if(use == 0b111)++ans;

    rec(now*10+7,use | 0b001, ans);
    rec(now*10+5,use | 0b010, ans);
    rec(now*10+3,use | 0b100, ans);
}

int main(){
    cin >> N;
    ll res = 0;
    rec(0,0,res);
    cout << res << endl;
    return 0;
}

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

    // 入力
    int n, k;  // 1 10
    cin >> n >> k;
    int x[n];  // 2
    rep(i, n) { cin >> x[i]; }

    // 処理
    int di[n] = {};
    for (int i = 0; i < n; i++) {
        if (x[i] < k - x[i]) {
            di[i] = x[i];
        } else {
            di[i] = k - x[i];
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += di[i] * 2;
    }

    // // 出力
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, d;
  cin >> n >> d;
  int grid[n][d];
  rep(i, n) {
    rep(j, d) cin >> grid[i][j];
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      double tmp = 0.0;
      for (int k = 0; k < d; ++k) {
        tmp += pow(grid[i][k] - grid[j][k], 2);
      }
      tmp = sqrt(tmp);
      if (floor(tmp) == ceil(tmp)) ans++;
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,M;
    cin >> N >> M;
    if(N==M) cout << "Yes" << endl;
    else cout << "No" << endl;



}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 300000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c && a % 2 == 0)puts("-1");
	else {
		int ans = 0;
		while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
			int p = a, q = b, r = c;
			a = q / 2 + r / 2;
			b = p / 2 + r / 2;
			c = p / 2 + q / 2;
			ans++;
		}
		cout << ans << endl;
	}
	ggr
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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 ll INF=1e18;

ll n,d;
ll a[3];

ll s[3]={2,3,5};

map<ll,ll> m;

ll dfs(ll g){
    if(g==0){
        return 0;
    }
    if(g==1){
        return d;
    }
    if(g==2){
        return min(a[0],d)+d;
    }
    if(m.count(g)){
        return m[g];
    }
    ll best=INF;
    if(g<INF/d){
        best=g*d;
    }
    rep(i,3){
        ll def=g-g/s[i]*s[i];
        best=min(best,dfs(g/s[i])+a[i]+def*d);
    }
    rep(i,3){
        ll def=(g/s[i]+1)*s[i]-g;
        best=min(best,dfs(g/s[i]+1)+a[i]+def*d);
    }
    return m[g]=best;
}

void testcase(){
    cin >> n;
    rep(i,3){
        cin >> a[i];
    }
    cin >> d;
    cout << dfs(n) << endl;
    return ;
}

int main()
{
    ll t;
    cin >> t;
    while(t--){
        testcase();
        m.clear();
    }
    return 0;
} 

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

using namespace std;
	
#define intt long long

const intt INF = 1e18L + 5;

int n, W;

int main() {
	
	cin >> n >> W;
	
	vector <int> w(n + 1), v(n + 1);
	for (int i = 1; i <= n; i ++) {
		cin >> w[i] >> v[i];
	}
	
	int V = 0;
	for (int i = 1; i <= n; i ++) {
		V += v[i];
	}
	
	vector <intt> dp(V + 1, INF);
	
	// dp[i] = the minimum weight of knapsack with value exactly i;
		
	dp[0] = 0;
	
	for (int k = 1; k <= n; k ++) {
		for (int x = V; x >= 0; x --) {
			if (x - v[k] >= 0) {
				dp[x] = min(dp[x], w[k] + dp[x - v[k]]);
			}
		}	
	}
	
	int ans = 0;
	for (int i = V; i >= 0; i --) {
		if (dp[i] <= W) {
			ans = i;
			break;
		}
	}
	
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
  ll n,k,ly,tx,ty,num,ans=-1,y_min;
  vector<P> xy;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> tx >>ty;
    xy.push_back(P(tx,ty));
  }
  sort(xy.begin(),xy.end());
  for(int r=0;r<n;r++){
    for(int l=r+k-1;l<n;l++){
      vector<ll> tmp;
      for(int i=r;i<=l;i++){
        tmp.push_back(xy[i].second);
      }
      sort(tmp.begin(),tmp.end());
      y_min = tmp[k-1] - tmp[0];
      for(int yr=0;yr<tmp.size();yr++){
        for(int yl=yr+k-1;yl<tmp.size();yl++){
          ly = tmp[yl]-tmp[yr];
          y_min = min(y_min,ly);
        }
      }
      num = y_min*(xy[l].first-xy[r].first);
      if(ans==-1) ans=num;
      ans = min(ans,num);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#include <set>

using namespace std;

long long n, k;


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for (int i = k - n + 1; i <= k + n - 1; i++)
    {
        cout << i << " ";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007
using namespace std;
typedef pair<llint, llint> P;
typedef pair<llint, P> E;

llint n;
llint a[200005];
set<P> S;

bool calc(llint p, llint x, bool flag)
{
	auto it = S.lower_bound(P(p, 0));
	auto pre = it; pre--;
	
	if(it->second < x){
		llint c = it->second;
		if(flag) S.erase(it, S.end());
		else S.erase(it);
		if(pre->first < p-1) S.insert(P(p-1, c));
		S.insert(P(p, c+1));
		return true;
	}
	
	if(pre->second == 0) return false;
	S.erase(it, S.end());
	S.insert(P(p, 1));
	return calc(pre->first, x, false);
}

bool check(llint x)
{
	S.clear();
	S.insert(P(0, 0));
	S.insert(P(a[1], 1));
	
	for(int i = 2; i <= n; i++){
		if(a[i-1] < a[i]){
			S.insert(P(a[i], 1));
			continue;
		}
		if(!calc(a[i], x, true)) return false;
	}
	return true;
}

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	llint ub = n+5, lb = 0, mid;
	while(ub-lb>1){
		mid = (ub+lb)/2;
		if(check(mid)) ub = mid;
		else lb = mid;
	}
	cout << ub << endl;
	
	return 0;
}


Measured memory_bytes: 14336
import math
import numpy as np
N = list(input())
lenN = len(N)

a = list(('10'*math.ceil(lenN/2))[:lenN])
b = list(('01'*math.ceil(lenN/2))[:lenN])

N, a ,b = np.array(N).astype(int), np.array(a).astype(int), np.array(b).astype(int)
print(min([(N != a).sum(), (N != b).sum()]))

Measured memory_bytes: 17476
#include<bits/stdc++.h>
#define REP(n)    for(int i = 0; i < (n); ++i)
#define RREP(n)   for(int i = (n); i >= 0; --i)
#define FOR(m, n) for(int i = (m); i < (n); ++i)
#define SZ(x)       ( (int)(x).size() )
#define BIT(n)      ( 1LL << (n) )
#define EXIST(x)    ( (x).find()		!= (x).end() )
#define DEBUG(n)    cerr << #n << " : " << n << '\n';
#define PB  push_back
#define MP  make_pair
#define UB  upper_bound			//k <
#define LB  lower_bound			//k	<= 
#define F   first
#define S   second
#define INF 1.0e9


using namespace std;

typedef long long			ll;
typedef pair<int, int>		pii;
typedef pair<long long, long long>   pll;
typedef vector<int>			vi;
typedef vector<double>		vd;
typedef vector<long long>   vll
;

template<class T> void chmax(T &	a, const T & b){ if( a < b ) a = b; }
template<class T> void chmin(T &	a, const T & b){ if( a > b ) a = b; }

int r_up(const int a, const int b){ return (a + b - 1) / b; }

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

struct UFT{
  vi	p;
  UFT(){}
  UFT(int N)       { p.resize( N, -1 ); }
  int	par(int a)   { if( p[a] >= 0 ){ p[a]  = par( p[a] ); return p[a]; } return a;  }
  int size(int a)  { return -p[par(a)]; }
  bool	same(int a, int b) { return par(a)	 == par(b); }
  void unite(int	a, int b){
	a													  = par(a);  b = par(b);
	if( a == b ) return;
	if( size(a) < size(b) ) swap(a,b);
	p[a]												 -= size(b);
	p[b]												  = a;
  }
};

int n,k;


int main(){
  cin>>n>>k;
  vector<pll> vp;
  REP(n){
	ll x,y;cin>>x>>y;
	vp.PB(MP(y,x));
  }
  sort(vp.rbegin(),vp.rend());

  vll ans(n+1,0);
  vi typ(n+1,0);
  ll cnt=0;
  
  ll tmp=0;

  REP(k){
	tmp+=vp[i].F;
	if(typ[vp[i].S]==0)cnt++;
	typ[vp[i].S]++;
  }
  ans[cnt]=tmp+cnt*cnt;

  
  while(1){
	ll org=-1,tar=-1;
	FOR(k,n)
	  if(typ[vp[i].S]==0){tar=i;break;}
	RREP(k-1)
	  if(typ[vp[i].S]>1){org=i;break;}

	if(org>-1&&tar>-1){
	  typ[vp[org].S]--; typ[vp[tar].S]++;
	  tmp-=vp[org].F;
	  tmp+=vp[tar].F;
	  swap(vp[org],vp[tar]);
	  vp.erase(vp.begin()+k,vp.begin()+tar);
	  cnt++;
	  ans[cnt]=tmp+cnt*cnt;
	}
	else break;
  }

  sort(ans.rbegin(),ans.rend());
  cout<<ans[0]<<endl;

  
  return 0;
}


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

int main() {
    int N; cin >> N;
    vector<int> D(N + 1);
    rep(i, 1, N + 1) {
        int n = i;
        rep(j, 2, n + 1)  {
            while(n % j == 0) {
                n /= j;
                D[j]++;
            }
        }
    }
    function<int(int)> f = [&](int x) {
        int res = 0;
        for(auto d : D) if(d >= x - 1) res++;
        return res;
    };
    int ans = f(75) + f(25) * (f(3) - 1) + f(15) * (f(5) - 1) + f(5) * (f(5) - 1) * (f(3) - 2) / 2;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int dp[3005][3000];
string a, b;
int len_a, len_b;
string ss = "";	
int LCS(int i, int j)
{
	if(i == len_a || j == len_b) return 0;
	if(dp[i][j] != -1) return dp[i][j];
	
	int ans = 0;
	if(a[i] == b[j]) ans = 1 + LCS(i+1, j+1);
	else
	{
		int ans1 = LCS(i, j+1);
		int ans2 = LCS(i+1, j);
		ans = max(ans1, ans2);
	}
	return dp[i][j] = ans;
}

void printLCS(int i, int j)
{
	if(i == len_a || j == len_b)
	{
		cout << ss << endl;
		return;
	}
	if(a[i] == b[j])
	{
		ss += a[i];
		printLCS(i+1, j+1);
	}
	else
	{
		if(dp[i][j+1] > dp[i+1][j]) printLCS(i,j+1);
		else printLCS(i+1,j);
	}
	return;
}

int main()
{
    memset(dp, -1, sizeof(dp));	
	cin >> a >> b;
	len_a = a.size() , len_b = b.size();	
	int sum = LCS(0,0);
	
	//cout << sum << endl;
	printLCS(0,0);
	return 0;
}


Measured memory_bytes: 35712
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

require 'bigdecimal'

T, X = get_ints

puts (BigDecimal(T)/X).to_f


Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
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; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int MAX=2e5;
const ll MOD=1e9+7;
const int INF=1<<30;
ll kiriage(ll a,ll b){return a%b==0?a/b:a/b+1;}

int main(){
  int N; cin >> N;
  vector<int> v(N);
  rep(i,N){
    cin >> v[i];
  }
  int ans=0;
  rep(i,N){
    if(v[i]==ans+1) ans++;
  }
  if(ans) cout << N-ans << endl;
  else cout << -1 << endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    ll ans = 0;
    if (n > k) ans = x * k + y * (n - k);
    else ans = x * n;
    cout << ans << endl;
    return 0;
}

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

int main(){
	int n,d1,x;
	scanf("%d%d%d",&n,&d1,&x);
	double s=2.*n*d1+1.*x*n*(2*n-1),ans=0;
	for (; n; n--){ ans+=s/2/n; s-=s/n/n; }
	printf("%.15f\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    vector<int> vec[n];
    REP(i,n){
        REP(j,n){
            int a;
            cin >> a;
            if(a == 1){
                vec[i].emplace_back(1 << j);
            }
        }
    }
    vector<vector<ll>> dp(vector<vector<ll>>(n + 1, vector<ll>(1 << n, 0)));
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int bit = 0; bit < (1 << n); bit++){
            if(i != __builtin_popcount(bit)) continue;
            for(int j = 0; j < vec[i].size(); j++){
                dp[i + 1][bit | vec[i][j]] += dp[i][bit];
                dp[i + 1][bit | vec[i][j]] %= MOD;
            }
        }
    }
    cout << dp[n][(1 << n) - 1] << endl;
    return 0;
}

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long int h;
  long long int n;
  cin>>h>>n;
  if(h%n==0){
  cout<<h/n;
  }else{
  cout<<h/n+1;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <class T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
void co() { cout << endl; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << endl; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18L+1;
constexpr ll MOD = 1e9L+7;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
    ll n, x, t;
    cin >> n >> x >> t;

    ll tmp = n / x;
    if(tmp * x < n) tmp++;
    co(tmp * t);

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    int sum = 0;
    vector<int> T(n);
    rep(i,n){
        cin >> T[i];
        sum += T[i];
    }
    int m; cin >> m;
    rep(i,m){
        int p,x; cin >> p >> x;
        cout << sum - T[p-1] + x << endl;
    }
}

Measured memory_bytes: 256
let id x = x
let n = Scanf.scanf "%d\n" id
 
let array = Array.init n (fun _ -> Scanf.scanf "%d\n" id)
let () = Array.sort compare array
let l = Array.length array
  
let rec pl i =
  if i = l then 0 else
    array.(i) + pl (i+1)
     
let rec func max i =
  if i = l then 0 else
    if ((max - array.(i)) mod 10 <> 0) then max - array.(i) else
      func max (i+1)
 
let m = pl 0        
let ans = if m mod 10 <> 0 then m else func (pl 0) 0
 
let () =
  Printf.printf "%d\n" ans

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

int main()
{
  const int MAX_PRIME = 1000000+1;

  bool p[MAX_PRIME];
  memset(p, true, sizeof(p));
  p[0] = p[1] = false;
  for (int i = 2; i*i <= MAX_PRIME; ++i) {
    if (p[i]) {
      for (int j = i+i; j < MAX_PRIME; j += i)
	p[j] = false;
    }
  }

  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    int ans = 0;
    for (int i = 0; i+i <= n; ++i) {
      if (p[i] && p[n-i])
	++ans;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import heapq
def main():
    N, Q = map(int, input().split())
    l = []
    for _ in range(N):
        s, t, x = map(int, input().split())
        l.append((s-x, 1, x))
        l.append((t-x, 0, x))
    for i in range(Q):
        d = int(input())
        l.append((d, 2, i))
    r = [-1] * Q
    l.sort()
    h = []
    se = set()
    for a, b, c in l:
        if b == 0:
            se.remove(c)
        elif b == 1:
            se.add(c)
            heapq.heappush(h, c)
        else:
            while h and h[0] not in se:
                heapq.heappop(h)
            r[c] = h[0] if h else -1
    print('\n'.join(map(str, r)))
            
main()


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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> food(M);
  int c=0;
  
  for(int j=0;j<N;j++){
    int K; cin>>K;
    for(int i=0;i<K;i++){
      int A; cin>>A;
      food[A-1]++;
    }
  }
  for(int k=0;k<M;k++){
    if(food[k]==N)
      c++;
  }
   
  cout<<c<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

signed main(){
  double a,b;
  cin>>a>>b;
  printf("%.9f\n",a/b);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll h; cin>>h;
	ll sum=0;
	ll num=1;
	while(h>0){
		if(h==1)h=0;
		else{
			h=h/2;
		}
		sum+=num;
		num*=2;
	}
	cout<<sum<<endl;
	return 0;
}


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

def dfs(s): # 文字列 s で始まる七五三数の個数
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0')) # 本当は dfs('') 

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>


using namespace std;

int main()
{
  char c;
  int sum;
  while(true)
  {
    sum = 0;
    while(true)
    {
      c = getchar();
      if(c == '\n')
        break;
      sum += c - '0';
    }
    if(sum == 0)
      break;

    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1120