akhauriyash/Code-Regression huggingface dataset:
//verma_ankit484

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

typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const ll mod = (ll) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

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

ll n;
vector<pair<ll, ll>> vc;

ll dp[1001][10001];

ll rec(ll i, ll h) {
  if (h <= 0) return 0;
  if (i >= n) return INT_MAX;
  ll &ans = dp[i][h];
  if (ans != -1) return ans;
  ans = rec(i+1, h);
  ans = min(ans, vc[i].second+rec(i, h - vc[i].first));
  return ans;
}

int main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  ll h;
  cin >> h >> n;
  vc.resize(n);
  for (ll i = 0; i < n; i++) {
    cin >> vc[i].first >> vc[i].second;
  }
  memset(dp, -1, sizeof(dp));
  cout << rec(0, h) << endl;
  return 0;
}


Measured memory_bytes: 78976
#include <stdio.h>

int main(void) {
  int i = 0;
  char s[101];
  scanf("%s", s);
  while (s[i] != '\0') {
    i++;
  }
  printf("%c%d%c\n", s[0], i - 2, s[i - 1]);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
using namespace std;
const int INF = 1e9;
typedef long long lint;
const lint LINF = 1e18;
const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}
 
int main(){
	int n,x; cin>>n>>x;
	vector<int> v(n);
	rep(i,n) cin>>v[i];
	v.push_back(x);
	sort(all(v));
	vector<int> d(n);
	rep(i,n){
		d[i] = v[i+1] - v[i];
	}
	int ans = 0;
	rep(i,n){
		ans = gcd(ans, d[i]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <ctype.h>
using namespace std;

typedef long long ll;

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

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

  int count = 0;
  for (int i = 2; i < s.size() - 1; ++i) {
    if (s.at(i) == 'C') {
      ++count;
      s.erase(s.begin() + i);
    }
  }
  if (s.at(0) != 'A' || count != 1) {
    cout << "WA" << endl;
    return 0;
  }
  s.erase(s.begin() + 0);
  for (int i = 0; i != s.size(); ++i) {
    if (islower(s[i]) == 0) {
      cout << "WA" << endl;
      return 0;
    }
  }

  cout << "AC" << endl;
  return 0;
}


Measured memory_bytes: 256
import collections

cnt = 0
s = []
tmp = []
n = int(input())
for i in range(n):
    string = input()
    string = ''.join(sorted(string))
    s.append(string)

# for i, e in enumerate(s):
#     count = s.count(e)
#     if count > 1 and not e in tmp:
#         cnt += count*(count-1)//2
#         tmp.append(e)
cc = collections.Counter(s)

for cv in cc.values():
    if cv > 1:
        cnt += cv*(cv-1)//2

print(cnt)


Measured memory_bytes: 68440
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 100010;
int n,x;
int b[MAX],l[MAX],u[MAX],zysk[MAX];
int p[MAX];
int zle = 0;
bool spr(int m){
  int ile = m / x;
  m %= x;
  int ak = 0;
  R(_,ile){
    int i = p[_];
    ak += zysk[i];
  }
  int ma = 0;
  for(int _ = ile; _ < n; _++){
    int i = p[_];
    maxi(ma, min(b[i], m) * l[i] + max(m - b[i], 0ll) * u[i]); 
  }
  if(ak + ma >= zle)return 1;
  ak = 0;
  int mi = 1e12;
  R(_,ile+1){
    int i = p[_];
    ak += zysk[i];
    mini(mi, zysk[i] - (min(b[i], m) * l[i] + max(m - b[i], 0ll) * u[i]));
  }
  return ak - mi >= zle;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> x;
  R(i,n){
    cin >> b[i] >> l[i] >> u[i];
    zle += b[i] * l[i];
    zysk[i] = b[i] * l[i] + (x - b[i]) * u[i];
    debug(zysk[i]);
  }
  debug(zle);
  R(i,n)p[i] = i;
  sort(p,p+n,[&](int a,int bb){
    return zysk[a] > zysk[bb];
  });
  int po = -1, ko = n * x;
  while(po + 1 != ko){
    int m = (po + ko) / 2;
    if(spr(m)){
      ko = m;
    }else{
      po = m;
    }
  }
  debug(ko / x, ko % x);
  cout << ko << "\n";
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  ll h;
  int n;
  cin>>h>>n;
  ll s=0;
  rep(i,n) {
    ll a;
    cin>>a;
    s+=a;
  }
  if(h<=s) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int main()
{
    while(true)
    {
        int n;cin>>n;if(n==0){break;}double ave=0;
        vector<double >a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];ave+=a[i];
        }
        ave/=(double)n;
     int count=0;
        for(int i=0;i<n;i++){
            if(a[i]<=ave){count++;}
        }
    cout<<count<<endl;}
    return 0;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,m;
    int ans;
    cin >> n >> m;
    vector<int> x(m);
    rep(i,m) cin >> x[i];
    sort(x.begin(),x.end());
    
    if(n >= m){
        cout << 0 << endl;
        return 0;
    }
    else{
        ll zenkukan = x[m-1] - x[0];
        vector<ll>kukan(m-1);
        ll hiku=0;
        rep(i,m-1){
            ll k;
            k = abs(x[i] - x[i+1]);
            kukan[i] = k;
        }
        sort(kukan.rbegin(),kukan.rend());
        rep(i,n-1){
            hiku += kukan[i];
        }
        ans = zenkukan - hiku;
        
    }
    cout << ans <<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b;
  cin >> a >> b;
  cout << max(a + b, max(a - b, a * b)) << endl;
}

Measured memory_bytes: 3588
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A, B, C, K = lr()
if K%2 == 0:
    answer = A - B
else:
    answer = B - A

if answer > 10 ** 18:
    answer = 'Unfair'

print(answer)


Measured memory_bytes: 3060
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}


// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int N,A,B,C;
vector<int> bamboo(10,0);

long long dfs(int current, int a, int b, int c){
    if(current==N){
        if(min({a,b,c})>0)
            return abs(A-a)+abs(B-b)+abs(C-c)-30;
        else
            return 10000;
    }
    long long ret0=dfs(current+1,a,b,c);
    long long ret1=dfs(current+1,a+bamboo[current],b,c)+10;
    long long ret2=dfs(current+1,a,b+bamboo[current],c)+10;
    long long ret3=dfs(current+1,a,b,c+bamboo[current])+10;

    return min({ret0,ret1,ret2,ret3});
}

int main() {

    cin >> N >>A >> B >> C;

    rep(i,N){
        cin >> bamboo[i];
    }

    cout << dfs(0,0,0,0) << endl;
    return 0;
}



Measured memory_bytes: 256
if __name__ == '__main__':
    s_input = input()
    assert len(s_input) == 4

    flag = 0
    if s_input[0] == s_input[1]:
        flag = 1
    elif s_input[1] == s_input[2]:
        flag = 1
    elif s_input[2] == s_input[3]:
        flag = 1

    if flag == 0:
        print('Good')
    elif flag == 1:
        print('Bad')


Measured memory_bytes: 3060
N,A,B = map(int,input().split())
if abs(B-A)%2==0 :
  print(abs(B-A)//2)
else:
  x1 = N-max(A,B)
  ans1 = N- max(A,B) + 1 + (-min(A,B)+max(A,B)-1)//2

  ans2 = min(A,B)+(max(A,B)-min(A,B)-1)//2
  print(min(ans1,ans2))

Measured memory_bytes: 38384
#include <stdio.h>
#include <stdlib.h>
#define INF 1000000001
 
void merge(int, int, int);
void mergeSort(int, int);
 
int n;
int A[200000];
int L[100001], R[100001];
long cnt = 0;
     
int main()
{
    int i;
    int n;
     
    scanf("%d", &n);
    for(i = 0; i < n; i++)
    {
        scanf("%d", &A[i]);
    }
     
    mergeSort(0, n);
 
    printf("%ld\n", cnt);
     
    return 0;
}
 
void mergeSort(int left, int right)
{
    int mid;
 
    if(left + 1 < right)
    {
        mid = (left + right)/2;
        mergeSort(left, mid);
        mergeSort(mid, right);
        merge(left, mid, right);
    }
}
 
void merge(int left, int mid, int right)
{
    int i, j, k;
    int n1, n2;
  
    n1 = mid - left;
    for(i = 0; i < n1; i++)
    {
        L[i] = A[left + i];
    }
    L[n1] = INF;
   
    n2 = right - mid;
    for(j = 0; j < n2; j++)
    {
        R[j] = A[mid + j];
    }
    R[n2] = INF;
 
    i = 0;
    j = 0;
    for(k = left; k < right; k++)
    {
        if(L[i] <= R[j])
        {
            A[k] = L[i];
            i++;
        }
        else
        {
            A[k] = R[j];
            cnt += n1 - i;
            j++;
        }
    }
}



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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Query {
  int index;
  int l, r;
};

// Supports two operations.
// - Updates a single element.
// - Returns a sum of a range.
// Verified: CF573Div1D
class BinaryIndexedTree {
 private:
  int n;
  vector<int64> xs;
 public:
  BinaryIndexedTree(int n) : n(n), xs(n) {}

  // Adds x to the i-th element.
  void Add(int i, int64 x) {
    int cur = i;
    while (cur < n) {
      xs[cur] += x;
      cur = cur | (cur + 1);
    }
  }

  // Returns a sum of a range [l, r).
  int64 SumRange(int l, int r) {
    if (l >= r) return 0;
    if (l > 0) {
      return SumRange(0, r) - SumRange(0, l);
    }
    int64 s = 0;
    int i = r - 1;
    while (i >= 0) {
      s += xs[i];
      i = (i & (i + 1)) - 1;
    }
    return s;
  }
};

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

  int n;
  int q;
  cin >> n >> q;
  vector<int> cs(n);
  for (int i = 0; i < n; i++) {
    cin >> cs[i];
    cs[i]--;
  }
  vector<vector<Query>> r_to_qs(n);
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    r_to_qs[r].push_back({i, l, r});
  }

  vector<int> last_pos_vector(n, -1);
  
  BinaryIndexedTree tree(n);
  
  vector<int64> ans(q);
  for (int r = 0; r < n; r++) {
    int c = cs[r];
    int p = last_pos_vector[c];
    last_pos_vector[c] = r;
    if (p >= 0) {
      tree.Add(p, -1);
    }
    tree.Add(r, 1);
    for (const auto& q : r_to_qs[r]) {
      int64 v = tree.SumRange(q.l, q.r + 1);
      ans[q.index] = v;
    }
  }
  for (int i = 0; i < q; i++) {
    cout << ans[i] << "\n";
  }
}


Measured memory_bytes: 38084
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] map = new char[h][w];
		for (int i = 0; i < h; i++) {
			map[i] = sc.next().toCharArray();
		}
		int cnt = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (map[i][j] == '#') {
					cnt++;
				}
			}
		}
		System.out.println((cnt == h + w - 1) ? "Possible" : "Impossible");

	}
}


Measured memory_bytes: 23636
#include<stdio.h>
int main()
{
    int n;
   while(scanf("%d",&n)!=EOF){
        int a,b,c=0;
        a=n%10;
        b=n/10;
        if(a==9||b==9)
           printf("Yes\n");
        else
         if(c==0)  printf("No\n");
     }
    return 0;
    
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

int N,B,A;

int main()
{
    cin >> N >> A >> B;
    chmin(B,A*N);
    cout << B <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>

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

using namespace std;

typedef long long ll;



int N;
string s;

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

	int cntI = 0;
	rep(i, N) {
		if (s[i] == 'I') cntI++;
	}

	int sumJ = 0, sumI = cntI;
	ll ret = 0;
	rep(i, N) {
		if (s[i] == 'J') sumJ++;
		if (s[i] == 'O') ret += sumJ * sumI;
		if (s[i] == 'I') sumI--;
	}

	ll crsJ = 0, crsO = 0, crsI = 0;
	sumJ = 0; sumI = cntI;
	rep(i, N) {
		if (s[i] == 'J') sumJ++;
		if (s[i] == 'I') sumI--;
		if (s[i] == 'O') {
			crsI += sumJ;
			crsJ += sumI;
		}
		crsO = max(crsO, (ll)sumJ * sumI);
	}

	cout << ret + max({ crsJ, crsO, crsI }) << endl;

	
	return 0;
}



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

la = list()
for i in range(N):
    la.append(int(input()))

lnum = [0]*N

i = 1
cnt = 0
while lnum[i-1] == 0 and i != 2:
    lnum[i-1] += 1
    i = la[i-1]
    cnt += 1

if i == 2:
    print(cnt)

else:
    print("-1")

Measured memory_bytes: 7852
def check(num):
    if num > 1:
        for i in range(2, num):
            if (num % i) == 0:
                return False
                break
        else:
            return True
    else:
        return False


a = int(input())

for i in range(a, 100500):
    if check(i):
        print(i)
        break

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

int main() {
  int A, B, C, D;
  int L, R;

  cin >> A >> B >> C >> D;

  L = A + B;
  R = C + D;
  
  if (L == R) {
    cout << "Balanced" << endl;
  } else if (L < R) {
    cout << "Right" << endl;
  } else if (L > R) {
    cout << "Left" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val t = Array(n) { mutableListOf<Int>() }
    repeat(m) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() - 1 }
        t[a].add(b)
        t[b].add(a)
    }
    val ans = Array(n) { -1 }
    var q = LinkedList<Int>()
    q.add(0)
    ans[0] = 0

    while (q.isNotEmpty()) {
        val nextQ = LinkedList<Int>()
        while (q.isNotEmpty()) {
            val cur = q.poll()
            for (next in t[cur]) {
                if (ans[next] != -1) continue
                ans[next] = cur
                nextQ.add(next)
            }
        }
        q = nextQ
    }
    println("Yes")
    for (i in 1 until n) {
        println(ans[i] + 1)
    }
}


Measured memory_bytes: 82588
# Author: cr4zjh0bp
# Created: Fri Mar  6 04:56:50 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

from heapq import *
from math import floor

q = []

N, M = na()
a = na()
q = []
for i in range(N):
    heappush(q, -a[i])

for i in range(M):
    p = heappop(q)
    p = -((-p) // 2)
    heappush(q, p)

print(abs(sum(q)))

Measured memory_bytes: 14380
n,l=gets.split.map &:to_i
result=[]
(1..n).each do |i|
  result<< i+l -1
end
result.sort!
sum = result.inject(:+)
if result.include?(0)
  puts sum
elsif result[-1]<0
  puts sum - result[-1]
else
  puts sum - result[0]
end

Measured memory_bytes: 1788
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
ans = ['a']
for i in range(n-1):
    tmp = []
    for s in ans:
        m = max(s)
        j = ord(m)-ord('a') + 1
        for k in range(j+1):
            tmp.append(s+chr(ord('a') + k))
    ans = tmp
print(*ans, sep='\n')


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


int main(){

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

  for(int i=0;i<k;i++){
    if(a>=c&&a>=b) a=2*a;
    else if(b>=a&&b>=c) b=2*b;
    else if(c>=a&&c>=b) c=2*c;

  }
  cout<<a+b+c<<endl;

  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define pb push_back
#define all(v) (v.begin(),v.end())
#define mp make_pair



int main()
{
long long A,B,K;
cin>>A>>B>>K;
if(A>=K){
    A-=K;
}else{
    if(B>=(K-A))B-=(K-A);
    else{
        B=0;
    }
    A=0;
}cout<<A<<' '<<B<<endl;
return 0;
}


Measured memory_bytes: 256
n = gets.to_i
c = 0
f = false

n.times do
    d1, d2 = gets.split.map(&:to_i)
    if d1 == d2
        c += 1
        f = true if c >= 3
    else
        c = 0
    end
end

puts f ? "Yes" : "No"

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

int main(void){
    int n;
    cin >> n;
    int p[n] = {};
    for (int i = 0; i < n;i++){
        cin >> p[i];
    }
    int cnt = 0;
    for (int i = 2; i < n; i++){
        if (p[i - 1] != min(p[i - 2], min(p[i - 1], p[i])) &&
         p[i - 1] != max(p[i - 2], max(p[i - 1], p[i]))){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,S=map(int,input().split())
A=list(map(int,input().split()))

mod=998244353

DP=[0]*(S+1)
DP[0]=pow(2,N,mod)

INV=pow(2,mod-2,mod)

for a in A:
    for i in range(S-a,-1,-1):
        DP[i+a]=(DP[i]*INV+DP[i+a])%mod
        
print(DP[S])


Measured memory_bytes: 68348
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		
		String str = stdIn.next();
		String[] s = new String[1000];
		int index = 0;
		int start = 0;
		for(int i = 0; i < str.length(); i++){
			if( i+3 < str.length() ){
				s[index] = str.substring(start);
			}
			if( str.charAt(i) == 'e' ){
				if( i+3 < str.length() ){
					if( str.charAt(i+3) == 'e' ){
						s[index] = str.substring(start, i+3);
						start = i+3;
						index++;
					}
					i += 2;
				} else {
					s[index] = str.substring(start);
					index++;
					break;
				}
			} else {
				if( i+7 < str.length() ){
					if( str.charAt(i+7) == 'c' ){
						s[index] = str.substring(start, i+7);
						start = i+7;
						index++;
					}
					i += 6;
				} else {
					s[index] = str.substring(start);
					index++;
					break;
				}
			}
		}
		int ans = 0;
		int max = 0;
		for(int i = 0; i < index; i++){
			if( s[i].length() > max ){
				max = s[i].length();
				ans = i;
			}
		}
		if( s[ans].charAt(s[ans].length()-1) == 'n' ){
			System.out.println("chicken");
		} else {
			System.out.println("egg");
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>

int main() {
  int n, m, sum = 0;
  int t[100], p[100], x[100];

  std::cin >> n;

  for (int i = 0; i < n; i++) {
    std::cin >> t[i];
    sum += t[i];
  }

  std::cin >> m;

  for (int i = 0; i < m; i++) {
    std::cin >> p[i] >> x[i];
  }

  for (int i = 0; i < m; i++) {
    std::cout << sum - t[p[i] - 1] + x[i] << "\n";
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
  int a, b, c, d;

  std::cin >> a >> b >> c >> d;

  if (a*b >= c*d) {
    std::cout << a*b << std::endl;
  } else {
    std::cout << c*d << std::endl;
  }

  return 0;
}


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

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

int main(void) {
	int n;
	cin >> n;
	if (n % 1000 == 0) {
		cout << 0 << endl;
		return 0;
	}
	cout << 1000-n%1000 << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main(){

    int C[30]={};
    char S[100010]={};
    string str, ans = "abcdefghijklmnopqrstuvwxyz";
    cin >> str;

    for(int i=0;i<str.length();i++){
        S[i]=str[i];
    }
    

    for(int i=0;i<str.length();i++){
        C[S[i]-'a']=1;
    }

    for(int i=0;i<26;i++){
        if(C[i]!=1){
            cout <<ans[i]<<endl;
            return 0;
        }
    }

    cout <<"None"<<endl;

    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

#define ll long long
const ll N = 1000000000;

void solve() {
}

int main(){
    ll x;
    cin >> x;
    for (ll b = -1000; b <= 1000; ++b) {
        ll bb = b * b * b * b * b;
        ll val = bb + x;
        ll a = floor(pow(val, 0.2));
        ll aa = a * a * a * a * a;

        if (aa == val) {
            cout << a << " " << b;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 4116
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vll A(1000010, 0);
  for(int i = 0; i < N; i++){
    ll a;
    cin >> a;
    A.at(a)++;
  }
 
  
  for(int i = 1; i <= 1000000; i++){
    if(A.at(i) == 0) continue;
    if(A.at(i) >= 2) A.at(i) = 0;
    for(int j = i * 2; j <= 1000000; j+=i){
      A.at(j) = 0;
    }
  }
  ll ans = 0;
  for(int i = 1; i <= 1000000; i++){
    ans += A.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 11132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    ll N;
    cin >> N;
    int ans = 10;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ans = min(ans, (int) to_string(N / i).size());
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
class Main{
    public static void main(String[] args){
        SC sc=new SC(System.in);
        int N=sc.nextInt();
        long W=sc.nextLong();
        long[][] dp=new long[N+1][N*1000+1];   //品物の番号、価値
        long INF=200000000000014L;
        for(int i=0; i<=N; i++){
            for(int j=0; j<=N*1000; j++){
                dp[i][j]=INF;
            }
        }
        dp[0][0]=0;
        int[][] products=new int[N][2];
        for(int i=0; i<N; i++){
            products[i][1]=sc.nextInt();        //重さ
            products[i][0]=sc.nextInt();        //価値
        }

        for(int i=0; i<N; i++){
            for(int j=0; j<=N*1000; j++){
                if(j-products[i][0]<0){
                    dp[i+1][j]=dp[i][j];        //品物が買えないとき
                }
                else if(j-products[i][0]>=0 && dp[i][j-products[i][0]]+products[i][1]<=W){
                    dp[i+1][j]=Math.min(dp[i][j], dp[i][j-products[i][0]]+products[i][1]);
                }
                else{
                    dp[i+1][j]=dp[i][j];
                }
            }
        }
        long valmax=0;
        for(int i=0; i<=N*1000; i++){
            if(dp[N][i]<=W){
                valmax=i;
            }
        }
        pl(valmax);
    }
    public static void pl(Object o) {
        System.out.println(o);
    }
    public static void pl() {
        System.out.println();
    }
    public static void p(Object o) {
        System.out.print(o);
    }
    static class SC {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public SC(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }
        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }
    }
}

Measured memory_bytes: 126704
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		long t = System.currentTimeMillis();
		new Main().run();
		System.err.println(System.currentTimeMillis() - t);
	}
	
	
	void run() {
		FastScanner sc = new FastScanner();
		long X=sc.nextLong();
		System.out.println(X/500*1000+X%500/5*5);
	}
	
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}
	
	
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    public int nextInt() {
    	return (int)nextLong();
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main() {
    char b; cin>>b;
    if(b=='A'){
        c('T');
    }else if(b=='C'){
        c('G');
    }else if(b=='G'){
        c('C');
    }else{
        c('A');
    }
}

Measured memory_bytes: 256
/*
 * 16-07-15_ARC078_D.cpp
 *
 *  Created on: 2017/07/15
 *      Author: ryoma
 */
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<limits.h>

using namespace std;
const int INF = INT_MAX;
/////// テンプレ///////////

typedef int Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
			src(src), dst(dst), weight(weight) {
	}
};
bool operator <(const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
			e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) :
			data(size, -1) {
	}
	bool unionSet(int x, int y) {
		x = root(x);
		y = root(y);
		if (x != y) {
			if (data[y] < data[x])
				swap(x, y);
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
void Dijkstra(const Graph &g, int s, vector<Weight> &dist, vector<int> &prev) {
	int n = g.size();
	dist.assign(n, INF);
	dist[s] = 0;
	prev.assign(n, -1);
	priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
	for (Q.push(Edge(-2, s, 0)); !Q.empty();) {
		Edge e = Q.top();
		Q.pop();
		if (prev[e.dst] != -1)
			continue;
		prev[e.dst] = e.src;
		for (__typeof(g[e.dst].begin()) f = g[e.dst].begin();
				f != g[e.dst].end(); f++) {
			if (dist[f->dst] > e.weight + f->weight) {
				dist[f->dst] = e.weight + f->weight;
				Q.push(Edge(f->src, f->dst, e.weight + f->weight));
			}
		}
	}
}
int main() {
	int N;
	cin >> N;
	Graph g(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(Edge(a, b, 1));
		g[b].push_back(Edge(b, a, 1));
	}

	vector<Weight> dist0,distN;
	vector<int> prev0,prevN;
	Dijkstra(g,0,dist0,prev0);
	Dijkstra(g,N-1,distN,prevN);

	int ans =0;
	for(int i=1;i<N-1;i++){
		if(dist0[i] <= distN[i]){
			ans++;
		}else{
			ans--;
		}
	}


	//cout << ans << endl;
	if (ans > 0) {
		cout << "Fennec" << endl;
	} else {
		cout << "Snuke" << endl;
	}

	return 0;
}



Measured memory_bytes: 8872
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef pair<string, int> P;
typedef long long ll;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
int main(){
    int n,l;cin>>n>>l;
    vector<ll> a(n);
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    for(int i=1;i<=n-1;++i){
        if(a[i-1]+a[i]>=l){
            cout<<"Possible"<<endl;
            for(int j=1;j<i;++j){
                cout<<j<<endl;
            }
            for(int j=n-1;j>=i;--j){
                cout<<j<<endl;
            }
            return 0;
        }
    }
    cout<<"Impossible"<<endl;
    return 0;
}

Measured memory_bytes: 4068
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n, k;
	cin >> n >> k;
	vector<int> l(n);
	for (auto& v : l)
	{
		cin >> v;
	}
	ALL(sort, l, greater<int>());

	int ans = 0;
	REP(i, k)
	{
		ans += l[i];
	}

	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static List<List<Integer>> switchList;

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

        int sum = 0;
        int count = 1;
        for (int i = 0; i < N; i++) {
            int val = sc.nextInt();
            sum += val;
            if (sum > X) {
                break;
            }
            count++;
        }
        sc.close();

        System.out.println(count);

    }

}


Measured memory_bytes: 23124
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  string s;
  int k;
  cin >> s >> k;

  int id = 0;
  REP(i,s.size()){
    if(s[i] == '1') id++;
    else break;
  }

  if(id >= k) cout << 1 << endl;
  else cout << s[id] << endl;

  return 0;
}

Measured memory_bytes: 256
n=int(input())
num=list(map(int,input().split()))
num.sort()
flag=0
for i in range(n):
    if flag==1:break
    for j in range(1,n-i):
        if flag==1:break
        elif (num[i+j]-num[i])%(n-1)==0:
            print(num[i],num[i+j])
            flag=1


Measured memory_bytes: 5616
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
bool flag=0;
inline LL read()
{
	LL kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){if(cc-'0'==7)flag=1;kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
int main()
{
	int k=read();
	if(flag)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                if (500 * i + 100 * j + 50 * k == X) ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//----------------------Shanu Garg here---------------------
//-------------Search on youtube : Shanu Garg---------------
//-Studying at National Institute of Technology Delhi(NITD)-
//---------------------From Delhi, India--------------------

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

#define f(i,n) for(auto i=0;i<n;i++)
#define fr(i,n) for(auto i=n-1;i>=0;i--)
#define fs(i,a,b,c) for(auto i=a;i!=b;i+=c)
#define fl(i,x) for(auto i : x)
#define memset(a,first,last,val) fs(i,first,last,1) a[i]=val
#define nl cout<<"\n";
#define chk(x) cout<<#x<<x<<" ", nl
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vvi vector<vi>
#define pr pair<ll, ll>
#define vii vector<pair<int, int>>
#define vll vector<pr>
#define vl vector<ll>
#define m(a,b) map<a, b>
#define mid(a,b) ((a+b)/2)
#define pb push_back
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;

vl vb;
int N;

class triplet{ll f, s, t;};

vl in(ll n){
    vl ar;
    ll x;
    f(i,n)
    cin>>ar[i];
    return ar;
}
vll in_pr(ll n){
    vll ar;
    ll x,y;
    f(i,n)
    {cin>>x>>y;
    ar[i]={x,y};
    }return ar;
}
void out(vl v, char ch='\0'){
    fl(i,v)
    cout<<i<<ch;
}

void printArray(vector<int> arr, int n) 
{ 
    ll num=0;
    for (int i = 0; i < n; i++) 
    num*=10, num+=i;

    if(n==N)
    vb.pb(num);
        
} 

int printfactorialof(int n){
    if(n<=1)
        return 1;
    
    return n*printfactorialof(n-1);
}

void solve(){
ll a,b;
cin>>a>>b;
if(a==0){
    if(b==100){
        cout<<101,nl
    }
    else
    {
        cout<<b,nl
    }
}
else{
    if(a==1){
        if(b==100)
        cout<<10100,nl
        else
        {
            cout<<b*100,nl
        }
        
    }
    else{
        if(b==100){
            cout<<1010000,nl
        }
        else
        {
            cout<<b*10000,nl
        }
        
    }
}
}

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

Measured memory_bytes: 3612
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
	int num = S.length();
	char[] ss = S.toCharArray();
 		for(int i=0; i<num; i++){
		ss[i] = 'x';
        }   
	System.out.println(String.valueOf(ss));
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int l,r,d;

int main(void){
	scanf("%d%d%d",&l,&r,&d);
	int cnt=0;
	for(int i=l;i<=r;i++){
		if(i%d==0){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){
    intf x;
    cin >>x;

    for(int i=-1000;i<1001;i++){
        
        for(int h=-1000;h<1001;h++){

            if(pow(i,5)-pow(h,5)==x){
                cout << i<<"\t" <<h <<endl;
                return 0;
            }
        }
        
    }
}

Measured memory_bytes: 4096