akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long s, w;

	std::cin >> s >> w;

	if (w >= s) {
		std::cout << "unsafe" << std::endl;
	}
	else {
		std::cout << "safe" << std::endl;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;

ll power(int x, unsigned int y) 
{ 
    ll res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = x*x;  // Change x to x^2 
    } 
    return res; 
}

int main(){
	int n ; cin>>n;
	vector<pair<int,int> >c(n);
	for(int i = 0 ; i< n ; i ++){
		int x,y; cin>>x>>y;
		c[i]=make_pair(x,y); 
	}
	int p[n];
	vector<int>perm;
	for(int i = 0 ; i< n ; i++){
		p[i]=i;
	}

	do{
		for(int i = 0 ; i< n ; i++){
			perm.push_back(p[i]);	
		}
	}
	while(next_permutation(p,p+n));
	

	
	double sum=0;
	for(int  i= 0 ; i < perm.size() ; i =i+n){
		double count=0;
		for(int j = i ; j< i+n-1 ; j++){
			count=count+sqrtl(power((c[perm[j]].first-c[perm[j+1]].first),2)+power((c[perm[j]].second-c[perm[j+1]].second),2));
		}
		sum=sum+count;
	}

	double si= perm.size()/n;
	printf("%0.9f",sum/si);



	int l ; cin>>l;
	
	
	
}

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

int main()
{
  typedef long long ll;
  ll N;
  cin >> N;
  vector<ll> _a(N);
  auto * const a = &_a[0];
  for (ll i = 0; i < N; ++i)
    cin >> a[i];
  ll cnt = N;
  ll num = 1;
  for (ll i = 0; i < N; ++i)
  {
    if (num == a[i])
    {
      --cnt;
      ++num;
    }
  }
  cout << ((N == cnt) ? -1 : cnt);
  return 0;
}


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

	public static void main(String[] args) {
		int i,j,k,v;
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		int array[] = new int[n];

		for(i=0;i<n;i++)array[i] = Integer.parseInt(in.next());

	for(i=0;i<n;i++){
		v = array[i];
		j = i-1;
		while(j>=0 && array[j]>v){
			array[j+1] = array[j];
			j--;
		array[j+1] = v;
		}
	    for(k = 0;k<n-1;k++)System.out.print(array[k]+" ");
	    if(i<(n-1))System.out.println(array[k]);
	    else System.out.println(array[n-1]);
	}
	}

}

Measured memory_bytes: 29820
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	String s=sc.next(),t=sc.next(),f;
    int n=s.length();
    char a=t.charAt(n);
    f=String.valueOf(a);
    if(t.equals(s+f)){
      System.out.print("Yes");
    }else{
      System.out.print("No");
    }
  }
}

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

int main(){
    int K,N;
    cin>>K>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }

    int max_d=0;
    for(int i=0;i<N-1;i++){
        if(max_d<A[i+1]-A[i]){
            max_d=A[i+1]-A[i];
        }
    }
    if(max_d<K-A[N-1]+A[0]){
        max_d=K-A[N-1]+A[0];
    }

    cout<<K-max_d<<endl;
    
    return 0;
}

Measured memory_bytes: 4044
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

a,b,c,d=map(int,input().split())
lcm=(c*d)//gcd(c,d)
num1=(b-a+1)
num2=b//c-(a-1)//c
num3=b//d-(a-1)//d
num4=b//lcm-(a-1)//lcm
ans=num1-num2-num3+num4
print(ans)

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s;cin>>s;
  int res=0;
  for(int i=0;i<s.size();i++){
    int len=0;
    for(int j=i;j<s.size();j++){
      if(s[j]=='A'||s[j]=='G'||s[j]=='C'||s[j]=='T')len++;
      else break;
    }
    res=max(len,res);
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

//Hit and Blow
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int[] a = new int[10];
			for(int i=1;i<=4;i++)a[sc.nextInt()]=i;
			int h = 0;
			int b = 0;
			for(int i=1;i<=4;i++){
				int x = sc.nextInt();
				if(i==a[x])h++;
				else if(a[x]>0)b++;
			}
			System.out.println(h+" "+b);
		}
	}
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <list>

using namespace std;

#define MAXN 100000

struct node {
    int odd, rep, par;
} con[MAXN];

list<int> edg[MAXN + 1];
long long cnt[3];

void dfs(int x) {
    list<int> :: iterator it;
    //printf("(%d)\n", x);
    
    if(edg[x].empty()) {
        cnt[2]++;
        return;
    }
    for(it = edg[x].begin(); it != edg[x].end(); it++) if(con[x].par != *it) {
        if(con[*it].par == 0) {
            con[*it].rep = con[x].rep;
            con[*it].odd = (con[x].odd + 1) % 2;
            con[*it].par = x;
            dfs(*it);
        }
        else if(con[*it].odd + con[x].odd != 1) con[con[x].rep].odd = 3;
    }
    
    if(con[x].rep == x) {
        if(con[x].odd == 3) cnt[0]++;
        else cnt[1]++;
    }
    //printf("[%d %d %d %d]\n", x, con[x].odd, con[x].rep, con[x].par);
}

int main() {
    int N, M;
    int u, v;
    int i;
    
    scanf("%d %d", &N, &M);
    for(i = 0; i < M; i++) {
        scanf("%d %d", &u, &v);
        edg[u].push_back(v);
        edg[v].push_back(u);
    }
    
    for(i = 1; i <= N; i++) con[i].rep = i, con[i].odd = 0, con[i].par = 0;
    cnt[0] = cnt[1] = cnt[2] = 0;
    
    for(i = 1; i <= N; i++) if(con[i].rep == i) con[i].par = -1, dfs(i);
    //printf("%lld %lld %lld\n", cnt[0], cnt[1], cnt[2]);
    printf("%lld", cnt[2] * N * 2 - cnt[2] * cnt[2] + (cnt[0] + cnt[1]) * (cnt[0] + cnt[1]) + cnt[1] * cnt[1]);
    
    return 0;
}

Measured memory_bytes: 18304
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/6 11:30:33
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 2e5 + 5;

int n, m;

void run() {
    cin >> n >> m;
    if (n & 1) {
        int st = 1, ed = n;
        for (int i = 1; i <= m; i++) {
            cout << st << ' ' << ed << '\n';
            ++st, --ed;   
        }
    } else {
        int st = 1, ed = n, first = 1;
        for (int i = 1; i <= m; i++) {
            if (first && ed - st - 1 <= (n - 2) / 2) {
                --ed; first = 0;
            }
            cout << st << ' ' << ed << '\n';
            ++st, --ed;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 3700
#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);
        cout << A.at(i);
        if (i != n - 1) {
            cout << " ";
        }
    }
    cout << endl;

    for (int i = 1; i < n; i++) {
        int v = A.at(i);
        int j = i - 1;
        while (j >= 0 && A.at(j) > v) {
            A.at(j + 1) = A.at(j);
            j--;
        }
        A.at(j + 1) = v;

        for (int k = 0; k < n; k++) {
            cout << A.at(k);
            if (k != n - 1) {
                cout << " ";
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

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

	vector< pair<string, string> > s(N);
	rep(i, N) {
		string s1 = S.substr(0, i);
		string s2 = S.substr(i, N);

		s[i] = make_pair(s1, s2);
	}

	int result = 0;
	rep(i, s.size()) {
		string s1 = s[i].first;
		string s2 = s[i].second;

		map<string, int> m1;
		int max = 0;

		rep(j, s1.length()) {
			m1[ s1.substr(j, 1) ] = 1;
		}
		rep(j, s2.length()) {
			string s3 = s2.substr(j, 1);
			if (m1[s3] == 1) max += 1;

			m1[s3] = -1;
		}

		if (max > result) result = max;
		max = 0; 
	}

	cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	static int N;
	static int W;
	static int[] w;
	static int[] v;
	static long [][]dp;
	public static long dp(int i,int ww) {
		if(ww<0)return -(int)1e9;
		if(i==N)return 0;
		if(dp[i][ww]!=-1)return dp[i][ww];
		long take=v[i]+dp(i+1,ww-w[i]);
		long leave=dp(i+1,ww);
		return dp[i][ww]=Math.max(take, leave);
	}
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		N=sc.nextInt();
		W=sc.nextInt();
		w=new int[N];
		v=new int[N];
		for(int i=0;i<N;i++) {
			w[i]=sc.nextInt();
			v[i]=sc.nextInt();
		}
		dp=new long[N+1][W+1];
		for(long []x:dp) {
			Arrays.fill(x,-1);
		}
		
		pw.println(dp(0,W));
		pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
		public int[] nextArr(int n) throws IOException{
			int arr[]=new int[n];
			for(int i=0;i<n;i++)arr[i]=nextInt();
			return arr;
		}

	}
}

Measured memory_bytes: 131016
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }

}

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

}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BSnakeToy solver = new BSnakeToy();
        solver.solve(1, in, out);
        out.close();
    }

    static class BSnakeToy {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints(), k = in.ints();
            int[] l = in.ints(n);
            Arrays.sort(l);
            int ans = 0;
            for (int i = 0; i < k; i++) {
                ans += l[n - i - 1];
            }
            out.println(ans);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

        public int[] ints(int length) {
            return IntStream.range(0, length).map(x -> ints()).toArray();
        }

    }
}



Measured memory_bytes: 26580
import java.util.Scanner;

public class Main {

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

		int[] inputNumbers = new int[4];
		for (int i = 0; i < 4; i++) {
			inputNumbers[i] = Integer.parseInt(sc.nextLine());
		}

		int count = 0;
		for (int i = 0; i <= inputNumbers[0]; i++) {
			for (int j = 0; j <= inputNumbers[1]; j++) {
				for (int k = 0; k <= inputNumbers[2]; k++) {
					if (inputNumbers[3] == 500 * i + 100 * j + 50 * k) {
						count++;
					}
				}
			}
		}
		System.out.println(count);

	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define rep(_,a,b) for(int _=a;_<b;_++)
#define per(_,a,b) for(int _=b-1;_>=a;_--)
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;

int f[140000];
int main(){
    int n;
    scanf("%d",&n);
    for(int x=1;x<=100;x++){
        if(((x+2)*(x+2)+x*x+2)/2>10000) break;
        for(int y=1;y<=100;y++){
            if(((x+y+1)*(x+y+1)+x*x+y*y+1)/2>10000) break;
            for(int z=1;z<=100;z++){
                if(((x+y+z)*(x+y+z)+x*x+y*y+z*z)/2>10000) break;
                f[((x+y+z)*(x+y+z)+x*x+y*y+z*z)/2]++;
            }
        }
    }
    for(int i=1;i<=n;i++){
        printf("%d\n",f[i]);
    }
}


Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  string t;
  cin >> s;
  cin >> t;
  int cnt=0;
  for(int i=0;i<3;i++) {
    if(s.at(i)==t.at(i)) {
      cnt++;}
  }
  cout << cnt <<endl;
  return 0;
}
      
    



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	cout << max(0ll, min(B, D) - max(A, C)) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARounding solver = new ARounding();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARounding {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.nextInt();
            int a = in.nextInt();
            out.println(x >= a ? 10 : 0);
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public void close() {
        }

    }
}



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

int main(){
  string s;
  cin >>s;
  int l = s.size();
  string ans = "AC";
  if(s[0] != 'A') ans = "WA";
  int cnt = 0;
  for(int i = 1; i<l; i++){
    if(isupper(s[i])){
      if(i==1 || i == l-1 || s[i] != 'C'){
        ans = "WA";
      }
      cnt++;
    }
  }
  if(cnt!=1) ans = "WA";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque

def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]

n,k=MI()
a=LI()

def slidmin(a,k):
    n=len(a)
    b=[0 for i in range(n-k+1)]
    q=deque()
    for i in range(k):
        while q and a[q[-1]]>=a[i]:
            q.pop()
        q.append(i)
    b[0]=a[q[0]]
    s=len(q)
    for i in range(k,n):
        while q and a[q[-1]]>=a[i]:
            q.pop()
            s-=1
        q.append(i)
        s+=1
        if q[0]<=i-k:
            q.popleft()
            s-=1
        b[i-k+1]=a[q[0]]
    return b

m=slidmin(a,k)
M=[-i for i in slidmin([-i for i in a],k)]
ans=1
p=-1
c=0
for i in range(k):
    if p<a[i]:
        c+=1
    else:
        c=1
    p=a[i]
fl=True if c==k else False

for i in range(n-k):
    if p<a[i+k]:
        c+=1
    else:
        c=1
    p=a[i+k]
    
    inc=1
    if c==k:
        if fl:
            inc=0
        fl=True
    if a[i]==m[i] and a[i+k]==M[i+1]:
        inc=0
    ans+=inc
print(ans)


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define in2(x, y) int x,y;cin>>x>>y
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)

#define lim5 100002
#define lim9 1000000002

int main(){
	int a, b;
    cin>>a>>b;
    cout<<(b+b>a?0:a-b-b)<<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

int a, b, c;

signed main()
{
    cin >> a >> b >> c;
    if((b - a) == (c - b)) { printf("YES\n"); }
    else { printf("NO\n"); }
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int n, a[200000];
ll ans;

int main()
{
    cin >> n;
    for(int i = 0; i<n; i++)
        cin >> a[i];
    sort(a,a+n);
    for(int i = 0; i<n-1; i++)
        ans+=ll(a[n-(i+1)/2-1]);
    cout << ans << endl;
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
char a[110], b[110], c[110], d[110];
int main()
{
	
	
	scanf("%s%s", a, b);
	int x = strlen(a);
	memset(c, '0', sizeof c);
	memset(d, '0', sizeof d);
	for (int i = 0; i < x; i++) {
		c[100 - x + i] = a[i];
	}
	x = strlen(b);
	for (int i = 0; i < x; i++) {
		d[100 - x + i] = b[i];
	}
	if (!strcmp(c, d)) {
		puts("EQUAL");
	} else if (strcmp(c, d) > 0) {
		puts("GREATER");
	} else {
		puts("LESS");
	}
}

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

c = 0
for i in range(N):
  n = i + 1
  if n % 2 == 0:
    continue
  if len(make_divisors(n)) == 8:
    c += 1

print(c)


Measured memory_bytes: 38384
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int[] a = sc.nextIntArray(5);
        int k = sc.nextInt();
        Arrays.sort(a);
        if(a[4]-a[0] > k){
            System.out.println(":(");
        }else{
            System.out.println("Yay!");
        }
        
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 21204
n,k=map(int, input().split())
s=input()
if s[k-1]=='A':
  print(s[0:k-1]+'a'+s[k::])
elif s[k-1]=='B':
  print(s[0:k-1]+'b'+s[k::])
else:
  print(s[0:k-1]+'c'+s[k::])

Measured memory_bytes: 9092
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;
typedef long long ll;

int main(){
    int n,k;

    cin >> n >> k;

    long double ans = 0;

    int tmp=0;
    long double count=1;

    for(int i=1;i<=n;i++){
        tmp = i;
        count = 1;
        while(tmp < k){
            tmp *= 2;
            count /= 2;
        }
        ans += count / (long double)n;
        
    }

    cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 256
s = input()

x = False
if 'N' in s and 'S' in s:
    x = True
if 'N' not in s and 'S' not in s:
    x = True
y = False
if 'W' in s and 'E' in s:
    y = True
if 'W' not in s and 'E' not in s:
    y = True

if x and y:
    print('Yes')
else:
    print('No') 

Measured memory_bytes: 8984
n=int(input())
a=[int(input()) for i in range(n)]
ans=0
for i in range(n-1):
  ans+=a[i]//2
  a[i]%=2
  if a[i]==1 and a[i+1]>=1:
    ans+=1
    a[i+1]-=1
ans+=a[-1]//2
print(ans)

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

class Cube {
  public:
  int f[6];
  Cube(){}
  void roll_z(){roll(1, 2, 4, 3);}
  void roll_y(){roll(0, 2, 5, 3);}
  void roll_x(){roll(0, 1, 5, 4);}
  void roll(int i, int j, int k, int l){
    int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
  }
  void move(char ch) {
    if (ch == 'E') for (int i = 0; i < 3; i++) roll_y();
    if (ch == 'W') roll_y();
    if (ch == 'N') roll_x();
    if (ch == 'S') for (int i = 0; i < 3; i++) roll_x();
  }
};

int main() {
  Cube c;
  string com;
  
  for (int i = 0; i < 6; i++) cin >> c.f[i];
  cin >> com;
  
  for (int i = 0; i < com.size(); i++) c.move(com[i]);
  cout << c.f[0] << endl;
}



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

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

int main() {
	int a, b;
	while (cin >> a >> b) {
		cout << gcd(a,b) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
<?php

  fscanf(STDIN,"%d %d",$N,$T);
  $routes = array();
  for($i=0;$i<$N;$i++){
    $routes[] = explode(" ",trim(fgets(STDIN)));
  }

  $min = $T+1;
  $filter_route = array();
  foreach($routes as $route){
    if($route[1]<=$T){
      $filter_route[] = $route[0];
    }
  }

  if(count($filter_route)==0){
    echo "TLE\n";
  }else{
    echo min($filter_route)."\n";
  }



Measured memory_bytes: 4856
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
#define INF 114514
using namespace std;




int main(){
	while (1) {
		int dp[99][99] = { 0 };
		int a, b, n, i, j;
		cin >> a >> b;
		if (a == 0 && b == 0) return 0;
		cin >> n;
		for (i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			dp[y][x] = INF;
		}
		dp[1][1] = 1;
		for (i = 1; i <= b; i++) {
			for (j = 1; j <= a; j++) {
				if (i == 1 && j == 1) continue;
				if (dp[i][j] == INF) dp[i][j] = 0;
				else dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
				//cout << dp[i][j] << endl;
			}
		}
		cout << dp[b][a] << endl;
	}
	return 0;
}

Measured memory_bytes: 3000
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int H, N;
	cin >> H >> N;
	int A[10000], B[10000];
	rep(i, N) {
		cin >> A[i] >> B[i];
	}

	int dp[10000] = {};
	rep1(i, H - 1) dp[i] = 2e9;

	int kotae = 2e9;
	rep(i, N) {
		rep(j, H) {
			if (dp[j] < 1e9) {
				int k = j + A[i];
				if (k >= H) chmin(kotae, dp[j] + B[i]);
				else chmin(dp[k], dp[j] + B[i]);
			}
		}
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
void swap(int *a,int *b);
int main(){
	int i,j,data[5];
	for(i=0;i<5;i++) scanf("%d",&data[i]);
	for(i=0;i<4;i++){
		for(j=i+1;j<5;j++) if(data[j]>=data[i]) swap(&data[i],&data[j]);
	}
	//for(i=0;i<5;i++) printf("%d ",data[i]);
	printf("%d %d %d %d %d\n",data[0],data[1],data[2],data[3],data[4]);
	//printf("\n");
	return 0;
}
void swap(int *a,int *b){
	int t;
	t=*a;
	*a=*b;
	*b=t;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int n;
long long int w[200],v[200];
long long int dp[200][100006];
long long int sum=0,W;

long long int knapsack(int i, int v1)
{
    if(v1<=0) return 0;

    if(i==n)
    {
        return INT_MAX;
    }

//    long long int res1=0,res2=0;
//
    if(dp[i][v1]!=-1)
        return dp[i][v1];
//    if(v1-v[i]>=0)
//        res1=w[i]+knapsack(i+1,v1-v[i]);
//    res2=knapsack(i+1,v1);
    //cout<<i<<" "<<res1<<" "<<res2<<" ";
    //cout<<min(res1,res2)<<endl;
    return dp[i][v1]=min(w[i]+knapsack(i+1,v1-v[i]),knapsack(i+1,v1));



}

int main()
{

   memset(dp,-1,sizeof dp);
    cin>>n>>W;
    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
        sum+=v[i];
    }
   // cout<<knapsack(0,0)<<endl;
    for(int i=sum;i>=0;i--)
    {

        long long int k1=knapsack(0,i);
       // cout<<k1<<endl;
        if(k1<=W )
        {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 159872
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n,m;
	cin>>n>>m;
	vi arr(n,0);
	while(m-->0) {
		int a,b;
		cin>>a>>b;
		if((a==1&&b==0&&n!=1)||(arr[a-1]!=0&&arr[a-1]!=b)||a>n) {
			cout<<-1;
			return;
		}
		arr[a-1]=b;
	}
	if(arr[0]==0&&n>1)arr[0]=1;
	for(int i=0;i<n;i++)cout<<arr[i];
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size()+1;i+=2)
    {
        if(s[i]=='L' || s[i+1]=='R')
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
arrs = M.times.map { gets.split.map(&:to_i) }
ways = N.times.map { |i| [i + 1, []] }.to_h
arrs.each do |from, to|
  ways[from] << to
  ways[to] << from
end

counter = 0
queue = [[1, [1]]]
until queue.empty?
  now_p, history = queue.shift
  if history.count == N
    counter += 1
    next
  end

  next_points = ways[now_p] - history
  next_points.each do |next_p|
    queue.push([next_p, history + [next_p]])
  end
end
p counter

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

int main(){
  int N;cin >> N;
  if(N == 25)cout << "Christmas" <<endl;
  if(N == 24)cout << "Christmas Eve" <<endl;
  if(N == 23)cout << "Christmas Eve Eve" <<endl;
  if(N == 22)cout << "Christmas Eve Eve Eve" <<endl;
}


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second

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

const ll MOD = 1e9+7;

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

	int a, b; cin >> a >> b;
	if(a > b) swap(a, b);
	if(a == 1 && b == 2)
		cout << "3\n";
	else if(a == 2 && b == 3)
		cout << "1\n";
	else if(a == 1 && b == 3)
		cout << "2\n";

 	return 0;
}

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

int main(void)
{
	char s[10];
	char t[10];
	char u[10];
	int n_s;
	int n_t;
	
	scanf("%s%s%d%d%s",s,t,&n_s,&n_t,u);
	
	if(strcmp(s,u)==0)
		printf("%d %d",n_s-1,n_t);
	else
		printf("%d %d",n_s,n_t-1);
	
	return 0;
}

Measured memory_bytes: 128
s = input()
t = input()
dt = {}
ds = {}
for i in range(len(s)):
    if t[i] in dt:
        if dt[t[i]] != s[i]:
            print("No")
            exit()
    else:
        dt[t[i]] = s[i]
    if s[i] in ds:
        if ds[s[i]] != t[i]:
            print("No")
            exit()
    else:
        ds[s[i]] = t[i]
print("Yes")

Measured memory_bytes: 3632
import os, sys, re, math

N,M = list(map(int,input().split(' ')))

dic = {}

for _ in range(N):
    tmp = list(map(int,input().split(' ')))
    for i in range(1,len(tmp)):
        if tmp[i] in dic:
            dic[tmp[i]] += 1
        else:
            dic[tmp[i]] = 1

ret = 0
for v in dic.values():
    if v == N:
        ret += 1
print(ret) 


Measured memory_bytes: 3188
from statistics import median
import math
n = int(input())
a = list(map(int,input().split()))
for i in range(0,n):
    a[i] = a[i]-(i+1)
b1 = round(median(a)) 
a1 = []
a2 = []
for i in range(0,n):
    a1.append(abs(a[i]-b1))
print(sum(a1))

Measured memory_bytes: 27248
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('tourist.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${TY%Wi`(5WFMt58Fc(Xq*VD9x7D&BPj>l7_bTkIj*Ai>${5yulNExGoBr<UD>{aRttH)I;%|$Qg=gd9dxR@Di;P73FNP9dUGDQ<!!6lSu|K~YBh-_ms0mLUn?gYZW#)-aa9<|QdNMzm)C?=0Ye!0PSL>Nlrr!HyueleslJL(9LLK>v^G%;rmuCIg#qB2DZxNO4vB|vjcygBlZci;a!M4%3#=<-KH%*=17Q{aUKnzd7$r^Mh?)~>JZY8tu?FNSSF3obEX4)B&4>QOg%{W&$?iM3r$#)#@1-i<G$3Tv!!YO=a7HK93>>2bH|?5DKSQZ$O1|v2Wz}2I=r-M5)Wxd_@vZhgv>n8k$Q*}~?$i?{b`*|*!&44o)o(qXPyC2tN78cW$sb`#As%5$;I{B+f6Pb!JtGS5K99vu#l*|yora61crqIw#8`%bf6>w5x%@H*ya+t$KlVq{`2")))
    os.system('cythonize -i -3 -b tourist.pyx')
import tourist

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

#define int long long

int n;
string num;
int k;

int dp[202][2][10];

signed main() {
    ios::sync_with_stdio(false);
    cin >> num >> k;
    n = num.length();

    memset(dp, 0, sizeof dp);
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int op = 0; op < 2; op++) {
            for (int j = 0; j <= 3; j++) {
                if (dp[i - 1][op][j] == -1) continue;
                for (int add = 0; add <= 9; add++) {
                    if (op == 0) {
                        if (add < num[i - 1] - '0') {
                            dp[i][1][j + (add > 0)] += dp[i - 1][op][j];
                        } else if (add == num[i - 1] - '0') {
                            dp[i][0][j + (add > 0)] += dp[i - 1][op][j];
                        }
                    } else {
                        dp[i][1][j + (add > 0)] += dp[i - 1][op][j];
                    }
                }
            }
        }
    }
    cout << dp[n][1][k] + dp[n][0][k] << endl;
    return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    rep(i, 0, n){
        cin >> a[i];
        sum ^= a[i];
    }
    rep(i, 0, n) {
        cout << (sum ^ a[i]) << endl;
    }
    return 0;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
//const int mod = 1e9 + 7;
const int mod = 998244353;
const double eps = 1e-9;

/*{
  }*/

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

  if(n%2 == 0){
    bool ok = true;
    rep(i, 0, n/2){
      if(s[i] != s[i+n/2]) ok = false;
    }

    if(ok){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  string S; cin>>S;
  int N=S.size();
  vi A(3);
  rep(i,0,N) A[S[i]-'a']++;
  sort(ALL(A));
  string ans="NO";
  if(A[2]-A[0]<=1) ans="YES";
  cout<<ans<<endl;
  }



Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, M, V, P, A[101010];

bool check(int X)
{
	int hoge = N - P;
	if (X < hoge) ++hoge;

	i64 ss = 0;
	for (int i = 0; i < hoge; ++i) {
		if (A[i] > A[X]) {
			int dd = A[i] - A[X];
			if (dd > M) return false;
			ss += dd;
		}
	}
	if (ss > (i64)M * (N - V)) return false;
	return true;
}

int main()
{
	scanf("%d%d%d%d", &N, &M, &V, &P);
	for (int i = 0; i < N; ++i) scanf("%d", A + i);
	sort(A, A + N);

	int left = 0, right = N - 1;
	while (left < right) {
		int mid = (left + right) / 2;
		if (check(mid)) {
			right = mid;
		} else {
			left = mid + 1;
		}
	}
	printf("%d\n", N - right);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }


template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}


// 最大公約数を求める(ユークリッドの互除法).
inline ll gcd (ll x, ll y) {
  if (y > x) swap(x,y);
  if (y == 0) return x;
  return gcd(x%y,y);
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), r(n), l(n);
  rep(i,n) {
    scanf("%lld", &a[i]);
  }
  
  l[0] = a[0], r[n - 1] = a[n - 1];
  
  for (int i = 1; i < n; ++i) {
    l[i] = gcd(a[i], l[i - 1]); 
  }

  for (int i = n - 2; i >= 0; --i) {
    r[i] = gcd(a[i], r[i + 1]);
  }

  ll mmax = 1, tmp;
  for (int i = 0; i < n; ++i) {
    tmp = 0;
    if (i == 0) tmp = r[i + 1];
    else if (i == n - 1) tmp = l[i - 1];
    else {
      tmp = gcd(l[i - 1], r[i + 1]);
    }
    // debug(tmp);
    chmax(mmax, tmp);
  }

  cout << mmax << endl;
}


Measured memory_bytes: 2560
N = int(input())
 
div = []
#約数の列挙
#(Nには√Nより小さい√N個の約数を持つ→これらをforで回すことで全約数を出せる)
for n in range(1, int(N ** 0.5) + 1):
    if N % n == 0:
        div.append(n)
        div.append(N // n)
        
ans = 0
# print(div)

for d in div:
    if d - 1 <= 0:
        continue
    if N // (d - 1) != (N % (d - 1)):
        continue
        
 #     if (d - 1) ** 2 <= N:
#         continue
    ans += (d - 1)
    
print(ans)

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


int main() {
    int H, W, K;
    cin >> H >> W >> K;
    char c[H][W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> c[i][j];
        }
    }

    int ans = 0;
    for(int bit_row = 0; bit_row < (1 << H); bit_row++){
        for(int bit_col = 0; bit_col < (1 << W); bit_col++){
            int b = 0;
            for(int row = 0; row < H; row++){
                for(int col = 0; col < W; col++){
                    if(((bit_row >> row) & 1) == 0 && ((bit_col >> col) & 1) == 0 && c[row][col] == '#'){
                        b++;
                    }
                }
            }
            if(b == K)
                ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
#include <set>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

ll llmin(ll x, ll y){
	if (x > y) return y;
	return x;
}


int main(){
	int n, m, x;
	cin >> n >> m >> x;
	int price[12];
	int power[12][12];

	for (int i = 0; i < n; i++){
		cin >> price[i];
		for (int j = 0; j < m; j++){
			cin >> power[i][j];
		}
	}
	int ans = MOD;

	for (int i = 0; i < (1<<n); i++){
		bool read[12];
		for (int j = 0; j < n; j++){
			if (i & (1<<j)){
				read[j] = true;
			}else{
				read[j] = false;
			}
		}
		int money = 0;
		int pram[12];
		for (int j = 0; j < 12; j++) pram[j] = 0;
		for (int j = 0; j < n; j++){
			if (read[j]){
				money += price[j];
				for (int k = 0; k < m; k++){
					pram[k] += power[j][k];
				}
			}
		}
		bool flg = true;
		for (int j = 0; j < m; j++){
			if (pram[j] < x){
				flg = false;
			}
		}
		if (flg){
			ans = min(money, ans);
		}
	}
	if (ans == MOD) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long a = 0;a < b;++a)
#define ALL(x) (x).begin(),(x).end()
void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
void solve() {
    long long a, b;
    cin >> a >> b;
    cout << a * b / gcd(a, b) << endl;
}

int main() {
    init();
    solve();
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int x = max({a, b, c});
  if ((3 * x) % 2 - (a + b + c) % 2 == 0) {
    cout << (3 * x - (a + b + c)) / 2 << endl;
  } else {
    cout << (3 * (x + 1) - (a + b + c)) / 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define M 100010

int main(){
	IOS;
	tihs;

	ll n;cin>>n;
	ll a[n];
	map<ll,ll>mp;
	rep(i,0,n){cin>>a[i];mp[a[i]]++;}
	bool ok=1;
	for(auto i:mp)if(i.se>1)ok=0;
	if(ok)cout<<"YES";
	else cout<<"NO";




	return 0;
}

Measured memory_bytes: 14336