akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int N, M;
vector<int> G[MAX_N];
bool visited[MAX_N];

int main(void)
{
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    // 0-indexed
    x--, y--;
    // create undirected graph
    G[x].push_back(y);
    G[y].push_back(x);
  }

  int cnum = 0;
  for (int u = 0; u < N; u++) {
    queue<int> q;
    if (!visited[u]) {
      q.push(u);
      cnum++;
    }
    // bfs
    while (!q.empty()) {
      int uu = q.front();
      q.pop();
      visited[uu] = true;
      for (int v : G[uu]) {
        if (!visited[v]) q.push(v);
      }
    }
  }

  cout << cnum << endl;

  return 0;
}


Measured memory_bytes: 6648
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N)cin >> A[i];
    sort(all(A));
    bool bad = 0;
    REP(i,N-1){
        if(A[i] == A[i+1])bad = 1;
    }
    if(bad){
        cout <<"NO"<< "\n";
    }else{
        cout <<"YES"<< "\n";
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main()
{
    while (1) {
        int n, m, k; cin >> n >> m >> k;
        if (!n) break;

        int N = pow(m, n);
        double a = 0;
        loop (N, I) {
            int i = I, sum = 0;
            loop (n, j) {
                sum += (i % m) + 1;
                i /= m;
            }
            sum = max(sum - k, 1);
            a += sum;
        }
        cout << setprecision(9) << fixed;
        cout << a / N << endl;
    }
    return 0;
}

Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
#define SYNC                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007s
#define all(c) c.begin(), c.end()
#define endl '\n'

typedef long long int lli;

int main()
{
    SYNC

        lli k,
        n, q;

    cin >> n >> k >> q;

    vector<lli> myVec(n, k);
    
    map<lli,lli> myMap;
    for(int i=0; i<q; i++)
    {
        int p;
        cin>>p;
        myMap[p] += 1;
    }


    for(int i=0; i<n; i++)
    {
        if(q - myMap[i+1] >= k)
        cout<<"No"<<endl;
        else
        cout<<"Yes"<<endl;

    }


    return 0;
}

Measured memory_bytes: 7680
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    ret = A * B - (A + B - 1)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


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

ll perm(ll n,ll k){
  if(n == 0) return 1;
  return (n%k*perm(n-1,k))%k;
}


int main() {
 ll N,M;
 cin >> N >> M;
 ll k = 1000000000+7;
  int ans = 0;
  if(abs(N-M)>=2) ans = 0;
  else if(abs(N-M) == 0){
    ans = (2*perm(N,k)*perm(M,k))%k;
  }
  else if(abs(N-M) ==1){
    ans = perm(N,k)*perm(M,k)%k;
  }
  
  cout << ans<< endl;
    
}

Measured memory_bytes: 3456
#include "bits/stdc++.h"

#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int k;
  cin >> k;
  vector<pair<char, int>> v;
  v.emplace_back(s[0], 1);
  int n = s.size();
  FOR(i, 1, n) {
    if (v.back().first != s[i]) {
      v.emplace_back(s[i], 1);
    } else {
      v.back().second++;
    }
  }
  if (v.size() == 1) {
    cout << ll(n) * k / 2 << endl;
    return 0;
  }
  ll ans = 0;
  REP(i, v.size()) ans += v[i].second / 2;
  ans *= k;
  if (s.front() == s.back() && v.front().second % 2 == 1 &&
      v.back().second % 2 == 1)
    ans += k - 1;
  cout << ans << endl;
}


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

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

#define roop(i, n) for(int i = 0;i < n;i++)

int main(void){

    string a, b;
    cin >> a >> b;

    a += a;

    bool ok = false;

    roop(i, a.length()-b.length()){
        roop(j, b.length()){
            if(a[i+j] != b[j]) break;
            if(j == b.length()-1) ok = true;
        }
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}



Measured memory_bytes: 3180
#include<iostream>
#include<math.h>
using namespace std;

long long int faktorisasi2(long long int n){
	long long int j = 0;
	while(n%2==0){
		n/=2;
		j++;
	}
	return j;
}

int main(){
	long long int a,b,c;
	scanf("%lld %lld %lld",&a,&b,&c);
	if((a==b && b==c && a==c ) && (a%2==1 && b%2==1 && c%2==1)){
		printf("0\n"); return 0;
	}
	if(a==b && b==c && a==c ){
		printf("-1\n");return 0;
	}
	if(a%2==0 && c%2==0 && b%2==0){
		//first round
		long long int a1 = b/2+c/2;
		long long int b1 = a/2+c/2;
		long long int c1 = b/2+a/2;
//		cout<<a1<<" "<<b1<<" "<<c1<<"\n";
		if((a1==b1 && b1==c1 && a1==c1 ) && (a1%2==1 && b1%2==1 && c1%2==1)){
			printf("1\n"); return 0;
		}
		if(a1==b1 && b1==c1 && a1==c1){
			printf("-1\n");return 0;
		}
		if(a1%2==0 && c1%2==0 && b1%2==0){
			long long int slisiha1 = abs(a-a1);
			long long int slisihb1 = abs(b-b1);
			long long int slisihc1 = abs(c-c1);
			
			if(slisiha1 == 0) slisiha1 = 2e9;	
			if(slisihb1 == 0) slisihb1 = 2e9;
			if(slisihc1 == 0) slisihc1 = 2e9;
			
			//bisa aja bil lbh kecil tapi mengandung faktor 2 lebih banyak
			long long int n = min(faktorisasi2(slisiha1),min(faktorisasi2(slisihb1),faktorisasi2(slisihc1)));
			printf("%lld\n",n+1);
			
		}else printf("1\n");
	}else printf("0\n");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);
int dp[(int)1e7][2];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    reverse(ALL(s));
    s.push_back('0');
    int n = s.size();
    rep(i,1e7)dp[i][0] = dp[i][1] = 1e9+7;
    dp[0][0] = 0;
    rep(i,n)rep(j,2){
        int x = s[i] - '0';
        x += j;
        rep(a,10){
            int b = a - x;
            int ni = i+1,nj = 0;
            if(b<0){
                nj = 1;
                b += 10;
            }
            dp[ni][nj] = min(dp[ni][nj],dp[i][j] + a + b);
        }
    }
    cout << dp[n][0] << endl;
}

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

int main(){
  int K, X;
  cin >> K >> X;

  int left;
  if (X - K + 1 >= -1000000){
    left = X - K + 1;
  }
  else
  {
    left = -1000000;
  }

  int right;
  if (X + K - 1 <= 1000000){
    right = X + K - 1;
  }
  else
  {
    right = 1000000;
  }

  for (int i = left; i <= right; i++){
    cout << i;
    if (i != right) cout << " ";
  }

  cout << "" << endl;
  
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <cfenv>
#include <cmath>
#include <string>
#include <algorithm>
#include <cassert>
#include <functional>
#include <deque>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  vector<ll> cnt(n,0);
  rep(i,n){
    cin >> v[i];
    cnt[v[i]-1]++;
  }

  ll ret = 0;
  rep(i,n){
    ret += cnt[i]*(cnt[i]-1)/2;
  }

  rep(i,n){
    cout << ret-cnt[v[i]-1]+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 4992
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
    int n,i;
    int q[100];
    int kaisu=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>q[i];
    }
    for(int i=0;i<n-1;i++){
        int minj = i;
        for(int j = i+1;j<n;j++){
            if(q[j]<q[minj]){
                minj = j;
            }
        }
        if(i!=minj){
            swap(q[minj],q[i]);
            kaisu++;
        }
    }
    
    for(i=0;i<n;i++){
        if(i<n-1)cout<<q[i]<<' ';
        else cout<<q[i]<<endl;
        
    }
    cout<<kaisu<<endl;
    return 0;
}






Measured memory_bytes: 3100
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        st: [(chars, i64); n],
        x: chars,
    }
    let mut idx = 0;
    for i in 0..n {
        if st[i].0 == x {
            idx = i;
            break;
        }
    }
    let mut tot = 0;
    for i in idx + 1..n {
        tot += st[i].1;
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define fast_io() ios::sync_with_stdio(false); cin.tie(nullptr)
#define fix(n) fixed << setprecision(n)

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    fast_io();
    ll n;
    cin >> n;
    ll count = 0;
    rep(i,n){
        rep(j,n){
            rep(k,n)count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    int a,b;
    Scd(N);
    vector<bool> v(N,false);
    vector< vector<int> > e(N);

    Rep(i,N-1){
        Scd2(a,b);
        a--, b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    int rad = 0;
    using pii = pair<int,int>;
    deque< pii > s;

    s.push_back( pii(0,1) );

    pii tmpii;
    while( !s.empty() ){
        tmpii = s.front();
        s.pop_front();
        int from = tmpii.first;
        int dep = tmpii.second;
        for( int to : e[from] ){
            if( !v[to] ){
                s.push_back( pii( to,dep+1 ));
                v[to] = true;
            }
        }
    }
    v.assign(N,false);
    tmpii.second = 1;
    s.push_back( tmpii );
    while( !s.empty() ){
        tmpii = s.front();
        s.pop_front();
        int from = tmpii.first;
        int dep = tmpii.second;
        for( int to : e[from] ){
            if( !v[to] ){
                s.push_back( pii( to,dep+1 ));
                v[to] = true;
            }
        }
    }
    int ans = tmpii.second;

    printf ("%s\n", ans % 3 != 2 ? "First" : "Second" );



    return 0;
}



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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){
     string S;
     cin >> S;
    int N = (S.at(0) - '0') * 111;
    int ans;
    if(stoi(S) <= N) ans = N;
    else  ans = N + 111;
     print(ans);
}


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

int main() {
  long long N,M,x,y,z;
  z=0;
  cin >>N>>M;
  vector<long long>a(N),b(N),c(M),d(M),e(N);
  for(int i=0;i<N;i++){
    cin>>a[i]>>b[i];
  }
    for(int i=0;i<M;i++){
    cin>>c[i]>>d[i];
  }
    for(int i=0;i<N;i++){
z=1000000000;
        for(int j=0;j<M;j++){
   x=abs(a[i]-c[j])+abs(b[i]-d[j]);
          if(x<z){
            e[i]=j+1;
            z=x;
          }
        }
  }
  for(int i=0;i<N;i++){
    cout<<e[i]<<endl;
  }
}

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

using namespace std;

typedef long long i64;

const i64 NMAX = 200;
const i64 VMAX = 1e5;
const i64 MOD  = 1e9 + 7;

i64 d[NMAX+2][VMAX+2];
i64 v[NMAX+2];
i64 N, start;

int main()
{
    cin >> N >> start;
    for( i64 i = 1;  i <= N;  ++i ) {
        cin >> v[i];
    }
    sort( v +1, v+N+1 );
    for( i64 val = 0;  val <= VMAX;  ++val )
        d[1][val] = val % v[1];
    for( i64 i = 2;  i <= N;  ++i ) {
        for( i64 val = 0;  val <= VMAX;  ++val ) {
            d[i][val] = d[i - 1][val % v[i]] + 1LL * (i - 1) * (d[i - 1][val]);
            d[i][val] %= MOD;
        }
    }
    cout << d[N][start] << '\n';
    return 0;
}


Measured memory_bytes: 157184
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pop_b pop_back
#define pf push_front
#define pop_f pop_front
#define mt make_tuple
#define eb emplace_back
#define sf(x) sizeof(x)
#define len(x) x.length()
#define sz(x) x.size()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef long double ld; 
typedef vector<int> vi;
typedef vector<set<ll>> vset;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef deque<ll> dql;
typedef deque<int> dqi;
typedef unsigned long long ull;
typedef tuple<int,int,int> State;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define vmax(type)   std::numeric_limits<type>::max()
#define vmin(type)   std::numeric_limits<type>::min()
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;
#define resize_vec(a) a.resize(unique(a.begin(), a.end()) - a.begin());
#define ms(dp, x) memset(dp, x, sf(dp))
#define endl '\n'

ll powm(ll a, ll b, ll mod) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const ll mod = 10002667;
const ll mod1 = 10000000019;
const ll N = 100005;
const ll inf = 1e9;

vi a;
ll n, k;

bool chk(ll val)
{
	ll rem = k;
	repr(i, n){
		rem -= (a[i] - 1)/ val ;
	}
	if(rem >= 0)
		return 1;
	return 0;
}

void solve()
{
	cin>>n>>k;
	a.resize(n);
	rep(i, n)
		cin>>a[i];

	sort(range(a));
	ll l = 1, r = 1e9 + 1, md = -1;
	while(l < r){
		ll mid = (r + l) / 2;
		if(md == mid)
			mid--;
		md = mid;
		if(chk(mid))
			r = mid;
		else
			l = 1+mid;
	}
	cout<<l<<endl;
}

// #define _DEBUG 
// #define testCases
signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cout << fixed << setprecision(15);
	
	int tc = 1;
#ifdef testCases
	cin>>tc;
#endif
	while(tc--)
	{
#ifdef _DEBUG
	int tt = clock();
#endif
		solve();
		
#ifdef _DEBUG
		cerr << "TIME = " << clock() - tt << endl;
		tt = clock();
#endif
	}
	return 0;
}



Measured memory_bytes: 3988
#include<stdio.h>

int main(){

	int a, b;
	char op;

	while(1){
		scanf("%d %c %d", &a, &op, &b);

		if(op == '?'){
			break;
		} else if(op == '+') {
			printf("%d\n", a + b);
		} else if(op == '-') {
			printf("%d\n", a - b);
		} else if(op == '*') {
			printf("%d\n", a * b);
		} else if(op == '/') {
			printf("%d\n", a / b);
		}

	}

	return 0;

}

Measured memory_bytes: 1028
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (abs(b-a) > 1)
    {
        printf("0\n");
        return 0;
    }

    const int m = 1000000007;
    if (a==b)
    {
        long long sol = 1;
        for(int i = 1; i <= a; i++)
            sol = (sol*i)%m;
        sol  = (sol*sol*2)%m;
        printf("%d\n",sol);
    }
    else
    {
        long long sol = 1;
        a = min(a,b);
        for(int i = 1; i <= a; i++)
            sol = (sol*i)%m;
        sol  = ((sol*sol)%m*(a+1))%m;
        printf("%d\n",sol);
    }
    return 0;
}


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

class Rect {
public:
	int x, y;

	int area() const
	{
		return x*y;
	}

	bool operator < (const Rect& r) const
	{
		return area() < r.area();
	}
};



int main()
{
	while (true) {
		int n, w, d;

		cin >> n >> w >> d;

		if (n == 0 && w == 0 && d == 0) {
			break;
		}

		vector<Rect> rects(1);
		rects[0].x = w;
		rects[0].y = d;

		for (int i = 0; i < n; i++) {
			int p, s;

			cin >> p >> s;

			Rect rect = rects[p - 1];
			Rect r1, r2;

			s %= (rect.x + rect.y) * 2;

			if (s < rect.x) {
				r1.x = s;
				r1.y = rect.y;
				r2.x = rect.x - s;
				r2.y = rect.y;
			}
			else if (s - rect.x < rect.y) {
				r1.x = rect.x;
				r1.y = s - rect.x;
				r2.x = rect.x;
				r2.y = rect.y - (s - rect.x);
			}
			else if (s - rect.x - rect.y < rect.x) {
				r1.x = s - rect.x - rect.y;
				r1.y = rect.y;
				r2.x = rect.x - (s - rect.x - rect.y);
				r2.y = rect.y;
			}
			else {
				r1.x = rect.x;
				r1.y = s - rect.x - rect.y - rect.x;
				r2.x = rect.x;
				r2.y = rect.y - (s - rect.x - rect.y - rect.x);
			}

			rects.erase(rects.begin() + p - 1);

			if (r1.area() < r2.area()) {
				rects.push_back(r1);
				rects.push_back(r2);
			}
			else {
				rects.push_back(r2);
				rects.push_back(r1);
			}
		}

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

		for (int i = 0; i <= n; i++) {
			cout << rects[i].area();

			if (i != n) {
				cout << " ";
			}
			else {
				cout << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3080
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(p,q) ((p>q)?(p):(q))
#define MIN(p,q) ((p<q)?(p):(q))

#define REP(i,n) for(i=0;i<n;i++)
void solve(int n);

int main(void)
{
  int n;
  scanf("%d",&n);
  solve(n);
  return 0;  
}

void solve(int n)
{
   int a = (n % 2 == 0)? 0 : 1;
   int m = (a - n) / 2;
   if(m != 0) solve(m);
   printf("%d",a);
}



Measured memory_bytes: 128
import numpy as np

def find_nearest(array, value):
    min_value = np.abs(max(array))
    min_idx = 0
    j = 0
    idx = np.abs(value - np.asarray(array)).argmin()

    #for i in array: 
     #   j += 1
      #  if(min_value > np.abs(value - i)):
       #     min_value = np.abs(value - i)
        #    min_idx = j
    return idx + 1

input_N = input()
input_two = input().split()
input_three = input().split()

N = int(input_N)
T = int(input_two[0])
A = float(input_two[1])

H_f = [float(s) for s in input_three]
j = 0
degree_list = list(range(j))
for i in H_f:
    degree_list.append(T-i*0.006)

print(find_nearest(degree_list, A))

Measured memory_bytes: 12448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}

//bool dp[81][81][13000];
vector<vector<vector<bool>>> dp(81, vector<vector<bool>>(81, vector<bool>(13010,false)));
vector<vector<int>> A,B,C;

int main() {
  int H,W; cin >> H >> W;
  A.resize(H, vector<int>(W)); B.resize(H, vector<int>(W)); C.resize(H, vector<int>(W));
  rep(i,H) {
    rep(j,W) cin >> A[i][j];
  }

  rep(i,H) {
    rep(j,W) cin >> B[i][j];
  }

  rep(i,H) {
    rep(j,W) C[i][j] = abs(A[i][j] - B[i][j]);
  }

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      for (int k = 0; k < 13000; k++) {
        if (i == 1 && j == 1) {
          dp[1][1][C[0][0]] = true;
          break;
        }
        if (dp[i][j-1][k]) {
          dp[i][j][k+C[i-1][j-1]] = true;
          dp[i][j][abs(k - C[i-1][j-1])] = true;
        } 
        if (dp[i-1][j][k]) {
          dp[i][j][k+C[i-1][j-1]] = true;
          dp[i][j][abs(k - C[i-1][j-1])] = true;
        }
      }
    }
  }
  int ans;
  for (int i = 0; i < 13000; i++) {
    if (dp[H][W][i]) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 13184
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
using namespace std;



int main(){
  string S;
  cin>>S;
  if(S=="Sunny") cout<<"Cloudy"<<endl;
  else if(S=="Cloudy") cout<<"Rainy"<<endl;
  else if(S=="Rainy") cout<<"Sunny"<<endl;
  return 0;
}



Measured memory_bytes: 256
#include "stdio.h"

int main(void){
  int N;
  scanf("%d",&N);
  
  int W[N];
  for(int i=0; i<N; i++){
    scanf("%d",&W[i]);  
  }
  int S[2]={0,0};
  int wareme=1;
  int min=999;
  int sa_temp;
  for(int i=0; i<N; i++){
    S[0]=0;
    S[1]=0;
    for(int j=0; j<N; j++){
      if(j<wareme)
        S[0]+=W[j];
      else
        S[1]+=W[j];
    }
    sa_temp=S[0]-S[1];
    if(sa_temp <0)
      sa_temp*=-1;
    if(sa_temp<min)
      min=sa_temp;
    wareme++;
  }
  printf("%d",min);
}


Measured memory_bytes: 128
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cins(S); Cins(T);
    int ans =0;
    rep(i,S.length())if(S[i]==T[i])ans++;
    cout << ans << nn;
    return 0;
}

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

if N == 1:
    print("Yes")
else:
    for i in range(N-1, 0, -1):
        #print(H[i-1], H[i])
        if H[i-1] <= H[i]:
            #print("@")
            continue
        elif (H[i-1] - 1) == H[i]:
            #print("#")
            H[i-1] = H[i]
        else:
            #print("=")
            break
    
    if i == 1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#define pb push_back
 
int main() {
 
    double n , m;
    cin >> n >> m ;
    vector<double> v(n) ;
    ll i ;
    double sum=0;
    for(i=0;i<n;i++) { cin >> v[i] ; sum+=v[i] ;}
    sort(v.begin(),v.end()) ;
    reverse(v.begin(),v.end()) ;
    ll tot = 0 ;
    for(i=0;i<n;i++) {
        if (v[i]>=(1/(4*m))*sum) tot++ ;
    }
    if (tot>=m) cout << "Yes\n" ;
    else cout << "No\n" ;
 
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int num,temp,sum,i;
    while (1) {
        scanf("%d\n",&num);
        if (num==0) break;
        sum=0;
        for (i=0; i<num/4; i++) {
            scanf("%d\n",&temp);
            sum+=temp;
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 604
N, W = map(int, input().split())
items = []
for _ in range(N):
    n, w = map(int, input().split())
    items.append([n, w])

C = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(1, N+1):
    for w in range(1, W+1):
        if items[i-1][1] <= w:
            if items[i-1][0] + C[i-1][w-items[i-1][1]] > C[i-1][w]:
                C[i][w] = items[i-1][0] + C[i-1][w-items[i-1][1]]
            else:
                C[i][w] = C[i-1][w]
        else:
            C[i][w] = C[i-1][w]
print(C[-1][-1])

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

int main(){
  int a;
  cin >> a;
  
  if( a % 1111 == 0 ){
    cout << "Yes" << endl;
  }else{
   	if( a/10 % 111 ==  0 ){
	    cout << "Yes" << endl;
    }else if( a % 10 % 111 == 0 ){
	    cout << "Yes" << endl;
    }else{
	    cout << "No" << endl;           
    }
  }
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = long long;
int main()
{
	ll a,b,k;
	cin>>a>>b>>k;
	   if(a>=k)
		{
			a=a-k;
			k=0;
		}
		else
		{
			k=k-a;
			a=0;
		}

		if(b>=k)
		{
			b=b-k;
			k=0;
		}
		else
		{
			k=k-b;
			b=0;
		}
	
	cout<<a<<" "<<b<<endl;
	return 0;
}

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

int main(){
    int h, w; cin >> h >> w;
    vector<vector<char>> mp(h, vector<char> (w));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> mp[i][j];
        }
    }
    int L[h][w], R[h][w], U[h][w], D[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(mp[i][j] == '#') L[i][j] = 0;
            else if (j == 0) L[i][j] = 1;
            else L[i][j] = L[i][j - 1] + 1;

            if(mp[i][j] == '#') U[i][j] = 0;
            else if (i == 0) U[i][j] = 1;
            else U[i][j] = U[i - 1][j] + 1;

            if(mp[i][w-1-j] == '#') R[i][w-1-j] = 0;
            else if (j == 0) R[i][w-1-j] = 1;
            else R[i][w-1-j] = R[i][w-j] + 1;

            if(mp[h-1-i][j] == '#') D[h-1-i][j] = 0;
            else if (i == 0) D[h-1-i][j] = 1;
            else D[h-1-i][j] = D[h-i][j] + 1;
        }
    }
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            //cout << L[i][j] << R[i][j] << U[i][j] << D[i][j] << endl;
            ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
        }
        //cout << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 66688
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,j,k,l,m,x,a,b;
    cin >> x;
    for(i=-1000; i<1000; i++)
    {
        for(j=-1000; j<1000; j++)
        {
            if(i*i*i*i*i - j*j*j*j*j == x)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}


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

int main(void){
	char str[26];

	cin >> str;
	for(int i=0; str[i] != '\0'; i++){
		for(int j = i+1; str[j] != '\0'; j++){
			if(str[i] == str[j]){
				cout << "no" << endl;
				return 0;
			}
		}
	}
	cout << "yes" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a,b,c,ans;
  ans=0;
  while(scanf("%d%d%d",&a,&b,&c)!=3);
  if(c<a+b+1){
	ans+=c+b;
  }else{
    ans+=a+b+1+b;
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
n = gets.to_i

def exchange(value:, unit:)
  case unit
  when 'BTC'
    value.to_f * 380000.0
  else
    value.to_f
  end
end

otoshidama_jpy = []
n.times do |_ni|
  value, unit = gets.split
  otoshidama_jpy << exchange(value: value, unit: unit)
end
puts otoshidama_jpy.inject(:+)


Measured memory_bytes: 1788
func calculateSatisfactionPoint(D: Int, cs: [Int], ss: [[Int]], ts: [Int]) -> Int {
    var lastContestDate: [Int] = Array(repeating: 0, count: 26)
    var vs: [Int] = [0]
    for d in 1...D {
        let todayContestType: Int = ts[d-1]
        vs.append(vs[d-1] + ss[d-1][todayContestType-1])
        lastContestDate[todayContestType-1] = d
        
        var decreaseSatisfactionPoint: Int = 0
        for i in 0..<26 {
            decreaseSatisfactionPoint -= cs[i]*(d - lastContestDate[i])
        }
        vs[d] += decreaseSatisfactionPoint
    }
    return vs[D]
}

func localOptimizationPiece(d: Int, q: Int) {
    let oldType: Int = ts[d - 1]
    ts[d - 1] = q

    var oldTypeBfd: Int = 0
    if let idx = ts[..<(d - 1)].lastIndex(of: oldType) { oldTypeBfd = idx + 1 }
    var oldTypeAfd: Int = D + 1
    if let idx = ts[d...].firstIndex(of: oldType) { oldTypeAfd = idx + 1 }

    var newTypeBfd: Int = 0
    if let idx = ts[..<(d - 1)].lastIndex(of: q) { newTypeBfd = idx + 1 }
    var newTypeAfd: Int = D + 1
    if let idx = ts[d...].firstIndex(of: q) { newTypeAfd = idx + 1 }
    
    let dScore: Int = ss[d - 1][q - 1] - ss[d - 1][oldType - 1] - (d - oldTypeBfd)*(oldTypeAfd - d)*cs[oldType - 1] + (d - newTypeBfd)*(newTypeAfd - d)*cs[q - 1]
    score += dScore
}

let D = Int(readLine()!)!
let cs: [Int] = readLine()!.split(separator: " ").map { Int($0)! }
let ss: [[Int]] = (1...D).map { _ in readLine()!.split(separator: " ").map { Int($0)! } }

var ts: [Int] = (1...D).map { _ in Int(readLine()!)! }
let M = Int(readLine()!)!
let dq: [[Int]] = (1...M).map { _ in readLine()!.split(separator: " ").map { Int($0)! } }

var score: Int = calculateSatisfactionPoint(D: D, cs: cs, ss: ss, ts: ts)

for i in 0..<M {
    localOptimizationPiece(d: dq[i][0], q: dq[i][1])
    print(score)	// (๑•ૅㅁ•๑)
}

Measured memory_bytes: 15132
from collections import defaultdict
N, K = map(int, input().strip().split())
ab = [list(map(int, input().strip().split())) for _ in range(N)]

dic = defaultdict(int)
for a, b in ab:
  dic[a] += b

cnt = 0
for i in range(1, 10**5+1):
  cnt += dic[i]
  if cnt >= K:
    print(i)
    break
  

Measured memory_bytes: 39816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    string s; cin >> s;

    if(s.size() == 2) {
        if(s[0] == s[1]) { cout << 1 << " " << 2 << endl; return 0; }
        else { cout << -1 << " " << -1 <<  endl; return 0; }
    }

    rep(i,s.size() - 2) {
        vei cnt(26, 0);
        string t = s.substr(i,3);
        rep(j,3) cnt[ t[j] - 'a' ]++;
        rep(j,26) if(cnt[j] >= 2) { cout << i+1 << " " << i + 3 << endl; return 0; }
    }
    cout << -1 << " " <<  -1 << endl;
    return 0;
}

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

int main(){
  int N;
  string S;
  cin >> N>>S;
  int ans=0;
  int sum=0;
  
  for (int i=0;i<N;i++){
    if(S[i]=='I'){
      sum++;
    }
    else{
      sum--;
    }
    ans = max(ans,sum);
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[103]={0};
int main()
{
int x,n;
scanf("%d %d",&x,&n);
for(int i=0;i<n;i++)
{
	int y;
	scanf("%d",&y);
	a[y]=-1;
}
int mn=10000000,ab,ans=10000;
for(int i=0;i<103;i++)
{
	if(a[i]==-1)continue;
	if(!a[i])
	ab = fabs(x-i);
	if(ab<mn)
	{
		mn=ab;
		ans=i;
	}
	
}

printf("%d\n",ans);

}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
#define ll long long
#define gcd(x,y) __gcd(x,y)
#define fi first
#define se second
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline ll abs(A &a) { return (a < 0 ? -a : a); }
using namespace std;
const ll inf=(1LL<<62);
const ll MOD=(1e9)+7;
const ll mod=998244353;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << "ACL";
  }
  cout << "\n";
  
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    string s;
    cin >> s;
    int a = s.length();
    int l,r,ans,b = s[a/2];
    if (a%2){
        ans = a/2+1;
        l = a/2-1;
        r = a/2+1;
    }
    else{
        ans = a/2;
        l = a/2-1;
        r = a/2;
    }
    while(l >= 0 && s[l] == b && s[r] == b){
        ans += 1;
        l--;
        r++;
    }
    PRINT(ans);
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#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 fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<ll,ll> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]

const ll MOD=10000000000000000;
int main(){
  int n; cin >> n;
  cout << "ABC";
  cout <<n;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a<=5){
		printf("0\n");
	}
	if(a>=13){
		printf("%d\n",b);
	}
	if(a>=6 && a<=12){
		printf("%d\n",b/2);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
using namespace std;
const constexpr int INF = 1e9;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9 + 7;
const int BITSIZE = 100010;

struct Less {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.second < y.second;
	}
};
struct More {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.first > y.first;
	}
};
//1-indexed
int bit[100010];

int bit_query(int i) {
	int res = 0;
	for (; i >= 1; i -= i & -i) res = max(res, bit[i]);
	return res;
}

void bit_set(int x, int v) {
	for (; x <= BITSIZE; x += x & -x) {
		bit[x] = max(bit[x], v);
	}
}
ll combination(ll n, ll r)
{
    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (combination(n - 1, r - 1)%MOD + combination(n - 1, r)%MOD);
}
ll pow_mod(ll a, ll b){
    ll sum =1;
    while(b>0){
        if(b&1){
            sum *= a%MOD;
        }
        a = a* a%MOD;
        b >>= 1;
    }
    return sum;
}
ll a[110];

int main() {
    int N; cin >> N;
    a[0]=2;
    a[1]=1;
    for(int i=2; i<=N; ++i){
        a[i] = a[i-1] + a[i-2];
    }
    cout << a[N] << endl;
	return 0;
}

Measured memory_bytes: 256
/* *****fireice**** */

#include<bits/stdc++.h>

#define ll long long int
#define ld long double
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pb push_back
#define el '\n'
#define N 1000000007
#define re return
#define F first
#define S second
#define L length
#define mp make_pair
#define PI 3.14159265
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int i=0;i<n;i++)
#define forf(i,x,n) for(int i=x;i<n;i++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
#define take(a,n) forup(i,n) cin>>a[i];
using namespace std;

int gcdExtended(int a, int b, int *x, int *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    int x1, y1; // To store results of recursive call
    int gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}

ll modInverse(int a, int m)
{
    int x, y;
    int g = gcdExtended(a, m, &x, &y);
        // m is added to handle negative x
    ll res = ((ll)x%m + (ll)m) % m;

    return res;
}

ll poww(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return poww(x*x,n/2);
    else                             //n is odd
        return x*poww(x*x,(n-1)/2);
}

ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

inline ll max(ll a, ll b)
{
  if(a>b) re a;
  else re b;
}

inline ll min(ll a, ll b)
{
  if(a>b) re b;
  else re a;
}

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

    if (a == b)
        return a;

    if (a > b)
        return gcd(a-b, b);
    else return gcd(a, b-a);
}

ll ncr(int n,int r)
{
  ll ans=1;
  r=min(r,n-r);
  forup(i,r)
  {
    ans=(ans*(n-i)/(i+1))%N;
  }
  re ans;
}

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

  int t=1;
  //cin>>t;
  while(t--)
  {
    ll n,m;
    ld k;
    cin>>n>>k;
    int a[n];
    m=0;
    forup(i,n)
    {
      cin>>a[i];
      m+=a[i];
    }

    sort(a,a+n,greater<int>());
    if(a[(int)k-1]<((ld)m/(4*k))){cout<<"No";}
    else cout<<"Yes";

  }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define REP(i, n) FOR(i, 1, ll(n) + 1)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

struct MAX {
    ll mx1, mx2;
    void f(const ll a) {
        if(mx1 < a) {
            mx2 = mx1;
            mx1 = a;
        } else
            chmax(mx2, a);
    }
    void f(const MAX m) {
        f(m.mx1);
        f(m.mx2);
    }
    ll sum() { return mx1 + mx2; }
};

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

    int n;
    cin >> n;

    vector<MAX> mx(1 << n);
    rep(i, 1 << n) {
        ll a;
        cin >> a;
        mx[i] = {a, -inf};
    }
    rep(j, n) rep(i, 1 << n) {
        if((i >> j & 1)) mx[i].f(mx[i ^ (1 << j)]);
    }

    ll ret = 0;
    FOR(i, 1, 1 << n) cout << (ret = max(ret, mx[i].sum())) << endl;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ll n, k;
	cin>>n>>k;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	vector<ll> dp(n, INT_MAX);
	dp[0]=0;
	ll sum=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<=i+k and j<n;j++){
			dp[j]=min(dp[j], dp[i]+abs(a[j]-a[i]));
		}
	}
	cout<<dp[n-1]<<endl;		
	// your code goes here
	return 0;
}

Measured memory_bytes: 1792
using System;

namespace MSTrust2019C
{
    class Program
    {
        private static bool Solve(int n)
        {
            if (n < 100) return false;
            if (n >= 2000) return true;
            for (int i = 1; i < 20; ++i)
            {
                if (n < 100 * (i + 1))
                {
                    return !(100 * i + 5 * i + 1 <= n);
                }
            }
            return false;
        }

        static void Main(string[] args)
        {
            var line = Console.ReadLine();
            var n = Convert.ToInt32(line);
            Console.WriteLine(Solve(n) ? 1 : 0);
        }
    }
}


Measured memory_bytes: 13268