akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;
bool solve(vector<int> a){
    int n=a.size();
    ll sum=0;
    for(int i=0;i<n;i++){
        sum+=a[i]-1;
    }
    if(sum==0)return false;
    if(sum%2)return true;
    int odd=0;
    for(int i=0;i<n;i++){
        if(a[i]%2)odd++;
    }
    if(odd>=2)return false;
    int k=-1;
    for(int i=0;i<n;i++){
        if(a[i]%2&&a[i]>=2)k=i;
    }
    if(k==-1)return false;
    a[k]--;
    int g=a[0];
    for(int i=0;i<n;i++){
        g=__gcd(a[i],g);
    }
    for(int i=0;i<n;i++){
        a[i]/=g;
    }
    return !solve(a);
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    if(solve(a)){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }
}

Measured memory_bytes: 10112
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;

#define _GLIBCXX_DEBUG
#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end())

void Add(ll &a, ll b){a=(a+b)%mod;}
void Pro(ll &a, ll b){a=(a*b)%mod;}

int main(){
    string y="ACL";
    ll N; cin>>N;
    string ans;
    rep(i,N) ans+=y;
    cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,m;
    cin>>n>>m;
    vector<ll>v(n);
    ll sum=0;
    for(ll i=0;i<n;i++)
    {
        cin>>v[i];sum+=v[i];
    }
    
    ll x=4*m;
    ll factor=0;
    if(sum%x==0)
    {
        factor=sum/x;
    }
    else
    {
        factor=sum/x+1;
    }
    
    ll counter=0;
    for(ll i=0;i<n;i++)
    {
        if(v[i]>=factor)
            counter++;
    }
    if(counter>=m)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    
}

Measured memory_bytes: 256
#define ll long long
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#include<bits/stdc++.h>
/*#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>*/
ll z =  1000000007 ;
ll inf = 100000000000000000 ;
ll p1 = 37 ;
ll p2 = 53 ;
ll mod1 =  202976689 ;
ll mod2 =  203034253 ;
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll power(ll a ,ll b , ll p){if(b == 0) return 1 ; ll c = power(a , b/2 , p) ; if(b%2 == 0) return ((c*c)%p) ; else return ((((c*c)%p)*a)%p) ;}
ll inverse(ll a ,ll n){return power(a , n-2 , n) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;
ll arr[10][1000] ;
ll ans = inf ;
vector<ll> h ;
ll n , m ,k ;


void solve()
{
	ll cnt = h.size()-1 ;
	vector<ll> curr ;
	fo(i , h.size())
	{
		curr.pub(0) ;
	}
	
	fo(i , m)
	{
		curr[0] += arr[h[0]][i] ;
		for(ll j =1 ; j < h.size() ; j++)
		{
			curr[j] += (arr[h[j]][i] - arr[h[j-1]][i]) ;
		}
		
		int flag= 0 ;
		fo(j , h.size())
		{
			if(curr[j] > k)
				flag = 1 ;
		}
		
		if(flag == 1)
		{
			cnt++ ;
			curr[0] = arr[h[0]][i] ;
			if(curr[0] > k)
			return ;
			for(ll j = 1 ; j < h.size() ; j++)
			{
				curr[j] = (arr[h[j]][i] - arr[h[j-1]][i]) ;
				if(curr[j] > k)
				    return ;
			}
		}
	}
	ans = min(ans , cnt) ;
	return ;
}

void get_ans(ll i)
{
	if(i == n-1)
	{
		h.pub(i) ;
		solve() ;
		h.pob() ;
		return ;
	}
	else
	{
		h.pub(i) ;
		get_ans(i+1) ;
		h.pob() ;
		get_ans(i+1) ;
	}
	return ;
}
 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	 
	
	cin >> n >> m >> k ;
	string str[n] ;
	fo(i , n)
	{
		cin >> str[i] ;
	}
	
	fo(j , m)
	{
		arr[0][j] = (ll)(str[0][j] - '0') ;
	}
	for(ll i = 1 ; i < n ; i++)
	{
		fo(j , m)
		{
			arr[i][j] = (arr[i-1][j] + (ll)(str[i][j] - '0')) ;
		}
	}
	
	get_ans(0) ;
	cout << ans << endl ;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

const int INF = 100100100;
int main() {
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> cost(N);
  vector<vector<int>> A(N,vector<int>(M));
  rep(i,N){
    cin >> cost[i];
    rep(j,M){
      cin >> A[i][j];
    }
  }
  int ans = INF;
  rep(is,1<<N){
    bool can = true;
    int sum = 0;
    vector<int> und(M,0);
    rep(i,N){
      if(is>>i&1){
        sum += cost[i];
        rep(j,M){
          und[j] += A[i][j];
        }
      }
    }
    rep(i,M){
      if(und[i] < X) can = false;
    }
    if(can){
      ans = min(ans,sum);
    }
  }
  if(ans == INF) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <cassert>
#include <random>
#include <stack>
#include <ctime>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    long a, b;
    cin >> a >> b;
    if (a < 9 && b < 9) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
}


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

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

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

	int n; cin >> n;

	int p = 0,now;
	int cnt = 0;
	int ans = -1;

	for (int i = 0;i < n;i++){
		cin >> now;
		if(now == 1 && p == 1) cnt++;
		else if(now == 1) cnt = 1;
		else{
			ans = max(ans,cnt+1);
			cnt = 0;
		}
		p = now;
	}

	ans = max(ans,cnt+1);

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 3140
#include <iostream>
#include <vector>
using namespace std;
#define MOD 1000000007
vector<int> v[100010];
bool b[100010];
long long ans;
int n,k;

void solve(int x,int m){
	int tmp = m;
	ans *= k-m-1;
	ans %= MOD;
	//cout<<k-m-1<<endl;
	m++;
	b[x] = 1;
	for(int i=0;i<v[x].size();i++)
		if(b[v[x][i]] == false)
			solve(v[x][i], m++-tmp);
}

main(){
	int tmpa,tmpb,ct;
	ct = 0;
	cin>>n>>k;
	for(int i=1;i<n;i++){
		cin>>tmpa>>tmpb;
		v[tmpa].push_back(tmpb);
		v[tmpb].push_back(tmpa);
	}
	b[1] = true;
	ans = k;
	for(int i=0;i<v[1].size();i++)
		solve(v[1][i],ct++);
	cout<<ans<<endl;
}

Measured memory_bytes: 9344
s = input().strip()
s = s[::-1]
ans = len(s)
i = 0
while (i + 1) < len(s):
    if s[i] != s[i + 1]:
        s = s[:i] + s[i + 2:]
        i = max(i - 1, 0)
    else:
        i += 1
print(ans - len(s))


Measured memory_bytes: 3420
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
using namespace std;
int main() {
	string s,nx;
	vector<int> x;
	int xnum = 0,nxnum = 0;
	int ans = 0;
	bool flag = false;
	cin >> s;
	for (int i = 0; i < s.length();i++) {
		if(s[i] == 'x'){
			if (flag) {
				x[xnum - 1]++;
			}
			else {
				x.push_back(1);
				xnum++;
				flag = true;
			}
		}
		else {
			if (flag == false) {
				xnum++;
				x.push_back(0);
			}
			else {
				flag = false;
			}
			nxnum++;
			nx.push_back(s[i]);
		}
	}
	if (flag == false) {
		xnum++;
		x.push_back(0);
	}
	for (int i = 0; i < nxnum / 2; i++) {
		if (nx[i] != nx[nxnum - 1 - i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (int i = 0; i < xnum/2;i++) {
		ans += abs(x[i] - x[xnum-1 - i]);
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  int n;
  cin >> n;
  priority_queue<ld>pq;
  for (int i = 0; i < n; i++){
    int x;
    cin >> x;
    pq.push(-x);
  }
  while (pq.size() > 1){
    ld x = -pq.top();
    pq.pop();
    ld y = -pq.top();
    pq.pop();
    pq.push(-((x + y) / 2.0));
  }
  cout << fixed << setprecision(10);
  cout << -pq.top() << '\n';
  return 0;
}


Measured memory_bytes: 256
// 2020-09-26 21:06:09
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
#include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
using namespace atcoder;

// clang-format on
void answer() {
  int n, m;
  cin >> n >> m;
  dsu d(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    d.merge(a, b);
  }
  cout << d.groups().size() - 1 << '\n';
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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


using namespace std;

const int N = 200100;

int a[N];
multiset <int> s;

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

	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		s.insert(a[i]);
	}

	sort(a, a+n);

	int ans = 0;
	for (int i = n-1; i >= 0; --i) {
		if(s.find(a[i]) != s.end()) {
			s.erase(s.find(a[i]));
			int at = a[i];
			int nxt = (1 << (32 - __builtin_clz(at))) - at;
			if(s.find(nxt) != s.end()) {
				s.erase(s.find(nxt));
				ans++;
			}
		}
	}
	printf("%d\n", ans);

}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N, M; cin >> N >> M;
    vector<ll> X(N), Y(M);
    rep(i,N) cin >> X.at(i);
    rep(i,M) cin >> Y.at(i);
    ll XA = 0, YA = 0;
    ll MOD = (ll)pow(10,9) + 7;
    for (ll i = 0; i < N; i++) XA += (i * X[i] - (N - 1 - i) * X[i]), XA %= MOD;
    for (ll i = 0; i < M; i++) YA += (i * Y[i] - (M - 1 - i) * Y[i]), YA %= MOD;
    cout << XA * YA % MOD << endl;
}


Measured memory_bytes: 1792
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
#include<numeric>
#include<chrono>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
#define mkp(a,b) make_pair(a,b)
using namespace std;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
inline int mex(unordered_set<int> st)
{
	int m = 0;
	while (st.find(m) != st.end())
	{
		m += 1;
	}
	return m;
}
inline int calculateGrundy(int n)
{
	if (n == 1)
		return 0;
	unordered_set<int> mexi;
	for (int i = 1; i <= sqrt(n); i += 1)
	{
		if (n % i == 0)
		{
			if (n / i != n)
				mexi.insert(calculateGrundy(n / i));
			mexi.insert(calculateGrundy(i));
		}
	}
	return mex(mexi);
}
inline ll gcd(ll a, ll b)
{
	// This is code taken from geeksforgeek
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
/*ll power(ll x, ll y)
{
	// This is code taken from geeksforgeek
	ll res = 1;

	x = x % N;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % N;
		y = y >> 1;
		x = (x * x) % N;
	}
	return res;
}*/
ll power(ll x, ll y, ll p)
{
	ll res = 1;

	x = x % p;

	while (y > 0)
	{

		if (y & 1)
			res = (res * x) % p;

		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}


ll modInverse(ll n, ll p)
{
	return power(n, p - 2, p);
}

ll nCrModPFermat(ll n, ll r, ll p)
{
	if (r == 0)
		return 1;

	vector<ll> fac(n + 1, 0);
	fac[0] = 1;
	for (ll i = 1; i <= n; i++)
		fac[i] = fac[i - 1] * i % p;

	return (fac[n] * modInverse(fac[r], p) % p *
		modInverse(fac[n - r], p) % p) % p;
}

bool check(ll a)
{
	ll count = 0;
	while (a % 2 == 0)
	{
		a /= 2;
		count += 1;
	}
	if (count > 1)
		return false;
	bool flag = true;
	for (ll i = 3; i <= sqrt(a); i += 2)
	{
		if (a % i == 0)
		{
			flag = false;
			break;
		}
	}
	return flag;
}
ll sum(ll n)
{
	return (n * (n + 1)) / 2;
}
ll sum_digit(ll n)
{
	ll ans=0;
	while(n)
	{
		ans+=n%10;
		n/=10;
	}
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin>>n;
	if(n%1000==0)
	{
		cout<<0;
		return 0;
	}
	ll temp=n/1000;
	temp+=1;
	temp*=1000;
	cout<<temp-n;
	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

int main() {
    int N, X;
    std::cin >> N >> X;

    std::vector<int> M(N);
    for (int& m : M) {
        std::cin >> m;
    }

    int all_donuts = std::accumulate(M.begin(), M.end(), 0);
    int min_donut = *std::min_element(M.begin(), M.end());
    std::cout << N + (X - all_donuts) / min_donut << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    if(n%2==1){
        ll s=0;
        rep(i,n)s+=a[i];
        if(s%2)cout<<"First"<<endl;
        else cout<<"Second"<<endl;
    }
    else {
        int mi = inf;
        rep(i,n)mi=min(a[i],mi);
        if(mi%2)cout<<"First"<<endl;
        else {
            ll s = 0;
            rep(i,n)s+=a[i];
            if(s%2)cout<<"First"<<endl;
            else cout<<"Second"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3624
#include <cstdio>

int main(){
	while(1){
		int m, f, r;
		scanf(" %d %d %d", &m, &f, &r);
		if(m==-1 && f==-1 && r==-1) break;
	
		if(m==-1 || f==-1 || m+f<30) printf("F\n");
		else if(m+f>=80) printf("A\n");
		else if(m+f>=65) printf("B\n");
		else if(m+f>=50 || (m+f>=30 && r>=50) ) printf("C\n");
		else printf("D\n");
	}

	return 0;
}

Measured memory_bytes: 1012
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,n,k) for(int i=n;i<k;i++)
#define P make_pair
#define F first
#define S second
#define M LLONG_MAX
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s1,s2;
    vector<int> v;
    cin>>n;
    int a[n];
    rep(i,0,n) cin>>a[i];
    map<int,int> nap;
    rep(i,0,n){
        if(nap.find(i+1-a[i])==nap.end())
        nap[i+1-a[i]]=1;
        else
        nap[i+1-a[i]]++;
    }
    rep(i,0,n){
        if(nap.find(i+1+a[i])==nap.end())
        continue;
        else
        ans+=nap[i+1+a[i]];
    }
    cout<<ans<<endl;
    
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    string s, t;
    cin >> s >> t;
    string ans = "";
    rep(i, s.size())
    {
        if (s == t)
        {
            ans = "Yes";
            break;
        }
        char mem = s.back();
        string bil = mem + s;
        bil.pop_back();
        s.swap(bil);
    }
    if (ans != "Yes")
        ans = "No";
    c(ans);
    return 0;
}

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

int main(){
    ll n; cin >> n;
    vector<ll> a(n),b(n),c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    vector<ll> left(n),right(n);
    rep(i,n){
        ll idx_lower = distance(a.begin(), lower_bound(a.begin(),a.end(),b[i]));
        left[i] = idx_lower;
    }
    rep(i,n){
        ll idx_upper = distance(c.begin(), upper_bound(c.begin(),c.end(),b[i]));
        right[i] = n-idx_upper;
    }
    ll ans = 0;
    rep(i,n) ans += left[i]*right[i];
    cout << ans << endl;
}

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

using namespace std;

int main()
{
    int  mx = 0, x = 0, n;
    cin>>n;
    string s;
    cin>>s;
    for(int i = 0; i<n; i++)
    {
        if(s[i]=='I')
            x++;
        else
            x--;
        if(mx<x)
            mx = x;
    }
    cout<<mx<<endl;
}


Measured memory_bytes: 384
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		int n = Integer.parseInt(st.nextToken());
 		int m = Integer.parseInt(st.nextToken());
 		StringTokenizer st1 = new StringTokenizer(bf.readLine());
 		int[] array = new int[n];
 		
 		array[0] = Integer.parseInt(st1.nextToken());
 		long currlcm = array[0]/2;
 		int ans = 0;
 		int temp = v2(array[0]/2);
 		for(int i = 1;i<n;i++){
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		array[i] = Integer.parseInt(st1.nextToken());
	 		if (v2(array[i]/2) != temp){
	 			out.println(0);
	 			out.close();
	 		}
	 		currlcm = currlcm*(array[i]/2)/gcd(currlcm, array[i]/2);
	 		if (currlcm > m){
	 			out.println(0);
	 			out.close();
	 		}
 		}
 		
 		
 		
 		out.println((m/currlcm+1)/2);
	 		
 		out.close();
 		
 		
 		
 	}
	public static long gcd(long a, long b){ 
	      if (b == 0) 
	        return a; 
	      return gcd(b, a % b);  
	    }
	public static int v2(int n){
		int count = 0;
		int temp = n+0;
		while(temp%2 == 0){
			temp/=2;
			count++;
		}
		return count;
	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 47720
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadLong();
            var ans = long.MaxValue;
            for (int i = 1; i <= Math.Sqrt(N); i++)
            {
                if (N % i == 0)
                {
                    if ((i + N / i - 2) < ans) ans = i + N / i - 2;
                }
            }
            
            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13140
S = input()

S1 = set(S[::2])
S2 = set(S[1::2])

if len(S1-set(["R","U","D"])) > 0:
    print("No")
    exit()
if len(S2-set(["L","U","D"])) > 0:
    print("No")
    exit()
print("Yes")



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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

int gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  char alp;
  cin >> alp;
  for (char i='a'; i<='z';i++){
    if (alp == i){
      cout << 'a' << endl;
      return 0;
    }
  }
  cout << 'A' << endl;
  return 0;
}

Measured memory_bytes: 3660
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())

####
from collections import Counter
def solve(N, A):
    # A[i] + A[i + d] = d
    # B[i] + i + B[i + d] + i + d = d
    # B[i + d] = -2i - B[i]
    # 2 3 3 1 3 1
    # 0 1 2 3 4 5
    # 2 2 1 -2 -1 -4
    B = [x-i for i,x in enumerate(A)]
    count = Counter()
    ans = 0
    for i in xrange(N - 1, -1, -1):
        ans += count[-B[i] - 2*i]
        count[B[i]] += 1
    return ans
    


    
print solve(rri(), rrm())


Measured memory_bytes: 116040
N=int(input())
B=list(map(int,input().split()))

A=[0]*N

A[0]=B[0]
A[1]=B[0]

for i in range(1,N-1):
    A[i+1]=B[i]
    if A[i] > B[i]:
        A[i] = B[i]
print(sum(A)) 

Measured memory_bytes: 9232
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        Set<Integer> sets = new HashSet<>();
        int X = sc.nextInt();
        int N = sc.nextInt();
        for(int i=0;i<N;i++){
            sets.add(sc.nextInt());
        }
        for(int i=0;i<2*N+20;i++){
            if(!sets.contains(X-i)){
                System.out.println(X-i);
                return;
            }
            if(!sets.contains(X+i)){
                System.out.println(X+i);
                return;
            }
        }
        System.out.println(0);
    }


}


Measured memory_bytes: 36136
package main

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

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	sum := 0
	for i := 1; i <= n-1; i++ {
		sum += i
	}
	fmt.Println(sum)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    vector<int> b = a;
    sort(b.rbegin(), b.rend());
    rep(i, 0, n){
        if(a[i] == b[0]){
            cout << b[1] << endl;
        }else{
            cout << b[0] << endl;
        }
    }
}

Measured memory_bytes: 4736
///////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF32		INT32_MAX
#define	INF64		INT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// main function
int main()
{
	ll A = 0;
	ll B = 0;

	cin >> A >> B;

	if (B % A == 0) {
		cout << A + B << endl;
	}
	else {
		cout << B - A << endl;
	}

	return 0;
}


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

int main(){
    int K;
    string S;
    cin >> K >> S;

    if(S.size() <= K){
        cout << S << endl;
    }
    else{
        for(int i = 0; i < K; i++){
            cout << S.at(i);
        }
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3616
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int):
    n = N
    ans = ""
    
    while n>0:
        mod = (n-1) % 26
        ans = chr(97+mod) + ans
        n = (n-mod)//26

    print(ans)
    return


# Generated by 1.1.7.1 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()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27148
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim().split(' ').map(Number);
    console.log(inputs.sort(function(a,b) {
    	return a-b;
    }).join(' '));    
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

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

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N + 1), B(N);
    rep(i, N + 1) cin >> A[i];
    rep(i, N) cin >> B[i];
    ll ans = 0;
    rep(i, N)
    {
        if (A[i] < B[i])
        {
            ans += A[i] + min(A[i + 1], (B[i] - A[i]));
            A[i + 1] = max(0LL, A[i + 1] - (B[i] - A[i]));
        }
        else
        {
            ans += B[i];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
def main():
    hoge = input().split()
    huga = list(map(int, input().split()))
    poyo = input()
    if hoge[0] == poyo:
        huga[0] = huga[0] -1
    else:
        huga[1] = huga[1] -1
    print(huga[0],huga[1])

if __name__ == '__main__':
    main()

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

int main(){
	int yama[10], i, p, Flag = 0, t;
	for(i = 0; i < 10; i++)
		cin >> yama[i];
	while(1){
		Flag = 0;
		for(i = 0; i < 10; i++){
			if(i + 1 != 10){
				if(yama[i] < yama[i + 1]){
					t = yama[i];
					yama[i] = yama[i + 1];
					yama[i + 1] = t;
					Flag++;
				}
			}
		}
		if(Flag == 0)
			break;
	}
	cout << yama[0] << "\n";
	cout << yama[1] << "\n";
	cout << yama[2] << "\n";
	return 0;
} 

Measured memory_bytes: 1164
#include<stdio.h>
int main(void)
{
  int i,j,H,W,count=0;
  while(1)
  {
    scanf("%d %d",&H,&W);
    if(H==0&&W==0)
      break;

    for(i=0;i<H;i++)
    {
      for(j=0;j<W;j++)
        printf("#");
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}



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

char tolower(char ch){
  if( 'A' <= ch && ch <= 'Z' ){
    return ch-'A'+'a';
  }else{
    return ch;
  }
}

int main(){
  int count=0;
  string W;
  cin>>W;
  string str;
  while(1){
    cin>>str;
    if(str=="END_OF_TEXT")break;
    for(int i=0;i<(int)str.size();i++){
      str[i]=tolower(str[i]);
    }
    if(str==W){
      count++;
    }
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 3156
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn string() -> String {
    read()
}

fn int() -> i64 {
    read()
}

fn char() -> char {
    read::<String>().pop().unwrap()
}

fn vecchar() -> Vec<char> {
    string().chars().collect()
}

fn vecint(n: i64) -> Vec<i64> {
    let mut vec = Vec::new();
    for i in 0..n {
        vec.push(int())
    }
    vec
}

fn main() {
    let (a, b, c) = (int(), int(), int());
    println!(
        "{}",
        match (a, b, c) {
            (5, 5, 7) => "YES",
            (5, 7, 5) => "YES",
            (7, 5, 5) => "YES",
            _ => "NO",
        }
    )
}


Measured memory_bytes: 4352
#include <cstring>
#include <cstdint>
#include <iostream>
#include <string>
#include <memory>
#include <queue>
#include <limits>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <sstream>
#include <random>
#include <functional>
#include<algorithm>
#include <array>
#include<random>
using namespace std;

int main() {
	long long N;
	cin >> N;
	bool allnine = true;
	if (N >= 10) {
		long long len = 0;
		while (N >= 10)
		{
			len++;
			if (N % 10 != 9)allnine = false;
			N /= 10;
		}
		if(allnine)cout << len * 9 + N;
		else cout << len * 9 + N - 1;
	}
	else {
		cout << N;
	}

	return 0;
}

Measured memory_bytes: 256
# 連続するK本のろうそくに火をつけるので、最小となる組を全探索する
N, K = map(int, input().split())
X = list(map(int, input().split()))

ans = float("INF")
for i in range(N - K + 1):
    lr = abs(X[i]) + abs(X[i] - X[i + K - 1])
    rl = abs(X[i + K - 1]) + abs(X[i + K - 1] - X[i])
    ans = min(ans, min([lr, rl]))

print(ans)

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, X; cin >> N >> X;
  vector<LL> xs(N);
  REP(i,N) cin >> xs[i];
  auto ys = xs;
  LL ans = 1e18;
  REP(d,N){
	LL s = 0;
	REP(i,N){
	  xs[i] = min(xs[i], ys[(i-d+N)%N]);
	  s += xs[i];
	}
	ans = min(ans, s+X*d);
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
 string s,h;
  cin>>s>>h;
  cout<<h<<s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 300005
#define ll long long
using namespace std;
int a[maxn];
int nx[30];
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	for(int i = 0; i < 30; i++)
		nx[i] = n + 1;
	ll ans = 0;		
	int mxs = n + 1;
	for(int i = n; i >= 1; i--)
	{
		for(int j = 0; j < 30; j++)	
			if(a[i] & (1 << j)) mxs = min(mxs, nx[j]);
		ans += mxs - i;
	//	cout<<i<<" "<<mxs<<endl;
		for(int j = 0; j < 30; j++)
			if(a[i] & (1 << j)) nx[j] = i;
	}
	printf("%lld\n", ans);
	return 0;
 } 

Measured memory_bytes: 1024
# 2019/07/12
# DFS ver

import sys

sys.setrecursionlimit(10**9)
input=sys.stdin.readline

n=int(input())
edge=[[] for _ in range(n)]
for _ in range(n-1):
    u,v,c=map(int,input().split())
    u-=1 ; v-=1
    edge[u].append((c,v))
    edge[v].append((c,u))

q,k=map(int,input().split())
k-=1

d=[0]*n
visited=[False]*n

def dfs(s,p):
    visited[s]=True
    for c,v in edge[s]:
        if visited[v] or p==v:continue
        d[v]=c+d[s]
        visited[v]=True
        dfs(v,s)
    return 


dfs(k,-1)
for _ in range(q):
    x,y=map(int,input().split())
    x-=1 ; y-=1
    print(d[x]+d[y])



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

int main(void){
    int A,B;
    cin>>A>>B;
    if(A%3==0 || B%3==0 || (A+B)%3==0)
        cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
    return 0;
}


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

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

  vector<int> a(N);
  for (int i=0; i<N; i++) cin >> a[i];
  int max = a[0];
  int min = a[0];
  for (int i=1; i<N; i++) {
    if (a[i] > max) max = a[i];
    if (a[i] < min) min = a[i];
  }

  cout << max - min << endl;
}

Measured memory_bytes: 256
def count(i):
    cnt = 0
    switch = 1
    while switch:
        if i % 2 == 1:
            return cnt
        else:
            cnt += 1
            i = i / 2

n = int(input())
correct_num = 1
split_cnt = 0
for i in range(n):
    m = count(i + 1)
    if m >= split_cnt:
        correct_num = i + 1
        split_cnt = m
print(correct_num)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
	int N;
	while (cin >> N, N) {
		int t[201];
		int ba=0;
		int card;
		for (int i = 0; i < 201; i++)
			t[i] = 0;
		for (int i = 0; i < N; i++) {
			cin >> card;
			t[card] = 1;
		}
		int H = N;
		int T = N;
		int turn=0;
		while (T&&H) {
			int OK=0;
			for (int i = ba+1; i <= 2 * N; i++) {
				if (t[i] == 1 && turn == 0) {
					ba = i; T--; t[i] = -1;  OK = 1; break;
				}
				else if (t[i] == 0 && turn == 1) {
					ba = i; H--; t[i] = -1; OK = 1;break;
				}
			}
			if (OK == 0) ba = 0;
			if (turn == 0) turn = 1;
			else turn = 0;
		}
		cout << H << endl << T << endl;
	}
	return 0;
}


Measured memory_bytes: 2984
from math import gcd
from collections import Counter

mod = 10 ** 9 + 7

N, *AB = map(int, open(0).read().split())

def std(a, b):
    if a == 0:
        return (0, int(b != 0))

    g = gcd(a, b)
    a, b = a // g, b // g
    return (a, b) if a > 0 else (-a, -b)

C = Counter()
for a, b in zip(*[iter(AB)] * 2):
    C[std(a, b)] += 1

ans = 1
cnt = 0
for (a, b), v in C.items():
    if b > 0:
        if (b, -a) in C:
            ans *= -1 + pow(2, v, mod) + pow(2, C[(b, -a)], mod)
            ans %= mod
        else:
            cnt += v
    elif (-b, a) not in C:
        cnt += v

ans *= pow(2, cnt, mod)
ans += C[(0, 0)] - 1

print(ans % mod)

Measured memory_bytes: 73048
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        n: usize,
        a: [u64; n]
    }

    let mut sum = 0;
    let mut right = 0;
    let mut ret = 0;
    for left in 0..n {
        while right < n && a[right] ^ sum == a[right] + sum {
            sum += a[right];
            right += 1;
        }
        
        ret += right - left;
        
        if right == left {right+=1;}
        else {sum -= a[left];}
    }

    println!("{}", ret);
}

Measured memory_bytes: 6396
import math

n = int(input())
a = list(map(int,input().split()))

med = 0
for i in a:
    med += i
    
p = math.ceil(med/n)
q = math.floor(med/n)

ans1 = 0
ans2 = 0

for i in a:
    ans1 += (p-i)**2
    ans2 += (q-i)**2
    
print(min(ans1,ans2))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  int i,j;
  for(i=0;i<N;i++)cin >> A[i];
  for(i=0;i<N;i++)B[i] = i-A[i];
  sort(B.begin(),B.end());
  long long ans = 0;
  for(i=0;i<N-1;i++) {
    int ll=0,lr=N,m;
    while(lr-ll>1) {
      m = (ll+lr)/2;
      if(B[m] < A[i]+i)ll = m;
      else lr = m;
    }
    int rl=0,rr=N;
    while(rr-rl>1) {
      m = (rl+rr)/2;
      if(B[m] <= A[i]+i)rl = m;
      else rr = m;
    }
    ans += rl-ll;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4840
p = [1] * (110000 + 1)
p[0], p[1] = 0, 0
for i in range(2, int(110000 ** 0.5) + 1):
    if not p[i]:
        continue
    for j in range(2 * i, 110000 + 1, i):
        p[j] = 0

p_num = [i for i in range(110000) if p[i] == 1]

while 1:
    n = int(input())
    if n == 0:
        break
    print(sum(p_num[:n]))



Measured memory_bytes: 6912
// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


use std::io;

fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }

    let log2c: Vec<usize> = a.iter().map(|x| {
        let mut c = 0;
        let mut p = *x;
        while p % 2 == 0 {
            p /= 2;
            c += 1;
            if c == 2 { break; }
        }
        c
    }).collect();

    let zero = log2c.iter().filter(|x| **x == 0).count();
    let one = log2c.iter().filter(|x| **x == 1).count();
    let two = log2c.iter().filter(|x| **x == 2).count();

    let mut ans = true;
    if one == 0 { ans = zero <= two + 1}
    else {
        ans = zero <= two;
    }

    println!("{}", if ans { "Yes" } else { "No" } );
}


Measured memory_bytes: 6396
N, M = map(int,input().split())
ships_1 = []
ships_2 = []
for m in range(M):
    tmp = list(map(int,input().split()))
    if tmp[0]==1:
        ships_1.append(tmp[1])
    elif tmp[1] == N:
        ships_2.append(tmp[0])

matched_list = list(set(ships_1) & set(ships_2))
if matched_list:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(2*m + 10);
	for (int i = 1; i <= 2 * m; i++) {
		int z;
		cin >> z;
		a[z]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << a[i] << endl;
	}
	return 0;
}


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

int main() 
{
	string s;
	cin >> s;

	int n = s.size();
	int ans = 999;

	for (int i= 0; i <= n-3; i++) {
		int num = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + s[i + 2] - '0';
		ans = min(ans, abs(num - 753));

	}
	cout << ans << endl;



}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  long long int count = 0;
  int N=0;
  int i;
  scanf("%d\n",&N);
  int A[N];
  int B[N];
  for(i=0;i<N;i++){
    scanf("%d %d\n",&A[i],&B[i]);
  }
  int d=0;
  for(i = N-1;i>=0;i--){
    if((A[i]+count)%B[i]==0) continue;
    d = B[i] - ((A[i]+count)%B[i]);
    count += d;
  }
  printf("%lld\n",count);
  return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
int main()
{
    int add = 0;
    char s[5];
    scanf("%s",s);
  	for(int i = 0; i < 3; i ++){ add += s[i] == 'x' ? 0 : 1; }
    
    printf("%d\n",700 + add * 100);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;
int main( void )
{
  ios::sync_with_stdio(false);
  ll d[3];
  cin >> d[0] >> d[1] >> d[2];
  if( d[0] % 2 == 0 || d[1] % 2 == 0 || d[2] % 2 == 0 ){
    cout << 0 << endl;
    return 0;
  }
  sort( d, d+3 );
  cout << d[0] * d[1] << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String string = scan.nextLine();
        String strings = string + string;
        String keywords = scan.nextLine();

        System.out.println(strings.matches(".*" + keywords + ".*")? "Yes" : "No");
    }
}

Measured memory_bytes: 26188