akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>                                                                                               
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 int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

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

signed main(){
    string s;
    cin >> s;
    int cnt = 0,n = s.size();
    rep(i,n){
        if(s[i] == '+') ++cnt;
        else --cnt;
    }   
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 764
/*input

*/

#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define pb          push_back
#define pp          pop_back
#define nl          cout << "\n"
#define MIN(con)    (*min_element(ALL(con)))
#define MAX(con)    (*max_element(ALL(con)))
#define NX(cont)    next_permutation(ALL(cont))
#define PX(cont)    prev_permutation(ALL(cont))
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define all(c)      c.begin(),c.end()
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define sp          cout << " "
#define ifalse      ios_base::sync_with_stdio(false),cin.tie(NULL)
#define debug(x)    cout << #x << " = " << x << "\n";

using ll = long long;
using ld = long double;
 
template <typename T> T GCD(T a, T b) { ll t; while(a){ t=a; a=b%a; b=t; } return b; }
template <typename T> T LCM(T a, T b) { return (a*b) / GCD(a, b); }
template <typename T> string toString(T a) { return to_string(a); }
template <typename T> void toInt(string s, T &x) { stringstream str(s); str >> x; }

ll add(ll x, ll y, ll MOD) { x += y; if(x >= MOD) x -= MOD; return x; }
ll sub(ll x, ll y, ll MOD) { x -= y; if(x < 0) x += MOD; return x; }
ll mul(ll x, ll y, ll MOD) { return ((x % MOD) * (y % MOD)) % MOD; }

ll powr(ll a, ll b, ll MOD) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a, MOD);
    a = mul(a, a, MOD);
    b >>= 1;
  }
  return x;
}

ll inv(ll a, ll MOD) { return powr(a, MOD-2, MOD); }
const ll INF =  1e18;
const int SINF = 1e9;
const ll MOD = 1e9 + 7;

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/************************************START***************************************/
const int N = 100005;

int main()
{
  ifalse;
  int n;
  cin >> n;
  vector < int > v;
  rep(i, 0, n) {
    int x;
    cin >> x;
    v.pb(x);
  }
  int ans = 1;
  for(int i = 1; i < n; i ++) {
    bool flag = 0;
    for(int j = i - 1; j >= 0; j --) {
      if(v[j] > v[i]) {
        flag = 1;
        break;
      }
    }
    if(!flag) {
      ans ++;
    }
  } 
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = 0
if n%2==1:
    dummy = [0]
    for i in range(1, 1+(len(a)-1)//2):
        dummy.append(2*i)
        dummy.append(2*i)
    if sorted(a) == dummy:
        ans = 2**((len(a)-1)//2)
else:
    dummy = []
    for i in range(1,  1+(len(a))//2):
        dummy.append(2*i - 1)
        dummy.append(2*i - 1)
    if sorted(a) == dummy:
        ans = 2**((len(a))//2)
print(ans%(10**9 + 7))

Measured memory_bytes: 14008
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

int main(){
  ll n,k;
  long double sum = 0.0;
  cin >> n >> k;
  for(int i=1;i<=n;i++){
    for(int j=0;j<mod;j++){
      if(i * pow(2.0,(double)j) >= k){
        sum += 1 / pow(2.0,(double)j);
        break;
      }
    }
  }
  sum /= n;
  printf("%.10Lf",sum);
}


Measured memory_bytes: 256
n, m = map(int, input().split())

s = [n for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    if s[a - 1] > b - 1:
        s[a - 1] = b - 1

result = 0
i = 0
while i < n - 1:
    hoge = min(s[i:])
    if hoge == n:
        break
    i = hoge
    result += 1

print(result)

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

typedef long long ll;

struct ToUpper{
    char operator()(char c){return toupper(c);}
};


int main(){
  string a,b,c;
  cin >> a >> b >> c;
  transform(a.begin(),a.end(),a.begin(),ToUpper());
  transform(b.begin(),b.end(),b.begin(),ToUpper());
  transform(c.begin(),c.end(),c.begin(),ToUpper());
  cout << a[0] << b[0] << c[0] << endl;
  return 0;
}


Measured memory_bytes: 384
N, W = map(int, input().split())
v, w = [0], [0]
for _ in range(N):
    a, b = map(int, input().split())
    v.append(a)
    w.append(b)

dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(1, N+1):
    for j in range(1, W+1):
        if w[i] > j:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-w[i]]+v[i])
print(dp[N][W])


Measured memory_bytes: 15684
N,M = map(int,input().split())

dicFood = {}
for _ in range(N):
	food = list(map(int,input().split()))
	for k in food[1:]:
		if k not in dicFood:
			dicFood[k] = 1
		else:
			dicFood[k] +=1
		
count = 0	
for v in dicFood.values():
	if v == N:
		count += 1
		
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<(int)n;i++)
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

int in(){
	int t;
	cin >> t;
	return t;
}

int main()
{
	int n,m;
	while(cin >> n >> m,(n&&m)){
        int d[2][100][100];
        for(int i=0;i<2;i++){
            for(int j=0;j<100;j++){
                for(int k=0;k<100;k++){
                    d[i][j][k]=inf;
                }
            }
        }
        for(int i=0;i<n;i++){
            int a,b,cost,time;
            cin >> a >> b >> cost >> time;
            a--;
            b--;
            d[0][a][b]=cost;
            d[0][b][a]=cost;
            d[1][a][b]=time;
            d[1][b][a]=time;
        }
        for(int i=0;i<m;i++){
            for(int j=0;j<m;j++){
                for(int k=0;k<m;k++){
                    for(int o=0;o<2;o++){
                        d[o][j][k] = min(d[o][j][k],d[o][i][j]+d[o][i][k]);
                    }
                }
            }
        }
        int k;
        cin >> k;
        for(int i=0;i<k;i++){
            int p,q,r;
            cin >> p >> q >> r;
            p--;q--;
            cout << d[r][p][q] << endl;
        }
	}
	return 0;
}

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

using namespace std;

using u32 = uint32_t;
using u64 = uint64_t;
using i64 = int64_t;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= a; i--)
#define RF0(i,b) RFO(i,0,b)
#define F first
#define S second

constexpr i64 A = 1 + 2 + 4 + 7 + 8 + 11 + 13 + 14;
constexpr i64 B = 15 * 8;
i64 fb(i64 N) {
  i64 r;
  i64 q = N / 15;
  r = q * A + q * (q - 1) / 2 * B;

  for (i64 i = q * 15; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      r += i;
    }
  }
  return r;
}

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

  int N;
  cin >> N;

  cout << fb(N);
}


Measured memory_bytes: 3648
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

bool check(char c){
    if(c!='A' && c!='C' && c!='G' && c!='T')return true;
    return false;
}

signed main() {
   tezz
   
    int n,m;
    cin >> n >> m;
    string s;
    cin >> s;
    vector<int> a(n,0);
    for(int i=1; i<n; i++){
        if(s[i]=='C' && s[i-1]=='A'){
            a[i]+=a[i-1]+1;
        }
        else{
            a[i]=a[i-1];
        }
    }
    // for(auto it: a)cout << it << " ";
    // cout << endl;
    int p,q;
    while(m--){
        cin >> p >> q;
        p--;q--;
        // if(p==0)cout << a[q] << endl;
        cout << a[q]-a[p] << endl;
    }
   
   return 0;
}

Measured memory_bytes: 1872
import sys

def main():
    line = map(int, raw_input().split())
    H = line[0]
    W = line[1]

    for i in xrange(H):
        line = raw_input()
        for j in xrange(2):
            for ch in line:
                sys.stdout.write(ch)
            print ''


if __name__ == "__main__":
    main()


Measured memory_bytes: 2568
#include <stdio.h>

int main() {
	long long n;
	scanf("%lld", &n);
	long long ans = 0;
	if(n%2==1){
		ans=0;
	}else{
		for (long long i = 10; i <= n; i=i*5) {
			ans+=n/i;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

int main(void) {
  long long X;
  cin >> X;

  long long ykn = 100;
  
  int ans = 0;
  while (ykn < X) {
    ans++;
    ykn += ykn / 100;
  }

  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<ll, ll>> vpll;

//mt19937 random(566);
//uniform_int_distribution<ll> distr;
//ll rnd(ll a, ll b) {return a + distr(random) % (b - a + 1);}

int n;

void gen(string s, int mx) {
    if (sz(s) == n) cout << s << "\n";
    else {
        forn(i, mx) {
            s.pb('a' + i);
            gen(s, mx);
            s.pop_back();
        }
        s.pb('a' + mx);
        gen(s, mx + 1);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    gen("", 0);
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A);
  vector<int> b(B);
  for (int i = 0; i < A; i++)
  {
    cin >> a[i];
  }
  for (int i = 0; i < B; i++)
  {
    cin >> b[i];
  }
  vector<int> x(M);
  vector<int> y(M);
  vector<int> c(M);
  for (int i = 0; i < M; i++) {
    cin >> x[i] >> y[i] >> c[i];
    x[i] -= 1; y[i] -= 1;
  }
  vector<vector<int>> vec2(B);
  vector<int> vec1(A);
  int min;
  int mina = a[0];
  int minb = b[0];
  for (int i = 1; i < A; i++) {
    if (a[i] < mina) mina = a[i];
  }
  for (int i = 1; i < B; i++) {
    if (b[i] < minb) minb = b[i];
  }
  min = mina + minb;
  for (int i = 0; i < M; i++)
  {
    if (min >= (a[x[i]] + b[y[i]] - c[i]))
      min = (a[x[i]] + b[y[i]] - c[i]);
  }
  cout << min;
}

Measured memory_bytes: 4992
#include<stdio.h>
main()
{
	int a,b,c;
	int n;
	scanf("%d",&n);
	a=n%10;
	n=n/10;
	b=n%10;
	c=n/10;
	if(c==7||a==7||b==7) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372036854775807ll;

void solve()
  {
   int n;
   cin>>n;
   vector<int> v(n);
   loop(i,0,n)
    cin>>v[i];
  sort(v.begin(), v.end());
  double ans = 1.0 * (v[0] + v[1])/2;
  loop(i,2,n)
    {
      ans = 1.0*(ans + v[i])/2.0;
    }
  cout<<ans;
  } 
signed main()
 {
 
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 256
def main():
    import itertools
    n = int(input())
    if n%2==0:
        rm = n+1
    else:
        rm = n
    ans = []
    for t in itertools.combinations((i+1 for i in range(n)), 2):
        if sum(t)!=rm:
            ans.append(t)
    print(len(ans))
    for a in ans:
        print(a[0],a[1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 9520
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	unordered_map<int,int> t;
	LL res = 0;
	for(int i=0;i<n;i++){
		int temp = i+1-a[i];
		res+=t[temp];
		t[i+1+a[i]]++;
	}
	cout<<res<<endl;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 19372
/*#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")*/
//#pragma GCC optimize("fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("Ofast,no-stack-protector")
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <math.h>
#include <random>
using namespace std;
typedef long long  ll;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
#define all(a) a.begin(), a.end()
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define pb(x) push_back(x)
#define fr(i, n) for(int i = 0; i < n; ++i)
//typedef cc_hash_table<int, int, hash<int>> hst2;
//typedef cc_hash_table<int, hst2, hash<int>> hst;
typedef pii ord_set_t;
#ifdef ABCD
typedef set<ord_set_t> ordered_set;
int __builtin_popcount(int x)
{
	int cnt = 0;
	for (; x > 0; x >>= 1) cnt += x & 1;
	return cnt;
}

#else
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
mt19937 rnd(239);
using namespace __gnu_pbds;
typedef tree<
	ord_set_t,
	null_type,
	less<ord_set_t>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
#endif
const int N = 100001;
int a[N];
int nx[N];
int ans[N];
int main()
{

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef ABCD
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else

#endif
	string str; cin >> str;
	int n = str.size();
	fr(i, n) a[i] = (str[i] == 'R');
	bool flg = 0;
	int pos = 0;
	for (int i = n - 1; i >= 0; --i)
	{
		if (!flg && a[i] == 1)
		{
			flg = 1;
			pos = i;
		}
		if (a[i] == 0)
		{
			flg = 0;
			continue;
		}
		nx[i] = pos;
	}
	flg = 0;
	for (int i = 0; i < n; ++i)
	{
		if (!flg && a[i] == 0)
		{
			flg = 1;
			pos = i;
		}
		if (a[i] == 1)
		{
			flg = 0;
			continue;
		}
		nx[i] = pos;
	}
	fr(i, n)
	{
		ans[nx[i] + ((abs(nx[i] - i) &1) * (a[i] ? 1 : -1))]++;
	}
	fr(i, n) cout << ans[i] << " ";
}


Measured memory_bytes: 1872
/*
        i Apologize 3la el Habda
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;
const int N = 1e5 + 50;
long double EPS = 1e-6;

int n ,arr[N][3];
int dp[N][3];
int main()
{
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    cin >> n;
    for(int i = 0; i < n; ++i)
            for(int j = 0; j < 3; ++j)
                cin >> arr[i][j];
    dp[0][0] = arr[0][0]; dp[0][1] = arr[0][1]; dp[0][2] = arr[0][2];
    for(int i = 1; i < n; ++i){
            for(int k = 0; k < 3; ++k){
                    for(int j = 0; j < 3; ++j){
                        if(j == k)continue;
                        dp[i][k] = max(dp[i][k],dp[i - 1][j] + arr[i][k]);
                    }
            }
    }
    cout << max(dp[n - 1][0],max(dp[n - 1][1],dp[n - 1][2])) << "\n";

 return 0;
}


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

int main(){
	int a[100] = {0};
	int b[100] = {0};
	int n = 0;
	string f = "No";
	int i;
	int count = 0;
	cin >> n;
	


	for(i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		if(a[i] == b[i])
			count++;
		else if(count < 3)
			count = 0;
	}
	if(count >= 3)	
		f = "Yes";
	cout << f;

	return 0;
}

Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		while (q-- > 0) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			sb.append(solve(a, b));
			sb.append("\n");
		}
		System.out.print(sb.toString());
	}

	private static long solve(long a, long b) {
		if (a == b) return 2 * (a - 1);
		if (a > b) {
			long t = a;
			a = b;
			b = t;
		}
		long l = 0;
		long r = b - 1;

		while (r > l) {
			long m = (l + r + 1) / 2;
			long l2 = 0;
			long r2 = m;
			while (r2 - l2 > 1) {
				long m2 = (l2 + r2) / 2;
				if ((m - (m2 - 1)) * (a + m2) <= (m - (m2)) * (a + 1 + m2)) {
					l2 = m2;
				} else {
					r2 = m2;
				}
			}

			if ((m - l2) * (a + 1 + l2) < a * b) {
				l = m;
			} else {
				r = m - 1;
			}
		}

		return (a - 1) + l;
	}
}


Measured memory_bytes: 21844
a,b=gets.split.map(&:to_i)
m=gets.split.map(&:to_i)
m.sort!
hash=m.group_by(&:itself)

h_c=hash.map{|key,value|[key,value.count]}.sort_by{|_,value|value}.to_h

h_c_key=h_c.keys

if hash.length<=b
   puts 0
   exit
else
v=h_c.length-b

count=0
i=0

while i<v
vv=h_c.shift
count+=vv[1]

i+=1
end
    
end


puts count

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    if (N % 2 == 0) cout << N << endl;
    else cout << N * 2 << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Apr  6 20:39:40 2019

@author: Yamazaki Kenichi
"""
import math

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
x = 10

a = 10
if A%x != 0:
    a = min(a,A%x)
if B%x != 0:
    a = min(a,B%x)
if C%x != 0:
    a = min(a,C%x)
if D%x != 0:
    a = min(a,D%x)
if E%x != 0:
    a = min(a,E%x)
if 0 == max(A%x,B%x,C%x,D%x,E%x):
    a = 10
b = math.ceil(A/x) + math.ceil(B/x) + math.ceil(C/x) + math.ceil(D/x) + math.ceil(E/x)

print((b-1)*10 + a)

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	int N;
	cin >> N;
	vector<vector<pair<ll, bool>>> A(N, vector<pair<ll, bool>>(N, pair<ll, bool>(0, true)));
	vector<vector<pair<ll, bool>>> B(N, vector<pair<ll, bool>>(N, pair<ll, bool>(0, true)));

	REP(i, N) {
		REP(j, N) {
			ll a;
			cin >> a;
			A[i][j].first = a;
			B[i][j].first = (a != 0)? a : (ll)1e10;
		}
	}
	REP(i, N) {
		REP(j, N) {
			REP(k, N) {
				if (B[i][j].first >= B[i][k].first + B[k][j].first) {
					B[i][j].first = B[j][i].first = B[i][k].first + B[k][j].first;
					B[i][j].second = B[j][i].second = false;
				}
			}
		}
	}
		
	ll c = 0;
	REP(i, N) {
		for (int j = 0; j < i; j++) {
			if (A[i][j].first != B[i][j].first) {
				cout << -1 << endl;
				return 0;
			}
			if (B[i][j].second) c += B[i][j].first;
		}
	}
	cout << c << endl;
	return 0;
}

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

using namespace std;
#define eps = (1e-10);
//点
struct Point{
    double x,y;
    Point(double _x=0,double _y=0):x(_x),y(_y){}
    Point operator + (Point p){return Point(x+p.x,y+p.y);}
    Point operator - (Point p){return Point(x-p.x,y-p.y);}
    Point operator * (double a){return Point(a*x,a*y);}
    Point operator / (double a){return Point(x/a,y/a);}
    double norm(){return x*x+y*y;}//模的平方
    double ABS() {return sqrt(norm());}//模
};
//线段
struct Segment{
    Point p1,p2;
};
//点积
double dot(Point a,Point b){
    return a.x*b.x+a.y*b.y;
}
//叉积
double cross(Point a,Point b){
    return a.x*b.y-a.y*b.x;
}
bool Intersect(Segment A ,Segment B){
    if(max(B.p1.x,B.p2.x)<min(A.p1.x,A.p2.x)) return 0;
    if(max(B.p1.y,B.p2.y)<min(A.p1.y,A.p2.y)) return 0;
    if(max(A.p1.y,A.p2.y)<min(B.p1.y,B.p2.y)) return 0;
    if(max(A.p1.x,A.p2.x)<min(B.p1.x,B.p2.x)) return 0;
    if(cross(A.p1-B.p1,A.p2-B.p1)*cross(A.p1-B.p2,A.p2-B.p2)>0) return 0;
    if(cross(B.p1-A.p1,B.p2-A.p1)*cross(B.p1-A.p2,B.p2-A.p2)>0) return 0;
    return 1;
}
double Pointdis(Point a,Point b){
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double Segdis(Point A ,Segment B){
    Point alp1=A-B.p1;
    Point beta1=B.p2-B.p1;
    Point alp2=A-B.p2;
    Point beta2=B.p1-B.p2;
    if(dot(alp1,beta1)<0||dot(alp2,beta2)<0){
        return min(Pointdis(A,B.p1),Pointdis(A,B.p2));
    }
    double a=B.p1.y-B.p2.y;
    double b=B.p2.x-B.p1.x;
    double c=B.p1.y*(B.p1.x-B.p2.x)-B.p1.x*(B.p1.y-B.p2.y);
    return fabs(a*A.x+b*A.y+c)/sqrt(a*a+b*b);
}
int main(){
    int q;
    scanf("%d",&q);
    while(q--){
        Segment A,B;
        scanf("%lf %lf %lf %lf",&A.p1.x,&A.p1.y,&A.p2.x,&A.p2.y);
        scanf("%lf %lf %lf %lf",&B.p1.x,&B.p1.y,&B.p2.x,&B.p2.y);
        if(Intersect(A,B)){
            cout<<0<<endl;continue;
        }
        double ans=min(Segdis(A.p1,B),min(min(Segdis(A.p2,B),Segdis(B.p1,A)),Segdis(B.p2,A)));
        printf("%.10lf\n",ans);
    }
    return 0;
}


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

bool solve(int a, int b, int c, int k) {
    if(a < b && b < c) return true;
	if(k == 0) return false;

	if(solve(2 * a, b, c, k - 1)) return true;
	if(solve(a, 2 * b, c, k - 1)) return true;
	if(solve(a, b, 2 * c, k - 1)) return true;
	return false;
}

int main() {
    int a,b,c; cin >> a >> b >> c;
	int k; cin >> k;
	if(solve(a, b, c, k)) cout << "Yes\n";
	else cout << "No\n";
}



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

int main(void){
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.size() <= k){
	cout << s << endl;
    }else{
	string t;
	t = s.substr(0, k);
	cout << t << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
H,W = map(int,input().split())
s = [input() for i in range(H)]
flag = True
for i in range(H):
  for j in range(W):
    if s[i][j] == '#' and flag:
      flag = False
      if i > 0:
        if s[i-1][j] == '#':
          flag = True
      if j > 0:
        if s[i][j-1] == '#':
          flag = True
      if i < H-1:
        if s[i+1][j] == '#':
          flag = True
      if j < W-1:
        if s[i][j+1] == '#':
          flag = True
if flag:
  print('Yes')
else:
  print('No')

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

int main(){
  int N, box, ans = 0 ;
  int A[3][3] ;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
        cin >> A[i][j] ;
    }
  }
  cin >> N ;
  for(int i=0;i<N;i++){
    cin >> box ;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(A[i][j] == box) A[i][j] = 0 ;
        }
      }
  }

  for(int i=0;i<3;i++){
    if( (A[i][0] == 0) && (A[i][1] == 0) && (A[i][2] == 0) ) {
        ans = 1 ;
        break ;
    }
    if( (A[0][i] == 0) && (A[1][i] == 0) && (A[2][i] == 0) ) {
        ans = 1 ;
        break ;
    }
  }
  if( (A[0][0] == 0) && (A[1][1] == 0) && (A[2][2] == 0) ) ans = 1 ;
  if( (A[2][0] == 0) && (A[1][1] == 0) && (A[0][2] == 0) ) ans = 1 ;
  
  if( ans == 1 ){
    cout << "Yes" << endl ;
  }  
  else{
    cout << "No" << endl ;
  }  
  return 0 ;
}

Measured memory_bytes: 256
import math

s = input()
n = len(s)

s1 = s[0 : int((n - 1) / 2)]
s2 = s[int((n + 3) / 2 - 1) : n]

sm = int((n + 1) / 2)
s1m = math.ceil(len(s1) / 2)
s2m = math.ceil(len(s2) / 2)

if len(s1) % 2 == 0 or len(s2) % 2 == 0:
    if s[0 : sm - 1] == s[sm : n] \
    and s1[0 : s1m] == s1[s1m : int(len(s1))][::-1] \
    and s2[0 : s2m] == s2[s2m : int(len(s2))][::-1]:
        print("Yes")
    else:
        print("No")
else:
    if s[0 : sm - 1] == s[sm : n] \
    and s1[0 : s1m - 1] == s1[s1m : int(len(s1))][::-1] \
    and s2[0 : s2m - 1] == s2[s2m : int(len(s2))][::-1]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cassert>

using namespace std;

#define MAXN 3005

const int inf = 1e9+10;

struct node{

    int val;
    int px,py;

};

vector<vector<node>> dp(MAXN,vector<node>(MAXN,{-inf,0,0}));

node max(node& a,node b){
    
    return a.val>b.val?a:b;

}

int main(){

    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);

    dp[0][0].val=0;

    string a,b;
    cin>>a>>b;
    for(int i=0;i<a.size();i++){

        for(int j=0;j<b.size();j++){

            if(a[i] == b[j]){
                
                dp[i+1][j+1]=max(dp[i+1][j+1],{dp[i][j].val+1,i,j});
    
            }
                dp[i+1][j] = max(dp[i+1][j],{dp[i][j].val,i,j});
                dp[i][j+1] = max(dp[i][j+1],{dp[i][j].val,i,j});
        }
    } 
    node maxx = {0,0,0};

    for(int i=0;i<=a.size();i++)
        for(int j=0;j<=b.size();j++){

            maxx = max(maxx,{dp[i][j].val,i,j});

        }
#ifdef NOTINAIR
    cerr<<maxx.val<<endl;
#endif

    node cur = maxx;
    string ans="";
    node prev;
    while(cur.px != 0 && cur.py!=0){
        prev = dp[cur.px][cur.py];
        if(prev.px == cur.px-1 && prev.py == cur.py-1){
            assert(a[cur.px-1] == b[cur.py-1]);
            ans+=a[cur.px-1];
        }
        cur = prev;

    }
     if(cur.px == cur.px-1 && prev.py == cur.py-1){
            assert(a[cur.px-1] == b[cur.py-1]);
            ans+=a[cur.px-1];
        }    
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;



}


Measured memory_bytes: 106240
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main(){
    int a,b;
    cin >> a >> b;
    if(a%3==0||b%3==0||(a+b)%3==0) puts("Possible");
    else puts("Impossible");

    return 0;
}

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

using namespace std;

typedef long long int lli;

lli s[200001] = { 0 };

pair<lli, lli> split(int _min, int _max) {
    pair<lli, lli> res(-1e+15, 1e+15);

    int l = _min, r = _max, mid;
    lli ls, rs;
    do {
        mid = l + (r-l) / 2;
        ls = s[mid+1] - s[_min];
        rs = s[_max+1] - s[mid+1];

        if (ls > rs) r = mid;
        else l = mid;

        if (abs(rs-ls) < abs(res.second-res.first)) {
            res.first = ls;
            res.second = rs;
        }
    } while (r-l > 1);

    // cout << ls << " " << rs << endl;

    mid = l + (r-l) / 2;
    ls = s[mid+1] - s[_min];
    rs = s[_max+1] - s[mid+1];

    // cout << ls << " " << rs << endl;
    
    if (ls > rs) r = mid;
    else l = mid;
    
    if (abs(rs-ls) < abs(res.second-res.first)) {
        res.first = ls;
        res.second = rs;
    }

    return res;
}

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

    int n, a[200000];

    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        s[i+1] = s[i] + a[i];
    }

    lli ans = 1e+15;
    for (int i=2; i<=n-2; i++) {
        pair<lli, lli> L = split(0, i-1), R = split(i, n-1);
        lli ss[4] = { L.first, L.second, R.first, R.second };

        sort(ss, ss+4);
        ans = min(ans, ss[3]-ss[0]);

        //cout << i << " : " << L.first << " " << L.second << " " << R.first << " " << R.second << endl;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<algorithm>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> b(N);
    vector<int> a(N);
    for(size_t i = 0; i < N; i++)
    {
        cin >> b[i];
    }
    for(int i = N; i > 0; i--)
    {
        bool found = false;
        for(int j = i; j > 0; j--){
            if(b[j-1] == j){
                a[i-1] = j;
                b.erase(b.begin()+j-1);
                found = true;
                break;
            }
        }
        if (!found){
            cout << -1 << endl; // removable not found
            return 0;
        }
    }
    for(auto thisa : a){
        cout << thisa << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())

mp = ['#'*(W+1)]
memo = [[-1]*(W+1) for _ in range(H+1)]

cnt = 0
for _ in range(H):
  s = '#'+input()
  cnt += s.count('.')
  mp.append(s)
  
ds = [[1,0], [-1,0], [0,1], [0,-1]]
h = deque([[1,1,1]])
while h:
  l = h.popleft()
  for d in ds:
    if l[0]+d[0] <= W and l[1]+d[1] <= H:
      if mp[l[1]+d[1]][l[0]+d[0]] == '.' and memo[l[1]+d[1]][l[0]+d[0]] == -1:
        memo[l[1]+d[1]][l[0]+d[0]] = l[2] + 1
        h.append([l[0]+d[0], l[1]+d[1], l[2] + 1])
  if memo[H][W] > -1:
    print(cnt-memo[H][W])
    exit()
    
print(memo[H][W])

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

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

#define endl '\n'

using ull = unsigned long int;
using ll = long long;

template <class Key, class Val>
using hmap = gp_hash_table<Key, Val>;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    const int precision = 13;
    cout.precision(precision);
    cout.setf(ios_base::fixed);

    int n; cin >> n;
    ll k; cin >> k;
    vector<vector<ll>> a(n, vector<ll>(n));
    for (auto& v : a) for (auto& u : v) cin >> u;

    const ll mod = 1e9+7;
    auto mult_in = [&mod, &n](vector<vector<ll>>& to, const vector<vector<ll>>& with) -> void {
      vector<vector<ll>> tmp(n, vector<ll>(n, 0));
      for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
          for (int k = 0; k < n; ++k) {
            tmp[i][j] = (tmp[i][j] + to[i][k] * with[k][j]) % mod;
          }
        }
      }
      swap(to, tmp);
    };

    vector<vector<ll>> ans(n, vector<ll>(n, 0));
    for (int i = 0; i < n; ++i) {
      ans[i][i] = 1;
    }
    while (k) {
      if (k&1) {
        mult_in(ans, a);
      }
      mult_in(a, a);
      k /= 2;
    }


    ll acc = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        acc = (acc + ans[i][j]) % mod;
      }
    }
    cout << acc << endl;


    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        int ans=0;
        for(int i=0;i<s.length();i++) {
            if(i == s.length()-2) {
                if(s.charAt(i)==s.charAt(i+1)) {
                    i++;
                }
            } else if (i!=s.length()-1){
                if(s.charAt(i)==s.charAt(i+1)) {
                    i++;
                    ans++;
                    i++;
                }
            }
            ans++;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 40516
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	list := getStdinIntArr()
	A := list[0]
	B := list[1]

	y := B - 2*A

	if y%2 == 0 {
		y = y / 2
		x := A - y
		if x+y == A && x >= 0 && y >= 0 {
			fmt.Printf("Yes\n")
			return
		}
	}
	fmt.Printf("No\n")
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


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

using namespace std;

int main(){
  vector<int> v;
  int n, x, alice = 0, bob = 0;
  bool isA = true;
  cin >> n;
  while(cin>>x) {
  	v.push_back(x); 
  }
  sort(v.begin(), v.end(), greater<int>());
  
  for(auto &i: v) {
  	 if (isA) {
       alice += i;
       isA = false;
     } else {
       bob += i;
       isA = true;
     }
  }
  
  printf("%d", alice - bob);
  return 0;
}

Measured memory_bytes: 256
// 
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


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

    int n;
    cin>>n;
    map<int,int> kind;
    ll total=0;
    rep(i,n){
        int a;
        cin>>a;
        if(kind.count(a)==1) kind[a]++;
        else kind[a]=1;
        total+=a;
    }
    int q;
    cin>>q;
    rep(i,q){
        int b,c;
        cin>>b>>c;
        int num;
        if(kind.count(b)==1){
            num=kind[b];
            kind[b]=0;
            if(kind.count(c)==1){
                kind[c]+=num;
            }else kind[c]=num;
            total+=(c-b)*num;
        }
        cout<<total<<endl;
    }
    return 0;
}

Measured memory_bytes: 7464
r, g, b, n = (int(x) for x in input().split())
a = 0
i_r = n // r + 1
for i in range(i_r):
    rem = n - i * r
    i_g = rem // g + 1
    for j in range(i_g):
        remain = rem - j * g
        if remain >= 0 and remain % b == 0: a += 1
print(a)


Measured memory_bytes: 2940
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

//Combination generator for int slice
func combinations(list []int, choose int) (c chan []int) {
	c = make(chan []int, 1)
	go func() {
		defer close(c)
		switch {
		case choose == 0:
			c <- []int{}
		case choose == len(list):
			c <- list
		case len(list) < choose:
			return
		default:
			for i := 0; i < len(list); i++ {
				for subComb := range combinations(list[i+1:], choose-1) {
					c <- append([]int{list[i]}, subComb...)
				}
			}
		}
	}()
	return
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	n := make([]int, 5)
	for i := 0; i < N; i++ {
		s := getString()
		switch s[0] {
		case 'M':
			n[0]++
		case 'A':
			n[1]++
		case 'R':
			n[2]++
		case 'C':
			n[3]++
		case 'H':
			n[4]++
		}
	}

	a := []int{0, 1, 2, 3, 4}

	ans := 0
	for comb := range combinations(a, 3) {
		x := 1
		for _, v := range comb {
			x *= n[v]
		}
		ans += x
	}
	out(ans)
}


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

using namespace std;

string s;

int main() {

   cin >> s;


   for (int i = s.length() - 2; i >=0; i-=2) {
    string s1 = s.substr(0, i/2);
    string s2 = s.substr(i/2, i/2);
    if (s1.compare(s2) == 0)  {// equal
        cout << i << endl;
        return 0;
    }
   }
   return 0;
   //s is always is even;

}

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

int main (){
  int A,B,C,K,count;
  string S,T;
  cin>>A>>B>>C>>K;

  count =0;
  for(int i=0;i<K;i++){
  	if(i<A) {count++;}
    else if(i<A+B){}
    else count--;
  }
  
  cout<<count<<endl;
    
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

void apply(vector<string>& ans, const vector<string>& p, int x, int y) {
    for (int i = x; i < x + p.size(); ++i) {
	    for (int j = y; j < y + p[0].size(); ++j) {
		    ans[i][j] = p[i - x][j - y];
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	vector<string> p4 = {
	  "aacd",
	  "bbcd",
	  "efgg",
	  "efhh"
	};
	
	vector<string> p5 = {
	  
	  "..hij",
	  "..hij",
	  "eeaad",
	  "ffb.d",
	  "ggbcc"
	};
	
	vector<string> p7 = {
	  "....pqr",
	  "....pqr",
	  "....hij",
	  "....hij",
	  "kkeeaa.",
	  "llff..b",
	  "mmgg..b"
	};
	
	int n;
	cin >> n;
	if (n <= 2) {
	   cout << -1 << endl;
	   return 0;
	}
	vector<string> ans(n);
	for (int i = 0; i < n; ++i) ans[i] = string(n, '.');
	
	if (n % 3 == 0) {
		for (int i = 0; i < n; i += 3) {
			ans[i][i] = 'a';
			ans[i][i + 1] = 'a';
			ans[i + 1][i + 2] = 'b';
			ans[i + 2][i + 2] = 'b';
		}
	} else if (n == 7) {
	    apply(ans, p7, 0, 0);
	} else if (n == 11) {
	    apply(ans, p7, 0, 0);
		apply(ans, p4, 7, 7);
	} else {
	    for (int k = 0; ; ++k) {
		    if ((n - 4 * k) % 5 == 0) {
				int l = (n - 4 * k) / 5;
				int i = 0;
				for (int j = 0; j < k; ++j) {
				    apply(ans, p4, i, i);
                    i += 4;	
				}for (int j = 0; j < l; ++j) {
				    apply(ans, p5, i, i);
                    i += 5;	
				}
				break;
			}
		}
	}
	
	for (int i = 0; i < n; ++i) {
	    cout << ans[i] << endl;
	}
	
	

    return 0;
}


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

//?????????????????\???????????§?????§??§19???????¶???????????????§???????????????
static const int INFTY = 2000000000;

void WarshallFloyd(int weight[][100], int verNum) {

	//k????¢??????????????????????????????°????¢??????????????????????????±???????
	//???????????????????¨???????
	for (int k = 0; k < verNum; k++)
		for (int i = 0; i < verNum; i++) {
			//?????????????????£?????????????????§??´??°???????????????????????????
			if (weight[i][k] == INFTY) continue;
			for (int j = 0; j < verNum; j++) {
				if (weight[k][j] == INFTY) continue;
				weight[i][j] = min(weight[i][j], weight[i][k] + weight[k][j]);
			}
		}
}

int main() {

	int weight[100][100];
	int verNum;
	int edgeNum;
	cin >> verNum >> edgeNum;

	//Initialize
	for (int i = 0; i < verNum; i++)
		for (int j = 0; j < verNum; j++)
			weight[i][j] = (i == j) ? 0 : INFTY;

	for (int i = 0; i < edgeNum; i++) {
		int first_ver, second_ver, wei;
		cin >> first_ver >> second_ver >> wei;
		weight[first_ver][second_ver] = wei;
	}

	WarshallFloyd(weight, verNum);

	//?????¨???
	bool negative = false;
	for (int i = 0; i < verNum; i++)
		if (weight[i][i] < 0) negative = true;

	if (negative)
		cout << "NEGATIVE CYCLE" << endl;
	else {
		for (int i = 0; i < verNum; i++) {
			for (int j = 0; j < verNum; j++) {
				if (j) cout << " ";

				string verVal;
				if (weight[i][j] == INFTY) verVal = "INF";
				else                                  verVal = to_string(weight[i][j]);

				cout << verVal;
			}
			cout << endl;
		}
	}

	return 0;
}

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

int main () {
  int N;
  cin >> N;
  vector <int> d(N);
  for (int i = 0; i < N; i++) cin >> d[i];
  int ans = 0;
  for (int i = 0; i < N-1; i++) {
    for (int j = i+1; j < N; j++) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
  return 0;
}

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

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/


int main() {
    string s, t;
    cin >> s;
    cin >> t;
    
    for (int i = 0; i < s.size(); i++) {
        char c = s[0];
        s.erase(s.begin() + 0);
        s += c;
        if (s == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }

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

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 256
import heapq
import math
n,h=map(int,input().split())
used=[0 for i in range(n)]
que=[]
for i in range(n):
    a,b=map(int,input().split())
    heapq.heappush(que,(-b,-a,i))
count=0
while h>0:
    b,a,i=heapq.heappop(que)
    if used[i]:
        b=-b
        count+=math.ceil(h/b)
        break
    else:
        used[i]=1
        h+=b
        count+=1
        heapq.heappush(que,(a,b,i))
print(count)

Measured memory_bytes: 21432
#include <bits/stdc++.h>
 
using namespace std;
 
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define ll	long long
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007
#define M_PI 3.141592653589793238462643383279502884L

int main() {
	ios;
	int n;
	cin>>n;
	map <int, int> m;
	for (int i = 1; i <= n; i++) m[i] = 0;
	int Ai;
	for (int i = 2; i <= n; i++) {
		cin>>Ai;
		m[Ai]++;
	}
	for (int i = 1; i <= n; i++) {
		cout<<m[i]<<endl;
	}
	return 0;
}


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

int main(){
  while(1){
    int n,l,r;
    cin >> n >> l >> r;
    if(n==0) return 0;
    vector<int> d(n);
    for(int i=0;i<n;i++) cin >> d[i];
    int count = 0;
    for(int i=l;i<=r;i++){
      bool ok=false;
      for(int j=0;j<n;j++){
	if(i%d[j]==0){
	  if(j%2==0) count++;
	  ok=true;
	  break;
	}
      }
      if(!ok&&n%2==0) count++;
    }
    cout << count << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
/*

Author: @karngyan
Team: BlundersPride

*/

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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
const ll N = 3010;
ll n;
std::vector<ld> a;
ld dp[N][N];

ld go(ll i , ll h)
{
	if(h > (n-h))
		return 1.0;
	
	if( i >= n)
		return 0.0;

	ld &ans = dp[i][h];

	if(ans != -1.0)
		return ans;

	ans = (a[i]*go(i+1 , h+1) + (1-a[i])*go(i+1 , h) );
	return ans;

}

signed main()
{

	fast;
	cout<<fixed<<setprecision(10);
////////////////////////////////////////////////////////////////////////////////////////////
	rep(i,0,N)
		rep(j,0,N)
			dp[i][j] = -1;

	cin >> n;
	cres(a , n);
	rep(i,0,n)
		cin >> a[i];

	cout<<go(0,0)<<endl;








////////////////////////////////////////////////////////////////////////////////////////////

	
	return 0;
}


Measured memory_bytes: 142080