akhauriyash/Code-Regression huggingface dataset:
/// 11:57 AM 03/05/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

template<typename T>
void ContainerError(T &v);

ll powmod(ll base, ll exp, ll MOD);

ll mpow(ll base, ll exp);

ll gcd(ll a, ll b);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n,m;
    cin >> n >> m;
    vector<ll> v(n);
    for(auto &x:v) {
        cin >> x;
    }
    vector<vector<ll> > G(n);
    for(ll i=0;i<m;i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    ll ans = 0;
    for(ll i=0;i<n;i++) {
        ll mh = INT_MIN;
        for(auto &x:G[i]) {
            mh = max(mh, v[x]);
        }
        if(v[i] > mh) {
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

template<typename T>
void ContainerError(T &v) {
    cout << "{";
    for (auto &x:v) { cout << x << ','; }
    cout << "}" << endl;
    return;
}

ll powmod(ll base, ll exp, ll MOD) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return (res % MOD);
}

ll mpow(ll base, ll exp) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base);
        base = (base * base);
        exp /= 2;
    }
    return (res);
}

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



Measured memory_bytes: 9764
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

#define MAXN 100000
int a[2*MAXN+10];
bool b[2*MAXN+10];
void solve(long long N, long long x){
	if (x==1||x==2*N-1) {
		puts("No");
		return;
	}	
	puts("Yes");
	memset(b,true,sizeof(b));
	if (x==2) {
		a[N]=2;
		a[N-1]=3;
		a[N+1]=1;
		a[N+2]=4;
		b[1]=b[2]=b[3]=b[4]=false;	
	} else {
		a[N]=x;
		a[N-1]=x-1;
		a[N+1]=x+1;
		a[N+2]=x-2;
		b[x-1]=b[x]=b[x+1]=b[x-2]=false;
	}
	stack<int> s;
	for(int i=1; i<2*N; ++i) {
		if (b[i]) s.push(i);
	}
	for(int i=1; i<2*N; ++i) {
		if (a[i]==0) {
			a[i]=s.top();
			s.pop();
		}
		cout<<a[i]<<' ';
	}
	puts("");
}

int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	long long x;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&x);
	solve(N, x);
	return 0;
}



Measured memory_bytes: 3100
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
//var input = 1463616;
var n = parseInt(input);
var on = n;

var primes = [];
while (n % 2 == 0) {
    primes.push(2);
    n = n / 2;
}
for (var i = 3; i * i <= n * n; i += 2) {
    while (n % i == 0) {
        primes.push(i);
        n /= i;
    }
}
if (n > 1) primes.push(n);

console.log(on + ': ' + primes.join(' '));


Measured memory_bytes: 16328
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 159, task d, 2020/09/08
//ms,
/*
方針は完璧だった。
recをintにしたのがバグの原因。
recそのものがintでおさまらないことはない。
だけどcasesに加えるとき、右辺の計算が一度intで処理されてしまうんだと思う。
recをint64_tにしたら通るし、右辺の計算時に一部にint64_tを含めばそれだけで勝ち。
*/

int main(void){
  int N;
  vector<int> rec(200001);//インデックスはボールに書かれた数字、要素は個数
  vector<int> a;
  int64_t cases=0;

  for(int i=0;i<200000;i++) rec[i]=0;

  cin >>N;
  for(int i=0;i<N;i++){
    int tmp_a;
    cin >>tmp_a;
    rec[tmp_a]++;
    a.push_back(tmp_a);
  }

  int64_t one=1;
  for(int i=1;i<200000;i++) cases+=one*rec[i]*(rec[i]-1)/2;

  for(int i=0;i<N;i++){
    int same_balls =rec[a[i]];
    int64_t ans=cases - same_balls*(same_balls-1)/2;
    ans += (same_balls-1)*(same_balls-2)/2;
    cout <<ans <<endl;

  }


  return 0;
}
/*
*/


Measured memory_bytes: 5104
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] nums = new int[N];
    int result=0;
    for (int i = 0; i < N; i++) {
      nums[i] = sc.nextInt();
    }

    Arrays.sort(nums);
    for (int i = 0; i < N; i++) {
      for (int j = i+1; j < N; j++) {
        int a = nums[i];
        int b = nums[j];
        for (int k = j+1; k < N; k++) {
          int c = nums[k];
          if(c>=a+b) break;
          if( (a<b+c) && (b<a+c) && (c<b+a) ){
            result++;
          }
        }
      }
    }


    System.out.println(result);
  }

}


Measured memory_bytes: 26680
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll k,a,b;
  cin >> k >> a >> b;
  if(b-a <= 2){
    cout << k+1 << endl;
  } else {
    ll accnt = k-(a-1);
    if(accnt < 2){
      cout << k+1 << endl;
    }else{
      cout << (a+(b-a)*(accnt/2)+(accnt%2)) << endl;
    }
  }
}


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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  
  int ab, ac, ad, ae;
  int bc, bd, be;
  int cd, ce;
  int de;
  
  ab = b - a; ac = c - a; ad = d - a; ae = e - a;
  bc = c - b; bd = d - b; be = e - b;
  cd = d - c; ce = e - c;
  de = e - d;
  
  if(ab > k || ac > k || ad > k || ae > k || bc > k || bd > k || be > k || cd > k || ce > k || de > k)
    cout << ":(" << endl;
  else
    cout << "Yay!" << endl;
}

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

int main(){
  long long n;
  cin >> n;
  stack<char> S;
  while(n>0){
    long long s;
    s = n%26;
    char x;
    if(s==1) x = 'a';
    if(s==2) x = 'b';
    if(s==3) x = 'c';
    if(s==4) x = 'd';
    if(s==5) x = 'e';
    if(s==6) x = 'f';
    if(s==7) x = 'g';
    if(s==8) x = 'h';
    if(s==9) x = 'i';
    if(s==10) x = 'j';
    if(s==11) x = 'k';
    if(s==12) x ='l';
    if(s==13) x ='m';
    if(s==14) x ='n';
    if(s==15) x ='o';
    if(s==16) x ='p';
    if(s==17) x ='q';
    if(s==18) x ='r';
    if(s==19) x ='s';
    if(s==20) x ='t';
    if(s==21) x ='u';
    if(s==22) x ='v';
    if(s==23) x ='w';
    if(s==24) x ='x';
    if(s==25) x ='y';
    if(s==0) x ='z';
    S.push(x);
    n = (n - s)/26;
    if(s==0) n--;
    
  }
  while(!S.empty()){
    cout << S.top();
    S.pop();
  }
}
    
    

  



Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>

int main(void)
{
	int x, h;
	double a, sh;
	
	while (scanf("%d %d", &x, &h), x != 0 || h != 0){
		a = x * x;
		sh = (x / 2.0) * (x / 2.0) + h * h;
		
		a += (x * sqrt(sh) / 2) * 4;
		
		printf("%f\n", a);
	}
	
	return (0);
}

Measured memory_bytes: 628
#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 A, P;
  cin >> A >> P;
  cout << (A*3 + P)/2 ;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  char a[100000][2];
  int n,m;
  char in;
  while(cin>>n,n){
    for(int i=0;i<n;i++){
      cin>>a[i][0]>>a[i][1];
    }
    cin>>m;
    for(int i=0;i<m;i++){
      cin>>in;
      bool flg=true;
      for(int j=0;j<n;j++){
	if(a[j][0]==in){cout<<a[j][1];flg=false;break;}
      }
      if(flg)cout<<in;
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define MAX 2000000

int main() {
  int n;
  scanf("%d", &n);
  long long A[n];
  for (int i=0; i<n; i++) {
    scanf("%llu", &A[i]);
  }

  int res=0;
  for (int i=0; i<n; i++) {
    while (A[i]%2 == 0) {
      A[i] = A[i] / 2;
      res++;
    }
  }


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

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

template
<
    typename TYPE,
    std::size_t SIZE
>
std::size_t array_length(const TYPE (&)[SIZE])
{
    return SIZE;
}

using namespace std;

int main(){
    map <char, int> score; //辞書作成
    char tags[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
    string str, s;
    while(getline(cin, s)){
        str += s;
    }

    for ( int i = 0; i < array_length(tags); i++ ){
        score[tags[i]] = 0;
    }
 
    for ( int i = 0; i < (int)str.size(); i++ ){
        score[str[i]] += 1;
        if( isupper( str[i] ) != 0 ) {
            score[char(str[i] + 0x20)] += 1;
         }
    }

    for( int i = 0; i < array_length(tags); i++ ) {
            cout << tags[i] << " : " << score[tags[i]]  << endl;
    }

    return 0;
}


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

using namespace std;

#define MP make_pair

typedef pair<int, int> PII;

const int SIZE = 100;

char line[SIZE], t[SIZE];
set<int> memo[SIZE][SIZE];
set<PII> used;
 
void eval(int const l, int const r) {
   
  set<int>& ret = memo[l][r];
  if(l == r) return;
   
  if(used.count(MP(l, r))) return;
  used.insert(MP(l, r));
   
  // check is digits [l, r)
  bool digits = true;
  for(int i=l; i<r; i++) { digits = digits && isdigit(line[i]); }
  strncpy(t, line+l, r-l); t[r-l] = 0;
  if(digits) { ret.insert(atoi(t)); return; }
   
  int par = 0; bool check = true;
  for(int i=l; i<r-1; i++) {
    if(line[i] == '(') { par ++; }
    if(line[i] == ')') { par --; }
    if(par == 0) { check = false; }
  }
   
  // "(expr)"
  if(check) {
    if(line[r-1] == ')') {
      eval(l+1, r-1); ret = memo[l+1][r-1]; return;
    }
  }
   
  par = 0;
  // parsing loop
  for(int i=l; i<r; i++) {
    if(line[i] == '(') { par ++; }
    if(line[i] == ')') { par --; }
    if(par != 0) continue;
     
    switch(line[i]) {
    case '+': case '-': case '*': case '/': {
      eval(l, i); eval(i+1, r);
      set<int>::iterator iter_a, iter_b;
      for(iter_a = memo[l][i].begin(); iter_a!=memo[l][i].end(); iter_a++) {
        for(iter_b = memo[i+1][r].begin(); iter_b!=memo[i+1][r].end(); iter_b++) {
          if(line[i] == '+') { ret.insert(*iter_a + *iter_b); }
          if(line[i] == '-') { ret.insert(*iter_a - *iter_b); }
          if(line[i] == '*') { ret.insert(*iter_a * *iter_b); }
          if(line[i] == '/') {
            if(*iter_b == 0) continue;
            ret.insert(*iter_a / *iter_b);
          }
        }
      }
      break;
    }
    default:;
    }
  } // for parsing loop
}
 
int main() {
   
  while(1) {
    scanf("%s\n", line);
    for(int i=0; i<SIZE; i++)
      for(int j=0; j<SIZE; j++)
        memo[i][j].clear();
     
    used.clear();
     
    if(0==strcmp(line, "#")) break;
    eval(0, strlen(line));
    cout << memo[0][strlen(line)].size() << endl;
  }
   
  return 0;
}

Measured memory_bytes: 1764
import collections

n = int(raw_input())
s = map(lambda x:ord(x) - ord('a'.upper()),list(raw_input()))

count,c = 0,0

for i in s:
	if i == c:
		c +=1
	else:
		c = 0
		if i == c: c +=1
	if c == 3:
		count +=1
		c = 0
print count


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

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

struct Tree	//create tree(directed) from graph(undirected)
{
    int n;
    int root;
    vector<vector<int>> t;
    vector<int> par;
    vector<int> dpt;
    
    void init(Graph &g, int root_){
        n = g.n;
        root = root_;
        t.resize(n);
        par.resize(n);
        dpt.resize(n);
        fill(dpt.begin(), dpt.end(), -1);
        queue<int> que;
        par[root] = -1;
        dpt[root] = 0;
        que.push(root);
        while(que.size()){
            int pa = que.front();
            que.pop();
            for(int ch : g.g[pa]){
                if(dpt[ch] == -1){
                    t[pa].push_back(ch);
                    par[ch] = pa;
                    dpt[ch] = dpt[pa] + 1;
                    que.push(ch);
                }
            }
        }
    }

    Tree(){}
    
    Tree(Graph &g, int root_){
        init(g, root_);
    }
    
    vector<int> toposort(){
        typedef pair<int, int> P;
        vector<P> p(n);
        for(int i = 0; i < n; i++) p[i] = P(dpt[i], i);
        sort(p.begin(), p.end(), greater<P>());
        vector<int> res(n);
        for(int i = 0; i < n; i++) res[i] = p[i].second;
        return res;
    }
};

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.add_edge(a, b);
        g.add_edge(b, a);
    }
    Tree t(g, 0);
    int l = 0;
    for(int i = 0; i < n; i++){
        if(t.dpt[i] > t.dpt[l]) l = i;
    }
    Tree tt(g, l);
    int d = 0;
    for(int i = 0; i < n; i++) d = max(d, tt.dpt[i]);
    if((d + 2) % 3) cout << "First" << endl;
    else cout << "Second" << endl;
}


Measured memory_bytes: 38952
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  map<int, int> A;
  for (int i = 0; i < N - 1; i++) {
  	int key;
    cin >> key;
    int tmpKey = key - 1;
    A[tmpKey] += 1;
  }
  for (int i = 0; i < N; i++) {
      cout << A[i] << endl;
  }
}

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

int n, ans=1;
string s[200004];

int main(){
	cin >> n;
	for (int i=0;i<n;i++) cin >> s[i];
	sort(s,s+n);
	for (int i=1;i<n;i++){
		if (s[i]!=s[i-1]) ans++;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 9892
//This code is written by Anubhav Srivastava(anubhavsrivastavawebpage.wordpress.com)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >>s;
    if(s[2]==s[3] && s[4]==s[5])	cout <<"Yes";
    else	cout << "No";
    
    return 0;
}


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



int main() {
	ll n;
	cin >> n;
	vector<ll> f(n+1);
	for (ll i=1;i<=n;++i) {
		for (ll j=1;i*j<=n;j++) f[i*j]++;
	}
	ll ans = 0;
	rep(i,n+1) ans += i*f[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 81380
#include <cstdio>
#include <vector>
#include <algorithm>

int main() {
  int N, K;
  scanf("%d %d", &N, &K);

  if (N == K) {
    printf("0\n");
    return 0;
  }

  std::vector<int> A(N+1);
  for (int i=0; i<N; ++i) {
    int a;
    scanf("%d", &a);
    ++A[a];
  }

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

  int nonzero=std::upper_bound(A.begin(), A.end(), 0)-A.begin();
  K += nonzero;

  int res=0;
  for (int i=nonzero; i<N; ++i) {
    if (N < K) break;

    if (A[i]) {
      res += A[i];
      ++K;
    }
  }

  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {


    public static void main(String[] args) throws IOException {

        Scanner s = new Scanner(System.in);
        String word = s.next();
        if(word.charAt(word.length()-1)=='s')word+="es";
        else word+="s";
        System.out.println(word);


    }


}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

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

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25380
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007
ll fac[1000000];
ll finv[1000000];
ll inv[1000000];

void comb_init(){
  fac[0] = 1;
  fac[1] = 1;
  for(int i=2;i<1000000;i++){
    fac[i] = i*fac[i-1];
    fac[i] %= MOD;
  }
  inv[1] = 1;
  for(int i=2;i<1000000;i++){
    inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
  }
  finv[0] = 1;
  finv[1] = 1;
  for(int i=2;i<1000000;i++){
    finv[i] = inv[i]*finv[i-1];
    finv[i] %= MOD;
  }
}

ll comb(ll n,ll k){
  ll c;
  c = fac[n];
  c *= finv[k];
  c %= MOD;
  c *= finv[n-k];
  c %= MOD;
  return c;
}

int main(){
  ll n,t;
  cin >> n >> t;
  ll a[n],b[n];
  pair<ll,ll> c[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    c[i] = make_pair(a[i],b[i]);
  }

  ll dp[n+1][t+1];

  for(int i=0;i<n+1;i++){
    for(int j=0;j<t+1;j++){
      dp[i][j] = 0;
    }
  }
  for(int i=1;i<n+1;i++){
    for(int j=1;j<t+1;j++){
      dp[i][j] = dp[i-1][j];
      if(j >= a[i-1]){
        dp[i][j] = max(dp[i-1][j],dp[i-1][j-a[i-1]]+b[i-1]);
      }
    }
  }

  ll dp_inv[n+2][t+1];

  for(int i=0;i<n+2;i++){
    for(int j=0;j<t+1;j++){
      dp_inv[i][j] = 0;
    }
  }
  for(int i=n;i>=1;i--){
    for(int j=1;j<t+1;j++){
      dp_inv[i][j] = dp_inv[i+1][j];
      if(j >= a[i-1]){
        dp_inv[i][j] = max(dp_inv[i+1][j],dp_inv[i+1][j-a[i-1]]+b[i-1]);
      }
    }
  }

  ll ans = 0;
  for(int i=1;i<n+1;i++){
    for(int j=0;j<t;j++){
      ans = max(ans,dp[i-1][j]+dp_inv[i+1][t-1-j]+b[i-1]);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 141056
lines = readlines.map(&:chomp).map{|line| line.split.map(&:to_i)}
lines.each do |line|
    break if line == [0, 0]
    line[0].times do |i|
        line[1].times do |j|
            if i == 0 || i == line[0]-1 || j == 0 || j == line[1]-1 then
                print "#"
            else
                print "."
            end
        end
        puts
        end
    puts
end


Measured memory_bytes: 6844
#include <bits/stdc++.h>
    
#define int long long

#define REP(i,n) for(int i=0;i<n;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 pb(x) push_back(x)
#define mp(x, y) make_pair(x, y) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
#define MOD (int)(1e9)+7

using namespace std;

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

int32_t main(){
    int a[]={399, 799, 1199, 1599, 1999, 2399, 2799, 3199};
    int n, ans=0, cnt=0;
    cin >> n;

    vector<bool> f(n, false);
    REP(i, n){
        int s;
        cin >> s;

        if(s>=3200){
            cnt++;
            continue;
        }

        REP(j, 8){
            if(a[j]>=s){
                if(!f[j]){
                    f[j]=true;
                    ans++;
                }
                break;
            }
        }
    }

    if(ans>0){
        cout << ans << endl;
    }
    else{
        cout << 1 << endl;
    }

    cout << ans+cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  ll n, q;
  cin >> n;
  ll sum = 0;
  map<ll, ll> m;
  vector<ll> a(n);
  rep(i, 0, n) {
    cin >> a[i];
    sum += a[i];
    m[a[i]]++;
  }
  cin >> q;
  
  rep(i, 0, q) {
    ll b, c;
    cin >> b >> c;
    sum -= m[b]*b;
    sum += m[b]*c;
    m[c] += m[b];
    m[b] = 0;    
    cout << sum << "\n";
  }
}

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

#define MAX_N 300000

long long int prime[MAX_N]; // i??????????´???°
bool is_prime[MAX_N + 1];   // is_prime[i]???true????????°i????´???°
int acc[MAX_N]={0};

// n??\???????´???°?????°?????????
long long int sieve(long long int n) {
    long long int p = 0;
    for (long long int i = 0; i <= n; i++)
        is_prime[i] = true;
    is_prime[0] = false;
    for (long long int i = 2; i <= n; i++) {
        if (is_prime[i]) {
            prime[p++] = i;
            for (long long int j = 2 * i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
    return p;
}

int main(){
    sieve(MAX_N);
    for(int i=2;i<MAX_N;++i)acc[i] = acc[i-1] + (is_prime[i] ? 1 : 0);
    int n;
    while(cin >> n, n != 0){
        cout << acc[2*n] - acc[n] << endl;
    }

    return 0;
}


Measured memory_bytes: 4752
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int A, B, C; cin >> A >> B >> C;

	cout << max(0, C - (A - B)) << endl;


	return 0;
}

Measured memory_bytes: 256
from copy import deepcopy
N, x = map(int, input().split())
a = list(map(int, input().split()))
c = 0
for i in range(N - 1):
    if a[i] + a[i + 1] > x:
        c += a[i] + a[i + 1] - x
        a[i + 1] -= a[i] + a[i + 1] - x
        if a[i + 1] < 0:
            a[i] -= -a[i + 1]
            a[i + 1] = 0
print(c)

Measured memory_bytes: 20528
import java.util.*;
 
public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int M = sc.nextInt();
    int D = sc.nextInt();
    int cnt = 0;
    for(int i=1;i<M+1;i++) { 
    for(int j=22; j<=D; j++){
      int d1 = j/10;
      int d10 = j%10;
      if(d1 >=2 && d10 >=2 && d1*d10 == i){
        cnt++;
      }
    }
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 35784
#include <bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
using G=vector<vector<int>>;
#define INF 10000000000000ll
int a,b,q;
vector<ll> s(100005),t(100005);
P sBS(ll x){
    int l=0,r=a-1;
    P p;
    if(s.at(0)>x){
        p.first=-INF;
        p.second=s.at(0);
        return p;
    }
    if(s.at(a-1)<x){
        p.first=s.at(a-1);
        p.second=INF;
        return p;
    }
    while(r-l>1){
        if(s.at((l+r)/2)>x) r=(l+r)/2;
        if(s.at((l+r)/2)<x) l=(l+r)/2;
    }
    
    p=make_pair(s.at(l),s.at(r));
    return p;
}
P tBS(ll x){
    int l=0,r=b-1;
    P p;
    if(t.at(0)>x){
        p.first=-INF;
        p.second=t.at(0);
        return p;
    }
    if(t.at(b-1)<x){
        p.first=t.at(b-1);
        p.second=INF;
        return p;
    }
    while(r-l>1){
        if(t.at((l+r)/2)>x) r=(l+r)/2;
        if(t.at((l+r)/2)<x) l=(l+r)/2;
        
    }
    p=make_pair(t.at(l),t.at(r));
    return p;
}
int main(){
    
    cin >> a >> b >> q;
    
    rp(i,a) cin >> s.at(i);
    rp(i,b) cin >> t.at(i);
    vector<ll>  ans(q);
    rp(i,q){
        ll x;
        cin >> x;
        ll cand;
        cand=x-tBS(sBS(x).first).first;
        cand=min(cand,tBS(sBS(x).second).second-x);
        cand=min(cand,(x-sBS(x).first)+(tBS(sBS(x).first).second-sBS(x).first));
        cand=min(cand,(sBS(x).second-x)+(sBS(x).second-tBS(sBS(x).second).first));
        cand=min(cand,x-sBS(tBS(x).first).first);
        cand=min(cand,sBS(tBS(x).second).second-x);
        cand=min(cand,(x-tBS(x).first)+(sBS(tBS(x).first).second-tBS(x).first));
        cand=min(cand,(tBS(x).second-x)+(tBS(x).second-sBS(tBS(x).second).first));
        ans.at(i)=cand;
    }
    for(auto an:ans){
        cout << an << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
  string c1, c2;
  cin >> c1 >> c2;
  if(c1[0]==c2[2]&&c1[1]==c2[1]&&c1[2]==c2[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


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();

        LinkedList<Long> list = new LinkedList<>();
        
        for (int i = 1; i < 10; i++) {
            recLun(1,(long)i, list);
        }
        long[] lunlun = list.stream().mapToLong(i->i).toArray();
        Arrays.sort(lunlun);
        System.out.println(lunlun[N-1]);
        

    }

    public static void recLun(int d, long num, LinkedList<Long> list){
        if(d == 11){
            return;
        }
        list.add(num);
        int b =(int)( num%10-1);
        for (int i = 0; i < 3; i++) {
            if(i+b >= 0 && i+b <= 9){
                recLun(d+1, num*10+b+i, list);
            }
        }
    }
}

Measured memory_bytes: 40620
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string s; cin>>s;
    ll pp,sum = 0, len = s.size();
    for(ll i=0; i<len; i++)
    {
        pp = s[i] - '0';
        sum += pp;
    }
    if(sum%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 3764
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

void solve() {
    int k;
    cin >> k;
    if (k < 10) {
        cout << k << endl;
        return;
    }
    VLL a;
    REP(i,1,10) a.push_back(i);
    int index = 0;
    while (a.size() < k) {
        LL v = a[index];
        int last = v % 10;
        REP(i,last-1,last+2) {
            if (i < 0 || i > 9) continue;
            a.push_back(v * 10 + i);
        }

        ++index; 
    }
    cout << a[k - 1] << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long i,n,l=0;
	scanf("%lld",&n);
	for(i=sqrt(n);i>=1;i--)
		if(n%i==0)break;
	i=n/i;
	while(i>0)
	{
		i/=10;
		l++;
	}
	printf("%lld\n",l);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    long long int n;
    cin >> n;
    n -= 1;
    long long int ans = 0;
    for (long long int i = 0; n > 0; i++)
    {
        ans += n;
        n -= 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input());
a = [int(num) for num in input().split()];

sum = [a[0]];
for i in range(1, n):
	sum.append(sum[i - 1] + a[i]);
	
mini = abs(sum[0] - (sum[n - 1] - sum[0]));
for i in range(1, n - 1):
	mini = min(mini, abs(sum[i] - (sum[n - 1] - sum[i])));
	
print(mini);

Measured memory_bytes: 24832
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] set = new int[N];
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            set[i] = sc.nextInt();
            min = Math.min(min, set[i]);
        }

        boolean[] dp = new boolean[K + 1];
        for (int i = min; i <= K; i++) {
            for (int j = 0; j < N; j++) {
                if (i - set[j] >= 0 && !dp[i - set[j]]) {
                    dp[i] = true;
                }
                if (dp[i]) break;
            }
        }

        if (dp[K]) {
            System.out.println("First");
        } else {
            System.out.println("Second");
        }


    }
}


Measured memory_bytes: 23508
/* ITP1_6_A */
import java.io.*;

class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();

    int n = Integer.parseInt(br.readLine()); // The number of elements
    String array[] = br.readLine().split(" "); // Array

    sb.append(array[n-1]);

    for(int i = n-2; i >= 0; i--) sb.append(" " + array[i]);

    System.out.println(sb);
  }
}

Measured memory_bytes: 24148
//Created by: Aditya Singh
//Bleed Blue
#include <bits/stdc++.h>

using namespace std;

#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define unm unordered_map<int,int>
#define pb emplace_back
#define nt _int128
#define PI 3.1415926535897932384626433
#define inf 1e18

const int N = 100005;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    // int t;cin>>t;while(t--)
    {
        int i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
        cin >> n >> m;
        int ar[n][2];
        for (i = 0; i < n; i++)
            cin >> ar[i][0] >> ar[i][1], sum += ar[i][1];
        vector<int> dp(sum + 1, inf);
        dp[0] = 0;
        for (i = 0; i < n; i++)
        {
            for (j = sum - ar[i][1]; j >= 0; j--)
                dp[j + ar[i][1]] = min(dp[j + ar[i][1]], dp[j] + ar[i][0]);
        }
        for (i = 0; i <= sum; i++)
        {
            if (dp[i] <= m)
                ans = max(ans, i);
        }
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 3924
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline int rd(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?x:-x;
}
int n,m,fa[100050],vis[100050],cnt,p[100050],ct;
long long val[100050],ans;
inline int find(int x){
	if(x!=fa[x]) return fa[x]=find(fa[x]);
	return fa[x];
}
inline void unionn(int x,int y){
	x=find(x);y=find(y);fa[x]=y;
}
vector<int>G[100050];
int main(){
	n=rd(),m=rd();
	for(int i=1;i<=n;i++){
		val[i]=rd(),fa[i]=i;
	}int x,y;
	for(int i=1;i<=m;i++){
		x=rd()+1,y=rd()+1;
		unionn(x,y);
	}
	if(m==n-1){
		puts("0");
		return 0;
	}
	if((n-m-1)*2>n){
		puts("Impossible");
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(vis[find(i)]) G[vis[fa[i]]].push_back(val[i]);
		else G[vis[find(i)]=++cnt].push_back(val[i]);
	}
	for(int i=1;i<=cnt;i++){
		sort(G[i].begin(),G[i].end());
		ans+=G[i][0];int sz=G[i].size();
		for(int j=1;j<sz;j++){
			p[++ct]=G[i][j];
		} 
	}sort(p+1,p+1+ct);
	for(int i=1;i<=n-m-2;i++){
		ans+=p[i];                  
	}
	cout<<ans;
	return 0;
}

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

typedef long long ll;
#define pb 			push_back
#define mp 			make_pair
#define max(a,b) 	(a>b?a:b)
#define min(a,b) 	(a<b?a:b)
const int sz = 1e5 + 5;

int main(){
	
	ios_base::sync_with_stdio(false);
	ll n, a, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++) cin >> a;
	ll ans = (n - 1 + m - 1 - 1) / (m - 1);
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

const ll D = 60, MAX_N = 210000;
ll to[D][MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, K;
    cin >> N >> K;
    rep(i,N) {
        cin >> to[0][i];
        to[0][i]--;
    }

    rep(i,D-1) rep(j, N) to[i+1][j] = to[i][to[i][j]];

    ll now = 0;
    for(ll i = D-1; i >= 0; i--) {
        ll l = 1ll<<i;
        if(l <= K) {
            now = to[i][now];
            K -= l;
        }
    }

    cout << now+1 << endl;
}


Measured memory_bytes: 97552
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int d = sc.nextInt();

        int search = 2 * d + 1;
        int ans = 0;
        for (int i = 0; i < 20; i++) {
            if (n <= 0) {
                break;
            }
            n -= search;
            ans++;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 22740
a = []
a = gets.split.map(&:to_i)
c = []
while s = gets
  c.push(s.split.map(&:to_i))
end

t_f = 0
t_l=1*10**5
#p c
for i in 0..a[1]-1
    if t_f<=c[i][0]
        t_f = c[i][0]
    end
    if t_l>=c[i][1]
        t_l = c[i][1]
    end
end
if t_l-t_f>=0
    puts t_l-t_f+1
else
    puts 0
end

Measured memory_bytes: 9596
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int H, W, h, w;
		H = sc.nextInt();
		W = sc.nextInt();
		h = sc.nextInt();
		w = sc.nextInt();
 
		while (h > 0) {
			h--;
			H--;
		}
 
		while (w > 0) {
			w--;
			W--;
		}
 
		int ans = H*W;
		if (ans < 0) {
			System.out.println(0);
		} else {
			System.out.println(ans);
		}
	}
 
}

Measured memory_bytes: 35672
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll n,k;
cin>>n>>k;
ll a[n];
for(ll i=1;i<=n;i++)
{
   a[i]=0; 
}
/*for(ll i=1;i<=n;i++)
{
    cout<<a[i]<<" ";
}*/
while(k--)
{
    ll d;
    cin>>d;
    while(d--)
    {
        ll x;
        cin>>x;
        a[x]=1;
    }
}
ll c=0;
for(ll i=1;i<=n;i++)
{
    if(a[i]==0)
    c++;
}
cout<<c<<endl;
    return 0;
    
}

Measured memory_bytes: 3656
#include<stdio.h>
int n;
int wza[8192],wzb[8192];
int nxt[8192],mx[8192];
char s[8192];
bool vis[8192];
void build(int wz,char* t)
{
	for(int i=0;i<(n<<1);i++)
	{
		vis[i]=false;
	}
	for(int i=wz;i<n;i=nxt[i])
	{
		vis[wza[i]]=true;
		vis[wzb[i]]=true;
	}
	int m=0;
	for(int i=0;i<(n<<1);i++)
	{
		if(vis[i])
		{
			t[m]=s[i];
			m++;
		}
	}
	t[m]='\0';
}
char s1[8192],s2[8192];
int main()
{
	scanf("%d%s",&n,s);
	int numa=0,numb=0;
	for(int i=0;i<(n<<1);i++)
	{
		if(s[i]=='a')
		{
			wza[numa]=i;
			numa++;
		}
		else
		{
			wzb[numb]=i;
			numb++;
		}
	}
	wza[n]=1000000;
	wzb[n]=1000000;
	mx[n]=n;
	for(int i=n-1;i>=0;i--)
	{
		if(wza[i]<wzb[i])
		{
			for(int j=i+1;;j++)
			{
				if(wza[j]>wzb[i])
				{
					nxt[i]=mx[j];
					break;
				}
			}
		}
		else
		{
			if(wzb[i+1]<wza[i])
			{
				nxt[i]=i+1;
			}
			else
			{
				nxt[i]=mx[i+1];
			}
		}
		build(i,s1);
		build(mx[i+1],s2);
		mx[i]=mx[i+1];
		for(int j=0;;j++)
		{
			if(s1[j]>s2[j])
			{
				mx[i]=i;
				break;
			}
			if(s1[j]<s2[j])
			{
				break;
			}
			if(s1[j]=='\0')
			{
				break;
			}
		}
	}
	build(mx[0],s1);
	printf("%s\n",s1);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  long n;  scanf("%ld", &n);

  int ans[100] = {0};

  do{
    if((n-1) / 26){
      ans[++ans[0]] = (n-1) % 26;
    }else{
      ans[++ans[0]] = n - 1;
    }
    n = (n-1) / 26;
  }while(n);

  while(ans[0])
    printf("%c", (char)(ans[ans[0]--]+(int)'a'));

  puts("");

  return 0;
}


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

int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1)
	{
	    c-=b;
	    if(c<=0)
	    {
	        cout<<"Yes";
	        exit(0);
	    }
	    a-=d;
	    if(a<=0)
	    {
	        cout<<"No";
	        exit(0);
	    }
	}
	return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	for (int h = 1; h <= 3500; h++) {
		for (int n = 1; n <= 3500; n++) {
			int a = 4 * h * n - N * n - N * h;
			if (a == 0)continue;
			int b = N * h * n;
			if (b % a == 0) {
				int w = b / a;
				if (w <= 0)continue;
				cout << h << " " << n << " " << w << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = 0, now = 0;
    rep(i, 0, s.size()){
        now = (now + 1) % 26;
        rep(j, 0, 26){
            if(now == 0) ans++;
            if(now == s[i] - 'A') break;
            now = (now + 1) % 26;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3192
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();
		for(int i=0 ; i<10 ;i++){
			int a = sc.nextInt();
			list.add(a);
		}
		
		Collections.sort(list);
		
		System.out.println(list.get(9));
		System.out.println(list.get(8));
		System.out.println(list.get(7));
		
		
	}

}

Measured memory_bytes: 26144
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int h,a;
	cin>>h>>a;
	cout<<(h/a) + (h%a !=0);
	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  int s,amari;
  s = a+b;
  amari = s%2;
  cout << (s+amari)/2 << endl;;
  // ここにプログラムを追記
}

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

#define pb push_back
#define ri(x) scanf("%d",&x)
#define rii(x,y) ri(x),ri(y)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define ms2(obj,val,sz) memset(obj,val,sizeof(obj[0])*sz)
#define FOR(i,f,t) for(int i=f;i<(int)t;i++)
#define FORR(i,f,t) for(int i=f;i>(int)t;i--)

typedef long long ll;
typedef vector<int> vi;

const int MAXN=1e5;

int N,A[MAXN],cnt1=0,cnt2=0,cnt3=0;

int main() {
	ri(N);
	FOR(i,0,N) ri(A[i]);
	FOR(i,0,N) {
		if(A[i] % 4 == 0) cnt1++;
		else if(A[i] % 2 == 0) cnt2++;
		else cnt3++;
	}
	if(cnt2 == 0) printf("%s\n", cnt1 >= cnt3 - 1 ? "Yes" : "No");
	else printf("%s\n", cnt1 >= cnt3 ? "Yes" : "No");
}


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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 400200;
const long long Q = N * 30;
const long long mod = 1e9 + 7;
const long long MAGIC = 30;

using namespace std;

int n;
int a[N];

void solve()
{
        cin >> n;
        int cnt = 0;
        for(int i = 1; i <= n; i++){
                cin >> a[i];
                if(a[i] == a[i - 1]){
                        a[i] = -1;
                        cnt++;
                }
        }
        cout << cnt << "\n";
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("island.in");
        //fout("island.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace PaizaSkillCheck
{
    public class Program
    {
        public static int[,] map;

        public static void Main(string[] args)
        {
            int d = int.Parse(Console.ReadLine());

            int n = 25 - d;

            StringBuilder sb = new StringBuilder();
            sb.Append("Christmas");

            for (int i = 0; i < n; i ++)
            {
                sb.Append(" Eve");
            }

            Console.WriteLine(sb.ToString());
            Console.ReadLine();
        }

    }

}


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

int N, C, imos[40][100100];

signed main()
{
    cin >> N >> C;
    for(int i = 0; i < N; i++){
        int a, b, c;
        cin >> a >> b >> c;
        imos[c][a - 1]++;
        imos[c][b]--;
    }
    for(int i = 1; i <= C; i++){
        for(int j = 1; j <= 100000; j++){
            imos[i][j] += imos[i][j - 1];
            if(imos[i][j])imos[0][j]++;
        }
    }
    int ans = 0;
    for(int i = 0; i <= 100000; i++){
        ans = max(ans, imos[0][i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12544
#include <iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include <set>
#include <numeric>
#include<math.h>
#include<queue>
#include<unordered_map>
#include<cmath>
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
#define ll long long int
#define pi (double)3.14159265359
#define vect vector <int>
#define pb push_back
using namespace std;

void solve() {
	int n, k;
	cin >> n >> k;
	vect v(n + 1);
	fo(i, n) cin >> v[i];
	sort(v.begin(), v.end());
	int ans = 0, j = 0;
	k++;
	while (k--) {
		ans += v[j];
		j++;
	}
	cout << ans;
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 3600