akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace std::chrono;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
///find_by_order, order_of_key

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

int main()
{
    #ifdef ljuba
    auto pocetakChronoSata123 = high_resolution_clock::now();
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);       
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll n;
    cin >> n;

    ll res = 0;
    for(ll i = 2; i * i <= n; ++i)
    {
        ll br = 0;
        while(n % i == 0)
        {
            n /= i;
            ++br;
        }

        for(int i = 1; ; ++i)
        {
            if(br - i >= 0)
            {
                br -= i;
                ++res;
            }
            else
            {
                break;
            }
        }
    }

    if(n > 1)
    {
        res += 1;
    }

    cout << res << '\n';
    
    #ifdef ljuba
    auto krajChronoSata123 = high_resolution_clock::now();
    auto trajanje = duration_cast<microseconds>(krajChronoSata123 - pocetakChronoSata123);
    cout << "----------------------------------------------------\n";
    cout << "Vreme u milisekundama: " << (ld)trajanje.count() / 1000.00 << '\n';
    #endif
    return 0;
}

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

int main(){
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++){
		if(a[i]%2==0){
			if(a[i]%3!=0&&a[i]%5!=0){
			   cout<<"DENIED"<<endl;
			   return 0;
		    }
		}
	}
	cout<<"APPROVED"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,m;
    scanf("%d",&n);
    m=n%10;
    if(m==3)
        printf("bon\n");
    else if((m==0)||(m==1)||(m==6)||(m==8))
        printf("pon\n");
    else 
        printf("hon\n");
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  string s; cin >> s;
  ll dp[N][N] = {}; fill_n(dp[0],N,1);
  rep(i,N-1) {
    if (s[i]=='<') {
      for (int j=(N-1)-i; j>=0; j--) {
        dp[i+1][j] = (dp[i+1][j+1] + dp[i][j+1]) % MOD;
      }
    }
    else {
      rep(j,(N-1)-i) {
        dp[i+1][j] = j==0 ? dp[i][j] : (dp[i+1][j-1] + dp[i][j]) % MOD;
      }
    }
  }
  // rep(i,N) debug(dp[i],dp[i]+N);

  ll result = dp[N-1][0];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 70528
// AOJ 2399
#include<iostream>
#include<vector>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

const int NMAX = 108;
bool KNOW[NMAX][NMAX], LEAK[NMAX];
int N, K;

void init() {
  REP(i, N) REP(j, N) {
    KNOW[i][j] = false;
  }
  REP(i, N) {
    LEAK[i] = false;
  }
}

bool can_leak(int suspect) {
  REP(l, N) {
    if ((not KNOW[suspect][l]) and LEAK[l]) {
      return false;
    }
  }

  return true;
}

int solve() {
  vector<int> suspects;

  REP(i, N) {
    if (can_leak(i)) {
      suspects.push_back(i);
    }
  }
  
  return (suspects.size() == 1 ? suspects[0] + 1 : -1);
}

int main() {
  while (cin >> N and N) {
    init();
    REP(i, N) {
      int M;
      cin >> M;
      REP(j, M) {
        int p;
        cin >> p;
        KNOW[i][--p] = true;
      }
    }

    cin >> K;
    REP(i, K) {
      int l;
      cin >> l;
      LEAK[--l] = true;
    }


    cout << solve() << endl;
  }
}

Measured memory_bytes: 1232
#include <stdio.h>

int main(void){
  double right, left;
  int eye[4][2], i;

  for(i = 0; i < 4; i++){
    eye[i][0] = 0;
    eye[i][1] = 0;
  }
  while(scanf("%lf%lf", &left, &right) != EOF){
    if(left >= 1.1){
      eye[0][0]++;
    }else if(left >= 0.6){
      eye[1][0]++;
    }else if(left >= 0.2){
      eye[2][0]++;
    }else{
      eye[3][0]++;
    }
    if(right >= 1.1){
      eye[0][1]++;
    }else if(right >= 0.6){
      eye[1][1]++;
    }else if(right >= 0.2){
      eye[2][1]++;
    }else{
      eye[3][1]++;
    }
  }

  for(i = 0; i < 4; i++){
    printf("%d %d\n", eye[i][0], eye[i][1]);
  }
  return 0;
}

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

struct node{
	struct node *right;
	struct node *left;
	struct node *parent;
	int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

	while(x->left != NIL)
		x = x->left;
	return x;
}

Node treeSearch(Node u, int k){
	if(u == NIL || u->key == k)
		return u;
	else if(u->key > k)
		return treeSearch(u->left, k);
	else if(u->key < k)
		return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){
	Node y;

	if(x->right != NIL)
		return treeMinimum(x->right);
	y = x->parent;
	while(y != NIL && x == y->right){
		x = y;
		y = y->parent;
	}
	return y;
}

void treeDelete(Node z){
	Node y; // node to be deleted
	Node x; // child of y

	if(z->left == NIL || z->right == NIL)
		y = z;
	else
		y = treeSuccessor(z);
	if(y->left != NIL)
		x = y->left;
	else
		x = y->right;
	if(x != NIL)
		x->parent = y->parent;
	if(y->parent == NIL)
		root = x;
	else if(y == y->parent->left)
		y->parent->left = x;
	else
		y->parent->right = x;
	if(y != z)
		z->key = y->key;



}

void insert(int k){
	Node y = NIL;
	Node x = root;
	Node z;

	z = (Node)malloc(sizeof(struct node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while(x != NIL){
		y = x;
		if(z->key < x->key)
			x = x->left;
		else
			x = x->right;
	}
	z->parent = y;
	if(y == NIL)
		root = z;
	else if(z->key < y->key)
		y->left = z;
	else
		y->right = z;


}

void inorder(Node u){
	if(u->left != NIL)
		inorder(u->left);
	printf(" %d",u->key);
	if(u->right != NIL)
		inorder(u->right);
}
void preorder(Node u){
	printf(" %d",u->key);
	if(u->left != NIL)
		preorder(u->left);
	if(u->right != NIL)
		preorder(u->right);
}


int main(){
	int n, i, x;
	char com[20];
	Node t;
	scanf("%d", &n);

	for ( i = 0; i < n; i++ ){
		scanf("%s", com);
		if ( com[0] == 'f' ){
			scanf("%d", &x);
			t = treeSearch(root, x);
			if ( t != NIL ) printf("yes\n");
			else printf("no\n");
		} else if ( com[0] == 'i' ){
			scanf("%d", &x);
			insert(x);
		} else if ( com[0] == 'p' ){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		} else if ( com[0] == 'd' ){
			scanf("%d", &x);
			treeDelete(treeSearch(root, x));
		}
	}

	return 0;
}

Measured memory_bytes: 19364
#include<stdio.h>
#include<algorithm>
using namespace std;
long long G[100+10][100+10];
int n;
long long nil=4294967296;
void floy()
{
    for ( int k=0;k<n;k++){
        for (int i=0;i<n;i++){
            if(G[i][k]==nil) continue;//找指向?点K的?;
            for (int j=0;j<n;j++){
                if(G[k][j]==nil) continue;//找k指向的?点；
                {
                    G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
                }
            }
        }
    }
}
int main()
{
    int e,a,b,c;
    scanf("%d%d",&n,&e);
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)
    {
        G[i][j]=((i==j)?0:nil);//将?角????0
    }
    for (int i=0;i<e;i++)
    {
        scanf("%d%d%d",&a,&b,&c);
        G[a][b]=c;
    }
    floy();
    bool zhi=false;
    for (int i=0;i<n;i++)
    {
        if(G[i][i]<0)
           {
               zhi=true;
               break;
           }
    }//?自身??数的串???；
    if(zhi==true) printf("NEGATIVE CYCLE\n");
    else {
        for (int i=0;i<n;i++)
        { for (int j=0;j<n;j++){
            if(j!=0) printf(" ");
            if(G[i][j]==nil) printf("INF");
           else printf("%d",G[i][j]);
        }
        printf("\n");
    }
    }
    return 0;
}

Measured memory_bytes: 2792
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll k,x;
    cin >> k >> x;

    ll now = k;
    for(int i=1;i<=2*k-1;i++){
        cout << x-now+1 << " ";
        now--;
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
   int n,m;
   cin>>n>>m;
   int a[n];
   rep(i,n){
       cin>>a[i];
   }
   int k,z;
   k=abs(a[0]-m);
   for(int i=1;i<n;i++){
       z=abs(a[i]-m);
       k=gcd(k,z);
   }
   cout<<k<<endl;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  ll x;
  cin >> x;
  
  ll def = 100;
  int count = 0;
  while(true) {
    if(x > def) {
      count++;
      def += def/100;
    }
    else break;
  }
  cout << count << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long

#define INF 999999999

using namespace std;

// input
stack<int> S1;
stack<pair<int, int> > S2;

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

    int  total = 0;
    char c;

    for(int index = 0; cin >> c;index++){
        if (c == '/') {
            if (S1.size() == 0) {
                continue;
            }

            int left = S1.top(); S1.pop();
            int capa = index - left;

            total += capa;

            while(S2.size() != 0 && S2.top().first > left) {
                capa += S2.top().second;
                S2.pop();
            }
            
            S2.push(make_pair(left,capa));
        }
        else if (c == '\\') {
            S1.push(index);
        }
    }

    cout << total << "\n";

    vector<int> anss;

    cout << S2.size();

    while(true){
        if(S2.size() == 0)
            break;

        pair<int,int> p = S2.top();
        S2.pop();

        anss.push_back(p.second);
    }

    reverse(anss.begin(),anss.end());


    for(int i = 0; i < anss.size();i++){
        cout << " " << anss[i];
    }
    cout << "\n";
}


Measured memory_bytes: 3256
//Sinhov : "Hi stalker!"
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
int main() {
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    ll i,t=0,n,a,b,c,d;
    cin>>a>>b>>c>>d;
    for(i=0;i<=100;i++){
        if(i>=a&&i<b&&i>=c&&i<d)
            t++;
    }
    cout<<t;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll


int t, n, m, k, a[300010], q, l;



int32_t main(){
INIT
cin>>n;



int res=0;
for(int i=2; i<=sqrt(n)+1; i++){
    int e=0;
    while(n%i==0){
        e++; n/=i;
    }
    int j=(-1+sqrt(1+8*e))/(2);
        res+=j;

}

if(n>1){res++;}
cout<<res;



return 0;
}



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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_bacn
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

int main()
{
	fast;
	int h, n;
	cin >> h >> n;
	vll dp(h + 1, 1e9 + 1);
	dp[0] = 0;
	FOR(n)
	{
		int c, d;
		cin >> c >> d;
		FOR(j, h + 1)
		dp[j] = min(dp[j], dp[max(0, j - c)] + d);
	}
	cout << dp[h];
}

Measured memory_bytes: 3664
#include <stdio.h>

int search(int A[], int n, int key) {
  int i = 0;  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}

int main(void) {
  int i, n, A[10000+1], q, key, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++) {
    scanf("%d", &key);
    if(search(A, n, key))sum++;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2104
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf = 10e17;
const ll mod = inf;//1000000007;
const ld eps = 10e-9;



ll solve(void);
ll gcd(ll x, ll y);


ll mulmod(ll x, ll y)
{
	return (x * y) % mod;
}

ll submod(ll x, ll y)
{
	return (x - y + 100 * mod) % mod;
}

ll power(ll n, ll r)
{
	if ( r == 0 ) { return 1; }
	if ( r == 1 ) { return n; }
	if ( n == 0 ) { return 0; }
	if ( n == 1 ) { return 1; }

	if (r % 2 == 0)
	{
		ll y = power(n, r/2);
		return mulmod(y, y);
	}
	else
	{
		ll y = power(n, (r-1)/2);
		return n * mulmod(y, y) % mod;
	}
}

ll gcd(ll x, ll y)
{
	if (y == 1) { return 1;}
	if (x % y == 0) { return y; }
	return gcd(y, x % y);
}

vector<ll> perm;
vector<ll> inv;
void init_inv(ll m)
{
	perm.resize(m);
	inv.resize(m);
	
	perm[0] = 1;
	inv[0] = 1;

	for (ll i = 1; i < m; i++)
	{
		perm[i] = mulmod(perm[i-1], i);
	}
	
	for (ll i = 1; i < m; i++)
	{
		inv[i] = power(perm[i], mod - 2);
	}
}

ll ncr(ll n, ll r)
{
	// n (n-1) ... (n-r)
	if ( r == n || r == 0 ) { return 1; }

	ll ans = 1;
	for (ll i = 0; i < r; i++)
		ans = mulmod(ans, n - i);

	 return mulmod(ans, inv[r]);
	// return mulmod(perm[n], mulmod(inv[n-r], inv[r]));
}

bool binary_check(ll mid, ll key)
{
	return mid >= key;
}

ll binary_search()
{
//	ll ng = 0;
//	ll ok = x;
//
//	while (abs(ok - ng) > 1)
//	{
	//	ll mid = (ok+ng) / 2;
	//	if (binary_check(mid, k)) ok = mid;
	//	else ng = mid;
	//}

	return 0;
	//return ok;
}

ll solve(void)
{
	ll n, m;
	cin >> n >> m;

	vector<ll> h(n);
	vector<bool> g(n, true);

	for (auto& hi: h)
		cin >> hi;

	for (ll i = 0; i < m; i++)
	{
		ll a, b;
		cin >> a >> b;
		a--; b--;
		if (h[a] >= h[b]) { g[b] = false; }
		if (h[a] <= h[b]) { g[a] = false; }
	}

	ll ans = 0;
	for (auto gi: g)
		if (gi) ans ++;
	cout << ans << endl;

	return 0;
}

int main(void)
{
	while (solve())
	{
	}
	return 0;
}


Measured memory_bytes: 3968
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <sstream>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int path(vector<int> &memo, vector<vector<int>> const &adjs, int s)
{
    if (memo[s] >= 0)
    {
        return memo[s];
    }

    int ret = 0;
    for (auto t : adjs[s])
    {
        chmax(ret, path(memo, adjs, t) + 1);
    }

    return memo[s] = ret;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n, m;
    cin >> n >> m;
    vector adjs(n, vector<int>());
    rep(i, m)
    {
        int s, t;
        cin >> s >> t;
        --s;
        --t;
        adjs[s].push_back(t);
    }

    int ans = -1;
    vector memo(n, -1);
    rep(s, n)
    {
        chmax(ans, path(memo, adjs, s));
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 11816
def primes(n):
    memo = [True] * (n + 1)
    i = 2
    while i * i <= n:
        if memo[i]:
            j = i << 1
            while j <= n:
                memo[j] = False
                j += i
        i += 1
    return [i for i in range(n + 1) if memo[i] and i >= 2]

N = int(input())

ans = []
for p in primes(1400):
    if p % 5 == 1:
        ans.append(p)
    if len(ans) == N:
        break

print(*ans)


Measured memory_bytes: 3060
import itertools

N = int(input())
P = tuple([int(p) for p in input().split()])
Q = tuple([int(q) for q in input().split()])
a, b = -1, -1
count = 1
for seq in itertools.permutations(tuple(range(1, N+1))):
    if seq == P:
        a = count
    if seq == Q:
        b = count
    if a != -1 and b != -1:
        break
    count += 1
print(abs(a-b))

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

#define         ld                  long double
#define         lli                 long long int
#define         vi                  vector<int>
#define         vlli                vector<lli>
#define         vvi                 vector<vi >
#define         vvl                 vector<vlli >
#define         str                 string
#define         vs                  vector<str>
#define         vb                  vector<bool>
#define         mp                  make_pair
#define         pii                 pair<int, int>
#define         pll                 pair<lli, lli>
#define         vpii                vector<pii>
#define         vpll                vector<pll>
#define         pb                  push_back
#define         all(a)              a.begin(),a.end()
#define         rev(a)              reverse(all(a))
#define         min3(a, b, c)       min(a, min(b, c))
#define         max3(a, b, c)       max(a, max(b, c))
#define         ft                  first
#define         sd                  second

#define         loop(i, s, l, j)    for(int i = s; i < l; i += j)
#define         rloop(i, s, l, j)   for(int i = s; i >= l; i -= j)
#define         rep(i, n)           loop(i,0,n,1)
#define         rrep(i, n)          rloop(i,n-1,0,1) 

#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

#define mod 1000000007
#define inf 10000000
#define limit 2000006

int n, m;
vvi g;
int vis[limit] = {};

void dfs(int root)
{
    vis[root] = 1;
    rep(i, (int)g[root].size())
    {
        int c = g[root][i];
        if(!vis[c])
            dfs(c);
    }
}

void solve(int test_case)
{
    cin >> n >> m;
    g.resize(n);
    rep(i,m)
    {
        int a, b;
        cin >> a >> b;
        g[a-1].pb(b-1);
        g[b-1].pb(a-1);
    }

    int cnt = 0;
    rep(i,n)
    {
        if(vis[i])
            continue;
        cnt++;
        dfs(i);
    }
    cout << cnt - 1 << '\n';
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    fastio();
    int q = 1;
    //cin >> q;
    rep(i,q)
        solve(i+1);
}


Measured memory_bytes: 9940
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	string s; cin >> s;
    int n = s.size();
    string ans = "";
    rep(i, n) {
        if(s[i] == '0') {
            ans += '0';
        } else if(s[i] == '1') {
            ans += '1';
        } else {
            if(s.size() == 0) {
                continue;
            } else {
                int m = (int)ans.size();
                ans = ans.substr(0, m - 1);
            }
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n,l,r;
    char a[1001],temp[1001],c[1001];
    scanf("%s",a);
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s",temp);
        if(temp[2]=='p'){
            scanf("%d%d",&l,&r);
            r++;
            scanf("%s",c);
            for(int j=0;j<r-l;j++){
                a[j+l]=c[j];
            }
        }
        if(temp[2]=='v'){
            scanf("%d%d",&l,&r);
            r++;
            for(int j=l;j<r;j++){
                c[j]=a[r+l-j-1];
            }
            for(int j=l;j<r;j++){
                a[j]=c[j];
            }
        }
        if(temp[2]=='i'){
            scanf("%d%d",&l,&r);
            r++;
            for(int j=l;j<r;j++)
                printf("%c",a[j]);
            printf("\n");
        }
    }
}

Measured memory_bytes: 2680
# 入力
s = input()

# 処理
leftLen = len(s) // 2 # 文字列の長さの半分
left = s[:leftLen] # sの左半分

# leftの回文チェック
leftReverse = left[::-1]
isPalindromeLeft = left == leftReverse;

# 全体の回文チェック
right = s[leftLen * -1:] # sの右半分
isPalindrome = isPalindromeLeft and (left == right)

# 結果
result = "Yes" if isPalindrome else "No"

# 出力
print(result)


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    double a=100.0,X;
    ll cnt=0;
    cin >> X;
    while(a<X){
        a=floor(a*1.01);
        cnt++;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3724
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

d = {}
for each in s:
  d[each] = d.get(each, 0) + 1
for each in t:
  d[each] = d.get(each, 0) - 1

print(max(0, max(d.values())))

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


int main() {
    ll n;
    cin >> n;

    map<ll,ll> p;

    ll i=2;
    while (n >= i*i) {
        while (n%i==0) {
            n /= i;
            p[i]++;
        }
        i++;
        if (i>3) i++;
    }
    if (n>1) p[n]++;
    ll ans = 0;
    for (auto itr: p) {
        ll key = itr.first;
        ll val = itr.second;
        //cout << key << "," << val << endl;
        for (int i=1; val>=i; i++) {
            val -= i;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		try(BufferedReader input = new BufferedReader(new InputStreamReader(System.in))){

			String[] l1 = input.readLine().split(" ");
			int N = Integer.parseInt(l1[0]);
			int M = Integer.parseInt(l1[1]);
			int C = Integer.parseInt(l1[2]);

			String[] l2 = input.readLine().split(" ");
			int[] B = new int[M];
			for(int i = 0; i < M; i++) {
				B[i] = Integer.parseInt(l2[i]);
			}

			int[][] data = new int[N][M];
			int cnt = 0;

			for(int i=0; i < N; i++) {
				int calc = 0;
				String[] lines = input.readLine().split(" ");
				for(int j = 0; j < M; j++) {
					calc += Integer.parseInt(lines[j]) * B[j];
				}
				if(calc + C > 0) cnt++;
			}

			System.out.println(cnt);

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 22228
a, b = gets.chomp.split(" ").map(&:to_i)
attrs = Array.new
while line = $stdin.gets
  attrs << line.split(//)
end
k = "Yes"
for i in 0..(a-1)
 for j in 0..(b-1)
  if ((i - 1) >= 0) and ((j-1) >= 0) and ((i+1) <= (a - 1)) and ((j + 1) <= (b - 1))
   if (attrs[i][j] == "#") and  (attrs[i-1][j] == ".") and  (attrs[i+1][j] == ".") and  (attrs[i][j-1] == ".") and  (attrs[i][j+1] == ".") 
    k = "No"
   end
 elsif ((i - 1) < 0) and ((j-1) >= 0) and ((i+1) <= (a - 1)) and ((j + 1) <= (b - 1))
   if (attrs[i][j] == "#") and  (attrs[i+1][j] == ".") and  (attrs[i][j-1] == ".") and  (attrs[i][j+1] == ".") 
    k = "No"
   end
elsif ((i - 1) >= 0) and ((j-1) < 0) and ((i+1) <= (a - 1)) and ((j + 1) <= (b - 1))
   if (attrs[i][j] == "#") and  (attrs[i-1][j] == ".") and  (attrs[i+1][j] == ".") and    (attrs[i][j+1] == ".") 
    k = "No"
   end
elsif ((i - 1) >= 0) and ((j-1) >= 0) and ((i+1) > (a - 1)) and ((j + 1) <= (b - 1))
   if (attrs[i][j] == "#") and  (attrs[i-1][j] == ".") and  (attrs[i][j-1] == ".") and  (attrs[i][j+1] == ".") 
    k = "No"
   end
elsif ((i - 1) >= 0) and ((j-1) >= 0) and ((i+1) <= (a - 1)) and ((j + 1) > (b - 1))
   if (attrs[i][j] == "#") and  (attrs[i-1][j] == ".") and  (attrs[i+1][j] == ".") and  (attrs[i][j-1] == ".") 
    k = "No"
   end
 end
end
end
puts k

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

// KMP 法 (Knuth-Morris-Pratt Algorithm)
struct KMP {
    string p; int len;
    vector<int> fail;
    KMP() {}
    KMP(string p_) : p(p_), len(p_.length()) {
        // 文字列 p[0:i-1] の接頭辞と接尾辞は最大何文字一致する？
        // ただし、|p[0:i-1]| 文字未満のみ考慮
        // MP 法に比べ、失敗時の遷移が log 回に改善されている
        // see also: http://www-igm.univ-mlv.fr/~lecroq/string/node8.html
        fail.resize(len + 1, -1);
        for(int i=1, j=-1; i<=len; i++) {
            // その時点で一致しなければ fail[j] 文字以下の一致となる
            // j を fail[j] に変更
            int step = 0;
            while(j >= 0 and p[j] != p[i-1]) j = fail[j], step++;
            fail[i] = (p[i] == p[++j] ? fail[j] : j);
        }
    }

    // 文字列 s における p の出現位置 (開始位置) のリスト
    vector<int> match(string s) {
        int N = s.length();
        vector<int> occur(N);
        for(int i=0, k=0; i<N; i++) {
            while(k >= 0 and s[i] != p[k]) k = fail[k];
            if(++k == len) {
                occur[i-len+1] = true;
                k = fail[k];
            }
        }
        return occur;
    }
};


int main() {
  int N, M;
  while(cin >> N >> M, N || M) {
    vector<string> pat(N);
    vector<KMP> kmps(N);
    for(int i=0; i<N; i++) cin >> pat[i], kmps[i] = KMP(pat[i]);

    string s = "";
    for(int i=0; i<M; i++) {
      string tmp; cin >> tmp;
      s += tmp;
    }
    
    // fprintf(stderr, "before match\n");
    int len = s.length();
    vector< vector<int> > match(N);
    for(int i=0; i<N; i++) match[i] = kmps[i].match(s);

    /*
    // for debug
    for(int i=0; i<N; i++) {
      for(int j=0; j<len; j++) {
        fprintf(stderr, "%d ", match[i][j]);
      }
      fprintf(stderr, "\n");
    }
    */

    vector<int> lens(1 << N);
    for(int bit=0; bit<(1<<N); bit++) {
      for(int i=0; i<N; i++) {
        if(bit >> i & 1) lens[bit] += pat[i].length();
      }
    }

    int whole_len = lens[(1 << N) - 1], ans = 0;
    for(int i=0; i<len-whole_len+1; i++) {
      vector<int> dp(1 << N);
      dp[0] = true;
      for(int bit=0; bit<(1<<N); bit++) {
        int cur_idx = i + lens[bit];
        for(int i=0; i<N; i++) {
          if(bit >> i & 1) continue;
          int nbit = bit | (1 << i);
          if(match[i][cur_idx]) dp[nbit] |= dp[bit];
        }
      }

      if(dp[(1 << N) - 1]) {
        // fprintf(stderr, "match %d\n", i);
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3312
# 基本的に問題はここで解く。

count = gets.chomp.to_i

max = Float::MIN
min = Float::MAX

num = gets.chomp.split.map{|x| x.to_i}

count.times do |i|

    if num[i] > max
        max = num[i]
    end

    if num[i] < min
        min = num[i]
    end

end

puts max - min 


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

int main()
{
  int a, b;
  cin >> a >> b;
  if (b % a == 0 ) cout << a + b << endl;
  else cout << b - a << endl;

  return 0;
}


Measured memory_bytes: 3652
#-*- coding:utf-8 -*-
import math
a = []
N,Z,W = map(int,input().split())
a = list(map(int,input().split()))

if N==1:
	print(abs(a[0]-W))
else :
	print(max(abs(a[N-1]-W),abs(a[N-2]-a[N-1])))

Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			Integer[] array = new Integer[n];
			for (int i = 0; i < n; i++) {
				array[i] = scanner.nextInt();
			}

			Arrays.sort(array, Comparator.reverseOrder());

			int alice = 0;
			int bob = 0;
			if (n >= 2) {
				for (int i = 0; i < n - 1; i += 2) {
					alice += array[i];
					bob += array[i + 1];
				}
			}

			if (n % 2 == 1) {
				alice += array[n - 1];
			}

			System.out.println(alice - bob);
		}
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>

char a[100][101];
int n, l;

void prn() {
    for(int i=0; i<n; i++)
        printf("%s ", a[i]);
    printf("\n");
}

void swap(int x, int y) {
    char t;
    for(int i=0; i<l; i++) {
        t=a[x][i];
        a[x][i]=a[y][i];
        a[y][i]=t;
    }
}

int cmp(int x, int y) {
    for(int i=0; i<l; i++) {
        if(a[x][i]<a[y][i]) return 0;
        else if(a[x][i]>a[y][i]) return 1;
    }
    return 1;
}

int main(void) {
    scanf("%d%d", &n, &l);
    
    for(int i=0; i<n; i++)
        scanf("%s", a[i]);
    
    for(int i=0; i<n-1; i++) {
        for(int j=i+1; j<n; j++) {
            if(cmp(i, j)) swap(i, j);
        }
    }
    
    for(int i=0; i<n; i++)
        printf("%s", a[i]);
    
    return 0;
}

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

main()
{
	int n,m,i,j,len;
	int flag=0;
	
	
	scanf("%d",&n);
	
	if(n<112)
	{
		printf("111");
	}
	else if(n<223)
	{
		printf("222");
	}
	else if(n<334)
	{
		printf("333");
	}
	else if(n<445)
	{
		printf("444");
	}
	else if(n<556)
	{
		printf("555");
	}
	else if(n<667)
	{
		printf("666");
	}
	else if(n<778)
	{
		printf("777");
}
	else if(n<889)
	{
		printf("888");
	}
	else if(n<=999)
	{
		printf("999");
	}
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r,a[3];
    for(i=0;i<3;i++)
    {
        cin>>a[i];
    }
    sort(a,a+3);
    if(a[0]==5 && a[1]==5 && a[2]==7)
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
const ll INF = 1LL<<60;

int main()
{
  ll k, t; cin>>k>>t;
  vector<ll> a(t);
  rep(i, t) cin>>a[i];
  ll x = 0;
  ll sum = 0;
  rep(i, t) {
    x = max(x, a[i]);
    sum += a[i];
  }
  sum -= x;
  cout << max(0LL, x-sum-1) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by zhangrunfeng on 2/18/20
 */
public class Main {

    private int N;
    private final int K = 10005;
    private int[] arr;

    private int maxElement = -1;
    private int minElement = Integer.MAX_VALUE;

    private int[] C;

    public Main (Scanner sc) {
        N = sc.nextInt();
        arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        C = new int[K];
    }

    public int[] bucketSort() {
        for (int i = 0; i < N; i++) {
            C[arr[i]]++;
        }

        for (int k = 1; k < K; k++) {
            C[k] += C[k-1];
        }

        int[] resArr = new int[N+1];
        for (int i = N-1; i >= 0; i--) {
            resArr[C[arr[i]]] = arr[i];
            C[arr[i]]--;
        }

        return resArr;
    }

    public String printArr(int[] arr) {
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i < N; i++) {
            sb.append(arr[i]).append(" ");
        }
        sb.append(arr[N]);
        return sb.toString();
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        int[] resArr = m.bucketSort();
        String res = m.printArr(resArr);
        System.out.println(res);
    }
}


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

void printVector(vector<int> v) {
    for (auto x : v) {
        cout << x << ' ';
    }
    cout << '\n';
}

void printArray(ll A[], int size) {
    for (int i = 0; i <= size - 1; i++) cout << A[i] << ' ';
}

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

    int n, m, c;
    cin >> n >> m >> c;
    int B[m];
    int tot = 0;
    for (int i = 0; i <= m - 1; i++) cin >> B[i];
    for (int i = 0; i <= n - 1; i++) {
        int tryThis = 0;
        for (int j = 0; j <= m - 1; j++) {
            int a;
            cin >> a;
            tryThis += (a * B[j]);
            //cout << tryThis << '\n';
        }
        tryThis += c;
        if (tryThis > 0) tot++;
    }
    cout << tot << '\n';
    return 0;
}

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

#define forn(i,m,n) for(int i=m;i<n;i++)
#define vv vector
#define vi vv<int>
#define ii pair<int,int>
#define vii vv<ii>
#define mp make_pair
#define pb push_back
#define PI 3.141592653589
#define ll long long
#define pll pair<ll,ll>
#define vl vv<ll>
#define ff first
#define ss second
#define MOD 1000000007

bool is_prime[1000001];
vi prime;
void sieve(int n)
{
    memset(is_prime,true,sizeof(is_prime));
    for(int i=2;i*i<=n;i++)
    {
        if(is_prime[i])
        {
            for(int j=i*i;j<=n;j+=i)
            {
                is_prime[j]=false;
            }
        }
    }
    forn(i,2,n+1)
    {
        if(is_prime[i])
            prime.pb(i);
    }
}


ll ex(ll a,ll b)
{
    ll res=1;
    a=a%MOD;
    while(b)
    {
        if(b%2){res=(res*a)%MOD;b--;}
        b/=2;
        a=(a*a)%MOD;
    }
    return res;
}

ll fermat_inv(ll a){ return ex(a,MOD-2); }
ll max(ll a,ll b){ return a>b?a:b; }
ll min(ll a,ll b){ return a<b?a:b; }


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
    //sieve(1000000);
    int te=1;
    //cin>>te;
    while(te--)
    {
        int n;
        cin>>n;
        ll a[n][3];
        forn(i,0,n)
            cin>>a[i][0]>>a[i][1]>>a[i][2];
        ll dp[n][3];
        dp[0][0]=a[0][0],dp[0][1]=a[0][1],dp[0][2]=a[0][2];
        forn(i,1,n)
        {
            dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
            dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
            dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
        }
        cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));


    }
}


Measured memory_bytes: 8340
S = input()

set_S = set(S)
if len(set_S) != 2:
    print("No")
    exit()

cnt = 0
tmp = list(set_S)[0]
for s in S:
    if tmp == s:
        cnt += 1
if cnt != 2:
    print("No")
else:
    print("Yes")

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	std::string s;
	std::cin >> s;
	int n = s.size();
	bool res = !(n & 1);
	for (int i = 0; i + 1 < n; i += 2) if (s[i] != 'h' || s[i + 1] != 'i') res = false;
	puts(res ? "Yes" : "No");
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>

int main() {
  long n;
  std::cin >> n;
  std::vector<long> x(n);
  std::vector<long> y(n);
  for (long i = 0; i < n; ++i) {
    std::cin >> x[i] >> y[i];
  }

  double sum = 0.0;
  for (long i = 0; i < n - 1; ++i) {
    for (long j = i + 1; j < n; ++j){
      sum += pow(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2), 0.5);
    }
  }

  std::cout << std::setprecision(10) << 2 * sum / n << std::endl;

  return 0;
}

Measured memory_bytes: 384
import math
A,B = map(int,input().split())
a = 100000
for i in range(1,1009):
  if A == math.floor(i*0.08) and B == math.floor(i*0.1):
    a = i
    break

if a == 100000:
  print(-1)
else:
  print(a)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#pragma GCC optimize "trapv"
#define _GLIBCXX_DEBUG
#define ll long long int
#define ld long double
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define MOD 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll		// this is 1e18 long long 
#define np next_permutation
#define PI acos(-1)
#define DEB(x) cout<<#x<<" "<<x<<endl;
#define rotate_left(vec,amt) rotate(vec.begin(),vec.begin()+amt,vec.end());
#define rotate_right(vec,amt) rotate(vec.begin(),vec.begin()+vec.size()-amt,vec.end());
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define clr(x) memset(x,0,sizeof(x))
using namespace std;
int main()
{
    speed;
    ll n;
  cin>>n;
  ll ans=0;
  rep(i,1,n+1)
  {
    ll x;
    cin>>x;
    if(i%2 && x%2)
      ans++;
  }
  cout<<ans<<endl;
    return 0;
}

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

using namespace std;
using namespace std;
typedef long long ll;
#define endl "\n";
#define MAX 10000001+9   //Maximum array size;
#define loop(n) for(ll i=0;i<n;i++)
#define loop2(n) for(ll i=0;i<n;i+=2)
#define all(v) v.begin(),v.end()
#define sz(v)  v.size()
typedef vector<ll> vi;
typedef set<ll> si;

void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}

int pow(int a, int b) {
    int pow = 1;
    loop(b)pow *= a;
    return pow;
    //thanks m7md :)
}

int main() {
    fast();
  //freopen("input.txt","r",stdin);
    int n;cin>>n;
    double answer;
    if(n%2==0)answer=n/2;
    else answer=n/2+1;
    cout<<fixed<<setprecision(9)<<(double)answer/n;

}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int T = sc.nextInt();
		int[][] time = new int[N][2];
		String[][] name = new String[N][2];
		for (int i = 0; i < N; ++i) {
			time[i][0] = time(sc.next());
			name[i][0] = sc.next();
			time[i][1] = time(sc.next());
			name[i][1] = sc.next();
		}
		ArrayList<Integer> res = new ArrayList<Integer>();
		for (int i = 0; i < N - 1; ++i) {
			if (time[i + 1][0] - time[i][1] >= T) res.add(i);
		}
		System.out.println(res.size());
		for (int i : res) {
			System.out.println(name[i][1] + " " + (time[i + 1][0] - time[i][1]));
		}
	}

	static int time(String hhmm) {
		int h = (hhmm.charAt(0) - '0') * 10 + hhmm.charAt(1) - '0';
		int m = (hhmm.charAt(3) - '0') * 10 + hhmm.charAt(4) - '0';
		return h * 60 + m;
	}

}

Measured memory_bytes: 17372
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    string s,t;
    cin >> s >> t;
    reverse(s.begin(),s.end());
    if(s == t)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

map<int,string> map1;
map<string,int> map2;
int main() {
    string s;
    while(cin>>s) {
        map1[-s.size()]=s;
        map2[s]++;
    }

    auto it = map2.begin();
    int maxi=0;
    string ans;
    while(it!=map2.end()) {
        if(maxi<it->sc) {
            maxi = it->sc;
            ans=it->fr;
        }
        it++;

    }
    cout<<ans<<" ";
    cout<<(map1.begin()->sc)<<endl;

    return 0;
}

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

const int Maxn = 405, p = 998244353;
int S;
long long fac[Maxn], finv[Maxn];
long long fast_pow(long long x, long long y)
{
	long long ans = 1, now = x;
	while (y)
	{
		if (y & 1) ans = ans * now % p;
		now = now * now % p;
		y >>= 1;
	}
	return ans;
}
void init(void)
{
	fac[0] = 1;
	for (int i = 1; i <= 400; i++)
		fac[i] = fac[i - 1] * i % p;
	finv[400] = fast_pow(fac[400], p - 2);
	for (int i = 399; i >= 0; i--)
		finv[i] = finv[i + 1] * (i + 1) % p;
}
void multi(long long x[], long long y[], long long ans[], int len)
{
	for (int i = 0; i <= S; i++)
		for (int j = 0; i + j <= S && j < len; j++)
			(ans[i + j] += p - x[i] * y[j] % p) %= p;
}
void add(long long x[], long long ans[])
{
	for (int i = 0; i <= S; i++)
		(ans[i] += x[i]) %= p;
}
int n, a[Maxn], b[Maxn];
long long ans, invS, f[Maxn][Maxn], g[Maxn][Maxn], tmp[Maxn];
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d%d", &a[i], &b[i]), S += a[i];
	init();
	invS = fast_pow(S, p - 2);
	f[0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		memcpy(g, f, sizeof(g));
		memset(f, 0, sizeof(f));
		tmp[0] = 1;
		for (int j = 1; j < b[i]; j++)
			tmp[j] = tmp[j - 1] * a[i] % p * invS % p;
		for (int j = 1; j < b[i]; j++)
			tmp[j] = tmp[j] * finv[j] % p;
		for (int j = 0; j <= S - a[i]; j++)
		{
			multi(g[j], tmp, f[j], b[i]);
			add(g[j], f[j + a[i]]);
		}
	}
	for (int d = 0; d < S; d++)
	{
		long long c = d * invS % p, L = 1 * fast_pow(1 - c + p, p - 2);
		(ans += L * f[d][0]) %= p;
		for (int i = 1; i <= S; i++)
		{
			L = fast_pow(1 - c + p, p - 2) % p * i % p * L % p;
			(ans += L * f[d][i]) %= p;
		}
	}
	printf("%lld", (p - ans) % p);
	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

int h,w,a,b;
int op[1010][1010];

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> h >> w >> a >> b;
    bool ok = 0;
    int p, q;
    for(p=0; p<=w; p++)
    {
        for(q=0; q<=h; q++)
        {
            if(p*b+(w-p)*(h-b) == q*a+(h-q)*(w-a))
            {
                ok = 1;
                break;
            }
        }
        if(ok) break;
    }
    if(!ok)
    {
        cout << -1 << endl;
        return 0;
    }
    priority_queue<pii> pq;
    forn(i, p) pq.push(mp(b, i));
    for(int i=p; i<w; i++) pq.push(mp(h-b, i));

    forn(i, q)
    {
        forn(j, a)
        {
            pii temp = pq.top();
            pq.pop();
            op[i][temp.S] = 1;
            temp.F--;
            pq.push(temp);
        }
    }
    for(int i=q; i<h; i++)
    {
        forn(j, w-a)
        {
            pii temp = pq.top();
            pq.pop();
            op[i][temp.S] = 1;
            temp.F--;
            pq.push(temp);
        }
    }
    forn(i, h)
    {
        forn(j, w)
        {
            cout << op[i][j];
        }
        cout << endl;
    }

}


Measured memory_bytes: 5248