akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int MAX = 1e4;
constexpr int NIL = -1;
struct Node { int parent = NIL, left = NIL, right = NIL; };
vector<Node> T(MAX);
vi D(MAX), H(MAX);
inline void setDepth(int u, int d) {
	if(u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d + 1);
	setDepth(T[u].right, d + 1);
}
inline int setHeight(int u) {
	int h1 = 0, h2 = 0;
	if(T[u].left != NIL)
		h1 = setHeight(T[u].left) + 1;
	if(T[u].right != NIL)
		h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1 : h2);
}
inline int getSibling(int u) {
	if(T[u].parent == NIL) return NIL;
	if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
		return T[T[u].parent].left;
	if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
		return T[T[u].parent].right;
	return NIL;
}
int main() {
	int n; cin >> n;
	int v, l, r;
	rep(i, 0, n) {
		cin >> v >> l >> r;
		T[v].left = l;
		T[v].right = r;
		if(l != NIL) T[l].parent = v;
		if(r != NIL) T[r].parent = v;
	}
	int root;
	rep(i, 0, n) if(T[i].parent == NIL) { root = i; break; }
	setDepth(root, 0);
	setHeight(root);
	rep(u, 0, n) {
		cout << "node " << u << ": "
			<< "parent = " << T[u].parent << ", "
			<< "sibling = " << getSibling(u) << ", ";
		int deg = 0;
		if(T[u].left != NIL) ++deg;
		if(T[u].right != NIL) ++deg;
		cout << "degree = " << deg << ", "
			<< "depth = " << D[u] << ", "
			<< "height = " << H[u] << ", ";
		if(T[u].parent == NIL) P("root");
		else if(T[u].left == NIL && T[u].right == NIL) P("leaf");
		else P("internal node");
	}
	return 0;
}

Measured memory_bytes: 3252
import java.util.Scanner;

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

        int num = 7;
        int cnt = 1;


        if(k % 2 == 0 ) {System.out.println(-1); return;}
        else{
            for (int i = 0; i< k; i++){
                
                if(num % k == 0){
                    System.out.println(cnt);
                    return;
                }else{
                    num = (num*10 + 7 ) % k; //这一步很关键，判断余数是不是所给数倍数即可
                    cnt++;
                }
            }
            System.out.println(-1);
            

        }
    }
    
}

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

int main(){
        int n, k;
        scanf("%d %d", &n, &k);
        std::vector<int> a(n);
        for(int i=0; i<n; i++) scanf("%d", &a[i]);

        std::vector<int> dp(n, 1e11);
        dp[0] = 0;
        for(int i=0; i<n; i++){
                for(int j=0; j<=k; j++){
                        if(i-j>=0) dp[i] = std::min(dp[i], dp[i-j]+abs(a[i]-a[i-j]));
                }
        }

        printf("%d\n", dp[n-1]);
        return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int dp[44][444][444];
const int INF = 1e9 + 7;
int N,A,B;

int main(){
	scanf("%d%d%d" , &N , &A , &B);
	repp(i,0,N+1){
		repp(j,0,444){
			fill(dp[i][j],dp[i][j]+444,INF);
		}
	}
	dp[0][0][0] = 0;
	repp(i,1,N+1){
		int x,y,z;
		scanf("%d%d%d" , &x , &y , &z);
		repp(j,0,401){
			repp(k,0,401){
				dp[i][j][k] = dp[i-1][j][k];
			}
		}
		repm(j,400-x,-1){
			repm(k,400-y,-1){
				dp[i][j+x][k+y] = min(dp[i][j+x][k+y] , dp[i-1][j][k] + z);
			}
		}
	}
	int ans = INF;
	for(int i = 1 ; i * A <= 400 && i * B <= 400 ; ++i){
		ans = min(ans , dp[N][i*A][i*B]);
	}
	if(ans == INF){
		printf("-1\n");
	} else {
		printf("%d\n" , ans);
	}
	return 0;
}


Measured memory_bytes: 32896
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    int four = 0;
    int two = 0;

    for(int i = 0;i < n;i++){
        cin >> a[i];
        if(a[i] % 4 == 0){
            four++;
        }else if(a[i] % 2 == 0){
            two++;
        }
    }

    if(four + two/2 >= n/2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }



    return 0;
}

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

template <int MOD=1000000007>
struct Modular {
  int value;
  static const int MOD_value = MOD;

  Modular(long long v = 0) { value = v % MOD; if (value < 0) value += MOD;}
  Modular(long long a, long long b) : value(0){ *this += a; *this /= b;}

  Modular& operator+=(Modular const& b) {value += b.value; if (value >= MOD) value -= MOD; return *this;}
  Modular& operator-=(Modular const& b) {value -= b.value; if (value < 0) value += MOD;return *this;}
  Modular& operator*=(Modular const& b) {value = (long long)value * b.value % MOD;return *this;}

  friend Modular mexp(Modular a, long long e) {
    Modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
    return res;
  }
  friend Modular inverse(Modular a) { return mexp(a, MOD - 2); }

  Modular& operator/=(Modular const& b) { return *this *= inverse(b); }
  friend Modular operator+(Modular a, Modular const b) { return a += b; }
  friend Modular operator-(Modular a, Modular const b) { return a -= b; }
  friend Modular operator-(Modular const a) { return 0 - a; }
  friend Modular operator*(Modular a, Modular const b) { return a *= b; }
  friend Modular operator/(Modular a, Modular const b) { return a /= b; }
  friend std::ostream& operator<<(std::ostream& os, Modular const& a) {return os << a.value;}
  friend bool operator==(Modular const& a, Modular const& b) {return a.value == b.value;}
  friend bool operator!=(Modular const& a, Modular const& b) {return a.value != b.value;}
};

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n, a, b, c;
  cin >> n >> a >> b >> c;

  Modular<> ans = 0, pa[2 * n + 1], pb[2 * n + 1], fact[2 * n + 1], inv[2 * n + 1], ab[2 * n + 1];
  pa[0] = pb[0] = fact[0] = inv[0] = ab[0] = 1;

  for (int i = 1; i <= 2 * n; ++i) {
    pa[i] = (a * pa[i-1]);
    pb[i] = (b * pb[i-1]);
    fact[i] = i * fact[i-1];
    inv[i] = 1 / fact[i];
    ab[i] = ab[i-1] * (a + b);
  }

  auto ncr = [&](int nn, int r) {
    return fact[nn] * inv[nn-r] * inv[r];
  };

  for (int i = 0; i < n; ++i) {
   ans += (n + i) * ncr(n + i - 1, i) * (pa[n] * pb[i] + pb[n] * pa[i]) / ab[n + i];
  }

  ans *= 100;
  ans /= (100 - c);
  cout << ans << '\n';
}


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

int main() {
    ll k;
    cin>>k;
    queue<ll> que;
    rep(i,9)que.push(i+1);
    rep(i,k-1){
        ll now=que.front();
        que.pop();
        if(now%10!=0)que.push(now*10+now%10-1);
        que.push(now*10+now%10);
        if(now%10!=9)que.push(now*10+now%10+1);
    }
    cout<<que.front()<<endl;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

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

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int N; map<string,int> M;
void input()
{
    cin>>N;
    rep(i,N){
        string a; cin>>a; M[a]++;
    }
    return;
}

void solve()
{
    int ma=0;
    for(auto itr=M.begin();itr != M.end(); ++itr){
        ma=max(ma,itr->second);
    }
    for(auto itr=M.begin();itr != M.end(); ++itr){
        if(itr->second==ma) cout<<itr->first<<endl;
    }
    return;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,pas,f[1009];
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a;
	for(c=1; c<=a; c++) cin>>f[c];
	for(b=1; b<=a; b++){
		for(c=b+1; c<=a; c++){
			pas+=f[b]*f[c];
		}
	}
	cout<<pas;
	return 0;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

typedef std::pair<long long, long long> pr;

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

	int N, M;
	std::vector<pr> v;
	cin >> N >> M;
	for(int i = 0; i < N; i++){
		long long a, b;
		cin >> a >> b;
		v.push_back(pr(a, b));
	}

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

	long long ans = 0, m = 0;
	for(int i = 0; i < N; i++){
		long long a, b;
		a = v[i].first;
		b = min(M - m, v[i].second);
		ans += a * b;
		m += b;
		if(m >= M)
			break;
	}
	cout << ans << endl ;
	return 0;
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
  
	int n, k; cin >> n >> k;
	vector<int> h(n), dp(n, INT_MAX);
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i - 1; j >= max(0, i - k); --j) {
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}
	cout << dp[n - 1] << endl;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(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 mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll X;
  cin >> X;
  ll d = (X-400)/200;
  cout << 8 - d;
  return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int n;
	cin >> n;
	map<int, int> x = { };
	REP(i, n){
		int a;
		cin >> a;
		x[a]++;
	}
	ll ans = 0;
	for(map<int, int>::iterator it = x.begin(); it != x.end(); ++it){
		if(it->second >= it->first) ans += (it->second - it->first);
		else ans += it->second;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(){
  int n, c, k;
  cin >> n >> c >> k;
  vector<int> T(n);
  for(auto&& t:T)cin >> t;
  sort(T.begin(), T.end());
  int ans = 0;
  for(int i=0, r=0, g=0;i<n;i++){
    if(r <= 0 || g + k < T[i]){
      g = T[i];
      r = c - 1;
      ++ans;
    }else{
      --r; 
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    ll A,B,C; cin >> A >> B >> C;

    if(A+B+1 >= C) cout << B+C << endl;
    else cout << A+B+1+B << endl;
    
    return 0;
}

Measured memory_bytes: 256
//?????°???????????????????????£???????????£???(orz)
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
#include <vector>
#include <cstdio>
#include <string>
#define int long long
using namespace std;
typedef tuple<int, int, int> T;

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

int h, w;
int sy, sx;
int gy, gx;
string s[500];
int a[500][500];	//??????????????°????????§????????¢
int b[500][500];	//??´???????????§?????????
int INF = 1145141919893810;

signed main() {
	int i, j;
	
	cin >> w >> h;
	for (i = 0; i < h; i++) cin >> s[i];
	
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (s[i][j] == 's') { sy = i; sx = j; }
			if (s[i][j] == 'g') { gy = i; gx = j; }
			a[i][j] = INF;
			b[i][j] = INF;
		}
	}
	
	queue<T> que;
	
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (s[i][j] == '*') {
				que.push(T(0, i, j));
				a[i][j] = 0;
			}
		}
	}
	
	while (!que.empty()) {
		T now = que.front(); que.pop();
		int cst = get<0>(now);
		int y = get<1>(now);
		int x = get<2>(now);
		
		for (i = 0; i < 4; i++) {
			int ny = y + dy[i];
			int nx = x + dx[i];
			if (!(0 <= ny && ny < h && 0 <= nx && nx < w)) continue;
			if (s[ny][nx] == '#' || a[ny][nx] <= cst + 1) continue;
			que.push(T(cst + 1, ny, nx));
			a[ny][nx] = cst + 1;
		}
	}
	
	que.push(T(0, gy, gx));
	
	while (!que.empty()) {
		T now = que.front(); que.pop();
		int cst = get<0>(now);
		int y = get<1>(now);
		int x = get<2>(now);
		
		for (i = 0; i < 4; i++) {
			int ny = y + dy[i];
			int nx = x + dx[i];
			if (!(0 <= ny && ny < h && 0 <= nx && nx < w)) continue;
			if (s[ny][nx] == '#' || s[ny][nx] == '*' || b[ny][nx] <= cst + 1) continue;
			que.push(T(cst + 1, ny, nx));
			b[ny][nx] = cst + 1;
		}
	}
	
	//?????????
	vector<T> cells;
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (s[i][j] == '.' || s[i][j] == 's') {
				cells.push_back(T(b[i][j] - a[i][j], a[i][j], b[i][j]));
			}
		}
	}
	sort(cells.begin(), cells.end());
	
	//(x?????°??????????????????????????????????????????(A)????????°. x + y????????????(B)????????°, E?????°??????????????§????????´???????????§??????????????°)
	//(Sx???A???g?????§????????????????????????, Hy???B-A?????°????????§???????????????????????????
	//??? E = (Sx + Hy) / x
	//???????????????. ?????£???, (x, y)?????¨??¨?????????, E = (Sx + Hy) / x??¨??????????????¨?????????x, y????????????????????¨??£?????????????????????????±???????
	//??£??????????????????????????????, E???????°????????±?????????°?????£??????E????±??????????
	//???????????£??????E???????????????x = 0??????????????¨????????????????????????????????§???x > 0??¨?????????
	
	int Sx = 0;
	int Hy = 0;
	for (i = 0; i < cells.size(); i++) Hy += get<1>(cells[i]);
	
	double minE = INF;
	
	for (int x = 0; x <= cells.size(); x++) {
		if (x > 0) {
			double E = (Sx + Hy) / (double)x;
			double eps = 1e-10;
			if (get<0>(cells[x - 1]) - eps <= E && E <= get<0>(cells[x]) + eps) {
				minE = min(minE, E);
			}
		}
		Sx += get<2>(cells[x]);
		Hy -= get<1>(cells[x]);
	}
	
	//2???????????????
	double ans = min((double)b[sy][sx], minE + a[sy][sx]);
	printf("%.14f\n", ans);
	return 0;
}

Measured memory_bytes: 13712
s = list(input())
t = list(input())
l = len(s)
sl = [[] for _ in range(26)]
for i in range(l):
	j = ord(s[i])-97
	sl[j].append(i)
sord = [[-1 for _ in range(l)] for _ in range(26)]
checksord = [0 for _ in range(26)]
for i in range(26):
	for j in range(len(sl[i])):
		cnt = sl[i][j]
		for q in range(checksord[i], cnt):
			sord[i][q] = cnt
		checksord[i] = cnt

for i in range(26):
	for j in range(l):
		if (sl[i] != []) & (sord[i][j] == -1):
			sord[i][j] = sl[i][0] + l

#print(sord)

j = ord(t[0])-97
if sl[j] == []:
	ans = -1
else: 
	ans = sl[j][0]

if ans != -1:
	for i in range(1, len(t)):
		j = ord(t[i])-97
		if sl[j] == []:
			ans = -1
			break
		else:
			w = ans % l
			ans = ans - w + sord[j][w]
			#print(ans)

if ans == -1:
	print(ans)
else:
	print(ans+1)


Measured memory_bytes: 119700
def p(x):
 for i in range(7,int(x**.5+1),2):
  if x%i==0:return 0
 else:return 1
def f():
 n,c=map(int,input().split());s='9'*n
 if c<0:return(11,s+s)[n>1]
 for h in'9731':
  if n-1:
   for m in range(int(10**~-n),0,-1):
    m=str(m-1)
    if(sum(int(k)for k in h+m)*2+c)%3:
     t=h+m.zfill(n-1);a=int(t+str(c)+t[::-1])
     if p(a):return a
  else:
   a=int(h+str(c)+h)
   if p(a):return a
 return s+b+s
print(f())


Measured memory_bytes: 5648
//https://www.codechef.com/viewsolution/30791639

#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

#define N 200005

ll val[N];
ll fans[N];

ll que(ll st[], ll l, ll r, ll l1, ll r1, ll i)
{
    if(l>r1 || l1>r)
        return 0;
    if(l>=l1 && r<=r1)
        return st[i];
    ll mid = (l+r)/2;
    
    return max(que(st,l,mid,l1,r1,2*i+1),que(st,mid+1,r,l1,r1,2*i+2));
}
 
void upd(ll st[], ll l, ll r, ll l1, ll i, ll val)
{
    if(l>l1||r<l1)
        return;
    if(l == r)
    {
        st[i] = val;
        return;
    }
    
    ll mid = (l+r)/2;
    upd(st,l,mid,l1,2*i+1,val);
    upd(st,mid+1,r,l1,2*i+2,val);
    
    st[i] = max(st[2*i+1], st[2*i+2]);
}

void dfs(ll curr, vector<ll> v[], ll st[], ll par, ll lim)
{
    ll prev = que(st,0,lim,val[curr],val[curr],0);
    ll now = que(st,0,lim,0,val[curr]-1,0) + 1;
    fans[curr] = max(st[0],now);
    if(now>prev){
        
    upd(st,0,lim,val[curr],0,now);
    
    autoit(v[curr],it)
    {
        if(*it == par)
            continue;
        dfs(*it,v,st,curr,lim);    
    }
    
    upd(st,0,lim,val[curr],0,prev);
    
    }
    
    else
    {
        autoit(v[curr],it)
        {
            if(*it == par)
                continue;
            dfs(*it,v,st,curr,lim);    
        }
    }
}

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   rep(n)
        cin>>val[i];
   map<ll,ll> comp;
   rep(n)
        comp[val[i]] = 1;
   ll curr = 0;
   autoit(comp,it)
        it->ss = curr++;
   rep(n)
        val[i] = comp[val[i]];
        
   vector<ll> v[n];
   rep(n-1)
   {
       ll a,b;
       cin>>a>>b;
       a--,b--;
       v[a].pb(b);
       v[b].pb(a);
   }
   
   ll lim = (comp.size());
   
   ll ht = ceil(log2(lim));
   //cout<<"ht = "<<ht<<"\n";
   ht = (1ll<<(ht+1)) - 1;
   ll st[ht];
   memset(st,0,sizeof(st));
   
   dfs(0,v,st,-1,lim-1);
   rep(n)
        cout<<fans[i]<<"\n";
   
   return 0;        
}  
   

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

int main() {
	int N, K;
	cin >> N >> K;
	int l[55];
	int i;
	for(i=0; i<N; ++i) cin >> l[i];
	sort(l, l+N, greater<int>());
	int S=0;
	for(i=0; i<K; ++i) S += l[i];
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using edge = struct {int to; ll cost;};
vector<vector<edge>> tree(100010);
vector<ll> depth(100010);

void dfs(int v, int p, ll d){
	depth[v] = d;
	for(auto &e: tree[v]){
		if(e.to == p) continue;
		dfs(e.to, v, d + e.cost);
	}
}

int main() {
	
	int n;
	cin >> n;
	rep(i, n-1){
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		tree[a].push_back({b, c});
		tree[b].push_back({a, c});
	}
	int q, k;
	cin >> q >> k;
	k--;
	
	dfs(k, -1, 0);
	rep(i, q){
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		cout << depth[x] + depth[y] << endl;
	}
	return 0;
}

Measured memory_bytes: 14336
#include<stdio.h>
int main()
{
    int a,i,j=0;

    scanf("%d",&a);

    int A[a];

    for(i=0;i<a;i++)
    {
        scanf("%d",&A[i]);

        if(A[i]!=i+1) j++;
    }

    if(j>2) printf("NO\n");
    else printf("YES\n");

    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;
#define rep(i,n) for (int i = 0; i < (n); i++)

ll b[100],n,ans;
int main(void) {
    cin >> n;
    rep(i,n-1) {
        cin >> b[i];
    }
    rep(i,n) {
        if (i == 0) {
            ans += b[0]; continue;
        }
        if (i == n-1) {
            ans += b[n-2]; break;
        }
        ans += min(b[i-1], b[i]);
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
	int W, H;
	int x, y, r;

	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
	W -= r, H -= r;
	if (r <= x && x <= W && r <= y && y <= H) printf("Yes\n");
	else printf("No\n");
	return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000

#define rep(i, a, n) for(int i = a; i < n; i++)
#define rrep(i, a, n) for(int i = a; i > n; i--)
#define lrep(i, a, n) for(long int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

int main()
{
    int N, A, B;
    cin >> N >> A >> B;

    cout << min(A * N, B) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a[200005],b[200005];
inline int read()
{
	char ch=getchar(); int ans=0;
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch<='9'&&ch>='0') ans=ans*10+ch-48,ch=getchar();
	return ans;
}
bool cmp(int x,int y){return x>y;}
int main()
{
	int n=read();
	for (int i=1; i<=n; i++) a[i]=read(),b[i]=a[i];
	sort(a+1,a+1+n,cmp);
	int x=n/2;
	for (int i=1; i<=n; i++)
	{
		int t=lower_bound(a+1,a+1+n,b[i])-a;
		if (t<=x) printf("%d\n",a[x]);
		else printf("%d\n",a[x+1]);
	}
	return 0;
}

Measured memory_bytes: 3712
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        sc.useDelimiter(",");
//        DecimalFormat df = new DecimalFormat("0.00000000");
        
        int n = Integer.parseInt(sc.next());
        int taro = 0;
        int hanako = 0;
        for (int i=0; i<n; i++) {
            String s1 = sc.next();
            String s2 = sc.next();
            if (s1.compareTo(s2) == 0) {
                taro++;
                hanako++;
            } else if (s1.compareTo(s2) > 0) {
                taro += 3;
            } else {
                hanako += 3;
            }
        }
        out.println(taro +" "+ hanako);
        out.flush();
    }
}


Measured memory_bytes: 29948
n = int(input())
input_lines = [input() for i in range(n)]

ans = 'Yes'
for i in range(1,n):
    if input_lines[i] not in input_lines[0:i] and input_lines[i][0]==input_lines[i-1][-1]:
        continue
    else:
        ans = 'No'
        break
print(ans)


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

const long long INF = 1LL << 60;

int main() {
    int H, W; cin >> H >> W;
    vector<vector<char>> data(H, vector<char>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> data.at(i).at(j);
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << data.at(i).at(j);
        }
        cout << endl;
        for (int j = 0; j < W; j++) {
            cout << data.at(i).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
using namespace std;

long double dist(long double a, long double b) {
    long double x = sqrt(a*a + b*b);
    return x;
}

int main(){
	long double a, b, h, m;
	cin >> a >> b >> h >> m;
	long double x1, x2, y1, y2, x, y, ans;
    long double PI = M_PI;
	x1 = a*sin((h+m/60)*(PI/6));
	x2 = b*sin(m*PI/30);
    y1 = a*cos((h+m/60)*(PI/6));
	y2 = b*cos(m*PI/30);
	x = x1 - x2;
	y = y1 - y2;
	ans = dist(x, y);
	cout << setprecision(15) << ans << endl;
	return 0;
}

Measured memory_bytes: 4144
#include <iostream>
#include <cstring>
using namespace std;
void utol(char ch[]) {
    for(int i = 0; i < strlen(ch); ++i) {
        if(isupper(ch[i])) ch[i] = tolower(ch[i]);
    }
}
int main() {
    char W[11], T[1001];
    cin >> W;
    int cnt = 0;
    while(true) {
        cin >> T;
        if(strcmp(T, "END_OF_TEXT") == 0) break;
        utol(T);
        if(strcmp(T, W) == 0) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
const ld eps=1e-9;
ll dp[64][64];
ll dp2[64][64];
int main(){
	int n,a,b;	cin>>n>>a>>b;
	vector<ll> v(n);
	for(int i=0;i<n;i++)	cin>>v[i];
	dp2[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=i;j++){
			if(dp[i+1][j]<dp[i][j]){
				dp[i+1][j]=dp[i][j];
				dp2[i+1][j]=dp2[i][j];
			}
			else if(dp[i+1][j]==dp[i][j]){
				dp2[i+1][j]+=dp2[i][j];
			}
			if(dp[i+1][j+1]<dp[i][j]+v[i]){
				dp[i+1][j+1]=dp[i][j]+v[i];
				dp2[i+1][j+1]=dp2[i][j];
			}
			else if(dp[i+1][j+1]==dp[i][j]+v[i]){
				dp2[i+1][j+1]+=dp2[i][j];
			}
		}
	}
	ld ret=0;
	for(int i=a;i<=b;i++)	ret=max(ret,(ld)dp[n][i]/i);
	printf("%.15Lf\n",ret);
	ll pattern=0;
	for(int i=a;i<=b;i++){
		if(fabs(ret-(ld)dp[n][i]/i)<eps)	pattern+=dp2[n][i];
	}
	printf("%Ld\n",pattern);
	return 0;
}
			


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

//repetition
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(), (x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//conversion
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
inline ll toLL(string s)
{
    ll v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

void dump(vector<vector<int>> &v)
{
    rep(i, v.size())
    {
        rep(j, v[0].size())
        {
            cerr << v[i][j] << " ";
        }
        cerr << endl;
    }
    cerr << "------" << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    while (true)
    {
        int n, m, t, p;
        cin >> n >> m >> t >> p;
        if (n == 0 && m == 0)
            break;
        int a[32][32];

        int w = n, h = m;
        rep(i, 32) rep(j, 32)
        {
            if (i < m && j < n)
                a[i][j] = 1;
            else
                a[i][j] = 0;
        }
        rep(_, t)
        {
            int d, c;
            cin >> d >> c;
            vector<vector<int>> b(32, vector<int>(32, 0));
            rep(i, 32) rep(j, 32)
                b[i][j] = 0;

            if (d == 1)
            {
                rep(i, 32) rep(j, 32)
                {
                    if (c + j < n)
                    {
                        b[i][j] += a[i][j + c];
                        // cerr << "add1 " << i << "," << j << "," << a[c + i][j] << endl;
                    }
                    if (c - j - 1 >= 0)
                    {
                        b[i][j] += a[i][c - 1 - j];
                        //   cerr << "add2 " << i << "," << j << "," << a[c - i - 1][j] << endl;
                    }
                }
                rep(i, 32) rep(j, 32)
                    a[i][j] = b[i][j];
            }
            else
            {
                rep(i, 32) rep(j, 32)
                {
                    if (c + i < m)
                    {
                        b[i][j] += a[i + c][j];
                        // cerr << "add1 " << i << "," << j << "," << a[c + i][j] << endl;
                    }
                    if (c - i - 1 >= 0)
                    {
                        b[i][j] += a[c - 1 - i][j];
                        //   cerr << "add2 " << i << "," << j << "," << a[c - i - 1][j] << endl;
                    }
                }
                rep(i, 32) rep(j, 32)
                    a[i][j] = b[i][j];
            }
                }
        rep(_, p)
        {
            int x, y;
            cin >> x >> y;
            cout << a[y][x] << endl;
        }
    }
    return 0;
}


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

void Sort(int array[],int n)
{
    int i,j,temp;
    
    for (i = 0;i < n - 1;i++) {
        for (j = 0;j < n - 1;j++) {
            if (array[j + 1] < array[j]) {
                temp = array[j];array[j] = array[j + 1];array[j + 1] = temp;
            }
        }
    }
}

int main()
{
  int heights[10];
  for(int i=0;i<10;i++){
    cin >> heights[i];
  }

  Sort(heights, 10);

  cout << heights[9] << endl << heights[8] << endl << heights[7] << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;


int main(){
	string s;
	cin>>s;
	ll st[110000]={0};
	ll x=1,y=0;

	ll p=0;
	rep(i,1,s.length()){
		if (s[i]=='R')x++;
		else if(s[i]=='L'&&x>0) {
			p=i;
			while(s[i]=='L'){y++;i++;}
			st[p-1]=ceil((double)x/2)+y/2;
			st[p]=ceil((double)y/2)+x/2;
			x=0,y=0;
			i--;
		}
	}
	rep(i,0,s.length())cout<<st[i]<<" ";
}

Measured memory_bytes: 1536
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007ll //998244353ll
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=300005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
int ar[N], st[4*N],n;
void build(int v, int l, int r)
{
    if(l==r)
    {
        st[v]=ar[l];
        return;
    }
    int m=(l+r)/2;
    build(v*2, l, m);
    build((v*2)+1, m+1, r);
    st[v]=max(st[v*2], st[(v*2)+1]);
    //cout<<l<<" "<<r<<" "<<t[v].o<<" "<<t[v].c<<" "<<t[v].ans<<"\n";
}
void update(int v, int l, int r, int pos)
{
    if(l==r)
    {
        st[v]=ar[l];
        return;
    }
    int m=(l+r)/2;
    if(pos<=m)
    update(v*2, l, m, pos);
    else
    update((v*2)+1, m+1, r, pos);
    st[v]=max(st[v*2], st[(v*2)+1]);
    //cout<<l<<" "<<r<<" "<<t[v].o<<" "<<t[v].c<<" "<<t[v].ans<<"\n";
}
int query(int v, int tl, int tr, int l, int r)
{
    if(l>r)
    return 0;
    if(tl==l&&tr==r)
    return st[v];
    int tm=(tl+tr)/2;
    return max(query((2*v), tl, tm, l, min(tm, r)), query((2*v)+1, tm+1, tr, max(tm+1, l), r));
}
int32_t main()
{
    IOS;
    int k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        a[i]++;
    }
    for(int i=1;i<N;i++)
    ar[i]=0;
    build(1, 1, N-1);
    int ans[n];
    for(int i=0;i<n;i++)
    {
        int lb=max(a[i]-k, 1ll);
        int ub=min(a[i]+k, N-1);
        ans[i]=1+query(1, 1, N-1, lb, ub);
        ar[a[i]]=max(ar[a[i]], ans[i]);
        update(1, 1, N-1, a[i]);
        if(i)
        ans[i]=max(ans[i], ans[i-1]);
    }
    cout<<ans[n-1];
}

Measured memory_bytes: 18888
#include<bits/stdc++.h>
using namespace std;
int n,a[1000005];
int main()
{
	scanf("%d%d",&n,&a[0]);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		ans+=(x>=a[0]);
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    int ans = (S.length() - S.replace("ABC", "").length()) / 3;
    System.out.println(ans);
  }
}


Measured memory_bytes: 25044
///*****************************************************///
///*.......................Faiyaj Bin Amin............................*///
///*...................................................................*///
///*.........................KUET CSE 2K17......................*///
///*...................................................*///
///*****************************************************///

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define fastio      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define ret return
#define rep(q, i, n) for(int q=i; q<n; q++)
#define forn(i, n) for(int i=0; i<n; i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pdd pair<double, double>

#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define seecontent(v) for(auto x : v) { cout << x << " ";} cout << "\n\n";

#define PI 2*acos(0.0)
#define lcm(a, b)  ((a / __gcd(a, b) ) * b)

#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)

#define mx 100005
#define INF 1e18+3
#define MOD 1000000007
#define MIN 0

//template <typename T>  using orderedSet =
//    tree<T, null_type, less_equal<T>,
//    rb_tree_tag, tree_order_statistics_node_update>; //find_by_order, order_of_key


/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0}; // Directional
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

/**------------------------------------BITMASK------------------------------------------**/
//int Change(int N, int pos){return N= N^(1<<pos);}
//bool Check(int N, int pos){return (bool)(N &(1<<pos));}  /// check bit 0 or 1
/**-----------------------------------------------------------------------------------------------**/

//using namespace __gnu_pbds;
using namespace std;

ll dp[mx][14];
int main()
{
    fastio;
    string s;
    cin >> s;

    dp[0][0]=1;
    forn(i, s.size())
    {
        int fl=100;
        if(s[i]!='?')
            fl=s[i]-'0';
        else
            fl=10;

        forn(j, 10)
        {
            if(fl==10 || fl==j)
            {
                forn(mul, 13)
                {
                    int val = (j+ mul * 10) % 13;
                    dp[i+1][val]+= dp[i][mul];
                    dp[i+1][val] = dp[i+1][val] % MOD;
                }
            }
        }
    }
    cout << dp[s.size()][5] << "\n";

    return 0;
}

Measured memory_bytes: 14656
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    dat = list(map(int, input().split()))

    for i in range(200):
        a = x - i
        if a not in dat:
            print(a)
            break
        a = x + i
        if a not in dat:
            print(a)
            break


Measured memory_bytes: 61692
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   

int main(){
    std::ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    int ans=1;
   	while(n--){
   		ans+=min(ans,k);
   	}
   	cout<<ans<<endl;
    //cout<<2*g-r<<endl;
    return 0;  
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int n;
    cin >> n;
    vector<vector<int>> tmp(n, vector<int>(26,0));
    REP(i, n){
        string S;
        cin >> S;
        SORT(S);
        for(auto && s : S) REP(j, 30){
            if((s-'a') == j) tmp[i][j]++;
        }
    }

    string ans = "";
    REP(i, 26){
        int m = INF;
        REP(j, n){
            m = min(m, tmp[j][i]);
        }
        REP(j, m){
            ans.push_back((char)('a'+i));
        }
    }
    pr(ans);
}

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

int H[100000];

int main(){
    int N;
    int ans = 1;
    cin >> N;

    //input
    for(int i = 0;i < N;i++){
        cin >> H[i];
    }

    //process
    for(int i = N - 1; i >= 1;i--){
        //cout <<"compare : "<< H[i] <<" "<< H[i-1] << endl;
        if(H[i] >= H[i-1]) continue;
        else if(H[i] >= H[i-1] - 1 ){
            H[i-1] = H[i-1]-1;
            continue;
        }else{
            ans = 0;
            break;
        }
    }

    //output
    if(ans == 0)cout << "No";
    else cout << "Yes";

    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

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

  vector<int> a(N);
  rep(i, N) { cin >> a[i]; }
  sort(a.begin(), a.end());

  int64_t result = 0;
  rep(i, N - 1) { result += a[N - 1 - (i + 1) / 2]; }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  string s;
  cin >> s;
  int a = stoi(s.substr(0, 2)), b = stoi(s.substr(2, 2));
  if (1 <= a && a <= 12 && 1 <= b && b <= 12)
    cout << "AMBIGUOUS\n";
  else if (1 <= a && a <= 12)
    cout << "MMYY\n";
  else if (1 <= b && b <= 12)
    cout << "YYMM\n";
  else
    cout <<"NA\n";
  return 0;
}


Measured memory_bytes: 3608
def primes(n)
  primes = Array.new(n+1, 1)
  primes[0], primes[1] = nil, nil
  (2..n).each do |i|
    next if primes[i].nil?
    break if i*i > n
    (i+i).step(n, i) { |j| primes[j] = nil }
  end
  primes
end

lr = Array.new(gets.chomp.to_i) { gets.chomp.split.map(&:to_i) }
primes = primes(10 ** 5)

sums = Array.new(10 ** 5 + 1, 0).tap do |y|
  (1..10**5).each do |i|
    y[i] = y[i-1] + (primes[i] && primes[(i+1)/2] ? 1 : 0)
  end
end

lr.each do |l, r|
  puts sums[r] - sums[l-1]
end


Measured memory_bytes: 11516
n=int(input())
x=0
y=0
t=0
f=0
for i in range(n):
    T,a,b=map(int,input().split())
    if not(abs(a-x)+abs(b-y)<=T-t and (abs(a-x)+abs(b-y)-(T-t))%2==0):
        f=1
    x=a
    y=b
    t=T
print("Yes" if f==0 else "No")


Measured memory_bytes: 73984