akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

const int MAX_N = 300050;
int N;
int P[MAX_N];

int loc[MAX_N], cnt[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> P[i];
    }

    for (int i = 1; i <= N; i++) {
        loc[P[i]] = i;
        cnt[i] = 0;
    }

    int ret = N - 1;
    for (int i = 1; i <= N; i++) {
        if (cnt[i] != -1) {
            int tmp = P[i];
            cnt[i] = 1;
            while(loc[tmp] < loc[tmp+1]) {
                cnt[loc[tmp+1]] = -1;
                tmp += 1;
                cnt[i]++;
            }
        }
        ret = std::min(ret, N - cnt[i]);
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for (int i=0; i < int(n); i++)


struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;
  // weight_diffs[i]: ノードpar[i]とノードiの重さの差。親ノードの方が重いとき正値をとる
  vector<int> weight_diffs;

  UnionFind(int n) : par(n), sizes(n, 1), weight_diffs(n) {
    rep(i,n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    int p = find(par[x]);
    weight_diffs[x] += weight_diffs[par[x]];  // 重み差を伝搬する
    return par[x] = p;
  }

  // xの方がyよりwだけ重い
  void unite(int x, int y, int w) {
    int nx = find(x);
    int ny = find(y);
    if (nx == ny) return;

    // xの重み差は増幅され、yの重み差は相殺される
    w += weight_diffs[x];
    w -= weight_diffs[y];

    x = nx;
    y = ny;

    if (sizes[x] < sizes[y]) {
      swap(x, y);
      w *= -1;
    }

    // xがyの親になるように連結する
    par[y] = x;
    weight_diffs[y] = w;
    sizes[x] += sizes[y];
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // w_x - w_y を求める
  int getdiff(int x, int y) {
    int nx = find(x);
    int ny = find(y);
    if (nx != ny) throw "bug";

    // w_x - w_y
    // = -(w_root - w_x) + (w_root - w_y)
    // = -weight_diffs[x] + weight_diffs[y]
    return -weight_diffs[x] + weight_diffs[y];
  }
};

int n, m;

int solve() {
  UnionFind uf(n);
  
  rep(qi, m) {
    char com;
    int a, b;
    cin >> com >> a >> b;
    a--;
    b--;
    if (com == '!') {
      int w;
      cin >> w;
      uf.unite(a, b, w);
    }
    else {
      if (uf.same(a, b)) {
        cout << uf.getdiff(a, b) << endl;
      }
      else {
        cout << "UNKNOWN" << endl;
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  while (cin >> n >> m, n||m) solve();
  return 0;
}

Measured memory_bytes: 2324
#include <cstdio>

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

using namespace std;

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

signed main() {
  int N = rint();
  int M = rint();
  int Q = rint();
  int S[N+1][N+1];
  dotimes(R, N+1)
    dotimes(L, N+1)
      S[R][L] = 0;
  dotimes(i, M) {
    int L = rint();
    int R = rint();
    S[R][L]++;
  }
  dotimes(R, N)
    dotimes(L, N)
      S[R+1][L+1] += S[R+1][L] + S[R][L+1] - S[R][L];
  dotimes(i, Q) {
    int p = rint() - 1;
    int q = rint();
    wint(S[q][q] + S[p][p] - S[q][p] - S[p][q]);
  }
  return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
int main() {
 string a, b;
 cin >> a >> b;
 int c = a.size();
  int cou = 0;
  for(int i=0;i<c;i++){
   if(a.at(i)!=b.at(i)){
     cou++;
   }
  }
  if(cou==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" <<endl;
}
}


Measured memory_bytes: 3604
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word
// also tink all answers possible for a question
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
#define sz 100005
ll inf = 1e9;
ll power(ll x, ll n, ll mod)
{
  ll res = 1;
  x %= mod;
  while (n)
  {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res%mod;
}
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  ll n;
  cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++)
    cin>>a[i];
  ll ans=0;
  for(ll i=0;i<n;i++)
  {
    for(ll j=i+1;j<n;j++)
    {
      for(ll k=j+1;k<n;k++)
      {
        ll b[3];
        b[0]=a[i];
        b[1]=a[j];
        b[2]=a[k];
        //cout<<b[0]<<b[1]<<b[2]<<'\n';
        if(b[0]!=b[1] && b[1]!=b[2] && b[2]!=b[0])
        {
          sort(b,b+3);
          if(b[0]+b[1]>b[2])
            ans++;
        }
      }
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
//const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
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;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){cout << a << " " << b << " " << c << endl;}
#define INT_MAX 1<<30;
const int MAX = 1020000;
const double EPS = 1e-6;
const int mod = 1e9+7;

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

ll lcm(ll a, ll b){
    return a/GCD(a,b)*b;
}

 
int main(){
    ll a,b; cin >> a >> b;
    cout << lcm(a,b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

typedef unsigned long long ull;
typedef long long lld;
typedef long double ld;

typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> vi;

int k, a, b;

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>k>>a>>b;
    bool flag=false;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            flag=true;
            break;
        }
    }
    if(flag)cout<<"OK";
    else cout<<"NG";
    return 0;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

ll gcd(const ll sx, const ll sy) {
    ll x = min(sx, sy);
    ll y = max(sx, sy);
    ll tmp;
    while (x > 0) {
        tmp = y;
        y = x;
        x = tmp % x;
    }
    return y;
}

int main(void) {
    int K;
    cin >> K;

    ll ans = 0;
    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            for (int k = 1; k <= K; k++) {
                ans += gcd(i, gcd(j, k));
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	string s;cin>>s;
	int n=s.size();
	ll cnt=0,ans=0;
	rep(i,n){
		if(s[i]=='B')cnt++;
		else{
			ans+=cnt;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <bitset>
#include <vector>

using namespace std;

template<typename value_type = bitset<26>>
class segment_tree
{
public:
	int data_count;

	vector<int> data_idx;
	vector<value_type> data_list;

	vector<value_type> tree;

public:
	segment_tree(int _data_count)
		: data_count(_data_count), data_idx(), data_list(), tree()
	{
		data_idx.assign(data_count, -1);
		data_list.assign(data_count, 0);

		int height = (int)ceil(log2(data_count));
		int tree_size = (1 << (height + 1));
		tree.assign(tree_size, 0);
	}

public:
	void init()
	{
		inner_init(1, 0, data_count - 1);
	}

	value_type inner_init(int node, int start, int end)
	{
		if (start == end)
		{
			data_idx[start] = node;
			return tree[node] = data_list[start];
		}
		else
		{
			int mid = (start + end) / 2;
			return tree[node] = (inner_init(node * 2, start, mid) | inner_init(node * 2 + 1, mid + 1, end));
		}
	}

	void update(int pos, value_type val)
	{
		int node = data_idx[pos];
		tree[node] = val;

		while (node > 1)
		{
			node /= 2;
			tree[node] = (tree[node * 2] | tree[node * 2 + 1]);
		}
	}

	value_type query(int pos)
	{
		return inner_query(1, 0, data_count - 1, pos, pos);
	}

	value_type query(int left, int right)
	{
		return inner_query(1, 0, data_count - 1, left, right);
	}

	value_type inner_query(int node, int start, int end, int left, int right)
	{
		if (right < start || end < left) return 0;
		if (left <= start && end <= right) return tree[node];

		int mid = (start + end) / 2;
		return (inner_query(node * 2, start, mid, left, right) | inner_query(node * 2 + 1, mid + 1, end, left, right));
	}
};

//segment_tree<int> seg(N);
//seg.data_list[i] = val;
//seg.init();
//seg.update(pos, val);
//int ret1 = seg.query(pos);
//int ret2 = seg.query(left, right);

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

	int N;
	cin >> N;

	segment_tree<> seg(N);

	string S;
	cin >> S;

	for (int i = 0; i < S.size(); i++)
	{
		bitset<26> curr_bit;
		curr_bit.set(S[i] - 'a');

		seg.data_list[i] = curr_bit;
	}

	seg.init();

	int Q;
	cin >> Q;

	for (int i = 0; i < Q; i++)
	{
		int c;
		cin >> c;

		if (c == 1)
		{
			int p;
			char ch;
			cin >> p >> ch;

			bitset<26> curr_bit;
			curr_bit.set(ch - 'a');

			seg.update(p - 1, curr_bit);
		}
		else
		{
			int l, r;
			cin >> l >> r;

			bitset<26> qvalue = seg.query(l - 1, r - 1);
			cout << qvalue.count() << "\n";
		}
	}
	
	return 0;
}

Measured memory_bytes: 15252
//BISMILLAH
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,inner,sum,humty,countt;
    cin>>k>>inner;
    if(k>=10)
        cout<<inner<<endl;
    else
        cout<<inner+(100*(10-k))<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100000
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
bool saw[100000];
ll a[100000];
vector<int> e[100000];

ll dfs(int v){
    saw[v] = true;
    vector<ll> tmp;
    rep(i,e[v].size()){
        if(saw[e[v][i]]) continue;
        ll rec = dfs(e[v][i]);
        if(rec == -1) return -1;
        tmp.push_back(rec);
    }
    ll sum = 0;
    if(tmp.size() == 0) return a[v];
    if(tmp.size() == 1){
        if(tmp[0] == a[v]){
            if(v == 0) return 0;
            return a[v];
        }
        else return -1;
    }
    sort(tmp.begin(),tmp.end(),greater<ll>());
    for(int i = 1; i < tmp.size(); i++) sum += tmp[i];
    ll t = 2*a[v]-sum-tmp[0];
    if((sum+tmp[0]-t)%2 != 0) return -1;
    ll s = (sum+tmp[0]-t)/2;
    if(s < 0) return -1;
    if(tmp[0] > sum){
        if(sum < s) return -1;
    } else{
        if((sum+tmp[0])/2 < s) return -1;
    }
    if(t < 0) return -1;
    return t;
}

int main(){
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n-1){
        int u, v;
        cin >> u >> v;
        u--; v--;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    cout << (dfs(0)==0?"YES":"NO") << endl;
}


Measured memory_bytes: 15872
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <climits>

//find out the use of the below
#include <list>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
const int mod = 1e9+7;
int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    char str[(int)1e5+5];
    
    scanf("%s", str);
    int len = strlen(str);
    long ans = 0;
    long pr[2][13];

    for (int i = 0; i < 13; ++i)
        pr[len-1&1][i] = (str[len-1] == '?' && i < 10)?1:0;
    if (str[len-1] != '?')
        pr[len-1&1][str[len-1]-'0'] = 1;

//    for (int zz = 0; zz < 13; ++zz)
//        cout << pr[len-1&1][zz] << ' ';
//    cout << endl;
    
    int pw = 10;
    for (int i = len-2; i >= 0; i--){
        MEM(pr[i&1]);
        if (str[i] == '?'){
            for (int j = 0; j <= 9; ++j){
                int pwj = (pw*j)%13;
               for (int r = 0; r < 13; ++r){
                   pr[i&1][(r+pwj)%13] = (pr[i&1][(r+pwj)%13] + pr[i+1&1][r])%mod;
               }
            }
        } else {
            int pwj = (pw*(str[i]-'0'))%13;
            for (int r = 0; r < 13; ++r)
                pr[i&1][(r+pwj)%13] = (pr[i&1][(r+pwj)%13] + pr[i+1&1][r])%mod;
        }
//        for (int zz = 0; zz < 13; ++zz)
//            cout << pr[i&1][zz] << ' ';
//        cout << endl;
        pw = (pw*10)%13;
    }
    cout << pr[0][5];
    return 0;
}
/* BEFORE submitting, check for:
 *  1. Integer overflow
 *  2. Float/Double precision errors
 *  3. Array index out of bounds
 *  4. Edge cases.(n=1, n=max, etc.)
 *  5. Time complexity. No TLEs
 */



Measured memory_bytes: 384
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while ( true ) {

	    final int n = stdin.nextInt();
	    if ( n == 0 ) {
		break;
	    }

	    final int m = stdin.nextInt();
	    int sum = 0;
	    for ( int i = 0; i < m; i++ ){
		final int from = stdin.nextInt();
		final int to = stdin.nextInt();
		sum += to - from;
	    }
	    if ( n <= sum ) {
		System.out.println( "OK" );
	    } else {
		System.out.println( n - sum );
	    }
	}	
    }    
}

Measured memory_bytes: 23540
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,s=0;
    cin>>n;
    for(i=1;i<=n;++i){
    	if(i%3==0 || i%5==0 || i%15==0){
    		continue;
		}
		else{
			s+=i;
		}
	}
	cout<<s;
}

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

int main() {
  string S,T;
  cin >> S >> T;
  
  int sum = 0;
  int N;
  for (int i = 0; i < 3; i++) {
   if(S.at(i)==T.at(i)) sum++;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;



int main() {
    ll N;
    ll ans;
    cin >> N;
    if (N < 10) ans = N;
    else if (N < 100) ans = N % 10;
    else  ans = N % 10;
    if (ans == 2 || ans == 4 || ans == 5 || ans == 7 || ans == 9) cout << "hon" << endl;
    if (ans == 0 || ans == 1 || ans == 6 || ans == 8) cout << "pon" << endl;
    if (ans == 3) cout << "bon" << endl;
    return 0;

}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
#define dbg3(x) cerr<<#x<<"\n"
using namespace std;
#define reg register
const int MN=1e4+4;
char s[5005];int K;
int c[MN][26],step[MN],val[MN],fa[MN],siz[MN],v[MN],rk[MN];
int last,cnt,n;
inline void init()
{
    last=cnt=1;memset(c,0,sizeof c);
    reg int i;
    for(i=1;i<n<<1;++i) val[i]=step[i]=fa[i]=0;
}
void Insert(int x)
{
    int p=last,np=++cnt;step[np]=step[p]+1;val[np]=1;
    for(;p&&!c[p][x];p=fa[p]) c[p][x]=np;
    if(!p) fa[np]=1;
    else 
    {
        int q=c[p][x];
        if(step[q]==step[p]+1) fa[np]=q;
        else 
        {
            int nq=++cnt;step[nq]=step[p]+1;
            memcpy(c[nq],c[q],sizeof c[q]);
            fa[nq]=fa[q];fa[np]=fa[q]=nq;
            for(;c[p][x]==q;p=fa[p]) c[p][x]=nq;
        }    
    }
    last=np;
}
inline void work()
{
    reg int i,j;
    for(i=1;i<=cnt;++i) ++v[step[i]];
    for(i=1;i<=n;++i) v[i]+=v[i-1];
    for(i=1;i<=cnt;++i) rk[v[step[i]]--]=i;
	for(i=2;i<=cnt;++i) val[i]=siz[i]=1;
    val[1]=siz[1]=0;
    for(i=cnt;i;--i)for(j=0;j<26;++j)
		if(c[rk[i]][j])siz[rk[i]]+=siz[c[rk[i]][j]];
}
char ans[MN];int len;
inline void dfs(int x,int k)
{
    if(k<=val[x]) return;k-=val[x];
    reg int i;
    for(i=0;i<26;++i)
        if(k>siz[c[x][i]]) k-=siz[c[x][i]];
        else {ans[len++]=i+'a',dfs(c[x][i],k);break;}
}
int main()
{
    reg int i,k;
    scanf("%s%d",s+1,&k);n=strlen(s+1);
    init();
    for(i=1;i<=n;++i) Insert(s[i]-'a');
    work();
    dfs(1,k),printf("%s",ans);
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
#define LL  long long
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return

int main(){
   CIN(A);CIN(B);CIN(C);CIN(D);
   cout<<min(A,B)+min(C,D)<<endl;
  return 0;
}


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

int main(){
  string s;cin>>s;
  bool flag[26];
  for(int i=0;i<26;i++){
    flag[i]=false;
  }
  for(int i=0;s[i]!='\0';i++){
    flag[s[i]-'a']=true;
  }
  for(int i=0;i<26;i++){
    if(!flag[i]){
      cout<<char(i+'a')<<endl;
      return 0;
    }
  }
  cout<<"None"<<endl;
  return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 23 20:22:31 2020

@author: liang
"""

N = int(input())
A = [int(x) for x in input().split()]

A.sort(reverse=True)

ans = list()
i = 0
while i < N-1:
    if A[i] == A[i+1]:
       # print("A")
        ans.append(A[i])
        i += 1
    if len(ans) == 2:
        break
    i += 1

import numpy as np
#print(ans)
if len(ans) < 2:
    print(0)
else:
    print(np.prod(ans))

Measured memory_bytes: 30108
def getinputdata():

    array_result = []    
    array_result.append(input().split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

s=arr_data[0][0]
t=arr_data[1][0]


for i in range(len(s)):
    
    if s==t:
        
        print("Yes")
        break
        
    else:
        s=s[-1]+s[0:-1]
        
else:
    print("No")


Measured memory_bytes: 3064
h,w=map(int,input().split())
a=[[i for i in input()] for j in range(h)]

x=[False]*w
y=[False]*h

for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            x[j]=True
            y[i]=True


for i in range(h):
    li=[]
    for j in range(w):
        if x[j]==True and y[i]==True:
            li+=a[i][j]
    if li!=[]:
        print(''.join(li))


Measured memory_bytes: 3064
#include<stdio.h>
#define min(a,b) ((a)<(b)?(a):(b))

int main(void){
    register int i;
    long long cap[5],n;
    scanf("%lld",&n);
    for(i = 0;i < 5;i++)scanf("%lld",&cap[i]);
    long long mincap = 1001001001001001;
    int minind;
    for(i = 0;i < 5;i++)if(cap[i] < mincap){
            mincap = cap[i];
            minind = i;
    }
    long long ans = 0;
    ans += minind;
    ans += (n + (mincap - 1)) / mincap;
    ans += 5 - 1 - minind;
    printf("%lld",ans);
}

Measured memory_bytes: 128
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	if(x == 7 || x == 5 || x == 3) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}


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

int k,n;
ll sum=0;
int ans[300005];

ll mod_pow(ll x,ll n){
	ll ans=1;
	while(n>0LL){
		if(n&1)ans=ans*x;
		x=x*x;
		n>>=1;
	}
	return ans;
}

ll calc(ll rest,ll val){
	ll ans=0;
	ll now=1;
	if(val==1)return rest;
	for(int i=0;i<rest;i++){
		ans+=now*val;
		ans=min(ans,INF);
		now*=val;
		now=min(now,INF);
		if(ans==INF)return INF;
	}
	return ans;
}

ll C(int v,int i){
	if(v==0)return 0;
	ll ans=1;
	ll now=v-1;
	if(now==0)return 1;
	if(k==1)return (ll)ans+now*(n-i);
	ans+=(ll)now*(1LL-mod_pow(k,n-i))/(1-k);
	/*
	for(int j=i;j<n;j++){
		ans+=now;
		now*=k;
	}
	*/
	return ans;
}

int main(void){
	scanf("%d%d",&k,&n);
	int size=0;
	if(k%2==0){
		size=n;
		ans[0]=k/2;
		for(int j=1;j<size;j++){
			ans[j]=k;
		}
	}else{
		ll diff=0;
		size=1;
		for(int i=0;i<n;i++){
			if(calc(n-i,k)<=1000000LL){
				ll rest=calc(n-i,k);
				if(rest<diff){
					i--;
					diff--;
				}
				ll zure=(rest-diff)/2;
				if((rest-diff)%2LL==1)zure++;
				while(zure>0LL && i<n){
					int l=0,r=k+1;
					while(l+1<r){
						int mid=(l+r)/2;
						if(C(mid,i)<=zure){
							l=mid;
						}else{
							r=mid;
						}
					}
					zure-=C(l,i);
					if(l==0)break;
					ans[i]=l;
					size++;
					i++;
				}
				break;
			}else{
				ans[i]=(k+1)/2;
				size++;
				diff++;
			}
		}
	}
	bool flag=false;
	for(int i=0;i<n;i++){
		if(ans[i]==0)break;
		if(flag)printf(" ");
		printf("%d",ans[i]);
		flag=true;
	}
	printf("\n");
	return 0;
}

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

using namespace std;

int main()
{
    int A, B;
    cin >> A>>B;
    int K;
    K=(B+A)/2;
    if(abs(A-K)==abs(B-K))
        cout << K;
    else
        cout <<"IMPOSSIBLE";
    return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n), w(n);
    for(auto& x : a) cin >> x;
    for(auto& x : w) cin >> x;

    vector<int> ord(n);
    iota(begin(ord), end(ord), 0);
    int ans = 10000000;
    do {
        int tans = 0;
        for(int i = 0; i < n; ++i) {
            if(a[ord[i]] == 0) {
                if(a[ord[(i + n - 1) % n]] == 1) {
                    tans += w[ord[i]];
                }
            } else {
                if(a[ord[(i + 1) % n]] == 0) {
                    tans += w[ord[i]];
                }
            }
        }
        ans = min(ans, tans);
    } while(next_permutation(begin(ord) + 1, end(ord)));

    cout << ans << endl;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

template <typename T> void max_self(T& a, T b){
  a = max(a,b);
}

template <typename T> void min_self(T& a, T b){
  a = min(a,b);
}

void solve(){	
  char ch; cin>>ch;
  if(ch >= 'A' && ch <= 'Z')
    cout<<"A\n";
  else
    cout<<"a\n";
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //int t; cin >> t;
  //while(t--) solve();
  //
  solve();
  return 0;
}


Measured memory_bytes: 3644
#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)
int a[999][8],n,t,s;main(){scanf("%d ",&n);a[0][1]=1;r(i,n){s=getchar();r(j,8)r(k,8)if(j&k&&k>>(s&1?s==73?2:1:0)&1)a[i+1][k]+=a[i][j]%10007;}r(i,8)t+=a[n][i];printf("%d\n",t%10007);}

Measured memory_bytes: 1052
<?php
$stdin = trim(fgets(STDIN));  
$array = explode(' ', $stdin);

$alice = $array[0];
$bob = $array[1];

if($alice == $bob) {
	echo "Draw";
	return;
}

if($alice == 1) {
	echo "Alice";
	return;
}

if($bob == 1) {
	echo "Bob";
	return;
}

if($alice < $bob) {
	echo "Bob";
	return;
}else {
	echo "Alice";
	return;
}


Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=1e5 + 10;
int n,m,Sub[MAX];
vector<int>g[MAX];
bool vis[MAX];
int dfs(int root)
{
    if(vis[root])return Sub[root];
    vis[root]=1;
    int ans=0;
    for(int x:g[root]){
            ans=max(ans,1+ dfs(x));
    }
    return Sub[root]=ans;
}
int main ()
{
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
    }
    int ans=0;
    for(int i=1;i<=n;i++) if(!vis[i])ans = max(ans,dfs(i));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int n,d[100002],mxd,ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&d[i]),mxd=max(mxd,d[i]);
	sort(d+1,d+n+1);
	for(int i=1;i<=mxd;i++){
		int p=lower_bound(d+1,d+n+1,i)-d;
		if(p==n/2+1)ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
class Main{
    public static void main(String[]$){
        Scanner s=new Scanner(System.in);
        int a=s.nextInt(),b=s.nextInt();
        System.out.println(((a%3*(b%3)*((a+b)%3)==0)?"P":"Imp")+"ossible");
    }
}

Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};


int main(){
    int n;cin >> n;
    vector<LL> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    LL r = -1, g = -1 ,b = -1;
    LL ans = 1;
    for (int i = 0; i < n; i++) {
        LL count = (a[i] == r + 1) + (a[i] == g + 1) + (a[i] == b + 1);
        if(a[i] == r + 1) r++;
        else if(a[i] == g + 1) g++;
        else if(a[i] == b + 1) b++;
        else{
            cout << 0 << endl;
            return 0;
        }
        ans = ans * count %mod;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    string a;
    int count = 0;

    cin >> a;

    if (a[0] == '1') {
        count++;
    }
    if (a[1] == '1') {
        count++;
    }
    if (a[2] == '1') {
        count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1000001
#define ll long long
using namespace std;
ll n,a[INF],ans;
inline ll read()
{
	ll number_read=0,if_ok_read=1;
	char ch_read=getchar();
	while(ch_read<'0'||ch_read>'9')
	{
		if(ch_read=='-')
			if_ok_read=-1;
		ch_read=getchar();
	}
	while(ch_read>='0'&&ch_read<='9')
	{
		number_read=number_read*10+ch_read-'0';
		ch_read=getchar();
	}
	return number_read*if_ok_read;
}
inline void write(ll x_write)
{
    if(x_write<0)
	{
    	putchar('-');
		x_write=-x_write;
	}
    if(x_write>9)
		write(x_write/10);
    putchar(x_write%10+'0');
    return ;
}
int main()
{
	//freopen(".IN","r",stdin); 
	//freopen(".OUT","w",stdout);
	n=read();
    for(ll i=1;i<=3*n;i++)
        a[i]=read();
    sort(a+1,a+1+3*n);
    for(ll i=(3*n)-1;i>=n+1;i-=2)
        ans+=a[i];
    write(ans);
    putchar('\n');
	return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<pair<long double, int> , null_type,less<pair<long double, int> >, rb_tree_tag,tree_order_statistics_node_update> 
 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const ll INF = ll(1e16);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
} 
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r; 
}
template<typename T_vector> // neal
void output_vector(const T_vector &v, bool add_one = false, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());
 
    for (int i = start; i < end; i++)
        cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}
int used[N];
vector<int> g[N];
void dfs(int v){
	used[v] = 1;
	for(int to : g[v]) if(!used[to]) dfs(to);

}
void solve(){
	int n, m;
	cin >> n >> m;
	rep(i, m){
		int l, r;
		cin >> l >> r;
		g[l].pb(r);
		g[r].pb(l);
	}
	int ans = 0;
	rep(i, n){
		if(!used[i + 1]){
			dfs(i + 1);
			++ans;
		}
	}
	cout << ans - 1;
}

	


int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 31112
N = str(input())

if N[-1]=='2' or N[-1]=='4' or N[-1]=='5' or N[-1]=='7' or N[-1]=='9':
    print('hon')
elif N[-1]=='0' or N[-1]=='1' or N[-1]=='6' or N[-1]=='8':
    print('pon')
else:
    print('bon')
   

Measured memory_bytes: 9112
import java.util.*

fun main(args:Array<String>){
    val scan = Scanner(System.`in`)
    val n = scan.nextInt()
    when (n) {
        1 -> println("Hello World")
        2 -> {
            val a = scan.nextInt()
            val b = scan.nextInt()
            println(a + b)
        }
    }
}

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

int a[110000];
int m[110000];
int n,k;

int dp(){
	m[0] = 0;
	for(int i = 1;i<n;i++){
		int temp = 2e9;
		for(int j = 1;j<=k;j++){
			if(i-j>=0){
				temp = min(temp,
					(m[i-j] + abs(a[i] - a[i-j]))
				);
			}else{
				break;
			}
		}
		m[i] = temp;
	}
//	for(int i = 0;i<n;i++) cout<<m[i]<<" ";cout<<"\n";
	return m[n-1];
}

int main(){
	cin>>n>>k;
	for(int i = 0;i<n;i++){
		cin>>a[i];
	}
	cout<<dp()<<"\n";
	return 0;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll sum = 0;
  string s;
  cin >> s;
  ll size = s.size();
  for(ll i=0;i<(1<<(size-1));i++){
    string t = "";
    t += s[0];
    rep(j,size-1){
      if(i & (1<<j)) t += '+';
      t += s[j+1];
    }
    ll pos=0, nextpos;
    while(t.find("+",pos) != string::npos){
      nextpos = t.find("+",pos);
      sum += stoll(t.substr(pos,nextpos-pos));
      pos = nextpos + 1;
    }
    sum += stoll(t.substr(pos));
  }
  cout << sum << "\n";
  return 0;
}

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

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ll n, m;
    cin >> n >> m;
    vi br(m), dp(n+1);
    dp[0] = dp[1] = 1;
    REP(i, 2, n+1)
        dp[i] = (dp[i-1] + dp[i-2])%M;
    REP(i, 0, m)
        cin >> br[i];
    ll p = 0, a = 1;
    REP(i, 0, m) {
        if (p == br[i])
            a = 0;
        a = (a * dp[br[i]-p-1])%M;
        p = br[i] + 1;
    }
    a = (a * dp[n-p])%M;
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.sqrt

fun main(args: Array<String>) {

    // IO Templates
    val br = BufferedReader(InputStreamReader(System.`in`))
    val out = PrintWriter(System.out)

    val (n, originX, m) = br.readLine()!!.split(' ').map { it.toLong() }

    var x = originX

    if (n == 1L) {
        println(x)
        return
    }

    val s = mutableSetOf(x)

    var loopRoot = 0L
    var loopEndAt = 0L
    var initialSum = 0L

    for (i in 1..n) {
        initialSum += x
        if(i == n) break
        x = x * x % m
        if (s.contains(x)) {
            loopRoot = x
            loopEndAt = i + 1
            break
        }
        s.add(x)
    }

    if(loopEndAt == 0L){
        println(initialSum)
        return
    }

    x = originX
    var loopStartAt = 0L
    var sumTillLoop = 0L
    for (i in 1..n) {
        if (x == loopRoot) {
            loopStartAt = i
            break
        }
        sumTillLoop += x
        x = x * x % m
    }

    val loopLength = loopEndAt - loopStartAt
    var oneLoopSum = 0L

    x = loopRoot

    for (i in 0..loopLength) {
        x = x * x % m
        oneLoopSum += x
        if (x == loopRoot) {
            break
        }
    }

    var ans = sumTillLoop + ((n - loopStartAt + 1) / loopLength) * oneLoopSum

    x = loopRoot

    for (i in 0 until (n - loopStartAt + 1) % loopLength) {
        ans += x
        x = x * x % m
    }

    out.println(ans)

    out.flush()
}

Measured memory_bytes: 46740
import java.util.Scanner;
public class Main {
	
	
	public static void main(String args[] ) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		Long sum = Long.valueOf(s);
		for( int i = 1; i < (1<<(s.length()-1)); i++ ) {
			String str = String.valueOf(s.charAt(0));
			for( int j = 0; j < s.length(); j++ ) {
				if( j == s.length()-1) {
					sum += Integer.valueOf(str);
				}
				else if((1 & i>>j) == 1) {
					sum += Integer.valueOf(str);
					str = String.valueOf(s.charAt(j+1));
				}
				else {
					str += s.charAt(j+1);
				}
			}
		}
		System.out.println( sum );
		
		
		sc.close();
	}
}

Measured memory_bytes: 39532
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem069c(n, a))
}

fun problem069c(n: Int, a: List<Long>): String {
    val fours = a.count { it % 4 == 0L }
    val odds = a.count { it % 2 != 0L }
    val twoCount = a.count { it % 2 == 0L && it % 4 != 0L }
    val tmp = n - fours
//    debugLog(tmp)
    val tmp2 = Math.min(0, fours + 1 - tmp)
//    debugLog(tmp2)
    val tmp3 = tmp2 + if (twoCount > 1) twoCount - 1 else 0
//    debugLog(tmp3)
    return if (tmp3 == 0) "Yes" else "No"
}

Measured memory_bytes: 51096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int N = 0, K = 0;
	cin >> N >> K;
	vector<int> l(N);

	for (int i = 0; i < N; ++i) {
		cin >> l.at(i);
	}

	sort(l.begin(), l.end(),greater<int>());
	int ans = 0;
	for (int i = 0; i < K; ++i) {
		ans += l.at(i);
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,k;cin >> a >> b >> k;
	for(int i=100;i>0;--i){
		if(a%i==0 && b%i==0) k--;
		if(k==0){
			cout << i << endl;
			break;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 1e5 + 5;\


 
int32_t main()
{
  IOS;
  int n;
  int b;
  cin>>n>>b;
  cout<<n*b;

  
  return 0;


   
   
}

Measured memory_bytes: 3652
#include <cstdio>

int ans = 0;

int main()
{
    char s[4];
    scanf("%s", s);
    for (int i = 0; i < 4; i++) {
        if (s[i] == static_cast<int>('+')) {
            ans++;
        } else {
            ans--;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll>a(n);
    rep(i,n){
        cin>>a[i];
        a[i] %= m;
    }
    vector<ll>r(n+1,0);
    map<ll,ll>mp;
    mp[0]++;
    rep(i,n){
        r[i+1] = r[i]+a[i];
        r[i+1] %= m;
        mp[r[i+1]]++;
    }
    ll ans = 0;
    for(auto it = mp.begin();it!=mp.end();it++){
        ll now = it->second;
        ans += (now-1)*now/2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
int H, W;
ll dist[55][55][2][1<<10];
string M[55];
string MS[16][55];
int gh, gw, sh, sw;
int S;
int dh[4] = {1, -1, 0, 0};
int dw[4] = {0, 0, 1, -1};

struct state {
    int h, w, f, bits;
};

bool can(state now) {
    if(now.h < 0 or now.h >= H) return false;
    if(now.w < 0 or now.w >= W) return false;
    if(M[now.h][now.w] == '#') return false;
    if(M[now.h][now.w] == '|') return true;
    int f = 0;
    if(M[now.h][now.w] == '^') f = 1;
    if(M[now.h][now.w] >= 'A' and M[now.h][now.w] <= 'Z') f = 1;
    for(int i = 0; i < S; i++) {
        if(!(now.bits & (1 << i))) continue;
        if(MS[i][now.h][now.w] == '*') f = 1 - f;
    }
    return now.f == f;
}

int main() {
    cin >> W >> H;
    for(int h = 0; h < H; h++) {
        cin >> M[h];
        for(int w = 0; w < W; w++) {
            if(M[h][w] == '%') {
                sh = h;
                sw = w;
            }
            if(M[h][w] == '&') {
                gh = h;
                gw = w;
            }
            for(int k = 0; k < 2; k++) {
                for(int j = 0; j < (1<<10); j++) {
                    dist[h][w][k][j] = INF;
                }
            }
        }
    }
    cin >> S;
    for(int s = 0; s < S; s++) {
        for(int h = 0; h < H; h++) {
            cin >> MS[s][h];
        }
    }
    state start;
    start.h = sh;
    start.w = sw;
    start.bits = 0;
    start.f = 0;
    dist[sh][sw][0][0] = 0;
    queue<state> que;
    que.push(start);
    while(!que.empty()) {
        auto from = que.front();
        que.pop();
        ll c = dist[from.h][from.w][from.f][from.bits] + 1;
        if(M[from.h][from.w] == '|') {
            auto to = from;
            to.f = 1 - to.f;
            if(chmin(dist[to.h][to.w][to.f][to.bits], c)) que.push(to);
        }
        for(int k = 0; k < 4; k++) {
            auto to = from;
            to.h += dh[k];
            to.w += dw[k];
            if(!can(to)) continue;
            if(chmin(dist[to.h][to.w][to.f][to.bits], c)) que.push(to);
        }
        for(int i = 0; i < S; i++) {
            auto to = from;
            if(M[to.h][to.w] == (char)('a' + i)) {
            } else if(M[to.h][to.w] == (char)('A' + i)) {
            } else {
                continue;
            }
            to.bits ^= (1 << i);
            if(MS[i][to.h][to.w] == '*') to.f ^= 1;
            if(chmin(dist[to.h][to.w][to.f][to.bits], c)) que.push(to);
        }
    }
    ll ans = INF;
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < (1 << S); j++) {
            chmin(ans, dist[gh][gw][i][j]);
        }
    }
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 43840
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, x;
    cin >> n >> x;
    ll m[n];
    ll sum = 0, minv = 1e6, ans = n;
    for (int i = 0; i < n; i++) {
        cin >> m[i];
        sum += m[i];
        minv = min(minv, m[i]);
    }
    x -= sum;
    ans += x / minv;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<pii> vpii;
typedef vector<vint> det1;
typedef vector<vpii> det2;

const int MAXN = 100000;
int A[MAXN];
int B[MAXN];
int N;

vector<int> ls;
vector<int> rs;

int main()
{
    cin >> N;
    rep(i, N) { cin >> A[i]; }
    rep(i, N) { cin >> B[i]; }

    rep(i, N)
    {
        if (A[i] < B[i]) { ls.push_back(B[i] - A[i]); }
        if (A[i] > B[i]) { rs.push_back(A[i] - B[i]); }
    }

    sort(ls.begin(), ls.end(), greater<int>());
    sort(rs.begin(), rs.end(), greater<int>());

    const auto rbase(rs);

    auto solve = [&]()
    {
        if (ls.size() == 0) { return 0; }

        int ri = 0;

        rep(li, ls.size())
        {
            int l = ls[li];

            while(l != 0 && ri < rs.size())
            {
                if (l <= rs[ri]) { rs[ri] -= l; l = 0; }
                else             { l -= rs[ri]; rs[ri] = 0; ++ri; }
            }

            if (l != 0) { return -1; }
        }

        return static_cast<int>(ls.size()) + (ri + (rs.size() <= ri || rbase[ri] == rs[ri] ? 0 : 1));
    };

    // for (const auto& n : ls) { cout<<n<<" "; } cout<<endl;
    // for (const auto& n : rs) { cout<<n<<" "; } cout<<endl;

    int ans = solve();
    cout << ans << endl;

    return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, a, b);
  out(max({a + b, a - b, a * b}));
}


Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;


int main(int argc, char const *argv[])
{
    string a, b, c;
    cin >> a >> b >> c;
    a[0] += 'A' - 'a';
    b[0] += 'A' - 'a';
    c[0] += 'A' - 'a';
    cout << a[0] << b[0] << c[0] << endl;
}


Measured memory_bytes: 256