akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    map<P,ll> mp;
    rep(i,N){
        string s;
        cin >> s;
        ll div_2=0,div_5=0;
        rep(i,s.size()){
            if(s[i]=='.'){
                div_2-=(s.size()-(i+1));
                div_5-=(s.size()-(i+1));
                s.erase(i,1);
            }
        }
        ll k=stoll(s);
        while(k%2==0){
            k/=2;
            div_2++;
        }
        while(k%5==0){
            k/=5;
            div_5++;
        }
        mp[{div_2,div_5}]++;
    }
    ll ans=0;
    FOR(i,-100,101){
        FOR(j,-20,21){
            ll res=0;
            FOR(ii,-100,101){
                FOR(jj,-20,21){
                    if(i+ii>=0&&j+jj>=0){
                        if(i==ii&&j==jj)res--;
                        res+=(mp[{ii,jj}]);
                    }
                }
            }
            ans+=res*mp[{i,j}];
        }
    }
    ans/=2;
    cout << ans << endl;
}

Measured memory_bytes: 4116
#include <bits/stdc++.h>
using namespace std;
#define LL long long int
LL A, B, C, D;
map<LL, LL> memo;
LL INF = (LL)5e18;
LL solve(LL n){
    if(n==0) return 0;
    if(n==1) return D;
    if (memo.count(n)) return memo[n];
    LL l2 = (n/2)*2;
    LL r2 = ((n+1)/2)*2;
    
    LL l3 = (n/3)*3;
    LL r3 = ((n+2)/3)*3;
    
    LL l5 = (n/5)*5;
    LL r5 = ((n+4)/5)*5;
    
    LL res = INF;
    if(n < res/D){
        res = n*D;
    }
    
    res = min(res, llabs(l2-n)*D + A + solve(l2/2));
    res = min(res, llabs(r2-n)*D + A + solve(r2/2));
    
    res = min(res, llabs(l3-n)*D + B + solve(l3/3));
    res = min(res, llabs(r3-n)*D + B + solve(r3/3));
    
    res = min(res, llabs(l5-n)*D + C + solve(l5/5));
    res = min(res, llabs(r5-n)*D + C + solve(r5/5));
    
    return memo[n] = res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    int T;
    cin >> T;
    for (int t = 0; t < T; t++) {
        memo.clear();
        LL N;
        // See Editorial...
        cin >> N;
        cin >> A >> B >> C >> D;
        cout << solve(N) << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 4372
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 20)

int a[MAXN];

int main() {
	int n;
	cin >> n;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		 cin >> a[i];
		 sum += a[i];
	}
	ll best = 2 * sum;
	ll curs = 0;
	for (int i = 0; i <= n; i++) {
		ll cur = llabs(2 * curs - sum);
		if (cur < best) {
			best = cur;
		}
		if (i < n) {
			curs += a[i];
		}
	}
	cout << best << endl;

	return 0;
}


Measured memory_bytes: 4420
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j;
   string s;
    long long int x=10000;
   cin>>s;
   for(i=0;i+2<s.size();i++)
   {
       string q;
       for(j=i;j<i+3;j++)
       {
           q+=s[j];
       }
       long long int l=stoi(q);
       //cout<<l<<endl;
       x=min(x,abs(753-l));
   }
    cout<<x;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  int n;
  cin >> n;
  int _A = 0,B_ = 0,BA = 0;
  ll res = 0;
  rep(i,n){
    string s;cin >> s;
    if(s[0] == 'B' && s.back() == 'A'){
      BA++;
    }else if(s[0] == 'B'){
      B_++;
    }else if(s.back() == 'A'){
      _A++;
    }
    for(int j = 1;j < s.size();j++){
      if(s[j] == 'B' && s[j-1] == 'A')res++;
    }
  }
  if(BA > 0){
    res += BA-1;
    if(B_ > 0)res++,B_--;
    if(_A > 0)res++,_A--;
  }
  res += min(B_,_A);
  cout << res << endl;








  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
using namespace std;
int main()
{
   int a,b,c;
   scanf("%d%d%d",&a,&b,&c);
    int cnt=0;
   for(int i=100;i>=0;i--)
   {
       if(a%i==0&&b%i==0){
        cnt++;
        if(cnt==c){
            printf("%d\n",i);
            return 0;
        }
       }
   }
}


Measured memory_bytes: 256
N, M = map(int,input().split())
L1 = [[] for k in range(3*(N+1))]
for k in range(M):
	u, v = map(int, input().split())
	L1[3*u].append(3*v+1)
	L1[3*u+1].append(3*v+2)
	L1[3*u+2].append(3*v)
S, T = map(int, input().split())
S = 3*S
T = 3*T

t = 0
sumi = [None for k in range(3*(N+1))]
sumi[T] = -1
now = [S]
flg = 0
while(len(now) != 0):
	t += 1
	pre = []
	for n in now:
		pre.extend(L1[n])
	now = []
	for p in pre:
		if sumi[p] == None:
			sumi[p] = t
			now.append(p)
		elif sumi[p] == -1:
			flg = 1
	if flg == 1:
		print(t//3)
		flg = 2
		break
if flg == 0:
	print(-1)

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

int main(){
    vector<int> a(3);
    int k;
    cin >> a[0] >> a[1] >> a[2] >> k;
    
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    
    for(int i=0; i<k; i++){
        a[0] *= 2;
    }
    
    cout << a[0]+a[1]+a[2] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <math.h>
#include <algorithm>

const long long MOD = 1000000007;

using namespace std;




int main(void) {

    long long i, j;
    long long n, m;
    long long sum = 0;
    long long temp, temp_b;
    long long min, max;
    string s1, s2;
    long long a, b;
    long long mod = 2019;
    vector<long long> t;
    vector<long long> dp;

    cin >> s1 >> s2;

    s2.pop_back();

    if(s1 == s2) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

int a,b,ar[N],c,s;

int main()
{

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
 	
	cin >> a >> b;
	for (int i = 0; i < a; ++i)
	{
		cin >> c;
		for (int i = 0; i < c; ++i)
		{
			cin >> s;
			ar[s]++;
		}
	}

	int ans = 0;

	for (int i = 1; i < b+1; ++i)
	{
		if(ar[i] == a)
			ans++;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	var a = input.split('')
	a[3] = "8"
	console.log(a.join(''))
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
double dp[3000][3000]={};
int main() {

	int n;
	double p[3000];
	cin>>n;

	rep(i,n){
		cin>>p[i+1];
	}
	dp[0][0]=1;
	for(int i=1; i<n+1; i++){
		for(int j=1; j<i+1; j++){
			dp[j][i]+=dp[j-1][i-1]*p[i];
			dp[j-1][i]+=dp[j-1][i-1]*(1-p[i]);
		}
	}
	double res=0;
	for(int i=n/2+1; i<n+1; i++)res+=dp[i][n];

	cout<<setprecision(12)<<res<<endl;
	return 0;
}


Measured memory_bytes: 70016
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++)


int ten(int a) {
	int i;
	for (i = a; i % 10 != 0; i++) {
	}
	return i;
}

int main() {
	int a[5],ans=0,k=10,mem;
	REP(i, 5) {
		cin >> a[i];
	}
	REP(i, 5) {
		if ((a[i] % 10 != 0) && (a[i] % 10 < k)) {
			mem = i;
			k = a[i] % 10;
		}
	}
	REP(i, 5) {
		if (i !=mem) {
			ans += a[i];
			ans = ten(ans);
		}
	}
	ans += a[mem];
	cout << ans;
	return(0);
}

Measured memory_bytes: 256
#define rep(i, m, n) for(int i = m; i < n; i++)
#define repM(i, m, n) for(int i = n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll; using namespace std;
//typedef pair<int,int> pii;
// d = distance(lower_bound(all(x)), upper_bound(all(x)));
int INF = 1e9;
int M = 1e9+7;
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>

#define N 30
#define K 3

int main(){
  int A, B; cin >> A >> B; int a=1, v=1;
  for(a=1; v<B; a++) {
    v+=A-1;
    //cout << v << "@" << a << "-";
  } a--;
  cout << a << endl;
}

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

inline bool check(set<int> v, int n) {
	while (n) {
		if (!v.count(n % 10))
			return true;
		n /= 10;
	}
	return false;
}

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	set<int> d = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
	REP(i, k) {
		int tmp;
		cin >> tmp;
		d.erase(tmp);
	}

	while (check(d, n))
		n++;
	cout << n << '\n';
	return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solve();
	}

	private static final void solve() {
		try (Scanner cin = new Scanner(System.in)) {
			String str = cin.next();
			char[] array = str.toCharArray();
			StringBuilder sb = new StringBuilder(array.length / 2);

			for (int i = 0; i < array.length; i += 2) {
				sb.append(array[i]);
			}
			System.out.println(sb.toString());
		} finally {
		}
	}

}


Measured memory_bytes: 23516
/*
 * https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/all/ALDS1_7_A
 * */
#include <bits/stdc++.h>
using namespace std;

void cin_to_in() {
    // Redirect text to cin
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
}

// definition
#define  MAX 100005
#define NIL -1


// left-child, right-child representation
struct Node { int parent, left, right; };
Node T[MAX];
int D[MAX];

void print(int u) {
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "depth = " << D[u] << ", ";

    if(T[u].parent == NIL) cout << "root, ";
    else if(T[u].left == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";
    for (int i = 0,  c = T[u].left; c != NIL; ++i, c = T[c].right) {
        if(i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

void recursive(int u, int p) {
    D[u] = p;
    if(T[u].right != NIL)
        recursive(T[u].right, p);
    if(T[u].left != NIL)
        recursive(T[u].left, p + 1);
}

int main() {
    // cin_to_in();
    int n, degree, vertex, child, left, right;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        T[i].parent = T[i].left = T[i].right = NIL;
    }

    for (int i = 0; i < n; ++i) {
        cin >> vertex >> degree;
        for (int j = 0; j < degree; ++j) {
            cin >> child;
            if(j == 0)
                T[vertex].left = child;
            else
                T[left].right = child;
            left = child;
            T[child].parent = vertex;
        }
    }

    for (int i = 0; i < n; ++i) {
        if(T[i].parent == NIL)
            right = i;
    }

    recursive(right, 0);

    for (int i = 0; i < n; ++i) {
        print(i);
    }

    return 0;
}


Measured memory_bytes: 7760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main() {
	int n, in, ans = 0;
	vi v, t;
	cin >> n;
	rep(i, n) {
		cin >> in; t.push_back(in * 2);
	}
	rep(i, n) {
		cin >> in; v.push_back(in * 2);
	}
	vi q; q.push_back(0);
	rep(i, n) {
		q.back() = min(q.back(), v[i]);
		rep(j, t[i]) {
			q.push_back(min(q.back()+1,v[i]));
		}
	}
	stack<int> s;
	int tmp = 0;
	for (int i = q.size() - 2; i > 0; i--) {
		tmp = min(q[i],tmp+1);
		s.push(tmp);
		ans += tmp;
	}
	rep(i, q.size()) {
		//cout << q[i] << endl;
	}
	while (!s.empty()) {
		//cout << s.top() << endl;
		s.pop();
	}
	printf("%lf\n", ans / 4.0);
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
  int mx,n,m,a,b;
  cin>>n>>m;
  mx=0;
  for(int i=0;i<n;i++){
    a=0;
    for(int j=0;j<m;j++){
      cin>>b;
      a+=b;
    }
    if(mx<a)mx=a;
  }
  cout<<mx<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;

int main(void) {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INFL = 1e18;
const int INF = 1000000007;
const ld PI = acos(-1);
const ld EPS = 1e-13;

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

    ll ans;
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ans = max({ a * c, a * d, b * c, b * d });
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3616
s = input()

start = -1
end = -1
for index,i in enumerate(s):
  if i == "A":
    start = index
    break
for index,i in enumerate(list(reversed(s))):
  if i == "Z":
    end = len(s) - index
    break
if end == -1 or start == -1:
  print(1)
else:
  print(end -start)

Measured memory_bytes: 47584
#include <bits/stdc++.h>
#include <set>
#include <queue>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define reps(i, s, n) for (int i = s; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define repsl(i, s, n) for (ll i = s; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl
#define readVarll(nam) ll nam; cin >> nam
#define INF 99999999999

ll calc(ll n, ll k)
{
  return n;
}

int main()
{
  ll n,x,t;
  cin >> n >> x >> t;

  //ll ans = calc(n, k);
  ll ans = (n/x) * t + (n%x == 0? 0 : t);
  cout << fixed << ans << endl;

  return 0;
}

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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    cout << n * (n - 1) / 2 << ln;
    return 0;
}


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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n,k=1;
string s;

void process()
{
    int vt=1;
    string t,t1;
    t+=s[0];
    while (vt<n)
    {
        while (vt<n && t1+s[vt]==t)
        {
            t1+=s[vt];
            vt++;
        }
        k++;
        t1+=s[vt];
        if (vt>=n)
            k--;
        t=t1;
        t1="";
        vt++;
    }
    cout<<k;
}

int main()
{
    cin>>s;
    n=s.length();
    process();
    return 0;
}


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

int main(){
  ll ans = 0;
  ll A,B,C,K;
  cin >> A >> B >> C >> K;
   ans += min(K,A);

  if(K-A-B > 0) ans += (K-A-B)*-1;
  cout << ans;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<int> nums(n);

    for (int i = 0; i < n; i++)
        cin >> nums[i];

    sort(nums.begin(), nums.end());

    int alice = 0, bob = 0;

    for (int i = 0; i < n; i++){
        if (i % 2 ==0){
            alice += nums[i];
        } else {
            bob += nums[i];
        }
    }
       
    cout << abs(alice - bob);

    return 0;
}

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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

struct node {
	int v, d;
	node(int v, int d) :v(v), d(d){}
	bool operator<(const node &n) const { return d > n.d; }
};
struct edge{ int to, weight; };

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

	vector<vector<edge>> g;
	g.assign(N, vector<edge>());
	for (int i = 0; i < N - 1; i++){
		int a, b, c;
		cin >> a >> b >> c;
		g[a - 1].push_back({ b - 1, c });
		g[b - 1].push_back({ a - 1, c });
	}
	int Q, K;
	cin >> Q >> K;
	K--;

	vector<int> dist;
	dist.assign(N, -1);
	priority_queue<node> que;
	que.push(node(K, 0));
	while (!que.empty()){
		int v = que.top().v, d = que.top().d;
		que.pop();
		if (dist[v] >= 0 and dist[v] <= d) continue;
		dist[v] = d;
		for (int i = 0; i < g[v].size(); i++)
			que.push(node(g[v][i].to, d + g[v][i].weight));
	}


	for (int i = 0; i < Q; i++){
		int ans = 0;
		int x, y;
		cin >> x >> y;
		x--; y--;
		ans = dist[x] + dist[y];
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 11120
#!/usr/bin/env python3
import sys
from itertools import combinations_with_replacement


def solve(X: int):
    xs = [i for i in range(-180, 181)]
    # xs = [i ** 5 for i in range(-3, 4)]
    L = list(combinations_with_replacement(xs, 2))
    for l in L:
        l5 = (pow(l[0], 5), pow(l[1], 5))
        if max(l5) - min(l5) == X:
            print("{0} {1}".format(max(l), min(l)))
            return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()

Measured memory_bytes: 72048
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstdlib>
using namespace std;
set<string> sp;
int main()
{
	string s;
	int k;
	cin>>s>>k;
	for(int i = 0;i < s.size(); ++i)
	{
		for(int j = 0;j < k; ++j)
		{
			if(i + j + 1 > s.size())
			{
				break;
			}
			sp.insert(s.substr(i,j + 1));
		}
	}
	set<string>::iterator iter = sp.begin();
	for(int i = 0;i < k; ++i,++iter);
	iter--;
	cout<<*iter<<endl;
	return 0;
}

Measured memory_bytes: 1664
N, K = map(int, input().split())
A = list(map(int, input().split()))

mod = 10**9 + 7

# そもそも超えている
already = 0
for i in range(N):
    for j in range(i + 1, N):
        if (i == j):
            continue
        if (A[i] > A[j] and i < j):
            already += 1
already_count = already * K

L = []
L.extend(A)
L.extend(A)
count = 0
for i in range(len(L)):
    for j in range(i + 1, len(L)):
        if (i == j):
            continue
        if (L[i] > L[j] and i < j):
            count += 1
inc = count - (already * 2)

tousa_sum = ((K - 1) * (1 + (K - 1))) // 2
print((inc * tousa_sum + already_count) % mod)


Measured memory_bytes: 9268
#include<bits/stdc++.h>
namespace FastIO{const char* ln="\n";struct Reader{char buf[1<<20],*s,*t;bool EOF_FLG;Reader():s(buf),t(buf),EOF_FLG(false) {};char gt() {return s==t&&((t=(s=buf)+fread(buf,1,1<<20,stdin))==s)?EOF:(*s++);}Reader& operator>>(char* str) {if(EOF_FLG)return *str=0,*this;while((*str=gt())!=' '&&*str!='\n'&&*str!=EOF)++str;if(*str==EOF)EOF_FLG=true;*str=0;return *this;}template<typename T>Reader&operator>>(T&x) {if(EOF_FLG)return *this;char c=0,d;while(c!=EOF&&(c<'0'||c>'9'))d=c,c=gt();if(c==EOF){EOF_FLG=true;return *this;}else x=0;while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=gt();if(d=='-')x=-x;return *this;}}in;struct Writer{char buf[1<<20],*s,*t;Writer():s(buf),t(buf+(1<<20)){}~Writer(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,1<<20,stdout),*s++=c):(*s++=c);}template<typename T>Writer&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[40],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}Writer&operator<<(const char*s) {while(*s)pt(*s++);return *this;}}out;}using namespace FastIO;
namespace ZDY{
	#define ll long long
	#define db double
	#define sht short
	#define MB template <class T>
	#define Fur(i,x,y) for(int i=x;i<=y;i++)
	#define fur(i,x,y) for(i=x;i<=y;i++)
	#define Fdr(i,x,y) for(int i=x;i>=y;i--)
	#define fdr(i,x,y) for(i=x;i>=y;i--)
	#define clr(x,y) memset(x,y,sizeof(x))
	#define cpy(x,y) memcpy(x,y,sizeof(x))
	#define inf 0x3f3f3f3f
	#define fin(s) freopen(s".in","r",stdin)
	#define fout(s) freopen(s".out","w",stdout)
	#define l2(n) (int(log2(n)))
	#define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
	#define fcin ios::sync_with_stdio(false)
	MB T ABS(T x){return x>0?x:-x;}
	MB T MAX(T x,T y){return x>=y?x:y;}
	MB T MIN(T x,T y){return x<=y?x:y;}
	MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
	void SWAP(int &x,int &y){x^=y;y^=x;x^=y;}
}using namespace ZDY;using namespace std;
#define int ll
#define N 100011
int a[N],n,k,len,ans=0,tot=0;
signed main(){
	in>>n>>k;len=log2(k);
	Fur(i,1,n)in>>a[i];
    Fdr(j,42,0){
        int x=0,y=0;
        Fur(i,1,n)
            if(a[i]&(1ll<<j))x++;else y++;
        if((ans+(1ll<<j))<=k)ans+=(x>y)?0:(1ll<<j);
    }
    Fur(i,1,n)tot+=(ans^a[i]);
    out<<tot<<ln;
}

Measured memory_bytes: 2048
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
using namespace std;

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

const long long INF = 1LL << 60;


// 入力
int N;
long long W, weight[110], value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[110][100100] = {0};

int main() {
  cin >> N >> W;
  for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

  // DPループ
  for (int i = 0; i < N; ++i) {
    for (int sum_w = 0; sum_w <= W; ++sum_w) {

      // i 番目の品物を選ぶ場合
      if (sum_w - weight[i] >= 0) {
          chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
      }

      // i 番目の品物を選ばない場合
      chmax(dp[i+1][sum_w], dp[i][sum_w]);
    }
  }

  // 最適値の出力
  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 79360
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
L = max(A).bit_length()
l = [0]*L

for a in A:
	for i, x in enumerate("{:b}".format(a).zfill(L)[::-1]):
		if x == "1":
			l[i] += 1

ans = 0

for i, x in enumerate(l):
	ans += (N-x)*x * pow(2, i, mod)
	ans %= mod
print(ans)


Measured memory_bytes: 121148
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<chrono>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds; 
#define lli long long int
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define bfr(i,a,b) for(lli i=a;i>=b;i--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
#define tc int t;cin>>t;while(t--)
#define mod 1000000007LL
#define mod2 998244353LL
#define all(vec) vec.begin(),vec.end()  
#define ld long double
#define pb push_back
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 


lli power(lli x,lli y,lli m)
{
    lli res=1;
    while(y>0)
    {
        if(y&1)res=((res%m)*(x%m))%m;
        y>>=2;
        x= ((x%m)*(x%m))%m;
    }
    return res%m;
}

int main()
{
   
                        
     fio

     
    
     lli n,m,k;
     cin>>n>>m>>k;
     vector<lli> a(n),b(m);
     fr(i,0,n)cin>>a[i];
     fr(j,0,m){cin>>b[j];if(j>0)b[j]+=b[j-1];}

     lli ans=0,sum=0;

     vector<lli>::iterator itr;
     itr = lower_bound(all(b),k);
     ans=itr-b.begin();
     if((*itr)==k)ans++;

     fr(i,0,n)
     {
         sum+=a[i];
         if(k-sum<0)break;
         itr = lower_bound(all(b),k-sum);
         lli temp=itr-b.begin();
         if((*itr)==k-sum)temp++;
         ans=max(i+1+temp,ans);

     }

     cout<<ans<<'\n';




      
     

     
              


return 0;}    


Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int sum=0,x=N;
  while (x>=1){
    sum+=x%10;
    x/=10;
  }
  if (N%sum==0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int r,g,b;
  
  scanf("%d%d%d",&r,&b,&g);
  
  if((r*100+b*10+g)%4==0)
  {
    printf("YES\n");
  }
  
  else
  {
    printf("NO\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;
ll digitsum(ll n)
{

    ll ans = 0;
    while (n > 0)
    {
        ans += n % 10;
        n /= 10;
    }
    return ans;
}
int main()
{
    int m;
    cin >> m;
    vector<ll> d(m), c(m);
    ll sum = 0;
    ll pure = 0;
    //ll tmp = 0;
    rep(i, m)
    {
        cin >> d[i] >> c[i];
        sum += (ll)d[i] * c[i];
        pure += c[i];
    }
   
    
    pure--;
    pure+=(sum-1)/9;
    cout << pure << endl;
}

Measured memory_bytes: 3328
/* ***********************************************
Author        :axp
Created Time  :2016/9/24 20:06:39
TASK		  :A.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

typedef long long ll;
const int inf = 1<<30;
const int md = 1e9+7;
int n,m;
int T;
string s;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    cin>>s;
	for(int i=0;i<4;i++)cout<<s[i];
	cout<<' ';
	for(int i=4;i<s.size();i++)cout<<s[i];
	cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int N,a,b,c,d,e,f,g,h,i,j;
    scanf("%d",&N);
    if((N==1000)||(N==2000)||(N==3000)||(N==4000)||(N==5000)||(N==6000)||(N==7000)||(N==8000)||(N==9000)||(N==10000))
    {


        printf("0\n");
    }
else if(N<1000){
        j=1000-N;
         printf("%d\n",j);
    }
    else if(N>1000 && N<2000)
    {
        a=2000-N;
        printf("%d\n",a);
    }

    else if(N>2000 && N<3000)
    {
        b=3000-N;
        printf("%d\n",b);
    }

    else if(N>3000 && N<4000)
    {
        c=4000-N;
         printf("%d\n",c);
    }

    else if(N>4000 && N<5000)
    {
        d=5000-N;
         printf("%d\n",d);
    }

    else if(N>5000 && N<6000)
    {
        e=6000-N;
        printf("%d\n",e);
    }

    else if(N>6000 && N<7000)
    {
        f=7000-N;
          printf("%d\n",f);
    }

    else if(N>7000 && N<8000)
    {
        g=8000-N;
        printf("%d\n",g);
    }

    else if(N>8000 && N<9000)
    {
        h=9000-N;
        printf("%d\n",h);
    }

    else if(N>9000 && N<10000)
    {
        i=10000-N;
         printf("%d\n",i);

    }

    return 0;
}







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

#define p(x) cout << x << endl

int main()
{
    int n;
    cin >> n;
    int a = n%10;
    int b = (n/10)%10;
    int c = (n/100)%10;
    if(a == 7 || b == 7 || c == 7 )
		p("Yes");
	else
		p("No");
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int k;
    cin>>k;

    vl run={1,2,3,4,5,6,7,8,9},tmp;
    k-=9;

    while(k>0){
        swap(tmp,run);
        rep(i,tmp.size()){
            // cerr<<tmp[i]<<" ";
            if(tmp[i]%10!=0)run.push_back(tmp[i]*10+tmp[i]%10-1);
            run.push_back(tmp[i]*10+tmp[i]%10);
            if(tmp[i]%10!=9)run.push_back(tmp[i]*10+tmp[i]%10+1);
        }
        vl().swap(tmp);
        k-=run.size();
    }
    k+=run.size();

    cout<<run[k-1]<<"\n";
    
    return 0;
}

Measured memory_bytes: 1712
# coding : utf-8

import math

N,M = map(int,input().split())

l = []
for i in range(1,int(math.sqrt(M))+1):
    if M % i == 0:
        l.append(i)
        l.append(M//i)

ans = 1
for l_ in l:
    if l_*N <= M:
        ans = max(ans,l_)

print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
 int n,a,b;
 cin>>n>>a>>b;
 if(a>b)
   cout<<b<<" ";
  else
   cout<<a<<" ";
int x=(a+b)-n;
if(x>0)
  cout<<x;
else
 cout<<"0";
return 0;
}

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

using namespace std;

class P{
public:  
  int d,r;
};

int data,res;
vector<string>sv;

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

void input(){
  string tmp;
  sv.clear();
  for(int i = 0 ; i < 9 ; i++)cin >> tmp,sv.push_back(tmp);
}

bool check(int x,int y){
  if(!(0 <= x && x < 3))return false;
  if(!(0 <= y && y < 3))return false;
  return true;
}

void dfs(int pos,int data,vector<P>v){

  //cout << "pos = " << pos << endl;//
  //cout << "res = " << res << endl;//

  if(pos == 9){
    res++;
    return;
  }
  
  for(int i = 0 ; i < 9 ; i++){
    if(data & (1 << i))continue;
    int ndata = (data | (1 << i));
    string str = sv[i];
    for(int j = 0 ; j < 4 ; j++){
      vector<P>nv = v;
      char u,r,d,l;

      u = str[j];
      r = str[(j+1)%4];
      d = str[(j+2)%4];
      l = str[(j+3)%4];
      
      int x,y;
      x = pos%3;
      y = pos/3;
      
      int nx,ny,npos;

      // up
      ny = y + dy[0];
      nx = x + dx[0];
      if(check(nx,ny)){
        npos = ny * 3 + nx;
        if(abs(v[npos].d - u) != abs('A'- 'a'))continue;
      }

      // left
      ny = y + dy[3];
      nx = x + dx[3];
      if(check(nx,ny)){
        npos = ny * 3 + nx;
        if(abs(v[npos].r - l) != abs('A'- 'a'))continue;
      }

      P p;
      p.r = r;
      p.d = d;
      
      nv.push_back(p);
      dfs(pos+1,ndata,nv);
    }
  }
}

void solve(){
  input();
  data = 0;
  res = 0;
  vector<P>v;
  dfs(0,data,v);
  cout << res << endl;
}

int main(){
  int n;
  cin >> n;
  for(int i = 0 ; i < n ; i++)solve();
  return 0;
}

Measured memory_bytes: 928
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;


namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       
         public static long GCM(long x,long y)
        {
            if (x < y)  GCM(y, x);


            while (y > 0)
            {
                var z = y;
                y = x % y;
                x = z;
            }
            
            return x;
        }

        



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var n = Read();
            var a = Reads();
            long count = 2;
            long f = 0 ;
            if (n > 1 && a[0] < a[1]) f = 1;
            if (n > 1 && a[0] == a[1]) count = 1;
            long ans = 1;
            
            
            for (int i = 1; i < n-1; i++)
            {
                if (a[i] < a[i + 1])
                {
                    if (f == 0 && count != 1) { ans++; count = 0; }

                    f = 1;
                    count++;
                }
                else if (a[i] > a[i + 1])
                {
                    if (f == 1 && count != 1) { ans++; count = 0; }

                    f = 0;
                    count++;
                }
                
               
            }
            
            WriteLine(ans);











            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 22880
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int n, a, b;cin>>n>>a>>b;
  cout<<((b-a)&1?"Borys":"Alice")<<endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc133/tasks/abc133_c

#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
using ll = long long;

struct C {
    ll L_{};
    ll R_{};
    explicit C(ll L, ll R) : L_(L), R_(R){}
    ll f() {
        auto N = R_ - L_;
        vector<ll> r{};
        for(ll i=0; i <= N && i < 2019; ++i) {
            r.emplace_back((L_ + i) % 2019);
        }
        auto n = r.size();
        ll mi = INT64_MAX;
        for(ll i=0; i < n; ++i) {
            for(ll j=i+1; j < n; ++j) {
                ll v = (r[i]*r[j]) % 2019;
                mi = min(mi, v);
            }
        }
        return mi;
    }
};

int main() {
    ll L, R;
    cin >> L >> R;
    C c{L, R};
    cout << c.f() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#define MN 40002
#define MM 5000001
#define ll long long
#define ld long double
#define inf 0x7fffffff
#define clz 1000000007
#define ers(arr,val) memset(arr,val,sizeof(arr));
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define repd(i,b,a) for(int i=(b);i>=(a);i--)
#define repe(i,u) for(int i=h[u];i;i=e[i].nx)
using namespace std;
int n,a[200001],Ans=0;
map<int,int> m;
int main(){
	scanf("%d",&n);
	rep(i,1,n){
		scanf("%d",&a[i]);
		m[a[i]]++;
	}
	sort(a+1,a+n+1);
	repd(i,n,1){
		if(!m[a[i]]) continue;
		repd(j,30,0){
			if(a[i]>(1<<j)) break;
			int x=(1<<j)-a[i],y=0;
			if(x==a[i]) y=1;
			if(m[x]>y) {m[a[i]]--;m[x]--;Ans++;break;}
		}
	}
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 29824
s = gets.chomp
t = gets.chomp

c = -1
i = s.size
t.each_char do |char|
  i = s.index(char, i + 1)
  if i.nil?
    c += 1
    i = s.index(char)
    break if i.nil?
  end
end

if i.nil?
  p -1
else
  p s.size * c + i + 1
end


Measured memory_bytes: 2300
def main5():
    N = int(input())
    S = list(input())

    r = g = b = 0
    for c in S:
        if c == "R":
            r += 1
        if c == "G":
            g += 1
        if c == "B":
            b += 1

    tmp = 0
    for i in range(len(S)):
        for j in range(i + 1, len(S)):
            k = 2*j - i
            if  k < len(S) and S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                tmp += 1
    
    ans = r*g*b - tmp

    print(ans)

if __name__ == "__main__":
    main5()

Measured memory_bytes: 9152
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int n=t.size(),p=s.size(),mini=INT_MAX;
	for(int i=0;i<=p-n;i++){
		string st=s.substr(i,n);
		int s=0;
		for(int h=0;h<n;h++){
			if(st[h]!=t[h])s++;
		}
		mini=min(s,mini);
	}
	cout<<mini;
	return 0;
}

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

int main() {
  for(int i = 0; ; i++){
    int a,b;
    string op;
    cin >> a >> op >> b;
  if(op == "?") break;
  else if(op=="+") cout << a+b <<endl;
  else if(op=="-") cout << a-b <<endl;
  else if(op=="*") cout << a*b <<endl;
  else if(op=="/") cout << a/b <<endl;
  }
}


Measured memory_bytes: 3084
#include<iostream>
#include<math.h>
using namespace std;

int main(){
  
  long double n,d; cin >> n >> d;
  int count = 0;
  while(n--){
    long double x,y; cin >> x >> y;
    long double sq = pow(x,2) + pow(y,2);
    long double dis = pow(sq,0.5);
    //printf("%llf\n",dis);
    if(dis<=d)count++;
  }
  printf("%d\n",count);
  
  
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

#define int long long

int N;
int A[100005];
int low, high;

int bit[300005];
int dat[300005];

int sum(int i){
	int ret = 0;
	while(i > 0){
		ret += bit[i];
		i -= i & -i ;
	}
	return ret;
}

void add(int i, int x){
	while(i <= N*2+100){
		bit[i] += x;
		i += i & -i;
	}
	return;
}

bool is_bigger(int val){
	memset(bit,0,sizeof(bit));
	memset(dat,0,sizeof(dat));

	dat[0] = N+10;
	for (int i = 0;i < N;i++){
		if(A[i] < val) dat[i+1] = dat[i]-1;
		else dat[i+1] = dat[i]+1;
	}

	ll s = 0;
	for (int i = 0;i <= N;i++){
		s += sum(dat[i]);
		add(dat[i],1);
	}
	
	ll all = (N*(N+1))/2;

	//cout << val << " " << s << endl;

	if(s*2 >= all) return true;
	else return false;

}

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

	cin >> N;

	low  = INT_MAX;
	high = INT_MIN;

	for (int i = 0;i < N;i++){
		cin >> A[i];
		low = min(low, A[i]);
		high = max(high, A[i]);
	}

	high++;

	while(high-low > 1){
		int mid = (low+high)/2;
		if(is_bigger(mid)) low = mid;
		else high = mid;
	}

	cout << low << endl;

	return 0;

}


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

int main(){
    int n;
    cin >> n;
    string a;
    cin >> a;
    int Rcnt=0;
    int ans=0;
    rep(i,n){
        if(a[i]=='R') Rcnt++;
    }
    if(a.length()>Rcnt){
        for(int i=Rcnt;i<a.length();i++){
            if(a[i]=='R') ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	string s, t;
	cin >> s >> t;

	int cnt = 0;
	int n = s.size();
	for(int i=0; i<n; ++i)
	{
		if(s[i] != t[i])
			++cnt;
	}
	cout << cnt << '\n';
	return 0;

}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> s(n+1);
    rep(i, n) s[i+1] = (s[i]%m+a[i]%m)%m;
    map<int, int> mp;
    ll ans = 0;
    rep(i, n+1) {
        int num = s[i];
        int rem = num%m;
        ans += mp[rem];
        mp[rem]++;
        debug(i, num, rem, ans);
    }
    cout << ans << endl;
    // int db = 0;
    // rep(i, n) FOR(j, i, n) {
    //     ll tot = 0;
    //     FOR(k, i, j+1) tot += a[k];
    //     if (tot%m==0) {
    //         debug(i, j, tot);
    //         db++;
    //     }
    // }
    // debug(db);
}

Measured memory_bytes: 3968
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define PB push_back
#define MP make_pair
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define INF (1 << 28)
#define LLINF (1LL << 60)
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

int main()
{
    ll n,x,m;
    cin>>n>>x>>m;
    ll num[100005] = {};
    ll roopstart = -INF, roopend;
    num[0] = x;
    ll i=1;
    while (1) {
        x = (x * x) % m;
        num[i] = x;
        for(ll j=0;j<i;j++){
            if(num[j]==x){
                roopstart = j;
                roopend = i-1;
            }
        }
        i++;
        if(roopstart!=-INF)
            break;
    }

    ll ans = 0, roopsum = 0;
    for (ll i = 0; i < roopstart; i++) {
        ans += num[i];
    }
    for (ll i = roopstart; i <= roopend;i++){
        roopsum += num[i];
    }
    ans += roopsum * ((n - roopstart) / (roopend - roopstart + 1));
    ll remain = n - (roopstart + (n - roopstart) / (roopend - roopstart + 1) * (roopend - roopstart + 1));
    for (ll i = roopstart; i < roopstart + remain;i++){
        ans += num[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4412
n, k = map(int, input().split())
s = list(map(int, input()))
cnt = 0
ans = 0
start = 0
for i in range(n):
    if s[i] == 0 and (i == 0 or s[i - 1] == 1):
        cnt += 1
    
    if cnt == k + 1:
        while True:
            start += 1
            if s[start - 1] == 0 and s[start] == 1:
                break
        cnt -= 1
    ans = max(ans, i - start + 1)

print(ans)


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

int main(){
	int n;
	scanf("%d",&n);
	double money[n];
	char kind[n][4];
	for(int i=0; i<n; i++){
		scanf("%lf", &money[i]);
		scanf("%s", kind[i]);
	}
	
	double dama=0, bitcoin=0;
	for(int i=0; i<n; i++){
		if(strcmp("JPY", kind[i]) == 0){
			dama += money[i];
		}
		else{
			bitcoin += money[i];
		}
	}
	dama += bitcoin*380000;
	printf("%lf", dama);
	
	return 0;
}

Measured memory_bytes: 128
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

ll nc2(ll n)
{
    if (n == 0)
    {
        return 0;
    }
    else if (n == 1)
    {
        return 0;
    }
    else
    {
        return (n * (n - 1)) / 2;
    }
}

void solve()
{
    ll N, M;
    cin >> N >> M;
    ll allnum = N + M;
    cout << nc2(N) + nc2(M) << endl;

    return;
}

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


Measured memory_bytes: 256
n = gets.chomp.to_i

h = Hash.new(0)
n.times do
  s = gets.chomp
  if s.start_with?("M", "A", "R", "C", "H")
    h[s[0]] += 1
  end
end

ans = 0
if h.keys.length < 3
  ans = 0
else
  h.keys.combination(3) do |a, b, c|
    ans += h[a] * h[b] *  h[c]
  end
end

puts ans

Measured memory_bytes: 1788
using System;
using System.Text;

class Security
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        string result = "Good";
        for(int i = 0; i<s.Length - 1; i++)
        {
            if (s[i].Equals(s[i + 1])){
                result = "Bad";
                break;
            }
        }
        Console.WriteLine(result);
    }
}


Measured memory_bytes: 13140
import sys

N, K = map(int, sys.stdin.readline().split())
p = tuple(map(int, sys.stdin.readline().split()))

max = 0
ite = N - K
base = sum(p[0:K])
max = base
index = 0
for i in range(ite):
    tmp = base + p[i+K] - p[i]
    if tmp > max:
        max = tmp
        index = i+1
    base = tmp

E = [(1+p[index+i])/2 for i in range(K)]
print(sum(E))


Measured memory_bytes: 24660
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N; cin >> N; int H[N], barrier[N] = {}, MAX = 0;
    for (int i = 0  ; i <  N; i++){
        cin >> H[i];
        if (i > 0) {
            if (H[i] <=  H[i-1]) barrier[i] = barrier[i-1]+1,
                 MAX = max( MAX, barrier[i] )  ;
            else                 barrier[i] = 0;
        }
    } cout << MAX << endl;

    return 0;
}


Measured memory_bytes: 1024