akhauriyash/Code-Regression huggingface dataset:
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define rall(v )  reverse(v.begin(), v.end())      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vll vector< pair<ll,ll> > 
#define mpl map<ll, ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) {return (a.second < b.second); }
ll soltn(ll x, ll n) {if(x>=0) return x%n;    else return n+x%n;}
ll pd(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}
ll coda(ll n,ll d){ll count=0;while(n!=0){if(n%10==d)count++;n/=10;}return count;}
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;
      
      
//	   cin>>t;
	      while(t--)
{
//jai shree mataji
/*
3 3 4
3 3
3 1
1 1
1 2*/
ll n,m,M;
cin>>n>>m>>M;
mpl X;
mpl Y;
ll a[M],b[M];
map<pair<ll,ll>,ll> K;
ll mx=0,my=0;
fo(i,M)
{
	cin>>a[i]>>b[i];
	K[{a[i],b[i]}]=1;
	X[b[i]]++;
	Y[a[i]]++;
	mx=max(mx,X[b[i]]);
	my=max(my,Y[a[i]]);
}
ll ans=mx+my;
vl v1;
vl v2;
fo(i,n)
{
	if(Y[i+1]==my)
	{
		v1.pb(i+1);
	}
}
fo(i,m)
{
	if(X[i+1]==mx)
	{
		v2.pb(i+1);
	}
}
fo(i,v1.size())
{
	fo(j,v2.size())
	{
		if(K[{v1[i],v2[j]}]==0)
		{
			cout<<ans;
			ee;
			return 0;
	//		break;
		}
	}
}
ans--;
cout<<ans;
ee;
}
return 0;
}














Measured memory_bytes: 72440
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const ll INF = 1ll << 62;

int main() {
  int N;
  while (cin >> N) {
    vector<pair<ll, ll>> players(N);
    for (int i = 0; i < N; i++) {
      cin >> players[i].first >> players[i].second;
    }
    sort(players.begin(), players.end(), [&](auto &a, auto &b) {
      return (a.first + a.second) < (b.first + b.second);
    });
    vector<ll> dp(N + 1, INF);
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
      int H = players[i].first, P = players[i].second;
      for (int j = N - 1; j >= 0; j--) {
        if (dp[j] <= H) {
          dp[j + 1] = min(dp[j + 1], dp[j] + P);
        }
      }
    }
    int res = N;
    while (dp[res] >= INF) --res;
    cout << res << endl;
  }
  return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  
  string s = "";
  for (int i = 0; i < h; i++) {
    string si;
    cin >> si;
    s += si;
  }
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s.at(i*w+j) == '#') cout <<"#";
      else{
        
        // 周囲の爆弾の数を数える
        int count_bomb = 0;
        for (int k = -1; k <= 1; k++) {
          for (int l = -1; l <= 1; l++) {
            if (i+k >= 0 && i+k < h && j+l >= 0 && j+l < w){
              int pos = (i+k)*w + (j+l);
              if (s.at(pos) == '#') count_bomb += 1;
            }
            
          }
        }
        cout << count_bomb;
        
      }
      
  	}
    cout << endl;
  }
}


Measured memory_bytes: 3640
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var M = one[1];
  var list = new Array(N);
  var lines = {};
  for(var i = 0; i < M; i++){
    var tmp = nextIntArray();
    var P = tmp[0] - 1;
    var Y = tmp[1];
    lines[Y] = i;
    if(list[P] == null){
       list[P] = new Array();
    }
    list[P].push(Y);
  }
  for(var i = 0; i < N; i++){
    if(list[i] != null){
       list[i].sort(function(a,b){
       	return a - b;
       });
    }
  }
  var output = new Array(M).fill("");
  for(var i = 0; i < N; i++){
    if(list[i] == null){
       continue;
    }
    var tmp = list[i];
    for(var j = 0; j < tmp.length; j++){
      var tmpY = tmp[j];
      var add = ("000000" + (i + 1).toString()).slice(-6) + ("000000" + (j + 1).toString()).slice(-6);
      output[lines[tmpY]] = add;
    }
  }
  myerr(output);
  myout(myconv(output,9));
}

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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(a.at(a.size()-1) == b.at(0) && b.at(b.size()-1) == c.at(0)) cout << "YES" << endl;
  else cout << "NO" << endl;
  


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int m,d;
	string day[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday",};
	int box[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int sum;
	int h;
	while(1){
		cin>>m>>d;
		if(m==0&&d==0)	break;
		sum=d;
		for(int i=0;i<m-1;i++){
			//cout<<i<<endl;
			sum+=box[i];
		}
		//cout<<sum<<endl;
		h=sum%7;
		cout<<day[h]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

int main() {
    long n, T;
    cin >> n >> T;
    vector<long> df;
    long t, u = 0;
    cin >> t;
    REP(i,n-1) {
        cin >> u;
        df.push_back(u-t);
        t = u;
    }
    long tot = u + T;
    REP(i,n-1) {
        if (df[i] > T) {
            tot -= df[i] - T;
        }
    }
    cout << tot << endl;
}



Measured memory_bytes: 2420
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
using namespace std;

int main() {
	long long n, a, b, ans;
	cin >> n >> a >> b;
	if (n == 1) {
		if (a == b) {
			ans = 1;
		}
		else {
			ans = 0;
		}
	}
	else {
		ans = (b - a)*(n - 2) + 1;
		if (ans < 0) {
			ans = 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N; ll L, T;
ll A[MAX_N], W[MAX_N];
ll ans[MAX_N];

void solve() {
	cin >> N >> L >> T;
	rep(i, 0, N) {
		cin >> A[i] >> W[i]; W[i]--;
	}
	ll cnt = 0;
	rep(i, 1, N) {
		if(W[i] != W[0]) {
			ll b; 
			if(W[0] == 0) b = A[i] - A[0];
			else b = L - (A[i] - A[0]);
			if(2 * T < b) continue;
			if(2 * T == b) cnt++;
			else {
				cnt += 1 + (2 * T - b) / L;
			}
		}
	}
	rep(i, 0, N) {
		ans[i] = W[i] == 0 ? (T + A[i]) % L : (L - (T - A[i] + L) % L) % L;
	}
	cnt %= N;
	if(W[0] == 1) cnt = (N - cnt) % N;
	ll at = ans[0];
	sort(ans, ans + N);
	ll id;
	ll b = lower_bound(ans, ans + N, at) - ans;
	if(upper_bound(ans, ans + N, at) - lower_bound(ans, ans + N, at) == 1) {
		id = b;
	}
	else {
		if(W[0] == 0) id = b + 1;
		else id = b;
	}
	// debug(vi(ans, ans + N), id, cnt);
	rep(i, 0, N) {
		cout << ans[(i + id - cnt + N) % N] << "\n";
		// else cout << ans[(-i + id - cnt + 2 * N) % N] << "\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 4480
n = gets.chomp.to_i
ary = gets.chomp.split(' ').map { |i| i.to_i }
(1..n).each { |i|
  if i < n
    print "#{ary[ary.size-i]} "
  else
    print "#{ary[ary.size-i]}\n"
  end
}

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

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  if(s.size() <= k) {
    cout << s << endl;
    return 0;
  }
  for(int i=0; i<k; i++) {
    cout << s.at(i);
  }
  cout << "..." << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s; cin >> s;
    for(int i = 0; i  <s.size(); i++){
        if(i%2 == 0){
            if(!(s[i]=='R'||s[i]=='U'||s[i]=='D')){
                puts("No");
                return 0;
            }
        }
        else{
            if(!(s[i]=='L'||s[i]=='U'||s[i] == 'D')){
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair<int64, int64> pii;
int64 dp[2002][2002];
vector<pii> A(2002);
int n;
int64 solve(int l, int r){
   if(l > r) return 0;
   int64 &ret = dp[l][r];
   if(ret >= 0) return ret;
   int pos = n - (r - l + 1);
   ret = A[pos].first * abs(A[pos].second - l) + solve(l + 1, r);
   ret = max(ret, A[pos].first * abs(A[pos].second - r) + solve(l, r - 1));
   return ret;
}
int main(){
	cin >> n;
    for(int i = 0; i < n; i++){
    	cin >> A[i].first;
        A[i].second = i;
    }
    sort(A.rbegin(), A.rend());
    memset(dp, -1, sizeof(dp));
    int64 ans = solve(0, n - 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35084
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;

int main(){
    char s[101];
    char p[101];
    int c,d,i,t;
    scanf("%s",s);
    scanf("%s",p);
    if(s[0] == '0'||p[0] == '0'||s[0] == '-'||p[0] == '-')
    	return 0;
    c = strlen(s);
    d = strlen(p);
    if(c > d)
    	printf("GREATER\n");
    else if(c < d)
        printf("LESS\n");
    else if(c == d)
{
				for(i = 0;i < c;i++){
                    if(s[i] != p[i])
                    	break;
                    if(s[i] == p[i])
                    	continue;
				}
				if(s[i] > p[i])
				    printf("GREATER\n");
				else if(s[i] < p[i])
                    printf("LESS\n");
                else
                	printf("EQUAL\n");
			}
     return 0;
}
 

Measured memory_bytes: 128
(N, K), Ps = readlines.map{|l| l.split.map(&:to_i)}

as = Ps.map{|p| (1 + p)/2.0}.inject([0]){|a, v| a << a.last + v}
puts (K .. N).map{|i| as[i] - as[i - K]}.max

Measured memory_bytes: 19588
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())

const int INF = 1e9;


// code
// ------------------------------------------------
int main() {

  int n,x,y;

  cin >> n >> x >> y;

  vector<int> a(n - 1);

  for(int i = 1;i < n ; i++)
  {
    for(int j = i + 1;j <= n ; j++)
    {
      int l;

      int g,h;
      int ans;

      g = j - i;
      h = abs(x - i) + 1 + abs(y - j);

      ans = g > h ? h : g;

      a[ans-1]++;
    }
  }

  rep(i,n - 1)
  {
    cout << a[i] << endl;
  }

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/array.hpp>
//#include <boost/range/numeric.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
//using namespace boost::multiprecision;

constexpr long long INF = LLONG_MAX;
constexpr long long MOD = 1000000007;
constexpr long double PI = M_PI;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << fixed << setprecision(12)
#define dbglf cerr << '\n'

#define ACCM(arr) accumulate(ALL(arr),0LL)
#define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl
#define YES(ex) cout << ((ex) ? "YES" : "NO") << endl

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void veccin(vector<T>& v) {
    for (auto && e : v) { cin >> e; }
}

template < typename T >
inline void dbg(T a) { cerr << a << ' '; }

ll n, m, k;
ll ans = 0, sum = 0, cnt = 0;
//ld d;
string s/*1, s2, s3*/;
char c/*1, c2, c3*/;
bool flag = false;

/*--------------------template--------------------*/

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

    cin >> n;

    cout << (ld)n *2.0*PI << endl;
}


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

typedef long long LL;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

#define fast ios_base::sync_with_stdio(0),cin.tie(0)
#define temp template<typename T>
#define debug(x) cerr<<"Line "<<__LINE__<<": "<<#x<<" = "<<x<<'\n'
#define itr(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define rep(i,a,b) for(int i=a;i<=(int)b;i++)
#define repr(i,a,b) for(int i=a;i>=(int)b;i--)
#define cas(n) printf("Case %d:",(int)n)
#define mem(x,v) memset(x,v,sizeof(x))
#define read(x) freopen(x,"r",stdin)
#define write(x) freopen(x,"w",stdout)
#define all(x) x.begin(),x.end()
#define aut(x,v) for(auto &x:v)
#define ini(n) scanf("%d",&n)
#define inl(n) scanf("%lld",&n)
#define ind(n) scanf("%lf",&n)
#define ins(n) scanf("%s",n)
#define insn(n) scanf(" %[^\n]",n)
#define outi(n) printf("%d",(int)n)
#define outl(n) printf("%lld",(LL)n)
#define outd(n,p) printf("%.*lf",p,(double)n)
#define outs(n) printf("%s",n)
#define sz(x) (int)x.size()
#define nl printf("\n")
#define sp printf(" ")
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

const int inf=0x3f3f3f3f;
const int mod=1000000007;
const int mx=2000001;
const LL  infL=0xf3f3f3f3f3f3f3f;
const double eps=1e-9;
const double pi=acos(-1.0);

set<int> st;

int main()
{
    //read("in.txt"),write("out.txt");
    int n,cnt=1;
    ini(n);
    st.insert(n);
    while(1)
    {
        if(n&1)
            n=3*n+1;
        else
            n>>=1;
        if(st.find(n)!=st.end())
            break;
        st.insert(n),cnt++;
    }
    outi(cnt+1),nl;
    return 0;
}


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

using namespace std;

#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

i64 N, A;

const i64 INFT = 100000000000000LL;

i64 mult(i64 a, i64 b)
{
	if (a == 0) return 0;
	if (INFT / a < b) return INFT;
	return a * b;
}

i64 getmax(i64 T, int S)
{
	i64 ans = 1;
	for (int i = 0; i < S; ++i) {
		ans = mult(ans, T / S + (i < T % S ? 1 : 0));
	}
//	printf("%lld %d %lld\n", T, S, ans);
	return ans;
}

int main()
{
	scanf("%lld%lld", &N, &A);

	i64 ret = N;
	for (int i = 1; i <= 40; ++i) {
		i64 left = i, right = N;
		while (left < right) {
			i64 mid = (left + right) / 2;
			if (getmax(mid, i) >= N) {
				right = mid;
			} else
			{
				left = mid + 1;
			}
		}
		ret = min(ret, A * (i - 1) + left);
	}

	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n;
    cin >> n;
    string s;
    cin >> s;
    lint ans;
    lint count = 0;
    for (int i=0; i<n; ++i){
        if(s[i] == '#'){
            count++;
        }
    }
    ans = count;
    count = 0;
    for (int i=0; i<n; ++i){
        if(s[i] == '.'){
            count++;
        }
    }
    ans = min(ans, count);
    // hoge
    vector<lint> p(n+1, 0);
    vector<lint> sh(n+1, 0);
    for (int i=0; i<n; ++i){
        p[i + 1] = ((s[i] == '.') ? 1 : 0) + p[i];
        sh[i + 1] = ((s[i] == '#') ? 1 : 0) + sh[i];
    }
    for (int i=1; i<=n; ++i){
        ans = min(ans, sh[i] + p[n] - p[i]);
    }
    cout << ans << endl;
    return 0;
}

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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	ll k;
	cin>>n>>k;
	vector<int> path(n);
	FOR(0, i, <n){
		cin>>path[i];
		path[i]--;
	}
	int slow = 0;
	int fast = 0;
	do{
		slow = path[slow];
		fast = path[fast];
		fast = path[fast];
	}while(slow != fast);
	slow = 0;
	while(slow != fast){
		slow = path[slow];
		fast = path[fast];
	}
	int cycStart = slow;
	int pt = 0;
	vector<int> pre;
	vector<int> cyc;
	while (pt != cycStart){
		pre.push_back(pt);
		pt = path[pt];
	}
	cyc.push_back(pt);
	pt = path[pt];
	while (pt != cycStart){
		cyc.push_back(pt);
		pt = path[pt];
	}
	if (k < (ll)pre.size()){
		cout<<pre[k]+1<<'\n';
	}else{
		k -= (ll)pre.size();
		k %= (ll)cyc.size();
		cout<<cyc[k]+1<<'\n';
	}
	return 0;
}

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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
const double INF=1e15;
int N;
typedef pair<double,int> P;

#define BITTYPE int
#define BITCNT  1
#define BITSIZE 512345
namespace BIT_{
    int i=0;
    BITTYPE t[BITCNT][BITSIZE];
    inline BITTYPE* get(){
        return t[i];
    }
}
//[1,n],0は扱えない!
struct BIT{
    using T=BITTYPE;
    T* bit;
    int n;
    BIT(T* _table,int n):bit(_table),n(n){
        std::fill(bit,bit+n+1,0);
    }
    BIT(int n):BIT(BIT_::get(),n){}
    T sum(int i){
        T s=0;
        while(i>0){
            s+=bit[i];
            i-=i&-i;
        }
        return s;
    }
    T sum(int lb,int ub){
        return sum(ub)-sum(lb-1);
    }
    void add(int i,T x){
        while(i<=n){
            bit[i]+=x;i+=i&-i;
        }
    }
    //v[1]+v[2]+...+v[x]>=wとなる最小のxを求める
    int lowerbound(T w){
        if(w<=0)return 0;
        int x=0;
        for(int k = (1<<(31-__builtin_clz(n)));k >0 ;k>>=1)
            if(x+k<=n&&bit[x+k]<w){
                w-=bit[x+k];
                x+=k;
            }
        return x+1;
    }
    void clear(int sz){
        std::fill(bit,bit+n+1,0);
    }

};   


double calc(vector<double> x,vector<double> y,vector<double> c){
    double lb=-INF;
    double ub=INF;
    int M=N*(N-1)/2;
    M=(M)/2;
    REP(loop,100){
        const double mid=(lb+ub)/2;
        vector<P> a(N);
        vector<P> b(N);
        
        vector<int> f(N);
        vector<int> t(N);
        vector<int> z(N);
        REP(i,N){
            a[i]={(c[i]-x[i]*mid)/y[i],i};
            b[i]={(c[i]-x[i]*INF)/y[i],i};
        }
        sort(ALL(a));
        sort(ALL(b));

        REP(i,N)f[a[i].se]=i;
        REP(i,N)t[b[i].se]=i;
        REP(i,N)z[f[i]]=t[i];
        BIT bit(N+10);
        int cnt=0;

        REP(j,N){
            int i=N-j-1;
            cnt+=bit.sum(z[i]+1);
            bit.add(z[i]+1,1);
        }
        if(cnt<=M)ub=mid;
        else lb=mid;
    }
    return ub;

}
int main(){
    cout<<fixed;
    cout<<setprecision(10);
    cin>>N;
    int num=N*(N-1)/2;
    vector<double> x(N),y(N),c(N);
    REP(i,N)cin>>x[i]>>y[i]>>c[i];

    cout<<calc(x,y,c)<<" "<<calc(y,x,c)<<endl;
    return 0;
}


Measured memory_bytes: 5036
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;

ll fastpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) {
    u += m;
  }
  return u;
}

int main() {
  ll n;
  scanf("%lld", &n);

  vector<ll> c(n);
  for (ll i = 0; i < n; i++) {
    ll v;
    scanf("%lld", &v);
    c[i] = (v % MOD);
  }

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

  ll ans = 0;
  ll patterns = fastpow(2, n, MOD) % MOD;
  ll diffs = fastpow(2, n - 1, MOD) % MOD;

  for (ll i = 0; i < n; i++) {
    ll rest = (n - i - 1LL) % MOD;
    // double expectNum = rest * 0.5;
    // ll plus = (expectNum + 1) * diffs;
    // ll plus = (rest / 2 + 1) * diffs;
    // ll plus = rest*diffs/2 + diffs
    ll plus = (rest * diffs) % MOD;
    // plus = (plus + diffs * 2LL) % MOD;
    // plus = plus * (patterns / 2LL % MOD) % MOD;

    plus = (plus + patterns) % MOD;
    plus = plus * (diffs % MOD) % MOD;

    plus = plus * c[i] % MOD;

    ans = (ans + plus) % MOD;
    // cout << ans << endl;
  }

  cout << ans << endl;
}


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

const int MAXN = 1e5 + 10;

int n, L, T, a[MAXN];

int main() {
	long long cnt = 0LL;
	scanf("%d%d%d", &n, &L, &T);
	for (int i = 0; i < n; ++i) {
		int x, k;
		scanf("%d%d", &x, &k);
		x += k == 1 ? T : -T;
		cnt += x / L;
		x %= L;
		if (x < 0) x += L, --cnt;
		a[i] = x;
	}
	sort(a, a + n);
	cnt = (cnt % n + n) % n;
	for (int i = 0; i < n; ++i) printf("%d\n", a[(i + cnt) % n]);
}

Measured memory_bytes: 1536
#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 per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define int long long
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define endl "\n"
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<vi>
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=(1ll<<62)-1;
signed main(){
  ll N; cin>>N;
  vi A(3*N);
  rep(i,0,3*N) cin>>A[i];
  sort(ALL(A));
  ll ans=0;
  REP(i,1,N){
    ans+=A[3*N-i*2];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#define MAX 100000
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	int N, X; cin >> N >> X;
	int sum = 0, light = MAX;
	rep(i, 0, N) {
		int tmp; cin >> tmp;
		sum += tmp;
		light = min(light, tmp);
	}
	int ans = N + (X - sum) / light;
	cout << ans << endl;

	return 0;
}

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

int main() {
    int n; scanf("%d", &n);
    vector<int> l(n),r(n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &l[i], &r[i]);
        r[i] = -r[i];
    }
    sort(l.begin(), l.end(), greater<int>()); 
    sort(r.begin(), r.end(), greater<int>());

    long long ans = 0;
    int iter = 2; while (iter--) {
        long long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += l[i]; ans = max(ans, sum);
            sum += r[i]; ans = max(ans, sum);
        }
        l.swap(r);
    }
    cout << 2*ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();
		
		int score = 0;
		for(int i=0;i<S.length()-1;i++) {
			if(S.charAt(i)==S.charAt(i+1)) score++;
		}
		int ans = Math.min(score+2*K, N-1);
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 25300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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 dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H,W; cin >> H >> W;
    vector<string> field(H);
    rep(i,H) cin >> field[i];
    
    bool seen[H][W];
    memset( seen, false, sizeof(seen) );
    
    int countsharp = 0;
    
    rep(i,H){
        rep(j,W){
            if(field[i][j]=='#') {
                seen[i][j] = true;
                countsharp++;
            }
        }
    }
    seen[0][0] = true;
    
    queue<pair<int, int>> que{};
    int dist[H][W];
    memset( dist, -1, sizeof(dist));
    
    que.push(make_pair(0, 0));
    dist[0][0] = 0;
    
    while(!que.empty()){
        
        
        int nowh = que.front().first;
        int noww = que.front().second;
        
        que.pop();
        
        
        
        
        for (int i = 0; i < 4; i++) {
            
            int newh = nowh + dx4[i];
            int neww = noww + dy4[i];
            if( !(0<=newh&&newh<H && 0<=neww&&neww<W) ) continue;
            if( seen[newh][neww] ) continue;
            
            que.push(make_pair(newh,neww));
            dist[newh][neww] = dist[nowh][noww] + 1;
            seen[newh][neww] = true;
        }
        
        
        
        
    }
    
    if(seen[H-1][W-1]){
        cout << H*W - countsharp - dist[H-1][W-1] - 1 << endl;
    }else{
        cout << -1 << endl;
    }
    
    
    
    
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#ifdef TEST
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock
#endif
#define ins insert
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef double db;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

string S;
int T;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> S;
	for (char c : S) T += c - '0';
	cout << (T % 9 == 0 ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 3748
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    int n; cin >> n;
    V<ll> a(3*n); rep(i, 3*n) cin >> a[i];
    ll sum = 0;
    priority_queue<int, V<int>, greater<int>> que;
    rep(i, n) {
        sum += a[i];
        que.emplace(a[i]);
    }
    V<ll> s_a(n+1);
    s_a[0] = sum;
    rep(i, n) {
        que.emplace(a[n+i]);
        sum += a[n+i];
        sum -= que.top(); que.pop();
        s_a[i+1] = sum;
    }

    priority_queue<int> quee;
    sum = 0;
    for (int i = 2*n; i < 3*n; i++) {
        sum += a[i];
        quee.emplace(a[i]);
    }
    V<ll> s_b(n+1);
    s_b[0] = sum;
    rep(i, n) {
        quee.emplace(a[2*n - i - 1]);
        sum += a[2*n - i - 1];
        sum -= quee.top(); quee.pop();
        s_b[i+1] = sum;
    }
    ll ans = -1e18;
    for (int i = 0; i <= n; i++) {
        chmax(ans, s_a[i] - s_b[n - i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8068
//ABCSwap.java
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
        int y=sc.nextInt();
        int z=sc.nextInt();

        System.out.println(z+" "+x+" "+y);
        sc.close();
    }
}

Measured memory_bytes: 22996
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}




int main(){//
	int N;
	cin >> N;
	vector<int> P(N), Q(N);
	for(int i=0; i<N; i++){
		int p;
		cin >> p;
		p--;
		P[i] = p;
	}
	for(int i=0; i<N; i++){
		int q;
		cin >> q;
		q--;
		Q[i] = q;
	}
	vector<int> order(N);
	for(int i=0; i<N; i++) order[i] = i;
	// cout << " P: "; print_vec(P);
	// cout << " Q: "; print_vec(Q);
	int cnt = 0;
	int a, b;
	do{
		int flag_p = 0, flag_q = 0;
		for(int i=0; i<N; i++){
			if(P[i] == order[i]) flag_p++;
			if(Q[i] == order[i]) flag_q++;
		}
		if(flag_p == N) a = cnt;
		if(flag_q == N) b = cnt;

		cnt++;

	}while(next_permutation(order.begin(), order.end()));

	// cout << " a: " << a << " b: " << b << endl;
	// cout << " P: "; print_vec(P);
	// cout << " Q: "; print_vec(Q);
	cout << max(a-b, b-a) << endl;
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n) {
    int ans = 0;
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        for (int k = 0; k < 10; k++) {
          int l = n - i - j - k;
          ans += (l >= 0 && l < 10);
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}


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

int main()
{
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double ans = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

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



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

int main(){
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<long long> arr(n);
    for (int i = 0; i < n; i++){
        cin >> arr[i];
    }
    int cnt = 0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            for (int k = j + 1; k < n; k++){
                if (arr[i] == arr[j] || arr[j] == arr[k] || arr[i] == arr[k])
                    continue;
                if (arr[i] + arr[j] + arr[k] > max(max(arr[i], arr[j]), arr[k]) * 2){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int N, M, X; cin >> N >> M >> X;
  vector<int> A(M);
  for(auto& a : A) cin >> a;

  auto it = boost::lower_bound(A, X);
  auto num0 = std::distance(A.begin(), it);
  auto num1 = M - num0;
  cout << std::min(num0, num1) << CRLF;

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
long long dp[16][16];
int x[100][2],y[100][2];
int main(){
	int t;
	cin>>t;
	for(int u=0;u<t;u++){
	int w,h;
	cin>>w>>h;
	for(int i=0;i<=h;i++){
		for(int j=0;j<=w;j++){
			dp[i][j]=0;
		}
	}
	int p;
	cin>>p;
	for(int i=0;i<p;i++){
		for(int j=0;j<2;j++){
			cin>>x[i][j]>>y[i][j];
		}
	}
	dp[0][0]=1;
	for(int i=1;i<=h;i++){
		bool na=false;
		for(int j=0;j<p;j++){
			if(x[j][0]==0&&x[j][1]==0){
				if(max(y[j][0],y[j][1])==i){
					na=true;
				}
			}
		}
		if(na)break;
		dp[i][0]=1;
	}
	for(int i=1;i<=w;i++){
		bool na=false;
		for(int j=0;j<p;j++){
			if(y[j][0]==0&&y[j][1]==0){
				if(max(x[j][0],x[j][1])==i){
					na=true;
				}
			}
		}
		if(na)break;
		dp[0][i]=1;
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			bool na=false;
			for(int k=0;k<p;k++){
				if(x[k][0]==j&&x[k][1]==j){
					if(max(y[k][0],y[k][1])==i){
						na=true;
					}
				}
			}
			if(!na){
				dp[i][j]+=dp[i-1][j];
			}
			na=false;
			for(int k=0;k<p;k++){
				if(y[k][0]==i&&y[k][1]==i){
					if(max(x[k][0],x[k][1])==j){
						na=true;
					}
				}
			}
			if(!na){
				dp[i][j]+=dp[i][j-1];
			}
		}
	}
	if(dp[h][w]==0){
		cout<<"Miserable Hokusai!"<<endl;
	}
	else{
		cout<<dp[h][w]<<endl;
	}
	}
	return 0;
}

Measured memory_bytes: 1164
// JAI SHREE RAM
#pragma GCC optimize("O3")
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define sec second
#define fir first
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(ll (i)=(m);(i)<(n);(i)++)
// #define all(a) (a).begin(),(a).end()
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define MOD 998244353
int n, k, c;
set<ll>st;
std::vector<ll> a,b;
void cnt(string x)
{

	int g = 0;
	for (int i = 0; i < n && g<k ; i++ )
	{
		if (x[i] == 'o')
		{
			g++;
			a.pb(i);
			i += c ;
		}

	}
	g = 0;
	for (int i = n - 1; i >= 0 && g<k ; i-- )
	{
		if (x[i] == 'o')
		{
			g++;
			b.pb(i);
			i -= (c);
		}

	}

	// for (auto el : st)
	// 	cout << el << endl;


	for(int i=0;i<k;i++)
	{
		if(a[i]==b[k-1-i])
			cout<<a[i]+1<<endl;
	}
	return ;
}
void solve()
{
	string s;
	cin >> n >> k >> c;
	cin >> s;
	cnt(s);
}

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	fast
	int T;
	// cin >> T;
	T = 1;
	while (T--)
	{
		solve();
	}
	return 0;
}


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

const int mod = 1e9+7;

long long int dp[1000001];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	memset(dp,-1,sizeof dp);
	dp[0]=1;
	for(int i=1,x;i<=m;i++){
		cin>>x;
		dp[x]=0;
	}
	if(dp[1]!=0)
		dp[1]=1;
	for(int i=2;i<=n;i++)
		if(dp[i]==-1)
			dp[i]=(dp[i-1]+dp[i-2])%mod;
	cout<<dp[n]<<endl;
}



Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int h,w;
char c[2010][2010];
int un[2010][2010],ri[2010][2010];
int le[2010][2010],up[2010][2010];
signed main(){
	cin>>h>>w;
	rep(i,h){
		rep(j,w){
			cin>>c[i][j];
		}
	}
	//up
	rep(j,w){
		int now=0;
		rep(i,h){
			if(c[i][j]=='#'){
				now=0;
				up[i][j]=now;
			}
			else{
				up[i][j]=now;
				now++;
			}
		}
	}
	//under
	rep(j,w){
		int now=0;
		for(int i=h-1;i>=0;i--){
			if(c[i][j]=='#'){
				now=0;
				un[i][j]=now;
			}
			else{
				un[i][j]=now;
				now++;
			}
		}
	}
	//left
	rep(i,h){
		int now=0;
		rep(j,w){
			if(c[i][j]=='#'){
				now=0;
				le[i][j]=now;
			}
			else{
				le[i][j]=now;
				now++;
			}
		}
	}
	//right
	rep(i,h){
		int now=0;
		for(int j=w-1;j>=0;j--){
			if(c[i][j]=='#'){
				now=0;
				ri[i][j]=now;
			}
			else{
				ri[i][j]=now;
				now++;
			}
		}
	}
	int ans=0;
	rep(i,h){
		rep(j,w){
			int cnt=ri[i][j]+le[i][j]+up[i][j]+un[i][j];
			ans=max(ans,cnt);
		}
	}
	cout<<ans+1<<endl;
	return 0;
}


Measured memory_bytes: 67328
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;

    vector<int> a;
    int b = (s[0] == '0'?0:1);
    a.push_back(1);
    for(int i=1;i<n;++i){
        if(s[i] == s[i-1]) {
            ++a.back();
        } else {
            a.push_back(1);
        }
    }
    int m = a.size();

    for(int i=1;i<m;++i) a[i] += a[i-1];

    int ans = 0;
    for(int i=0;i<m;++i) {
        if(b == 0) {
            ans = max(ans, a[min(m-1, i+2*k-1)] - ((i>0)?a[i-1]:0));
        } else {
            ans = max(ans, a[min(m-1, i+2*k)] - ((i>0)?a[i-1]:0));
        }
        b = 1-b;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1020
import java.util.Scanner;
import java.util.*;
class Main {
  public static void main (String args[]) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    if (K >= 1 && K <= Math.pow(10,6)) {
      int c = 7%K;
      Set<Integer> a = new HashSet<Integer>();
      int i = 1;
      while (!a.contains(c)) {
        if (c == 0) {
          break;
        }
        a.add(c);
        c = (c*10+7)%K;
        ++i;
      }
      if (c != 0) {
        System.out.println("-1");
      } else {
        System.out.println(i);
      }
    }
  }
}

Measured memory_bytes: 102548
n  = gets.to_i
r = gets.split.map(&:to_i)
l = []

def sum(ary)
  sum = 0
  ary.each{|a| sum+=a}
  return sum
end

min = Float::INFINITY
while not r.empty?
  min = [(sum(l) - sum(r)).abs, min].min
  l << r.shift
end

p min

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    vector<int> bou(n);
    REP(i, n) cin >> bou[i];
    whole(sort, bou, greater<>());
    ll hen1 = 0, hen2 = 0, cnt = 0;
    REP(i, n){
        if(hen1 and hen2) break;
        else{
            if(cnt == 0) cnt++;
            else if(cnt == 1){
                if(bou[i - 1] == bou[i]){
                    if(!hen1){
                        hen1 = bou[i];
                        cnt = 0;
                    }
                    else{
                        hen2 = bou[i];
                        break;
                    }
                }
            }
            else cnt = 0;
        }
    }

    cout << hen1 * hen2 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 2e3+155;
int n,i,j,triunghiuri,mij,st,dr,a[N];
int main()
{
    cin>>n;
    for (i=1; i<=n; ++i)
        cin>>a[i];
    sort(a+1,a+n+1);
    for (i=1; i<=n; ++i)
    {
        for (j=i+1; j<n; ++j)
        {
            st=j+1;
            dr=n;
            mij=0;
            while (st<dr)
            {
                mij=(st+dr+1)/2;
                if (a[i]+a[j]>a[mij] && a[i]+a[mij]>a[j] && a[j]+a[mij]>a[i])
                    st=mij;
                else
                    dr=mij-1;
            }
            if (a[i]+a[j]>a[st] && a[i]+a[st]>a[j] && a[j]+a[st]>a[i] && st!=i && st!=j)
                triunghiuri+=(st-j);
        }
    }
    cout<<triunghiuri<<"\n";
}


Measured memory_bytes: 256