akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int def(char X[],char Y[]);
int main()
{
    char A[10000],B[10000];
    scanf("%s %s",A,B);
    int m,n,ans=0;
    m=strlen(A);
    n=strlen(B);
    if(m!=n)
    {
        printf("No\n");
        return 0;
    }
    ans=def(A,B);
    if(ans==1)
    {
        printf("Yes\n");
        return 0;
    }
    if(ans==-1)
    {
        printf("No\n");
        return 0;
    }
    return 0;
}

int def(char X[],char Y[])
{
    int M,i=0,j=0,put=0,K=0;
    char C[100];
    M=strlen(X);

    while(K<M)
    {
j=0;

    for(i=0;i<M;i++)
    {
        if(X[i]==Y[i])
        {
            j++;
        }
    }
    if(j==M)
    {
        put=1;
        return put;
    }

    if(put==1)
    break;
C[0]=X[M-1];
    for(i=M-1;i>0;i--)
    {

        X[i]=X[i-1];
    }
    X[0]=C[0];


    if(put==0 && K==M-1)
    {
        put=-1;
        return put;
    }
    K++;
    }


}


Measured memory_bytes: 256
import java.util.Scanner;

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

        String x = sc.next();
        char[] cary = x.toCharArray();

        for(char i = 'a';i <= 'z' ;i++){
            if(!charAryHasChar(cary,i)){
                System.out.print(i);
                return;
            }
        }
        System.out.print("None");

    }

    private static boolean charAryHasChar(char[] charary,char needle){
        boolean result = false;
        int l = charary.length;

        for(int j = 0;j<l;j++ ){
            if(needle == charary[j]){
                result= true;
                break;
            }
        }
        return  result;
    }
}

Measured memory_bytes: 26564
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a <= 9 && b <= 9)
            System.out.println(a*b);
        else
            System.out.println(-1);
        sc.close();
    }
}


Measured memory_bytes: 22740
#include <vector>
#include <iostream>
#include <map>
#include <algorithm>
#include <random>
#include <complex>
#include <unordered_map>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <bitset>

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

ll gcd(ll a, ll b) {
    if (!a) return b;
    return gcd(b%a, a);
}
ll ext_gcd(ll a, ll b, ll &x, ll &y) {
    ll d = a;
    if (b) {
        d = ext_gcd(b, a%b, y, x);
        y -= a / b*x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

int w, d, n, m, t, u, h;
int x, tu, th;
void init() {
    m = t-m%t;
    u = gcd(t, w+d), h = gcd(t, m);
    tu = t/u; th = t/h;
    ll xx, y;
    ext_gcd(m, t, xx, y);
    x = ((xx % th) + th) % th;
}
int solve() {
    init();
    int res = 0;
    int l = 0;

    int s = 0;
    int wud = w/u, wum = w%u;
    int hud = h/u, hum = h%u;
    int iud = 0, ium = 0;
    for (int i = 0; i < th; i++) {
        if (s<n) {
            int k = iud - wud;
            if (ium < wum) k--;
            res += max(0, k);
            //l = iud;
            iud = 0;
        }
        s += x;
        if (s >= th) s -= th;
        iud += hud;
        ium += hum;
        if (ium >= u) {
            iud++;
            ium -= u;
        }
    }
    int k = iud - wud;
    if (ium < wum) k--;
    res += max(0, k);
    return res;
}

int main() {
    cin >> w >> d >> n >> m >> t; w++; d--;
    printf("%.20f\n", 1.0 * solve() / tu);
    return 0;
}

Measured memory_bytes: 1176
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;


int main()
{

    int n,m;
    scanf("%d %d",&n,&m);
    int flag=0;
    int a=1,b=1+m;
    while(b-a>=1&&flag<m)
    {
        printf("%d %d\n",a,b);
        a=a+1;
        b=b-1;
        flag=flag+1;
    }

    a=2+m;
    b=a+m-1;
    while(flag<m)
    {
        printf("%d %d\n",a,b);
        a=a+1;
        b=b-1;
        flag=flag+1;
    }
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
const int N=105;
const int L=10000005;
int n;
int a[L],b[L];
int totc,c[N<<1];
bool isprime(int x)
{
	if(x==1) return 0;//
	int m=int(sqrt(x));
	for(int i=2;i<=m;i++)
		if(x%i==0) return 0;
	return 1;
}
int val1[N<<1],cnt1,val2[N<<1],cnt2;
int sum,h[N<<1];
struct Edge{int v,nxt;}e[2*N*2*N];
void adde(int x,int y){sum++;e[sum].v=y;e[sum].nxt=h[x];h[x]=sum;}
bool v[N<<2];
int match[N<<2];
bool dfs(int x)
{
	for(int i=h[x];i;i=e[i].nxt)
	{
		int y=e[i].v;
		if(v[y]) continue;
		v[y]=1;
		if(!match[y]||dfs(match[y]))
		{
			match[y]=x;
			return 1;
		}
	}
	return 0;
}
int main()
{
	scanf("%d",&n);
	int mx=0;
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		a[x]=1;
		mx=max(mx,x);
	}
	if(a[1]==1) b[1]=1,c[++totc]=1;
	for(int i=2;i<=mx+1;i++)//for(int i=2;i<=mx;i++)
	{
		b[i]=a[i-1]^a[i];
		if(b[i]) c[++totc]=i;
	}
	//for(int i=1;i<=totc;i++) printf("%d ",c[i]);printf("\n");
	for(int i=1;i<=totc;i++)
	{
		if(c[i]&1) val1[++cnt1]=c[i];//if(c[i]&1) val1[++cnt1]=i;
		else val2[++cnt2]=c[i];//else val2[++cnt2]=i;
	}
	//for(int i=1;i<=cnt1;i++) printf("%d ",val1[i]);printf("\n");
	//for(int i=1;i<=cnt2;i++) printf("%d ",val2[i]);printf("\n");
	for(int i=1;i<=cnt1;i++)
		for(int j=1;j<=cnt2;j++)
			if(isprime(abs(val2[j]-val1[i])))//if(isprime(val2[j]-val1[i]))
				adde(i,200+j);
	int matched=0;
	for(int i=1;i<=cnt1;i++)
	{
		memset(v,0,sizeof(v));
		if(dfs(i)) matched++;
	}
	//printf("%d %d %d\n",cnt1,cnt2,matched);
	int ans=matched;
	ans+=(cnt1-matched)/2*2;
	//ans+=((cnt1-matched)&1)*3;
	ans+=(cnt2-matched)/2*2;
	//ans+=((cnt2-matched)&1)*3;
	if(((cnt1-matched)&1)&&((cnt2-matched)&1)) ans+=3;
	else if(((cnt1-matched)&1)||((cnt2-matched)&1)) ans+=3;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 77696
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

vector<int> P,S;

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

    for(int i = 0;i < N;i++) {
        int a;
        cin>>a;
        P.push_back(a);
        S.push_back(a);
    }

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

    int ans = 0;
    for(int i = 0;i < N;i++) {
        if(S[i] != P[i])
            ans++;
    }

    if(ans == 2 || ans == 0) {
        cout<<"YES"<<endl;
    } else {
        cout<<"NO"<<endl;
    }

    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = null;
    int totalCases, testNum;

    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    void solve() throws IOException {

    }

    void execute() throws IOException {
        int k = ni();
        String s = ns();
        if (s.length() <= k) {
            out.println(s);
        } else {
            out.println(s.substring(0, k) + "...");
        }

        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().execute();
    }

    void debug(Object... os) {
        System.out.println(Arrays.deepToString(os));
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

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

    String nline() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    boolean input() throws IOException {
        return true;
    }

}


Measured memory_bytes: 25408
//{{{
#include <bits/stdc++.h>
using namespace std;
//types
typedef long long ll;
typedef pair<int,int> pii;
//input
bool SR(int &_x){return scanf("%d",&_x)==1;}bool SR(ll &_x){return scanf("%lld",&_x)==1;}
bool SR(double &_x){return scanf("%lf",&_x)==1;}bool SR(char *_s){return scanf("%s",_s)==1;}
bool RI(){return true;}
template<typename I,typename... T>bool RI(I &_x,T&... _tail){return SR(_x) && RI(_tail...);}
//output
void SP(const int _x){printf("%d",_x);}void SP(const ll _x){printf("%lld",_x);}
void SP(const double _x){printf("%.16lf",_x);}void SP(const char *s){printf("%s",s);}
void PL(){puts("");}
template<typename I,typename... T>void PL(const I _x,const T... _tail)
{SP(_x);if(sizeof...(_tail)) putchar(' ');PL(_tail...);}
//macro
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define PER1(i,a,b) for(int i=(a);i>=int(b);i--)
#define pb push_back
#define mkp make_pair
#define F first
#define S second
//debug
#ifdef darry140
template<typename A,typename B>
ostream& operator <<(ostream&_s, const pair<A,B> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It>
ostream& _OUTC(ostream &_s,It _b,It _e)//container
{
    _s<<"{";
    for(auto _it=_b;_it!=_e;_it++) _s<<(_it==_b?"":" ")<<*_it;
    _s<<"}";
    return _s;
}
template<typename A,typename B>
ostream& operator <<(ostream&_s, const map<A,B> &_c){return _OUTC(_s,ALL(_c));}
template<typename T>
ostream& operator <<(ostream&_s, const set<T> &_c){return _OUTC(_s,ALL(_c));}
template<typename T>
ostream& operator <<(ostream&_s, const vector<T> &_c){return _OUTC(_s,ALL(_c));}
template<typename I>
void _DOING(const char *_s,I&& _x){cerr<<_s<<"="<<_x<<endl;}//without ','
template<typename I,typename... T>
void _DOING(const char *_s,I&& _x,T&&... _tail)//with ','
{
    int _c=0;
    static const char _bra[]="({[";
    static const char _ket[]=")}]";
    while(*_s!=',' || _c!=0)//eg. mkp(a,b)
    {
        if(strchr(_bra,*_s)) _c++;
        if(strchr(_ket,*_s)) _c--;
        cerr<<*_s++;
    }
    cerr<<"="<<_x<<", ";
    _DOING(_s+1,_tail...);
}
#define debug(...) do{\
    fprintf(stderr,"%s:%d - ",__PRETTY_FUNCTION__,__LINE__);\
    _DOING(#__VA_ARGS__,__VA_ARGS__);\
}while(0)
#else
#define debug(...)
#endif
//}}}

int main()
{
    ll x;RI(x);
    ll n=1;
    while(n*(n+1)/2<x) n++;
    PL(n);
    return 0;
}




































/*End Of File*/




Measured memory_bytes: 256
ary = Array.new(4){Array.new(3){Array.new(10,0)}}

n = gets.chomp.to_i
while line = gets
b,f,r,v = line.split.map(&:to_i)
ary[b-1][f-1][r-1] += v
end

for i in 0..3
  for j in 0..2
    puts " " + ary[i][j].join(" ")
  end
  puts "#" * 20 if i < 3
end


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}


class Solution {
public:
	void solve() {
		int n, k;
		cin >> n >> k;
		vector<int> a(n, 0);
		map<int, int> cnt;
		for(int i=0; i<n; i++)cin >> a[i];
		for(int i=0; i < n; i++)a[i] = (a[i] - 1 + k) % k;
		long long ret = 0;
		int s = 0;
		int s2 = 0;
		for(int i=0; i < n; i++){
			s = (s + k - a[i]) % k;
			cnt[(s + a[i]) % k]++;
			if(i >= k-1){
				s2 = (s2 + k - a[i-k+1]) % k;
				cnt[(s2 + a[i-k+1]) % k]--;
			}
			ret += cnt[s];
		}
		cout << ret << "\n";
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1e9;

int main() {
  int N;
  cin >> N;
  if (N < 3) cout << 0 << endl;
  else if (N % 3 == 0) cout << N / 3 << endl;
  else cout << (N - (N % 3)) / 3 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,d;
    cin >> n >> d;
    set<int> se;
    rep(i,200) se.insert(i*i);
    vvi x(n,vi(d));
    rep(i,n) cin >> x[i];
    int ans = 0;
    rep(i,n) rep(j,n) {
        if(i >= j) continue;
        int now = 0;
        rep(k,d) {
            now += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        if(se.count(now)) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 3005;
const int   mod = 1e9 + 7;

void add(int &a,int b)  {
    a += b;
    if (a >= mod)
        a -= mod;
}
void sub(int &a,int b)  {
    a -= b;
    if (a <  0)
        a += mod;
}
int mul(int a,int b)    {
    return  1ll * a * b % mod;
}
int Pow(int a,int b)    {
    int ans = 1;
    while (b)   {
        if(b & 1)   ans = mul(ans,a);
        a = mul(a,a);   b >>= 1;
    }
    return  ans;
}
int inv(int a,int p)    {
    return  a == 1 ? 1 : p - 1ll * p * inv(p % a,a) / a;
}

typedef pair<int,int>   ii;

int f[N][N];

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

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

    vector<int> a(n);

    for(int&x : a)
        cin >> x;

    for(int i = 0 ; i < n ; ++i)
    for(int j = 0 ; j < n ; ++j)
        f[i][j] = (a[i] > a[j]);

    for(int i = 0 ; i < q ; ++i)    {
        int x;  cin >> x;   --x;
        int y;  cin >> y;   --y;

        for(int j = 0 ; j < n ; ++j)    if (x != j && y != j)   {
            int S = 0;
            add(S,f[j][x]);
            add(S,f[j][y]);

            f[j][x] = f[j][y] = mul(S,500000004);   S = 0;

            add(S,f[x][j]);
            add(S,f[y][j]);

            f[x][j] = f[y][j] = mul(S,500000004);
        }
        add(f[x][y],f[y][x]);

        f[x][y] = mul(f[x][y],500000004);
        f[y][x] = f[x][y];
    }
    int ans = 0;

    for(int i = 0 ; i < n ; ++i)
    for(int j = i ; j < n ; ++j)
        add(ans,f[i][j]);

    cout << mul(ans,Pow(2,q)) << endl;
}


Measured memory_bytes: 35456
//22
#include<iostream>
#include<algorithm>

using namespace std;

void mrp(int &a,int b){
  if(a<b){
    a=b;
  }
}

int main(){
  for(int c,d,w,x;cin>>c>>d>>w>>x,c|d|w|x;){
    int e[15][30];
    for(int i=0;i<c;i++){
      for(int j=0;j<d;j++){
	cin>>e[i][j];
      }
    }
    int f[15][30];
    for(int i=0;i<c;i++){
      for(int j=0;j<d;j++){
	cin>>f[i][j];
      }
    }
    int dp[31][6][51]={};
    for(int i=0;i<d;i++){
      copy(dp[i][0],dp[i+1][0],dp[i+1][0]);
      for(int j=0;j<=x;j++){
	for(int k=0;k<=w;k++){
	  for(int l=0;l<c;l++){
	    int cf=k+f[l][i];
	    if(e[l][i]==0||cf>w)continue;
	    int ce=dp[i][j][k]+e[l][i];
	    mrp(dp[i+1][j][cf],ce);
	    if(j==x)continue;
	    for(int d=-1;d<=1;d+=2){
	      int df=cf;
	      int de=ce;
	      for(int ll=l+d;0<=ll&&ll<c;ll+=d){
		int nf=df+f[ll][i];
		if(e[ll][i]==0||nf>w)break;
		int ne=de+e[ll][i];
		mrp(dp[i+1][j+1][nf],ne);
		de=ne;
		df=nf;
	      }
	    }
	  }
	}
      }
    }
    cout<<*max_element(dp[0][0],dp[31][0])<<endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);  cout.tie(0);
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    long long ans=0;
    int l=0;
    long long xr=0,ttl=0;
    for(int r=0;r<n;r++){
        ttl+=v[r];
        xr^=v[r];
        while(xr!=ttl){
            ttl-=v[l];
            xr^=v[l];
            l++;
        }
        ans+=(long long)(r-l+1);
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3924
#define DEBUG(...)
/*                        Strip me down and go to town                        */
/*                          Lick me over upside down                          */
/*                     Pound and pound and pound and pound                    */
/*                        Baby make me make that sound                        */
/*                Aaah, aaah, aaah, aaah, aaaaaaaaaaaaaaaaaah!                */
#include<stdio.h>

long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  if (b == 0) return a;
  long long int rem = 1;
  while (rem) {
    rem = a % b;
    a = b;
    b = rem;
  }
  return a;
}

bool isprime[1000005];
int sieve(long long int n) {
  int ans = 1;
  for (int i = 2; i < 1000005 && i <= n; i++) {
    if (isprime[i] == 0) {
      if (n % i == 0) {
        ans++;
        while (n % i == 0) {
          n /= i;
        }
      }
      for (int j = 0; j < 1000005; j += i) {
        isprime[j] = 0;
      }
    }
  }
  if (n > 1) {
    ans++;
  }
  return ans;
}

int main() {
  long long int A, B;
  scanf("%lld %lld", &A, &B);
  printf("%d\n", sieve(gcd(A, B)));
  return 0;
}

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

using namespace std;
using ll = long long;

int main()
{
	ll a, b, n;
	cin >> n >> a >> b;
	ll ans = abs(a-b);
	if(ans%2==0){
		cout << ans/2 <<"\n";
	}
	else{
		ans = min(a-1, n-b)+1+(abs(a-b)-1)/2;
		cout << ans <<"\n";
	}			
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = [int(c) for c in input().split()]
Ap = []
An = []
Az = []
for i in range(N):
  if A[i]>0:
    Ap += [A[i]]
  elif A[i]<0:
    An += [A[i]]
  else:
    Az += [A[i]]
lp = len(Ap)
ln = len(An)
lz = len(Az)
Ap.sort(reverse=True)
An.sort(reverse=True)
def f(m, B, C):
  cnt = 0
  j  = 0
  lb = len(B)
  lc = len(C)
  for i in range(lc):
    while j<lb:
      if B[j]*C[i]>=m:
        cnt += j
        break
      j += 1
    else:
      cnt += j
  return cnt
if K<=lp*ln:
  r = 1
  l = -10**18+10
  while l+1<r:
    n = (l+r)//2
    if f(n,Ap,An)>=K:
      r = n
    else:
      l = n
  print(l)
  import sys
  sys.exit()
K -= lp*ln
if K<=lz*(lp+ln) + lz*(lz-1)//2:
  print(0)
  import sys
  sys.exit()
K -= lz*(lp+ln) + lz*(lz-1)//2
r = 10**18+10
l = -1
while l+1<r:
  n = (l+r)//2
  P = f(n,Ap[::-1],Ap)
  for i in range(lp):
    if Ap[lp-1-i]*Ap[lp-1-i]<n:
      P -= 1
    else:
      break
  P //= 2
  N = f(n,An,An[::-1])
  for i in range(ln):
    if An[i]*An[i]<n:
      N -= 1
    else:
      break
  N //= 2
  if P+N>=K:
    r = n
  else:
    l = n
print(l)

Measured memory_bytes: 120916
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF  int(1e6+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<long long int>a(n);
	rep(i, 0, n)cin >> a[i];
	rep(i, 0, n - k) {
		if (a[k + i] - a[i] > 0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}



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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
ll a[200005];
void solve() {
    cin >> n;
    rep(i, n) cin >> a[i];

    bool ok = a[0] == 0;
    ll ans = 0;
    rep(i, n - 1) {
        if (a[i + 1] - a[i] > 1) { ok = false; break; }
        if (a[i + 1] - a[i] == 1) ++ans;
        else ans += a[i + 1];
    }

    if (ok) cout << ans << endn;
    else cout << -1 << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 1920
n, m = map(int, input().split())
cakes = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for bit in range(1 << 3):
    b = []
    for i in range(n):
        tmp = 0
        for j in range(3):
            if bit & (1 << j):
                tmp += cakes[i][j]
            else:
                tmp -= cakes[i][j]
        b.append(tmp)
    b.sort(reverse=True)
    ans = max(ans, sum(b[:m]))
print(ans)

Measured memory_bytes: 3316
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int e[101][101];
    int R, C, r, c;
    int s, total;
 
    scanf("%d%d", &R, &C);
    for (r = 1; r <= R; r++) {
        for (c= 1; c <= C; c++) scanf("%d", &e[r][c]);
    }
     
    for (r = 1; r <= R; r++) {
        s = 0;
        for (c = 1; c <= C; c++) s += e[r][c];
        e[r][0] = s;
    }
    total = 0;
    for (c = 1; c <= C; c++) {
        s = 0;
        for (r = 1; r <= R; r++) s += e[r][c];
        e[0][c] = s;
        total += s;
    }
    for (r = 1; r <= R; r++) {
        for (c = 1; c <= C; c++) printf("%d ", e[r][c]);
        printf("%d\n", e[r][0]);
    }
    for (c = 1; c <= C; c++) printf("%d ", e[0][c]);
    printf("%d\n", total);
    return 0;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
#include <math.h>

typedef long long ll;
typedef unsigned long long ull;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    std::string N;
    std::cin >> N;
    ll num = 0;

    for(int i = 0; i < N.length(); ++i)
        num += ((int)N[i] - 48);
    
    if(num % 9 == 0)
    {
        print("Yes");
    }

    else
    {
        print("No");
    }

    return 0;
}

Measured memory_bytes: 3748
S = input()
S = S[::-1]
mod = 10 ** 9 + 7
N = len(S)
table = [[0] * 13 for _ in range(N + 1)]
table[0][0] = 1

dd = 1

for i in range(N):
    if S[i] == '?':
        for j in range(13):
            for k in range(10):
                table[i+1][(j + dd * k)  % 13] += table[i][j]
                table[i+1][(j + dd * k)  % 13] %= mod
    else:
        num = int(S[i])
        for j in range(13):
            table[i+1][(j + dd * num)  % 13] += table[i][j]
            table[i+1][(j + dd * num)  % 13] %= mod

    dd = (dd * 10) % 13

print(table[N][5])


Measured memory_bytes: 61916
N = int(input())
S = input()
R = []
G = []
B = []
for i in range(N):
    if S[i] == 'R':
        R.append(i)
    elif S[i] == 'G':
        G.append(i)
    else:
        B.append(i)
#print(R, G, B, sep='\n')
Bs = set(B)
ans = 0
for r in R:
    for g in G:
        l, g = min(r, g), max(r, g)
        ans += len(B)
        ans -= (2*g - l) in Bs
        ans -= (2*l - g) in Bs
        ans -= (g + l) % 2 == 0 and (g + l)//2 in Bs
print(ans)


Measured memory_bytes: 68892
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define nav(...) "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
#define oo INT_MAX/2
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
	~debug() {cerr<<endl;}
	template<class T> debug& operator<<(T x) {cerr<<boolalpha<<x; return *this;}
	template<class B, class C> debug& operator<< (pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
	template<class T> debug& operator<<(rge<T> x) {
		*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
	template<class T> debug& operator<<(vector<T> x){ return *this<<range(all(x));}
#else
	template<class T> debug& operator <<(const T&) {return *this;}
#endif
};


bool solve(void) {

	int n;
	cin>>n;
	vector<int> arr(n);
	for(int& x : arr) cin>>x;
	cout << (set<int>(arr.begin(), arr.end()).size() == arr.size() ? "YES" : "NO") << endl;
	return true;
}

int main(int argc, char* argv[]) {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}


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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        int n;
        cin >> n;
        for( int i = 1; i <= 100000; i++ ) {
                if( int(i * 1.08) == n ) return cout << i << endl,0;
        }
        cout << ":(" << endl;
        return 0;
}










Measured memory_bytes: 256
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

k,x = inp
((x-k+1)..(x+k-1)).each do |i|
  p i
end

Measured memory_bytes: 1788
from sys import stdin

s = [x for x in stdin.readline().rstrip()]

ans = "Yes"

for i in range(len(s)):
    if ((i + 1) % 2 == 0) and (s[i] == "R"):
        ans = "No"
        break
    elif ((i + 1) % 2 != 0) and (s[i] == "L"):
        ans = "No"
        break
print(ans)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;
int maxv=0;
struct node{
    int a,b,c,d;
};
node tmp[100];
int arr[20];
int n,m,q;
void dfs(int u,int last){
    if(u==n+1){
        int sum=0;
        for(int i=1;i<=q;i++){
            if(arr[tmp[i].b]-arr[tmp[i].a]==tmp[i].c){
                sum+=tmp[i].d;
            }
        }
        maxv=max(maxv,sum);
        return ;
    }
    for(int i=last;i<=m;i++){
        arr[u]=i;
        dfs(u+1,i);
    }
}
int main()
{
    cin>>n>>m>>q;
    for(int i=1;i<=q;i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        tmp[i]={a,b,c,d};
    }
    dfs(1,1);
    cout<<maxv<<endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<cinttypes>

using ui64 = std::uint64_t;
using ui = std::uint32_t;

int main(){

	ui n, a, b, c, d;
	std::string s;
	std::cin >> n >> a >> b >> c >> d;
	std::cin >> s;

	--a; --b; --c; --d;

	std::string ans;

	auto check = [&s]( auto first, auto last )
	{
		bool enable_pass = true;
		for( ui i{ first }; i < last; ++i )
			if( s[i] == '#' && s[i + 1] == '#' )
			{
				enable_pass = false;
				break;
			}
		return enable_pass;

	};

	if( c < d )
	{
		bool enable_pass;

		if( c < b )
			enable_pass  = check( a, c ) && check( b, d );
		else
			enable_pass = check( a, d );
		
		ans = enable_pass ? "Yes" : "No";

	}
	else
	{

		bool swappable = false;
		for( ui i{ b-1 };i<d;++i )
		{
			const auto b
				= s[i] == '.'
				&& s[i] == s[i+1]
				&& s[i] == s[i+2];
			if( b )
			{
				swappable = true;
				break;
			}
		}

		s[d] = '#';
		ans = swappable||check( a, c ) ? "Yes" : "No";

	}

	std::cout << ans << "\n";

	return 0;
}

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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
  int X ;
  cin >> X ;
  int ans ;
  for(int i=X;i<X+10000;i++){
    if(IsPrime(i)){
      ans = i ;
      break;
    }
  }
  
  cout << ans <<endl;
}
      

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	long long T;
	cin>>N>>T;
	vector<long long> A(N,0);
	int i;
	for (i=0;i<N;i++){
		cin>>A[i];
	}
	vector<long long> MinI(N,0);
	MinI[0]=A[0];
	for (i=1;i<N;i++){
		MinI[i]=min(MinI[i-1],A[i-1]);
	}
	vector<long long> d(N,0);
	for (i=0;i<N;i++){
		if (A[i]>MinI[i]){
			d[i]=A[i]-MinI[i];
		}
	}
	sort(d.begin(),d.end(),greater<long long>());
	long long x=d[0];	
	int aw=1;
	for (i=1;i<N-1;i++){
		if (x==d[i]){
			aw++;
		}
	}
	cout<<aw<<endl;
	return 0;
}

Measured memory_bytes: 2688
/*
 * Name        : a
 * Creat       : Thu Jul 11 21:40:52 CST 2019
 * Accept      : Thu Jul 11 21:42:03 CST 2019
 * Author      : landcold7
 * Motivation  : Action speaks louder more than words
 */
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define sz(x) ((int)(x).size())
#ifndef _has_trace
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n * a, b) << "\n";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};


int main(){
  string L; cin >> L;
  int n = L.size();

  vvl dp(n+1,vl(2));
  dp[0][0] = 1;

  rep(i,n) {
    if(L[i] == '1'){
      dp[i+1][0] = 2*dp[i][0];
      dp[i+1][1] = dp[i][0] + 3*dp[i][1];
    }
    else{
      dp[i+1][0] = dp[i][0];
      dp[i+1][1] = 3*dp[i][1];
    }
    dp[i+1][0] %= MOD;
    dp[i+1][1] %= MOD;
  }

  cout << (dp[n][0] + dp[n][1])%MOD << endl;
}

Measured memory_bytes: 5760
n = int(input())
san = n // 3
go = n // 5
juugo = n // 15
ans = 0
ALL = ((1 + n)*n)//2
three = ((3 + 3*san)*san)//2
five = ((5 + 5*go)*go)//2
juugo = ((15 + 15*juugo)*juugo)//2

ans = ALL - three - five + juugo

print(ans)

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

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

int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> y(n+1);
    rep(i, n) cin >> y[i];
    y[n] = x;
    sort(y.begin(), y.end());
    int t = y[1] - y[0];
    repl(i, 1, n) {
        int s = y[i + 1] - y[i];
        t = gcd(s, t);
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 3764
#include "bits/stdc++.h"
using namespace std;

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
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; }

void Solve()
{
	ll H, W;
	cin >> H >> W;
	VL A(H), B(H);
	REP(i, H) {
		cin >> A[i] >> B[i];
		A[i]--, B[i]--;
	}

	map<ll, ll> mp;
	multiset<ll> set;
	REP(i, W) {
		set.insert(0);
		mp[i] = i;
	}

	VL ans(H, -1);
	REP(i, H) {
		ll insOne = -1;
		ll l = A[i];
		ll r = B[i] + 1;
		auto it = mp.lower_bound(l);
		for (; it != mp.end(); ) {
			auto one = *it;
			ll start = one.second;
			ll now = one.first;
			if (r < now) {
				break;
			}
			auto dist = now - start;
			mp.erase(it++);
			set.erase(set.find(dist));
			insOne = max(insOne, start);
		}

		if (insOne != -1) {
			if (r != W) {
				mp[r] = insOne;
				set.insert(r - insOne);
			}
		}
		if (set.size()) {
			ans[i] = *set.begin() + i + 1;
		}
	}

	for (auto one : ans) {
		cout << one << endl;
	}
	return;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 29840
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#define R register
inline int read(){
	R int x; R bool f; R char c;
	for (f=0; (c=getchar())<'0'||c>'9'; f=c=='-');
	for (x=c^'0'; (c=getchar())>='0'&&c<='9'; x=(x<<1)+(x<<3)+(c^'0'));
	return f?-x:x;
}
#define MN 100005
int n,to[MN<<1],nxt[MN<<1],col[MN],en,hd[MN];
inline void ins(int u,int v){to[++en]=v;nxt[en]=hd[u];hd[u]=en;}
inline void insw(int x,int y){ins(x,y);ins(y,x);}
bool dfs(int u,int f=0){
	R int cnt=0;
	for (R int i=hd[u]; i; i=nxt[i])
		if (to[i]!=f){
			if (dfs(to[i],u)) ++cnt;
			if (cnt>>1) puts("First"),exit(0); 
		}col[u]=cnt^1;return col[u];
}
int main(){
	n=read();for (R int i=1; i<n; ++i)
		insw(read(),read());
	dfs(1);if (col[1]) puts("First");
	else puts("Second");return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define MAXN 1000005
#define INF 0x3f3f3f3f
#define MS(x, i) memset(x, i, sizeof x)
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define MOD 1000000007
#define NOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;


ll a[MAXN];

ll mid, n, k, cnt;

inline ll read() {
    ll ret = 0, sgn = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if(ch == '-') sgn = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        ret = ret*10 + ch - '0';
        ch = getchar();
    }

    return ret*sgn;
}

ll check(ll mid)
{
    cnt = 0;
    for(int i = 1; i < n; i++)
    {
        if(a[i] == 0)
        {
            if(mid >= 0)
            {
                cnt += n - i;
                continue;
            }
        }
        ll lt = i + 1, rt = n;

        while(lt <= rt)
        {
            ll midt = (lt + rt) >> 1;
            if(a[i] * a[midt] <= mid)
            {
                if(a[i] < 0)
                    rt = midt - 1;
                else
                    lt = midt + 1;
            }
            else
            {
                if(a[i] < 0)
                    lt = midt + 1;
                else
                    rt = midt - 1;
            }
        }
        int lens = lt - (i + 1);
        if(a[i] < 0)
            cnt += (n - i) - lens;
        else
            cnt += lens;
    }
    return cnt < k;
}

int main()
{
    NOS
    cin >> n >> k;
    ll l = -1000000000000000005;
    ll r = 1000000000000000005;
    for(int i = 1; i <= n; i++)
        cin >> a[i];

    sort(a + 1, a + 1 + n);

    while(l < r)
    {
        mid = (l + r) >> 1ll;
        if(check(mid))
        {
            l = mid + 1;
        }
        else
        {
            r = mid;
        }
    }

    cout << r << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  ll n;
  cin >> n;
  ll ans = INFLL;
  for (ll i = 1; i*i <= n; ++i) {
    if (n%i != 0) continue;
    ll j = n/i;
    ans = min(ans, i+j-2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np
n, m = map(int, input().split())
a = np.array([list(input()) for _ in range(n)])
b = np.array([list(input()) for _ in range(m)])

for i in range(n-m+1):
    for j in range(n-m+1):
        flag = True
        for k in range(m):
            for l in range(m):
                if a[0+i+k, 0+j+l] != b[0+k, 0+l]:
                    flag = False
        if flag:
            break
    if flag:
        break
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12388
#include <stdio.h>

int main(void) {
	int n;
	scanf("%d", &n);
	
	int a[n + 1];
	int count = 0;
	
	for(int i = 1; i < n + 1; i++){
		scanf("%d",&a[i]);
	}
	
	for(int i = 1; i < n + 1; i++){
			if(a[a[i]] == i){
				count++;
			}
	}

	printf("%d\n", count/2);
	
	return 0;
}

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

long long N, C, x[100009], v[100009], s1[100009], maxn = -(1LL << 60);

long long solve() {
	for (int i = 0; i <= N; i++) s1[i] = -(1LL << 60);
	long long G = 0, ret = 0;
	for (int i = 1; i <= N; i++) {
		G += v[i];
		s1[i] = max(s1[i - 1], G - x[i]);
	}
	ret = max(ret, s1[N]);
	long long Z = 0;
	for (int i = N; i >= 1; i--) {
		Z += v[i];
		ret = max(ret, s1[i - 1] + (Z - (C - x[i]) * 2));
	}
	return ret;
}

int main() {
	cin >> N >> C;
	for (int i = 1; i <= N; i++) cin >> x[i] >> v[i];

	for (int i = 0; i < 2; i++) {
		maxn = max(maxn, solve());
		for (int j = 1; j <= N; j++) x[j] = C - x[j];
		reverse(x + 1, x + N + 1);
		reverse(v + 1, v + N + 1);
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;

struct data_t {
	string name;
	double eff;

	bool operator<(const data_t& right) const {
		if (eff == right.eff) {
			return ( name < right.name ) || ( name == right.name );
		}
		else {
			return ( eff > right.eff );
		}
	}
};

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

	while ( N != 0 ) {
		vector<data_t> LS(N);
		vector<int> T(N,0);
		int p,temp,d,e,f,s,m;
		for (int i = 0; i < N; i++) {
			cin >> LS[i].name;
			cin >> p;
			for (int j = 0; j < 3; j++) {
				cin >> temp;
				T[i] += temp;
			}
			cin >> d >> e >> f >> s >> m;
			T[i] += m * (d+e);
			LS[i].eff = (double)((m*f*s)-p)/T[i];
		}

		std::sort(LS.begin(), LS.end());

		for (int i = 0; i < N; i++) {
			cout << LS[i].name << endl;
		}
		cout << "#" << endl;
		cin >> N;
	}

	return 0;
}

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

const int MAX_N = 1e+7;
bool is_p[MAX_N+1] = {false,false};

void sieve(){
	for(int i = 2 ; i <= MAX_N ; i++ )
		is_p[i] = true;
	for(int i = 2 ; i*i <= MAX_N ; i++ ){
		if( is_p[i] ){
			for(int j = i+i ; j <= MAX_N ; j += i ){
				is_p[j] = false;
			}
		}
	}
}

int main(){
	sieve();
	int k;
	while( cin >> k , k ){
		int a, b;
		for(int i=k ; 2 <= i ; i-- ){
			if( is_p[i] ){
				a = i;
				break;
			}
		}
		for(int i=k ; true ; i++ ){
			if( is_p[i] ){
				b = i;
				break;
			}
		}
		cout << b - a << endl;
	}
}

Measured memory_bytes: 10924
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int A,B;
    cin >>A>>B;
    A -=2*B;
    if(A<0){
        A=0;
    }
    cout <<A<<endl;
}


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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  string S;
  ull K;
  cin >> S >> K;
  smatch what;
  if (regex_match(S, what, regex("^(1+)([1-9]*)$"))) {
    if (what.length(1) >= K) {
      cout << 1 << endl;
    } else if (what.size() > 2) {
      cout << what.str(2).front() << endl;
    } else {
      assert(false);
    }
  } else {
    cout << S.front() << endl;
  }
  return 0;
}


Measured memory_bytes: 3804
#include <iostream>
using namespace std;
int main(void){
    
    int A, B, C;
    cin >> A >> B >> C;
    
    if(A == B && B != C ){
        cout << "Yes" << endl;
    }
    else if(A != B && B == C){
        cout << "Yes" << endl;
    }
    else if(A == C && C != B){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
 
}

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

int main(){

    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for(int i=0; i < n; i++){
        cin >> a[i];
    }
    int sum;
    sum = accumulate(a.begin(), a.end(), 0);
    int total = 0;

    for(int i=0; i < n; i++)
    if(a[i]*4*m >= sum){
        total++;
    }
    if(total >= m){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int n, k, a, s, c[200005];
int main() {
	int i;
	scanf("%d%d", &n, &k);
	for(i=0; i<n; i++) scanf("%d", &a), c[a]++;
	int m=n-k;
	sort(c, c+n+1);
	for(i=0; i<=n-k; i++) s += c[i];
	printf("%d", s);
	return 0;
}

Measured memory_bytes: 896
import sys
n = int(input())

if n%7 != 0 and n%4 != 0 and n%11 != 0:
    for a in range(1, 25):
        for b in range(1, 14):
            if n%(7*b + 4*a) == 0:
                print('Yes')
                sys.exit()
else:
    print('Yes')
    sys.exit()
print('No')

Measured memory_bytes: 3060
import sys
import math

input = sys.stdin.readline


def prime_factorization(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors


def main():
    N = int(input())

    ef = [0] * (N + 1)
    ans = 0
    for i in range(2, N + 1):
        x = prime_factorization(i)
        for xx in x:
            ef[xx] += 1

    a, b, c, d, e = 0, 0, 0, 0, 0
    for ee in ef:
        if ee >= 74:
            a += 1
            b += 1
            c += 1
            d += 1
            e += 1
        elif ee >= 24:
            a += 1
            b += 1
            c += 1
            d += 1
        elif ee >= 14:
            a += 1
            b += 1
            c += 1
        elif ee >= 4:
            a += 1
            b += 1
        elif ee >= 2:
            a += 1

    ans += e
    ans += d * (a - 1)
    ans += c * (b - 1)
    ans += b * (b - 1) * (a - 2) // 2

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064