akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std; 

#define NOT_FOUND -1
#define rep(i,n) for(int i=0;i<(int)(n); i++)
/*for文のマクロ定義
rep(i,回数){
    処理
}
*/

void swap(int *a, int *b){
	*b=*a-*b;
	*a-=*b;
	*b+=*a;
}

int sosu_judge(int N){
	/*素数ならば1
	  素数でなければ0を返す
	*/
	int i,j;

	if(N==2)   return 1;
	if(N%2==0) return 0;

	for(i=3;i<N && N%i!=0;i+=2);

	if(i>=N) return 1;
	
	return 0;
}

int factorial(int N){  //Nの階乗を求める関数
	int ans=1;

	while(N--) ans*=(N+1);
	return ans;
}

//クイックソートをする関数
void q_sort(int a[], int first, int last){
    int i,j;
    int x,t;

    x = a[(first + last) / 2];
    i = first; j=last;

    while(1){
        while( a[i] < x) i++;
        while( x < a[j]) j--;
        
        if( i >= j) break;
        
        swap(&a[i],&a[j]);
        i++; j--;
    }
    if(first < i-1) q_sort(a, first,i-1 );
    if(last > j+1)  q_sort(a, j+1,  last);
}

int b_search(int target, int array[],int right, int left){
    /*二分探索を行う関数である。
      戻り値は探索したい値の格納されている位置である。
      もし値が存在しない場合、NOT_FOUND(-1)を返す
    */
    int mid;
    while(left<right){
        mid=(right+left)/2;
        if(array[mid]<target) left =mid+1;
        else                  right=mid;
    }
    if(array[mid]==target) return mid;
    return NOT_FOUND;
}

unsigned long combination(int n, int r){
    /*nCrの値を求める関数である。
      値が巨大になる可能性があるため、戻り地はunsigned longである
    */
    int i,j;
    unsigned long a[17];

    if(n-r<r) r=n-r;
    if(r==0 ) return 1;
    if(r==1 ) return n;
    if(r>17 ) return 0;
    for(i=1;i<r;i++) a[i]=i+2;
    for(i=3;i<=n-r+1;i++){
        a[0]=i;
        for(j=1;j<r;j++)a[j]+=a[j-1];
    }
    return a[r-1];
}
   
int main(){
    int N;
    int ans;

    cin>>N;

    if(N%2==1)ans=N/2+1;
    else      ans=N/2;

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


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	sort.Ints(arr)

	preSize := -1
	count := 0
	for _, e := range arr {
		if preSize != e {
			count++
			preSize = e
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
let n = read_int ()

let a = Array.make n 0

let rec read_ints = function
  | 0 -> ()
  | k -> (Scanf.scanf " %d" (fun x -> a.(x-1) <- n-k)); read_ints (k-1)

let ps = read_ints n

let base = n*n+1

let rec solvea i = if i = n then () else begin Printf.printf " %d" ((i+1)*n + base + a.(i)); solvea (i+1) end

let rec solveb i = if i = n then () else begin Printf.printf " %d" (-(i+1)*n + base); solveb (i+1) end

let () = begin solvea 0; print_newline (); solveb 0 end

Measured memory_bytes: 3200
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

while True:
    n = input()
    if n == 0:
        break
    s, t, b = raw_input().split()
    s = ord(s) - ord('A')
    t = ord(t) - ord('A')
    b = ord(b) - ord('A')
    lst = [0.0 for i in range(9)]
    lst[s] = 1.0
    for loop in range(n):
        lst2 = [0.0 for i in range(9)]
        for i in range(9):
            x = i % 3
            y = i / 3
            if y > 0 and (y - 1) * 3 + x != b:
                lst2[(y - 1) * 3 + x] += lst[y * 3 + x] / 4
            else:
                lst2[y * 3 + x] += lst[y * 3 + x] / 4
            if y < 2 and (y + 1) * 3 + x != b:
                lst2[(y + 1) * 3 + x] += lst[y * 3 + x] / 4
            else:
                lst2[y * 3 + x] += lst[y * 3 + x] / 4
            if x > 0 and y * 3 + x - 1 != b:
                lst2[y * 3 + x - 1] += lst[y * 3 + x] / 4
            else:
                lst2[y * 3 + x] += lst[y * 3 + x] / 4
            if x < 2 and y * 3 + x + 1 != b:
                lst2[y * 3 + x + 1] += lst[y * 3 + x] / 4
            else:
                lst2[y * 3 + x] += lst[y * 3 + x] / 4
        lst = lst2
    print "%.10f" % lst[t]


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

using namespace std;
using namespace std;
typedef long long ll;
#define endl "\n";
#define MAX 10000001+9   //Maximum array size;
#define loop(n) for(ll i=0;i<n;i++)
#define loop2(n) for(ll i=0;i<n;i+=2)
#define all(v) v.begin(),v.end()
#define sz(v)  v.size()
typedef vector<ll> vi;
typedef set<ll> si;

void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}

int pow(int a, int b) {
    int pow = 1;
    loop(b)pow *= a;
    return pow;
    //thanks m7md :)
}

int solution(vector<int> &A) {
    sort(A.begin(), A.end());
    int n = A.size();
    int l = 0, r = n - 1, solu = 2 * (1e9 + 1);
    while (l < n) {
        if (abs(A[r - 1] - A[l]) >= abs(A[l + 1] - A[r])) {
            solu = min(solu, abs(A[r - 1] - A[l]));
            r--;
        } else {
            solu = min(solu, abs(A[l + 1] - A[r]));
            l++;
        }
    }
    for (int i = 0; i < n; ++i) {
        solu = min(solu, abs(A[i] + A[i]));
    }
    return solu;
}

int main() {
    fast();
    int w, h, q;
    cin >> w >> h >> q;
    int x1 = 0, y1 = 0, x2 = w, y2 = h;
    while (q--) {
        int x, y, a;
        cin >> x >> y >> a;
        switch (a) {
            case 1 :
                x1 = max(x, x1);
                break;
            case 2 :
                x2 = min(x, x2);
                break;
            case 3 :
                y1 = max(y, y1);
                break;
            case 4 :
                y2 = min(y, y2);
                break;
        }
    }
    if (x1 > x2||y1>y2)cout << 0;
    else {
        int height = x2 - x1;
        int width = y2 - y1;
        cout << height * width;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long
ll mod = 1000000007;
ll dp[1<<21];
int main(){
    int n; cin >> n;
    int a[n][n];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin >> a[i][j];
    dp[0] = 1;
    for(int i=1;i<1<<n;++i){
        int cnt = 0;
        for(int j=0;j<n;j++)
            if((1<<j)&i) ++cnt;
        for(int j=0;j<n;j++){
            if((1<<j)&i && a[cnt-1][j]){
                dp[i]+=dp[i^(1<<j)];
            }
        }
        dp[i]%=mod;
    }
    if(dp[(1<<n)-1]<0) dp[(1<<n)-1]+=mod;
    cout << dp[(1<<n)-1];
}


Measured memory_bytes: 19548
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;

int main(){
  int N,M;
  cin>>N>>M;
  if (N>=M) {
    cout<<0<<endl;
    return 0;
  }
  vector<int> X(M);
  for (int i=0;i<M;i++) cin>>X[i];
  sort(X.begin(),X.end());  
  vector<int> dd(M,0);
  for (int i=0;i<M-1;i++){
    dd[i]=abs(X[i]-X[i+1]);
  }
  sort(dd.begin(),dd.end(),greater<int>());
  int sum=0;
  for (int i=0;i<N-1;i++){
    sum+=dd[i];
  }
  int ans=X[M-1]-X[0]-sum;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1152
f=lambda:map(int,input().split())
n,m=f()
g=[[] for _ in range(n)]
for _ in range(m):
  a,b=f()
  g[a-1]+=[b-1]
  g[b-1]+=[a-1]
p=[0]*n
from collections import*
q=deque([0])
while q:
  v=q.popleft()
  for c in g[v]:
    if p[c]<1: p[c]=v+1; q.append(c)
if 0 in p: print('No')
else: print('Yes',*p[1:],sep='\n')

Measured memory_bytes: 38948
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
// #pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll a,b;
    cin>>a>>b;
    cout<<(a*b)/(__gcd(a,b));


}


Measured memory_bytes: 256
#include <stdio.h>

int main() 
{

    int hwnum, day;
    int hw;
    int sumday = 0;

    scanf("%d %d", &day, &hwnum);

    for (int i = 0; i < hwnum; ++i){
        scanf("%d", &hw);
        sumday += hw;
    }

    if ( sumday > day ){
        printf("%d",-1);

    }  else {
        printf("%d", day - sumday);
    }
    
    return 0;

}



Measured memory_bytes: 1732
#include <stdio.h>

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

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N, 0);
  for(int ii=1; ii<N; ii++){
    int a;
    cin >> a;
    A[a-1]++;
  }
  for(auto& a : A){
    cout << a << endl;
  }
  return 0;
}


Measured memory_bytes: 4052
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main implements Runnable {
	public static void main(String[] args) {
		new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start();
		// new Main().run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; ++i) {
			arr[i] = sc.nextInt();
		}
		solve(n, arr);
	}

	int n;
	int[] p;
	SegTree[] seg;

	public void solve(int n_, int[] p_) {
		n = n_;
		p = p_;
		int[] ref = new int[n + 1];
		Arrays.fill(ref, -1);
		for (int i = 0; i < n; ++i) {
			ref[p[i]] = i;
		}
		seg = new SegTree[2];
		for (int i = 0; i < 2; ++i) {
			seg[i] = new SegTree(n);
		}
		for (int i = 0; i < n; ++i) {
			seg[i % 2].v[i + seg[i % 2].n - 1] = p[i];
		}
		for (int t = 0; t < 2; ++t) {
			for (int i = seg[t].n - 2; i >= 0; --i) {
				seg[t].v[i] = Math.min(seg[t].v[2 * i + 1], seg[t].v[2 * i + 2]);
			}
		}
		ArrayList<Integer> ans = new ArrayList<>();
		PriorityQueue<Interval> pq = new PriorityQueue<>();
		pq.add(new Interval(0, n, seg[0].query(0, n)));
		while (!pq.isEmpty()) {
			Interval I = pq.poll();
			if (I.r - I.l <= 1)
				continue;
			int v = I.v;
			int vIdx = ref[v];
			int u = seg[1 - I.l % 2].query(vIdx + 1, I.r);
			int uIdx = ref[u];
			seg[I.l % 2].setVal(vIdx, Integer.MAX_VALUE / 10);
			seg[1 - I.l % 2].setVal(uIdx, Integer.MAX_VALUE / 10);
			pq.add(new Interval(I.l, vIdx, seg[I.l % 2].query(I.l, vIdx)));
			pq.add(new Interval(vIdx + 1, uIdx, seg[(vIdx + 1) % 2].query(vIdx + 1, uIdx)));
			pq.add(new Interval(uIdx + 1, I.r, seg[(uIdx + 1) % 2].query(uIdx + 1, I.r)));
			ans.add(v);
			ans.add(u);
		}
		for (int i = 0; i < ans.size(); ++i) {
			System.out.print(ans.get(i) + (i == ans.size() - 1 ? "\n" : " "));
		}
	}

	class Interval implements Comparable<Interval> {
		int l, r;
		int v;

		public Interval(int l_, int r_, int v_) {
			l = l_;
			r = r_;
			v = v_;
		}

		@Override
		public int compareTo(Interval o) {
			return Integer.compare(v, o.v);
		}
	}

	class SegTree {
		int n;
		int[] v;

		public SegTree(int n_) {
			n = 1;
			while (n < n_) {
				n *= 2;
			}
			v = new int[2 * n - 1];
			Arrays.fill(v, Integer.MAX_VALUE / 10);
		}

		void setVal(int k, int val) {
			k += n - 1;
			v[k] = val;
			while (k > 0) {
				k = (k - 1) / 2;
				v[k] = Math.min(v[2 * k + 1], v[2 * k + 2]);
			}
		}

		int query(int a, int b, int l, int r, int k) {
			if (a <= l && r <= b) {
				return v[k];
			} else if (r <= a || b <= l) {
				return Integer.MAX_VALUE / 10;
			} else {
				int vl = query(a, b, l, (l + r) / 2, 2 * k + 1);
				int vr = query(a, b, (l + r) / 2, r, 2 * k + 2);
				return Math.min(vl, vr);
			}
		}

		int query(int a, int b) {
			return query(a, b, 0, n, 0);
		}
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 105700
#include<stdio.h>

int main()
{
  int N,X;
  int m[101];
  int i;
  int a,b;
  scanf("%d",&N);
  scanf("%d",&X);
  scanf("%d",&m[0]);
  a=m[0];
  X-=m[0];
  for(i=1;i<N;i++){
    scanf("%d",&m[i]);
    X-=m[i];
    if(m[i]<a) a=m[i];
  }
  b=X/a;
  printf("%d",N+b);
  return 0;
}


Measured memory_bytes: 1712
import java.util.Scanner;

public class Main {

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

            if (n <= 999) {
                System.out.println("ABC");
            } else {
                System.out.println("ABD");
            }
        }
    }

}


Measured memory_bytes: 21972
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int main ()
{
	char c;
	scanf("%c\n",&c);
	if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o') {
		puts("vowel");
	}else{
		puts("consonant");
	}

	return 0;
}

Measured memory_bytes: 128
package main

import (
  "fmt"
)

func main() {
  res := "Yes"
  var n int
  var s string 
  fmt.Scan(&n, &s)
  if n & 1 == 1 {
    res = "No"
  } else {
    t := s[:n/2]
    if t + t != s {
      res = "No"
    }
  }
  fmt.Println(res)
  
}

Measured memory_bytes: 512
H, W = map(int, input().split())
S = [[0]*W for _ in range(H)]

for i in range(H):
    Si = list(input())
    for j in range(W):
        if Si[j] == '#':
            S[i][j] = 1

# row
S_row = [[0]*W for _ in range(H)]
for i in range(H):
    c = 0
    for j in range(W):
        if S[i][j] == 1:
            c = 0
        else:
            c += 1
        S_row[i][j] = c
    # reverse
    for j in range(W-2, -1, -1):
        if S_row[i][j+1] > 0 and S_row[i][j] > 0:
            S_row[i][j] = S_row[i][j+1]

# col
S_col = [[0]*W for _ in range(H)]
for j in range(W):
    c = 0
    for i in range(H):
        if S[i][j] == 1:
            c = 0
        else:
            c += 1
        S_col[i][j] = c
    # reverse
    for i in range(H-2, -1, -1):
        if S_col[i+1][j] > 0 and S_col[i][j] > 0:
            S_col[i][j] = S_col[i+1][j]

# res
res = max([max([S_row[i][j] + S_col[i][j] - 1 for j in range(W)]) for i in range(H)])
print(res)


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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<string, ll> anal_cnt;
    REP(i, n) {
        string s;
        cin >> s;
        sort(ALL(s));
        anal_cnt[s]++;
    }

    ll ans = 0;
    for (auto& ac : anal_cnt) {
        ans += ac.second * (ac.second - 1) / 2;
    }
    cout << ans << ln;
    return 0;
}


Measured memory_bytes: 11412
#include<stdio.h>
int main()
{
	char N[17];
	int len;
	int jadge = 1;
	scanf("%s", N);
	len = strlen(N);
	int ans;

	//二桁目以下が全部９なのか
	for (int i = 1; i < len; i++)
	{
		if (N[i] != '9')
		{
			jadge = 0;
			break;
		}
	}
	//二桁目以下が全部９の場合
	if (jadge)
	{
		ans = N[0] - '0' + (9 * (len - 1));
	}
	else
	{
		ans = N[0] - '0' - 1 + (9 * (len - 1));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
//#include <cstdio>
//#include <functional>
//#include <bits/stdc++.h>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
#include <string>
//#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define rt0 return 0
using namespace std;
 
int main()
{
	int n,m,x,A[100];
	int i;
	int ans=0;

	cin>>n>>m>>x;
	for(i=0;i<m;i++) {
		cin>>A[i];
		if(x>A[i]) ans++;
	}
	if(ans>m/2) ans=m-ans;

	cout<<ans;
		

    rt0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

using namespace std;

int main()
{
    int a[3];
    int sum = 0;
    for (int i = 0;i < 3;i++){
        cin >> a[i];
        sum += a[i];
    }
    
    if (sum > 21){
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int dp[405][405];
int power[405][405];
const int mod=1e9+7;
int pp[405][405];

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n,k;
    cin>>n>>k;
    pair<int,int>p[n+1];
    for(int i=1;i<=n;i++)
        cin>>p[i].first;
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
        cin>>p[i].second;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
        {
            for(int l=p[i].first;l<=p[i].second;l++)
            {
                if(j==0)
                    power[0][l]=1;
                else
                    power[j][l]=(power[j-1][l]*l)%mod;
            }
        }
        for(int j=0;j<=k;j++)
        {
            for(int l=p[i].first;l<=p[i].second;l++)
            {
                pp[i][j]+=power[j][l];
                pp[i][j]%=mod;
            }
        }
    }

    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
        {
            int z=0;
            for(int l=0;l<=k;l++)
            {
                if(j>=l)
                z+=(dp[i-1][j-l]*pp[i][l])%mod;
                z%=mod;
            }
            dp[i][j]=z;
        }
    }

    cout<<dp[n][k];

} 


Measured memory_bytes: 4096
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]

l,r,d = MI()





print(r//d-(l-1)//d)

Measured memory_bytes: 27056
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1234567;
const ll INF=1000000010;
const ll LINF=1000000000000000010LL;
const int MAX=500010;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
struct edge{int from,to;ll cost;};
vector<edge> G;
int n,m;
ll di[1010];
bool h(){
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            edge e=G[j];
            if(di[e.to]>di[e.from]+e.cost){
                di[e.to]=di[e.from]+e.cost;
                if(i==n-1&&e.to==n-1){
                    return true;
                }
            }
        }
    }
    return false;
}
int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;ll c;
        cin>>a>>b>>c;a--;b--;
        G.push_back({a,b,-c});
    }
    vector<ll> d(n,LINF);
    d[0]=0;
    for(int i=0;i<n-1;i++){
        for(int j=0;j<G.size();j++){
            edge e=G[j];
            if(d[e.from]==LINF)continue;
            d[e.to]=min(d[e.to],d[e.from]+e.cost);
        }
    }
    if(h()){
        cout<<"inf"<<endl;
        return 0;
    }
    cout<<-d[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
N,M= list(map(int, input().split())) 
H = list(map(int, input().split())) 
A = [0]*M
B = [0]*M
ans = [1]*N

for i in range(M):
    A[i], B[i]= map(int, input().split())
    

for i in range(M):
    a = A[i]-1
    b = B[i]-1
    if H[a] < H[b]:
        ans[a]=0
    elif H[a] > H[b]:
        ans[b]=0
    else:
        ans[a]=0
        ans[b]=0
        
print(ans.count(1))

Measured memory_bytes: 21832
using System;

namespace ALDS1_1_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int x = int.Parse(str[0]);
            int y = int.Parse(str[1]);

            int Ans = GCD(x, y);
            Console.WriteLine("{0}", Ans);

//            string pause = Console.ReadLine();

        }

        static private int GCD(int x, int y)
        {
            if (y == 0)
            {
                return x;
            }
            else if (y > x)
            {
                return GCD(y, x);
            }
            else
            {
                return GCD(y, x % y);
            }
        }
    }
}

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


int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int q;
  cin >> q;
  int b[q];
  int c[q];
  rep(i, q) cin >> b[i] >> c[i];
  vector<int> num(100001);
  ll sum = 0;
  rep(i, n){
    num[a[i]] ++;
    sum += a[i];
  }
  rep(i, q){
    sum += (c[i] - b[i]) * num[b[i]];
    num[c[i]] += num[b[i]];
    num[b[i]] = 0;
    cout << sum << endl;
  }
}



Measured memory_bytes: 4816
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

int N;

struct Edge {
    int from, to, cost;
}

Edge[][] G;

bool input() {
    scanf("%d\n", &N);
    if (N == 0) return false;
    G = new Edge[][N];
    foreach (i; 0 .. N) {
        foreach (j; 0 .. 2) {
            int a, cost;
            scanf("%d %d", &a, &cost);
            G[i] ~= Edge(i, a, cost);
        }
    }
    return true;
}

void solve() {

    auto used = new bool[N];

    Edge[] cycle(int v) {
        Edge[] es;
        void dfs(int v) {
            foreach (e; G[v]) {
                if (used[e.to]) continue;
                used[e.to] = true;
                es ~= e;
                dfs(e.to);
            }
        }
        es ~= G[v];
        used[ G[v][0].to ] = true;
        dfs( G[v][0].to );
        return es;
    }

    const MOD = 10007;
    int ret = 1;
    foreach (int i; 0 .. N) {
        if (used[i]) continue;
        used[i] = true;
        auto es = cycle(i);
        //writeln(es);
        auto m = es.map!"a.cost".reduce!max;
        ret = ret * es.count!((a) => a.cost == m) % MOD;
    }
    writeln(ret);

}

void main() {
    while (input) solve;
}

Measured memory_bytes: 3108
package main

import (
  "fmt"
)
  
func main() {
  var N int
  fmt.Scanf("%d\n", &N)
  arr := make([]int, N)
 
  for i := 1; i < N; i++ {
    var c int
    fmt.Scanf("%d", &c)
    arr[c-1]++
  }
  for i := 0; i < N; i++ {
    fmt.Println(arr[i])
  }
}


Measured memory_bytes: 6484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    int ans = inf;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        ans = 0;
    } else {
        ans = min({a * b, b * c, c * a});
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
char str[101];
int check()
{
	int len=strlen(str);
	if(len==1)return 1;
	int l=len/2;
	for(int i=0;i<l;i++)
	{
		if(str[i]!=str[len-1-i])return 0;
	}
	return 1;
}
int main()
{
	int ans=0;
	while(cin>>str)
	{
		if(check())ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1140
from heapq import *
from collections import *

N, M = map(int, input().split())
L, R, C = [0] * M, [0] * M, [0] * M

for i in range(M):
    L[i], R[i], C[i] = map(int, input().split())
    L[i] -= 1
    R[i] -= 1

start = defaultdict(lambda: [])
end = defaultdict(lambda: [])
for i in range(M):
    start[L[i]].append(i)
    end[R[i]].append(i)

state = []
for i in start[0]:
    heappush(state, (C[i], i))

for i in range(1, N):
    while len(state) > 0 and R[state[0][1]] < i:
        heappop(state)

    if len(state) == 0:
        print(-1)
        exit()

    for j in start[i]:
        heappush(state, (state[0][0] + C[j], j))

print(state[0][0])


Measured memory_bytes: 94424
function Main(input) {
	var lines = input.split("\n");
    var x,y,z;
	var parsed = lines[0].split(" ").map(function(v,i,a){return parseInt(v);});
    x = parsed[0]; y = parsed[1]; z = parsed[2];
	console.log(Math.floor((x-z)/(y+z)));
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>
#define MOD 1000000007
using namespace std;


int main(void){
    int n;
    cin>>n;
    int num[3] = {};
    long long ans=1;

    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        int count = 0;
        for(int j=0;j<3;j++){
            if(a==num[j]){
                if(count==0) num[j] ++;
                count ++;
            }
        }
        ans *= count;
        ans %= MOD;
    }
    cout<<ans<<endl;
}

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

int main()
{
	string S, T;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	string U;
	cin >> U;

	if (U == S) {
		cout << A - 1 << " " << B << endl;
	}
	else {
		cout << A << " " << B - 1 << endl;
	}
}





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

int main()
{
    string N;
    cin >> N;
    atoi(N.substr(0, 3).c_str()) % 111 == 0 || atoi(N.substr(1, 3).c_str()) % 111 == 0 ? cout << "Yes" : cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
int gi() { 
	int res = 0, w = 1; 
	char ch = getchar(); 
	while (ch != '-' && !isdigit(ch)) ch = getchar(); 
	if (ch == '-') w = -1, ch = getchar(); 
	while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar(); 
	return res * w; 
} 
const int Mod = 1e9 + 7; 
struct Matrix { 
	int m[3][3]; 
	Matrix () { memset(m, 0, sizeof(m)); } 
	int *operator [] (const int &id) { return m[id]; } 
	Matrix operator * (const Matrix &r) const { 
		Matrix res; 
		for (int i = 0; i < 3; i++)
			for (int k = 0; k < 3; k++) { 
				if (!m[i][k]) continue; 
				for (int j = 0; j < 3; j++) 
					res[i][j] = (res[i][j] + 1ll * m[i][k] * r.m[k][j]) % Mod; 
			} 
		return res; 
	} 
} F, G[30], H; 
int N, M; 
int main () { 
#ifndef ONLINE_JUDGE 
    freopen("cpp.in", "r", stdin); 
#endif 
	G[0][0][0] = 1, G[0][0][1] = 2, G[0][0][2] = 1; 
	G[0][1][0] = 0, G[0][1][1] = 1, G[0][1][2] = 1; 
	G[0][2][0] = 1, G[0][2][1] = 2, G[0][2][2] = 2; 
	H = G[0]; 
	H[2][0] = H[2][1] = 0, H[2][2] = 1; 
	for (int i = 1; i <= 29; i++) G[i] = G[i - 1] * G[i - 1]; 
	F[0][0] = 1; 
	N = gi(), M = gi(); 
	int pos = -1; 
	for (int i = 1; i <= M; i++) { 
		int x = gi(); 
		for (int j = 0; j < 30; j++) 
			if ((x - pos - 1) >> j & 1) F = F * G[j]; 
		F = F * H; 
		pos = x; 
	} 
	for (int j = 0; j < 30; j++) 
		if ((N - pos - 1) >> j & 1) F = F * G[j]; 
	printf("%d\n", F[0][2]); 
    return 0; 
} 

Measured memory_bytes: 3732
#include<stdio.h>

int main(void){
	
	int H,W,a,i,j,k;
	while(1){
		a=1;
		scanf("%d %d",&H ,&W);
		if((H==0)&&(W==0)){
			break;
		}
		for(k=1;k<=H;k++){
			if((a%2)==1){
				for(i=1;i<=W;i++){
					if((i%2)==1){
						printf("#");
					}
					else if((i%2)==0){
						printf(".");
					}
				}
				printf("\n");
			}
			if((a%2)==0){
				for(j=1;j<=W;j++){
					if((j%2)==1){
						printf(".");
					}
					if((j%2)==0){
						printf("#");
					}
				}
				printf("\n");
			}
		a++;
				
		}
		printf("\n");
	}
	return 0;
	
}

Measured memory_bytes: 572
while True:
	mark = map(int, raw_input().split())
	chukan = mark[0]
	kimatu = mark[1]
	saishi = mark[2]
	wa = chukan + kimatu
	if chukan == -1 and kimatu == -1 and saishi == -1:
		break
	elif chukan == -1 or kimatu == -1:
		print("F")
	elif 80 <= wa:
		print("A")
	elif 65 <= wa and wa < 80:
		print("B")
	elif 50 <= wa and wa < 65:
		print("C")
	elif 30 <= wa and wa < 50:
		if 50 <= saishi:
			print("C")
		else:
			print("D")
	else:
		print("F")

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

char c[1002][1002];

int main()
{
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) c[i][j] = '.';
    if(n % 2){
        for(int j = 0; j < m - 1; j++){
            if(a == 0) break;
            if(c[0][j] != '.' || c[0][j + 1] != '.') continue;
            c[0][j] = '<', c[0][j + 1] = '>';
            a--;
        }
        if(m >= 3 && m % 2 == 1 && a % 2 == 1 && b >= 2){
            c[0][m - 1] = c[1][m - 3] = '^';
            c[1][m - 1] = c[2][m - 3] = 'v';
            c[2][m - 2] = '<';
            c[2][m - 1] = '>';
            a--;
            b -= 2;
        }
    }
    for(int j = 0; j < m - 1; j += 2){
        for(int i = n - 1; i >= 0; i--){
            if(c[i][j] != '.' || c[i][j + 1] != '.' || a == 0) break;
            c[i][j] = '<', c[i][j + 1] = '>';
            a--;
        }
    }
    for(int j = 0; j < m; j++){
        for(int i = n - 1; i > 0; i -= 2){
            if(b == 0) break;
            if(c[i][j] == '.' && c[i - 1][j] == '.'){
                c[i][j] = 'v', c[i - 1][j] = '^';
                b--;
            }
        }
    }
    if(a > 0 || b > 0){
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++) cout << c[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<ll> a(n),b(n),c(n),cnt(n),sum(n+1,0);
	rep(i,n) cin>>a[i];
	rep(i,n) cin>>b[i];
	rep(i,n) cin>>c[i];
	sort(begin(a),end(a));
	sort(begin(b),end(b));
	sort(begin(c),end(c));
	rep(i,n){
		cnt[i]=end(c)-upper_bound(begin(c),end(c),b[i]);
		sum[i+1]=sum[i]+cnt[i];
	}
	ll ans=0;
	rep(i,n){
		int ind=upper_bound(begin(b),end(b),a[i])-begin(b);
		ans+=sum[n]-sum[ind];
	}
	cout<<ans<<endl;
}

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

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

  if(s[0]=='A'){
    s='T';
  }

  else if(s[0]=='T'){
    s='A';
  }

  else if(s[0]=='G'){
    s='C';
  }

  else if(s[0]=='C'){
    s='G';
  }

cout <<s <<endl;

}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

vector<P> G[100005];
bool flag[100005];

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

    int N,R; cin >> N >> R;

    for (int i = 0;i < R;i++){
        ll a,b,d;
        cin >> a >> b >> d;
        G[a].push_back(P(b,d));
        G[b].push_back(P(a,d));
    }

    vector<vector<ll> > d(N+1,vector<ll>(N+1,INT_MAX));

    ll ma = 0;

    for (int i = 1;i <= N;i++){
        priority_queue<P,vector<P>, greater<P> > que; 
        que.push(P(0,i));
        for (int j = 1;j <= N;j++){
            d[i][j] = INT_MAX;
        }
        d[i][i] = 0;
        while(que.size()){
            P p = que.top(); que.pop();
            ll now = p.second;
            ll sum = p.first;
            if(sum > d[i][now]) continue;
            for (int j = 0;j < G[now].size();j++){
                ll to = G[now][j].first;
                ll l = G[now][j].second;
                //cout << now << " " << to << " " << sum  << " " << l << " " << d[to] << endl;
                if(d[i][to] > sum+l){
                    d[i][to] = sum+l;
                    que.push(P(d[i][to],to));
                }
            }
        }
        for (int j = i;j <= N;j++){
            ma = max(d[i][j],ma);
        }
        //cout << i << " " << ma << endl;
    }

    vector<ll> mp[10005];

    for (int i = 1;i <= N;i++){
        for (int j = i;j <= N;j++){
            if(d[i][j] == ma){ mp[i].push_back(j);}
        }
    }

    for (int i = 1;i <= N;i++){
        ll from = i;
        queue<ll> que;
        bool used[10005];
        memset(used,0,sizeof(used));
        for (int j = 0;j < mp[i].size();j++){
            que.push(mp[i][j]);
            used[mp[i][j]] = true;
            flag[mp[i][j]] = true;
        }
        while(que.size()){
            ll now = que.front(); que.pop();
            for (int j = 0;j < G[now].size();j++){
                ll nex = G[now][j].first;
                ll cos = G[now][j].second;
                if(!used[nex] && (d[from][nex]+cos == d[from][now])){
                    used[nex] = true;
                    flag[nex] = true;
                    que.push(nex);
                }
            }
        }
    }

    ll M = 0;
    vector<ll> ans;
    for (int i = 1;i <= N;i++){
        if(!flag[i]){
            M++;
            ans.push_back(i);
        } 
    }

    cout << M << endl;

    for (int i = 0;i < ans.size();i++){
        cout << ans[i] << endl;
    }

    return 0;

}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = pow(10,9) + 7;

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

int main(){

    int a, b;
    string sa, sb;
    cin >> a >> b;
    
    for(int i = 0; i < b; i++){
        sa += to_string(a);
    }
    for(int i = 0; i < a; i++){
        sb += to_string(b);
    }

    if(sa < sb) cout << sa << endl;
    else cout << sb << endl;


    return 0;
}

Measured memory_bytes: 256
import sys
n = int(input())
a = []
for l in sys.stdin:
    a.append(l.replace('\n',''))
    
def count(a,str):
  return len([i for i in a if i ==str])

print(f'AC x {count(a,"AC")}')
print(f'WA x {count(a,"WA")}')
print(f'TLE x {count(a,"TLE")}')
print(f'RE x {count(a,"RE")}')

Measured memory_bytes: 16800
// Example program
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

const int MAXN = 1e5 + 1;

int a[MAXN];

int main()
{
    int n;
    cin >> n;
    int e = 0;
    int o = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] % 2 == 0)
            e++;
        else
            o++;
    }
    e += (o / 2);
    if (o % 2 == 1 && e != 0)
        cout << "NO";
    else
        cout << "YES";
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main()
{
    string s;
    cin >> s;
    int len = s.size();
    int cnt = 0;
    rep(i, 0, len) {
        if (s[i] == '2') cnt ++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 768
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {

	public static void main(String []args) {
	Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int d = a/b;
		int r = a%b;
		double f = ((double)a)/b;
		//DecimalFormat df = new DecimalFormat("#.00000");
		//System.out.printf(d+" "+r+" ");
		System.out.printf("%d %d %.5f",d,r,f);
	in.close();
	}
}


Measured memory_bytes: 26400
# -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
write = sys.stdout.write
def ii(): return int(readline())
def mi(): return map(int, readline().rstrip().split())
def li(): return list(readline().rstrip())
def lmi(): return list(map(int, readline().rstrip().split()))
def end(*arg): print(*arg); sys.exit()
# template


def main():
    n = ii()
    a = lmi()
    i = 0
    tmp = 1
    while i < n:
        if a[i] == tmp:
            tmp += 1
            i += 1
        else:
            i += 1
    if(tmp == 1):
        print(-1)
    else:
        print(n - (tmp - 1))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 72304
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a; i <= b; ++i)
#define PER(i, a, b) for (int i = a; i >= b; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;

int query(LL x){
	cout << "? " << x << endl;
	cout.flush();
	string s; cin >> s;
	return s == "Y" ? 1 : 0;
}

int ans[10][2];
LL pwr[10];

int main(){
	if (query(1000000000)){
		for (LL i = 1; ; i *= 10)
			if (query(i << 1)){
				cout << "! " << i << endl;
				return 0;
			}
	}
	for (LL i = 1000000000; i >= 1; i /= 10) if (query(i)){
		LL l = i + 1, r = i * 10 - 1, res = -1;
		while (l <= r){
			LL mid = l + r >> 1;
			if (query(mid * 1000))
				res = mid, r = mid - 1;
			else l = mid + 1;
		}
		cout << "! " << res << endl;
		return 0;
	}
	return 0;
}

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

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

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

    int alice, bob;
    alice = 0;
    bob = 0;

    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) alice += a.at(i);
        else bob += a.at(i);
    }

    cout << abs(alice - bob) << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main(){
    int n,m=1;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
        if(a.at(i)==m){
            m++;
        }
    }
    if(m==1){
        cout << -1 << endl;
    }
    else{
        cout << n-m+1 << endl;
    }

}

Measured memory_bytes: 1024
N = int(input())
B = [[] for i in range(N)]
C = []
for i in range(N):
  M = int(input())
  C.append(M)
  for j in range(M):
    B[i].append([int(s) for s in input().split()])

def check_val(val, digit):
  return (val%2**(digit+1))//(2**(digit))

count = 0
for i in range(2**N):
  A = []
  for j in range(N):
    A.append(check_val(i, j))
  A.reverse()
  flg = True
  for j, Ad in enumerate(A):
    if Ad == 1:
      for E, F in B[j]:
        if F != A[E-1]:
          flg = False
  if flg == True:
    count = sum(A)
print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int* c = new int[14];
  int temp = 1;
  for(int i=0;i<8;i++) {
    c[i] = temp;
    temp *= 6;
  }
  temp = 9;
  for(int i=0;i<6;i++) {
    c[i+8] = temp;
    temp *= 9;
  }
  sort(c,c+14);
  int count = 1000000000;
  for(int i=0;i<=n/9;i++){
    int ama = n - i*9;
    int cand = 0;
    int nin = i;
    while(nin>0){
      cand += nin%9;
      nin /= 9;
    }
    while(ama>0){
      cand += ama%6;
      ama /= 6;
    }
    count = min(count,cand);
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<float> vfloat;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vstr> vvstr;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


vint divisor(int n) {
    vint ans;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ans.push_back(i);
            if (i*i != n) ans.push_back(n/i);
        }
    }
    sort(all(ans));
    return ans;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vint d = divisor(m);
    int ans;
    ans = d[0];
    rep(i, d.size()) {
        int sum = m / d[i];
        if (n > sum) break;
        ans = d[i];
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

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

    vector<ll> a(n);
    vector<ll> sum(n-1);
    for(int i=0;i<n;i++) {
        cin >> a.at(i);
    }
    for(int i=0;i<n-1;i++) {
        sum.at(i) = a.at(i) + a.at(i+1);
    }

    ll ans=0, eaten;
    for(int i=0;i<n-1;i++) {
        if(sum.at(i)>x) {
            ans += sum.at(i)-x;
            if(i!=n-2) sum.at(i+1) -= min(sum.at(i)-x, a.at(i+1));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792