akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    vector<int> rsum(N+1, 0), wsum(N+1, 0);
    for (int i = 1; i <= N; i++) {
        rsum[i] = rsum[i-1];
        wsum[i] = wsum[i-1];
        if (S[i-1] == 'R') rsum[i]++;
        else wsum[i]++;
    }
    
    int ans = N;
    for (int i = 0; i <= N; i++) {
        int wtor = i-rsum[i];
        int rtow = N-i-(wsum[N]-wsum[i]);
        ans = min(ans, max(rtow, wtor));
    }
    cout << ans << endl;
    return 0;
    
}


Measured memory_bytes: 5240
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "YES" : "NO") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

//vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

int main()
{
    int A,B;
    cin >> A >> B;
    if(A==B)
    {
        cout << "Draw" << endl;
    }
    else if(A == 1 || (A > B && B != 1))
    {
        cout << "Alice";
    }else
    {
        cout << "Bob";
    }
}

Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    double i,j,a,b;
    cin>>a>>b;
    cout.setf(ios::fixed);
    cout.precision(7);
    cout<<a/b<<endl;

    return 0;
}





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

int main(){
  int N,M,j=0;
  cin>>N>>M;
  vector<int> A(N);
  for(int &i:A){
    cin>>i;
    j+=i;
  }
  sort(A.begin(),A.end());
  if(A[N-M]*4*M<j)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 3616
//#define DEB1 //output check function
//#define DEB2 //same output, input from input.txt

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VVI = vector<VI>;


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


#ifdef DEB1
#define DPRINT(x) cout<< #x << "=" << (x) << endl; // print at debug mode
#else
#define DPRINT(x) ;
#endif
#ifdef DEB1
#define DCHECK(x) cout<< "debug check" << #x << endl;
#else
#define DCHECK(x) ;
#endif
 


/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const LL INF= 1LL<<60 ;//INF = 1001001001001; //1e9

// Main program
void solve(){
    string S;
    cin >> S;
    int size = S.size();
    DPRINT(size)
    if(size==19){
        cout << "0 0 1000000000 0 0 1000000000 " << endl;
        return;
    }
    if(size < 10){
        cout << "0 0 1 0 0 "+S << endl;
        return;
    }
    else{
        string left,right;

        right = S.substr(size-9,9);
        left = S.substr(0,size-9);
        DPRINT(left)
        LL iright = stoi(right);
        LL ileft = stoi(left);
        LL b1 = 1000000000 - iright;
        LL b2 = ileft + 1;
        cout << "0 0 1000000000 1 "<< b1 << " " << b2<< endl;
        //LL check;
        //check = 1000000000 - b1;
        //DPRINT(check)
    }

}



// ----------------------------------------------
int main() {

#ifdef DEB2
    cout << "DEBUG MODE"  << endl;
	ifstream in("input.txt"); //for debug
	cin.rdbuf(in.rdbuf()); //for debug
#endif

	int T=1; 

	for (int i = 0; i < T; ++i) {
		solve();
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
int a[20],b[20],ten[9];
int d;
int i,j,k,l,t,n,m,tot,top;
ll num,sum,wdc,pp,ans;
bool czy;
int main(){
    ten[0]=1;
    fo(i,1,8) ten[i]=ten[i-1]*10;
    scanf("%d",&d);
    pp=1;
    if (d%10==0){
        czy=1;
        while (d%10==0){
            d/=10;
            pp*=10;
        }
        pp=pp/10*9;
    }
    fo(l,1,7)
    fo(i,0,ten[l]-1){
        t=0;
        k=i;
        top=0;
        fo(j,1,l){
            a[++top]=k%10;
            k/=10;
        }
        k=i+d;
        tot=0;
        fo(j,1,top){
            b[++tot]=k%10;
            k/=10;
        }
        if (!czy&&b[1]==0) continue;
        reverse(b+1,b+tot+1);
        fo(j,1,tot) a[++top]=b[j];
        num=0;
        wdc=1;
        fo(j,1,top){
            num+=(ll)a[j]*wdc;
            wdc*=10;
        }
        sum=0;
        wdc=1;
        reverse(a+1,a+top+1);
        fo(j,1,top){
            sum+=(ll)a[j]*wdc;
            wdc*=10;
        }
        if (num+(ll)d==sum){
            ans++;
        }
        //continue;
        reverse(a+1,a+top+1);
        top-=tot;
        a[++top]=0;
        fo(j,1,tot) a[++top]=b[j];
        num=0;
        wdc=1;
        fo(j,1,top){
            num+=(ll)a[j]*wdc;
            wdc*=10;
        }
        sum=0;
        wdc=1;
        reverse(a+1,a+top+1);
        fo(j,1,top){
            sum+=(ll)a[j]*wdc;
            wdc*=10;
        }
        if (num+(ll)d==sum){
            ans+=10;
        }
    }
    ans*=pp;
    printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <string>

using namespace std;

typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
   int N,tmp;
   cin>>N;
   vector<string> s;
   string tmpstr;

    for (int i = 0; i < N; i++)
    {
        cin >> tmpstr;
        s.push_back(tmpstr);
    }
    

    sort(s.begin(),s.end());
s.push_back("");

    int maxn = 1;
    for (int i = 0; i < N; i++)
    {
        int tmp1 = 0;
        while(s[i]==s[i+tmp1]){
            tmp1++;
        }
        maxn = max(tmp1,maxn);
        i+=tmp1-1;
    }
    for (int i = 0; i < N; i++)
    {
        int tmp1 = 1;
        while(s[i]==s[i+tmp1]){
            tmp1++;
        }
        if(tmp1==maxn){
            cout<<s[i]<<endl;
        }
        i+=tmp1-1;
    }

    
    return 0;
}

Measured memory_bytes: 14832
icase=0
if icase==0:
    n=int(input())
    s=list(input())
    icmax=0
    for i in range(n):
        si=set(s[0:i])
        ti=set(s[i:n])
        icnt=len(si&ti) 
        icmax=max(icmax,icnt)
    print(icmax)

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

int main(){
   int A,B,C,K;
   cin >> A>>B>>C>>K;

   if(K<A){
       cout << 1*K<<endl;
   }

   else if(K>A+B){
       cout << 1*A-1*(K-A-B)<<endl;
   }

    else{
        cout << A*1 <<endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int X[202020],Y[202020];
string U[202020];

vector<pair<int,int>> LR[402020],UD[402020],RU[402020],LD[402020],LU[402020],RD[402020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	int ret=1<<30;
	cin>>N;
	FOR(i,N) {
		cin>>X[i]>>Y[i]>>U[i];
		
		if(U[i]=="L" || U[i]=="R") LR[Y[i]].push_back({X[i],i});
		if(U[i]=="U" || U[i]=="D") UD[X[i]].push_back({Y[i],i});
		if(U[i]=="L" || U[i]=="D") LD[X[i]+Y[i]].push_back({Y[i],i});
		if(U[i]=="R" || U[i]=="U") RU[X[i]+Y[i]].push_back({Y[i],i});
		if(U[i]=="L" || U[i]=="U") LU[Y[i]-X[i]+200000].push_back({X[i],i});
		if(U[i]=="R" || U[i]=="D") RD[Y[i]-X[i]+200000].push_back({X[i],i});
		
	}
	
	FOR(i,400001) {
		sort(ALL(LR[i]));
		sort(ALL(UD[i]));
		sort(ALL(LD[i]));
		sort(ALL(RU[i]));
		sort(ALL(LU[i]));
		sort(ALL(RD[i]));
		FOR(j,(int)LR[i].size()-1) if(U[LR[i][j].second]=="R"&&U[LR[i][j+1].second]=="L") ret=min(ret,(LR[i][j+1].first-LR[i][j].first)*5);
		FOR(j,(int)UD[i].size()-1) if(U[UD[i][j].second]=="U"&&U[UD[i][j+1].second]=="D") ret=min(ret,(UD[i][j+1].first-UD[i][j].first)*5);
		FOR(j,(int)LD[i].size()-1) if(U[LD[i][j].second]=="L"&&U[LD[i][j+1].second]=="D") ret=min(ret,(LD[i][j+1].first-LD[i][j].first)*10);
		FOR(j,(int)RU[i].size()-1) if(U[RU[i][j].second]=="U"&&U[RU[i][j+1].second]=="R") ret=min(ret,(RU[i][j+1].first-RU[i][j].first)*10);
		FOR(j,(int)LU[i].size()-1) if(U[LU[i][j].second]=="U"&&U[LU[i][j+1].second]=="L") ret=min(ret,(LU[i][j+1].first-LU[i][j].first)*10);
		FOR(j,(int)RD[i].size()-1) if(U[RD[i][j].second]=="R"&&U[RD[i][j+1].second]=="D") ret=min(ret,(RD[i][j+1].first-RD[i][j].first)*10);
		
	}
	
	
	
	if(ret==1<<30) {
		cout<<"SAFE"<<endl;
	}
	else {
		cout<<ret<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    
  
  	int k[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  	int n;
  	cin>>n;
    
  	cout<<k[n-1];
    
	
	
	
	return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    int N,K;cin>>N>>K;
    vector<vector<int>> W(K+1,vector<int>(K+1,0)),B(K+1,vector<int>(K+1,0));
    for(int i=0;i<N;i++){
        int a,b;cin>>a>>b;
        a=a%(2*K);
        b=b%(2*K);
        char c;cin>>c;
        bool flag=false;
        if((a>=K&&b>=K)||(a<K&&b<K)) flag=true;
        if(flag){
            if(c=='W') W[a%K+1][b%K+1]++;
            else B[a%K+1][b%K+1]++;
        }else{
            if(c=='W') B[a%K+1][b%K+1]++;
            else W[a%K+1][b%K+1]++;
        }
    }
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            W[i][j]=W[i][j]+W[i][j-1];
            B[i][j]=B[i][j]+B[i][j-1];
        }
    }
    for(int j=1;j<=K;j++){
        for(int i=1;i<=K;i++){
            W[i][j]+=W[i-1][j];
            B[i][j]+=B[i-1][j];
        }
    }
    int ans=0;
    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
            int sum=0;
            sum+=W[i][j];
            sum+=(W[K][K]-W[i][K]-W[K][j]+W[i][j]);
            sum+=(B[K][j]-B[i][j]);
            sum+=(B[i][K]-B[i][j]);
            ans=max(ans,sum);
        }
    }
    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
            int sum=0;
            sum+=B[i][j];
            sum+=(B[K][K]-B[i][K]-B[K][j]+B[i][j]);
            sum+=(W[K][j]-W[i][j]);
            sum+=(W[i][K]-W[i][j]);
            ans=max(ans,sum);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

long long dp[100001];
int main(int argc, char const *argv[]){
    int n, k, h[100001];
    cin >> n >> k ;
    for(int i=0;i<n;i++){
        cin >> h[i];
        dp[i]=INF;
    }
    dp[0]=0;
    for(int i=1;i<n;i++){
        for(int j=1;j<=k;j++){
            if((i-j)<0) break;
            chmin(dp[i], dp[i-j]+abs(h[i]- h[i-j]) );
        }
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<int> a(N, 0);
	rep (i, N){
		cin >> a[i];
	} // end rep

	map<int,int> cnt; cnt.clear();
	rep (i, N){
		++cnt[a[i]];
	} // end rep

	int res = 0;
	map<int,int>::iterator it = cnt.begin();
	for (; it != cnt.end(); ++it){
		int n = (*it).first;
		int c = (*it).second;
		if (c % 2 == 1){
			++res;
		} // end if
	} // end for
	
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define ll long long
#define fm_t  ll t;cin>>t;while(t--)
#define fr(i,a,b) for( ll i=a;i<b;i++)
#define fr1(i,n,a) for( ll i=n-1;i>=a;i--)
#define sz(x) (ll)(x).size()
#define all(v)  (v).begin(), (v).end()
#define Sort(x) sort(x.begin(),x.end())
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
const ll mod = 998244353;
#define Mod 1000000007

#define inf 1e18
#define ld long double
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll >
#define pi pair<ll, ll>
#define ppi pair<pair<ll, ll>, ll>
#define ump unordered_map<ll,ll>
#define pri priority_queue< pair<ll,ll> , vector< pair<ll,ll> >, greater< pair<ll,ll> > >
void ingraph(vl graph[], ll m){ll x, y;fr(i,0,m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
const ll MAX = 500009; 
//setprecision(10)
//greater<int>()
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}


ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll modinv(ll a){
    return modpower(a,mod-2);
}  

struct Query 
{ 
  ll l, r, idx; 
}; 


bool cmp(Query x, Query y) 
{ 
  return x.r < y.r; 
} 


void update(ll idx, ll val, ll bit[], ll n) 
{ 
  for (; idx <= n; idx += idx&-idx) 
    bit[idx] += val; 
} 

 
ll query(ll idx, ll bit[], ll n) 
{ 
  ll sum = 0; 
  for (; idx>0; idx-=idx&-idx) 
    sum += bit[idx]; 
  return sum; 
} 


vl solve(ll arr[], ll n, Query queries[], ll q) 
{ 
  
  ll bit[n+1]; 
  memset(bit, 0, sizeof(bit)); 

  
  ll last_visit[MAX]; 
  memset(last_visit, -1, sizeof(last_visit)); 

  
 vl ans(q);
  ll query_counter = 0; 
  for (ll i=0; i<n; i++) 
  { 
    
    if (last_visit[arr[i]] !=-1) 
      update (last_visit[arr[i]] + 1, -1, bit, n); 

    
    last_visit[arr[i]] = i; 
    update(i + 1, 1, bit, n); 

    
    while (query_counter < q && queries[query_counter].r == i) 
    { 
      ans[queries[query_counter].idx] = 
          query(queries[query_counter].r + 1, bit, n)- 
          query(queries[query_counter].l, bit, n); 
      query_counter++; 
    } 
  } 

  
  return ans; 
} 
     
int main()
{
      
  fast;
  ll n,q;
  cin>>n>>q;
  ll a[n];
  fr(i,0,n)
  cin>>a[i];

  Query ql[q];

  fr(i,0,q)
  {
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    ql[i].l=a;
    ql[i].r=b;
    ql[i].idx=i;
  }

  sort(ql,ql+q,cmp);

  vector<ll> vec=solve(a,n,ql,q);

  fr(i,0,q)
  cout<<vec[i]<<endl;
//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
return 0;
}

Measured memory_bytes: 31088
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

#define U1 unsigned char
#define S1 char
#define	S4 int
#define DU double

#define MAX_CITY_WIDTH          (100000)
#define MAX_CITY_HIGHT          (100000)

#define NOT_REACH               (0)

/* いもす法で使う */
#define ENTER                   (1)
#define EXIT                    (-1)

S4 main()
{
	//S4 s4_t_scanfRtn;
	U1 u1_t_delimiter;
	S4 s4_t_loopIndex;
	S4 s4_t_ix;
	S4 s4_t_iy;
	
	S4 s4_t_numBaseStation;
	S4 s4_t_cityWidth;
	S4 s4_t_cityHight;
	S4 s4_t_x;
	S4 s4_t_y;
	S4 s4_t_w;
	S4 s4_tp_isReachX[MAX_CITY_WIDTH + 1];
	S4 s4_tp_isReachY[MAX_CITY_HIGHT + 1];
	S4 s4_t_isReachWifiX;
	S4 s4_t_isReachWifiY;

	/* ある基地局の電波が届く範囲 */
	S4 s4_t_minX;
	S4 s4_t_maxX;
	S4 s4_t_minY;
	S4 s4_t_maxY;

	/* 初期化 */
	for (s4_t_ix = (S4)0; s4_t_ix <= (S4)MAX_CITY_WIDTH; s4_t_ix++)
	{
		s4_tp_isReachX[s4_t_ix] = (U1)NOT_REACH;
	}

	for (s4_t_iy = (S4)0; s4_t_iy <= (S4)MAX_CITY_HIGHT; s4_t_iy++)
	{
		s4_tp_isReachY[s4_t_iy] = (U1)NOT_REACH;
	}

	/* 入力 */
	//s4_t_scanfRtn = scanf("%d,%lf,%lf%c", &s4_t_studentNum, &du_t_weight, &du_t_height, &u1_t_delimiter);
	(void)scanf("%d %d %d%c", &s4_t_numBaseStation, &s4_t_cityWidth, &s4_t_cityHight, &u1_t_delimiter);
	
	/*wifi到達範囲の計算 */
	for (s4_t_loopIndex = (S4)0; s4_t_loopIndex < s4_t_numBaseStation; s4_t_loopIndex++)
	{
		(void)scanf("%d %d %d%c", &s4_t_x, &s4_t_y, &s4_t_w, &u1_t_delimiter);

		/* koto距離の性質上、x方向で届くならy方向の距離にかかわらず到達する。そのため、x方向・y方向独立で到達を判断すれば良い */
		/* x方向 */
		s4_t_minX = s4_t_x - s4_t_w;
		s4_t_maxX = s4_t_x + s4_t_w;
		/* 街の外から届く→いもす法の入口 */
		if (s4_t_minX < (S4)0)
		{
			s4_t_minX = (S4)0;
		}
		s4_tp_isReachX[s4_t_minX] += (S4)ENTER;
		/* 端まで到達→いもす法の出口は無い */
		if (s4_t_maxX > s4_t_cityWidth)
		{
			/* 何もしない */
		}
		else
		{
			s4_tp_isReachX[s4_t_maxX] += (S4)EXIT;
		}

		/* y方向 */
		s4_t_minY = s4_t_y - s4_t_w;
		s4_t_maxY = s4_t_y + s4_t_w;
		/* 街の外から届く→いもす法の入口 */
		if (s4_t_minY < (S4)0)
		{
			s4_t_minY = (S4)0;
		}
		s4_tp_isReachY[s4_t_minY] += (S4)ENTER;
		/* 端まで到達→いもす法の出口は無い */
		if (s4_t_maxY > (S4)s4_t_cityHight)
		{
			/* 何もしない */
		}
		else
		{
			s4_tp_isReachY[s4_t_maxY] += (S4)EXIT;
		}
	}

	/* 全ての地点にwifiが到達したか判定 */
	/* x方向・y方向いずれか全てで到達ならば全地点に到達 */
	s4_t_isReachWifiX = (U1)0;
	s4_t_isReachWifiY = (U1)0;
	for (s4_t_ix = (S4)0; s4_t_ix <= s4_t_cityWidth; s4_t_ix++)
	{
		s4_t_isReachWifiX += s4_tp_isReachX[s4_t_ix];
		/* 途中で入口の数＜出口の数となる→到達範囲が途絶えた */
		if (s4_t_isReachWifiX <= (U1)0)
		{
			break;
		}
	}

	for (s4_t_iy = (S4)0; s4_t_iy <= s4_t_cityHight; s4_t_iy++)
	{
		s4_t_isReachWifiY += s4_tp_isReachY[s4_t_iy];
		/* 途中で入口の数＜出口の数となる→到達範囲が途絶えた */
		if (s4_t_isReachWifiY <= (U1)0)
		{
			break;
		}
	}

	/* 結果を出力 */
	/* 全範囲を網羅している判定 */
	if ((s4_t_ix >= s4_t_cityWidth) ||
		(s4_t_iy >= s4_t_cityHight))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return((S4)0);
}



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

using namespace std;

const int INF = 1000000;

int main(){
    string S;
    cin >> S;
    
    int ans = INF;
    
    string b, w;
    for(int i = 0; i < S.length(); i++){
        if(i % 2 == 0){
            b += '0';
            w += '1';
        }
        else{
            b += '1';
            w += '0';
        }
    }
    
    int cnt = 0;
    for(int i = 0; i < S.length(); i++){
        if(S[i] != b[i]){
            cnt++;
        }
    }
    ans = min(ans, cnt);
    
    cnt = 0;
    for(int i = 0; i < S.length(); i++){
        if(S[i] != w[i]){
            cnt++;
        }
    }
    ans = min(ans, cnt);
    
    cout << ans << endl;
    
    // cout << b << endl << w << endl;
}

Measured memory_bytes: 768
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        BigDecimal[] nums = new BigDecimal[N];
        for (int i = 0; i < N; i++) {
            nums[i] = new BigDecimal(sc.next());
        }
        final BigDecimal limit = new BigDecimal("1000000000000000000");
        Arrays.sort(nums);
        BigDecimal ans = nums[0];
        if (ans.longValue() == 0) {
            System.out.println(0);
        } else {
            boolean over = false;
            for (int i = 1; i < N; i++) {
                ans = ans.multiply(nums[i]);
                if (limit.compareTo(ans) < 0) {
                    System.out.println(-1);
                    over = true;
                    break;
                }
            }
            if (!over) {
                System.out.println(ans);
            }
        }
    }
}

Measured memory_bytes: 66520
#include <stdio.h>

int main(void){

   int i,a;
   int x,y,z,w;
  
    scanf("%d",&a);
   x=a/1000;y=(a-x*1000)/100;z=(a-x*1000-y*100)/10;
   w=(a-x*1000-y*100-z*10);
  if(x==y||y==z||z==w)
    printf("Bad");
  else
    printf("Good");

}

Measured memory_bytes: 128
using System;

public class Hello
{
    public static void Main()
    {
        var x = int.Parse(Console.ReadLine().Trim());
        var res = 0;
        var imax = (int)Math.Sqrt(1000) + 1;
        var jmax =(int)( Math.Log(1000) / Math.Log(2)) + 1;
        for (int i = 1; i <= imax; i++)
            for (int j = 2; j <= jmax; j++)
            {
                var w = (int)Math.Pow(i, j);
                if (w <= x) res = Math.Max(res, w);
                else break;
            }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, m, d;
    cin >> n >> m >> d;
    double ans = 0;
    if (d == 0) {
        ans = (double)(m - 1) / n;
    } else {
        ans = 2.0 * (n - d) * (m - 1) / (n * n);
    }
    cout << fixed << setprecision(10) << ans << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <vector>
#include <fstream>
#include <math.h>
using namespace std;

int main()
{
    long long N;
    cin>>N;
    long long ans=sqrt(1+8*N);
    long long res=0;
    if(ans*ans==1+8*N){
        res=(ans-1)/2;
    }
    else res=(ans-1)/2+1;
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
	static int[] a;
	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());

		a = new int[n];

		string[] input = Console.ReadLine().Split(' ');
		for (int i = 0; i < a.Length; i++)
		{
			a[i] = int.Parse(input[i]);
		}

		BubbleSort();
	}

	static void BubbleSort()
	{
		int count = 0;

		bool flag = true;
		while (flag)
		{
			flag = false;
			for (int i = a.Length-1; i > 0; i--)
			{ 
				if (a[i] < a[i - 1])
				{
					int buf = a[i - 1];
					a[i - 1] = a[i];
					a[i] = buf;
					count ++;
					flag = true;
				}
			}
		}

		string output = "";
		for (int i = 0; i < a.Length; i++)
		{
			output += a[i] + ((i == a.Length-1) ? "" : " ");
		}

		Console.WriteLine(output);
		Console.WriteLine(count);
	}
}



Measured memory_bytes: 17924
#include<iostream>
using namespace std;
int c_digit(long long n) {
  int ret = 0;
  while(n > 0) {
    ret++;
    n /= 10;
  }
  return ret;
}
int main() {
  long long n;
  cin >> n;
  int ret = (1<<29);
  for(long long i=1; i*i <= n;i++){
    if(n%i == 0) {
      int d = max(c_digit(i), c_digit(n/i));
      ret = min(d, ret);
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
// to be build tomorrow
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main ()
{
    ll t = 1;
    while (t--)
    {
        ll x1, x2, x3, x4, x5;
        cin >> x1 >> x2 >> x3 >> x4 >> x5;
        ll p = 0;
        if (!x1)
        p = 1;
        else if (!x2)
        p=2;
        else if (!x3)
        p = 3;
        else if (!x4)
        p = 4;
        else 
        p = 5;
        cout << p;
    }
    return 0;
}


Measured memory_bytes: 3588
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int N, mn=100, mx=0, ans=INF, a;

    cin >> N;

    vector<int> X(N);

    rep(i, N) {
        cin >> X[i];
        mn = min(mn, X[i]);
        mx = max(mx, X[i]);
    }

    for(int i=mn; i<=mx; i++) {
        a = 0;
        rep(j, N) {
            a += pow(X[j]-i, 2);
        }
        ans = min(ans, a);
    }

    cout << ans << endl;

    return 0;
    
}

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

int main()
{

    int l, r, d;
    int cnt = 0;
    cin >> l >> r >> d;
    for (int i = l; i <= r; i++)
    {
        if (!(i % d))
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int a = S / 100;
		int b = S % 100;
		if(0 < a && a <= 12) {
			if(0 < b && b <= 12) {
				System.out.println("AMBIGUOUS");
			} else {
				System.out.println("MMYY");
			}
		} else {
			if(0 < b && b <= 12) {
				System.out.println("YYMM");
			} else {
				System.out.println("NA");
			}
		}

	}

}


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

const int MAXN = 100005;

long long a[MAXN];
int n, k;
long long pre[MAXN], suf[MAXN];

int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++)
		scanf("%lld", &a[i]), pre[i] = max(a[i], 0ll), suf[i] = max(a[i], 0ll);
	for (int i = 1; i <= n; i++) a[i] += a[i-1], pre[i] += pre[i-1];
	for (int i = n; i >= 1; i--) suf[i] += suf[i+1];
	long long ans = 0;
	for (int i = 1; i+k-1 <= n; i++)
		ans = max(ans, pre[i-1]+suf[i+k]+max(a[i+k-1]-a[i-1], 0ll));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
N = int(input())
A = list(map(int, input().split()))
A.sort()
# print (A)
flag = True
if N%2 == 0:
    for i in range(N//2):
        if A[2 * i] == 2 * i+1 and A[2 * i+1] == 2 * i+1:
            pass
        else:
            flag = False
else:
    if A[0] == 0:
        pass
    else:
        flag = False
    for i in range((N)//2):
        # print (i)
        if A[2 * i+1] == 2 * (i+1) and A[2 * i+2] == 2 * (i+1):
            pass
            # print ('A')
        else:
            # print ('B')
            flag = False

if flag:
    print ((2 ** (N//2))%(7 + 10 ** 9))
else:
    print (0)




Measured memory_bytes: 14008
D=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(D):
    s.append(list(map(int,input().split())))

last=[0]*26
ans=0
for d in range(1,D+1):
    mx=-3650000
    mxt=-1

    for j in range(26):
        temp=last[j]
        last[j]=d
        score=0
        for i in range(26):
           score-=c[i]*(d-last[i])
        score+=s[d-1][j]

        if mx<score:
            mx=score
            mxt=j
        last[j]=temp
    last[mxt]=d

    print(mxt+1)





Measured memory_bytes: 9380
#include<iostream>
using namespace std;
#include<stdlib.h>    // use "exit" function.

int main()
{
    int i, n, d, p, q;  // n:how many node.
    cin >> n;
    int *P, *C, *S;  // P:parent, C:children, S:sibling.
    P = new int [n]; C = new int [n]; S = new int [n];
    if(P == NULL || C == NULL || S == NULL) exit(EXIT_FAILURE);

    for(i = 0; i < n; i++){ P[i] = -1; S[i] = -1; }  // initialize for -1.

    while(cin >> i){
        cin >> d;       // d:how many child.
        if(d == 0){     // if nobody ??? -1.
            C[i] = -1;
        }else{
            cin >> p;    // p is the first.
            C[i] = p; P[p] = i;
            while(d > 0){
                if(d == 1){ break; }
                else{ 
                    cin >> q;   // q is sibling of p.
                    S[p] = q; P[q] = i;  // i is parent of q.
                    p = q; d--;
                }
            };
        }
    };

    for(i = 0; i < n; i++){
        cout << "node " << i << ": parent = " << P[i] << ", depth = ";
        p = P[i]; d = 0;
        while(p >= 0){ p = P[p]; d++; };
        cout << d << ", ";
        if(P[i] < 0){
            cout << "root";
        }else if(C[i] < 0){
            cout << "leaf";
        }else{
            cout << "internal node";
        }
        cout << ", [";
        if(C[i] >= 0){
            cout << C[i];
            p = C[i];
            while(S[p] >= 0){ cout << ", " << S[p]; p = S[p]; };
        }
        cout << "]" << endl;
    }
    delete [] P; delete [] C; delete [] S;

    return 0;
}

Measured memory_bytes: 2324
#include <climits>
#include <iostream>
using namespace std;
using int64    = long long;
using PII      = pair<int, int>;
const int MAXN = 100005;
const int INF  = 0x3f3f3f3f;

int64 a[MAXN], cnt[MAXN];

int64 check(int64 n, int64 beg) {
    for(int64 i=beg;i*i<=n;i++) {
        if(n%i==0) return i;
    }
    return -1;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    int64 n;
    cin >> n;
    if(n==1) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    int64 beg = check(n,2);
    if(beg==-1) {
        cout << 1 << endl;
        return 0;
    }
    for(int64 i=beg;i<=n;) {
        int cnt = 0;
        while(n%i==0) {
            cnt++;
            n/=i;
        }
        for(int i=1;cnt>=i;i++) {
            cnt-=i;
            ans++;
        }
        if((beg=check(n,beg+1))==-1) {
            cout << (n==1?ans:ans+1) << endl;
            return 0;
        } else {
            i = beg;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3196
#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, tot = 0;
  cin >> n;
  vector<int> l(n);
  rep(i,n) {
    cin >> l[i];
    tot += l[i];
  }

  sort(l.begin(), l.end());
  if (l[n-1] < tot-l[n-1]) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    set<string> strs;
    for (int i = 0; i < N; ++i)
    {
        string s; cin >> s;
        strs.insert(s);
    }
    cout << strs.size() << endl;
}


Measured memory_bytes: 19180
#include <stdio.h>

int main()
{
    char s[110];
    scanf("%s",s);

    bool ans=true;
    int len;
    for(int i=0;;i++)
    {
        if(s[i]=='\0')
        {
            len=i;
            break;
        }
    }
    for(int i=0;i<len;i+=2)
    {
        if(s[i]!='R'&&s[i]!='U'&&s[i]!='D')
        {
            ans=false;
            break;
        }
    }
    for(int i=1;i<len;i+=2)
    {
        if(ans&&s[i]!='L'&&s[i]!='U'&&s[i]!='D')
        {
            ans=false;
            break;
        }
    }
    if(ans) printf("Yes\n");
    else printf("No\n");
}

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

int main(){
  string S;
 long long N,c,d,p,ans,k;
cin>>S;
  if(S.size()==2){
  cout<<S<<endl;
    return 0;
  }
cout<<S[2]<<S[1]<<S[0]<<endl; 
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main() {
  long double a, b, h, m;
  cin >> a>> b>> h >> m;
  long double teta = (((60*h + m)/720)  - (m/60))*2*M_PI;
  //cout <<teta <<endl;
  long double res =  pow(a*a + b*b - 2*a*b * cos(teta), 0.5);
  cout.precision(40);
  cout <<res<<endl;
  return 0;
  
}


Measured memory_bytes: 4164
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
const int64_t INF = 1e18;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(auto &e : A) cin >> e;
    using P = pair<int64_t, int64_t>;
    vector<vector<P>> dp(N + 1, vector<P>(N + 1));
    auto f = [&](auto &&f, int l, int r) -> P {
        if(dp[l][r] != P(0LL, 0LL)) return dp[l][r];
        if(l + 1 == r) return make_pair(0, A[l]);
        P res = make_pair(INF, INF);
        for(int i = l + 1; i < r; ++i) {
            auto left = f(f, l, i);
            auto right = f(f, i, r);
            auto cost = left.first + right.first;
            auto sz = left.second + right.second;
            if(res.first > cost + sz) {
                res.first = cost + sz;
                res.second = sz;
            }
        }
        return dp[l][r] = res;
    };
    cout << f(f, 0, N).first << '\n';
}


Measured memory_bytes: 5900
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int a[3];

    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);

    cout << a[2]*10 + a[1] + a[0] << endl;
}


Measured memory_bytes: 3608
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<cstdlib>
#include<ctime>
#include<cctype>
#include<set>
#include<map>
#include<vector>

using namespace std;

int a;
int main()
{
	cin >> a;
	for(int i = 1; i <= 3; i++)
	{
		int b = a % 10;
		//cout << b << endl;
		if(b == 7)
		{
			printf("Yes\n");
			return 0;
		}
		a /= 10;
	}	
	printf("No\n");
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main() {
  ll n, X;
  cin >> n >> X;
  lvec x(n);
  REP(i, n) {
    int tmp;
    cin >> tmp;
    x[i] = abs(tmp - X);
  }

  ll ans = 1e10;
  REP(i, n - 1) ans = min(ans, gcd(x[i], x[i + 1]));
  if (n == 1) ans = x[0];
  print(ans);
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  string s;
  cin>>s;
  s[5]=' ';
  s[13]=' ';
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
 
int main(void) {
    string s;
    int n, k;
    cin >> n >> k >> s;
    s[k - 1] = s[k - 1] + 32;
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    vl vec;
    vb flags(m, false);
    ll last;
    while(!flags[x]){
        if(x == 0){
            ll ans = 0;
            rep(i, min(n, (ll)vec.size())){
                ans += vec[i];
            }
            cout << ans << endl;
            return 0;
        }
        if(x == 1){
            ll ans = 0;
            rep(i, (ll)vec.size()){
                ans += vec[i];
            }
            ans += n-vec.size();
            cout << ans << endl;
            return 0;
        }
        vec.push_back(x);
        flags[x] = true;
        x = (x*x)%m;
        last = x;
    }
    vl vec2;
    bool isok = false;
    rep(i, vec.size()){
        if(isok) vec2.push_back(vec[i]);
        else{
            if(vec[i] == last){
                isok = true;
                vec2.push_back(vec[i]);
            }
        }
    }
    ll notIterableLength = vec.size()-vec2.size();
    ll iterableLength = vec2.size();
    if(notIterableLength>=n){
        ll ans = 0;
        rep(i, n){
            ans += vec[i];
        }
        cout << ans << endl;
    }else{
        ll sum = 0;
        rep(i, vec2.size()){
            sum += vec2[i];
        }
        ll ans = 0;
        rep(i, notIterableLength){
            ans += vec[i];
        }
        ll shou = (n-notIterableLength) / vec2.size();
        ans += sum*shou;
        rep(i, (n-notIterableLength)%vec2.size()){
            ans += vec2[i];
        }
        cout << ans << endl;
    }
    

    
    return 0;
}

Measured memory_bytes: 4268
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int th,ts,ah,as;
	cin>>th>>ts>>ah>>as;
	int a,b;
	if(ah%ts==0)
	a=ah/ts;
	else
	a=1+ah/ts;
	if(th%as==0)
	b=th/as;
	else
	b=1+th/as;
	if(a<=b)
	cout<<"Yes";
	else
	cout<<"No";
}

Measured memory_bytes: 3632
from collections import deque
N, M = map(int, input().split())

V = [list(map(int, input().split())) for _ in range(M)]

class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return False
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return True

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

ans = 0
for i in range(M):
        uf = UnionFind(N)
        for j, (a, b) in enumerate(V):
            if i != j:
                uf.union(a-1, b-1)
        if not uf.same(V[i][0]-1, V[i][1]-1):
            ans += 1
print(ans)


Measured memory_bytes: 3316
from collections import deque

S = deque(map(str, input().split()))
Q = int(input())
Left = False

for i in range(Q):
    TFC = input()

    if TFC[0] == "1":
        Left = not Left

    else:
        _, f, c = TFC[0], TFC[2], TFC[4]
        f = int(f)
        if Left ^ (f == 1):
            S.appendleft(c)

        else:
            S.append(c)

T = "".join(S)
if Left:
    T = T[::-1]

print(T)



Measured memory_bytes: 6900
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

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

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val s = br.readLine()!!
    val t = br.readLine()!!
    var min = Int.MAX_VALUE
    for (i in s.dropLast(t.length - 1).indices) {
        var count = 0
        for (j in t.indices) {
            if (s[i + j] != t[j]) count++
        }

        min = kotlin.math.min(min, count)
    }
    out.println(min)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 35908
#include <iostream>
using namespace std;
int main(){
    int w,h,C;
    cin>>w>>h>>C;
    int a=w,b=h,c;
    if(a<b)swap(a, b);
    while (a%b!=0) {
        c=a%b;
        a=b;
        b=c;
    }
    cout<<(w/b)*(h/b)*C<<endl;
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1e9 + 7;
const int Maxn = 3e2 + 10;
const ll Inf = 1e16;

bool is_prime(ll x){
	for(int i = 2; i < x; i++) if(x % i == 0) return false;
	return true;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, a, b;
	cin >> n >> a >> b;
	ll la, x;
	cin >> la;
	ll ans = 0;
	for(int i = 1; i<n; i++){
		cin >> x;
		ans += min(b, (x - la) * a);
		la = x;
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

map<ll,ll> prime_factor(ll n) {
  map<ll,ll> res;
  for(ll i=2;i*i<=n;i++) {
    while(n%i==0) {
      res[i]++;
      n/=i;
    }
  }
  if(n!=1) {
    res[n]++;
  }
  return res;
}

int main() {
  ll n;
	cin >> n;
	map<ll,ll> cnt=prime_factor(n);
	ll ans=0;
	for(auto p:cnt) {
		for(ll i=1;i<=p.second;i++) {
			ans++;
			p.second-=i;
		}
	}
	cout << ans << endl;
}

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

ans = 0
i = 0
while i < N:
    j = i + 1
    t = 0
    while j < N:
        if A[j - 1] == A[j]:
            j += 1
            continue
        elif t == 0 and A[j - 1] != A[j]:
            t = (A[j] - A[j - 1]) / abs(A[j] - A[j - 1])
        elif t != 0 and t != (A[j] - A[j - 1]) / abs(A[j] - A[j - 1]):
            break
        j += 1
    ans += 1
    i = j

print(ans)

Measured memory_bytes: 14428
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define SANKOU(n, a, b) cout << ((n) ? (#a) : (#b)) << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
//#define S set<int>

int N, S[100010], K;
int s[100010], n;
int ans;

void solve()
{
    n = 0;
    if (S[0] == 1) {
        s[0] = 0;
        n++;
    } else {
        s[0] = 0;
        s[1] = 0;
        n += 2;
    }
    FOR(i, 1, N)
    {
        if (S[i] != S[i - 1]) {
            s[n] = i;
            n++;
        }
    }
    if (S[N - 1] == 1) {
        s[n] = N;
        n++;
    } else {
        s[n] = N;
        n++;
    }
    if (K * 2 + 1 >= n && S[0] == 0) {
        ans = N;
        return;
    }
    if (K * 2 + 1 >= n && S[0] == 1) {
        ans = N;
        return;
    }
    for (int i = 0; i + K * 2 + 1 < n; i += 2) {
        ans = max(ans, s[i + K * 2 + 1] - s[i]);
    }
}

signed main()
{
    cin >> N >> K;
    FOR(i, 0, N)
    {
        char c;
        cin >> c;
        S[i] = c - '0';
    }
    solve();
    int T[100010];
    FOR(i, 0, N)
    {
        T[i] = S[i];
    }
    FOR(i, 0, N)
    {
        S[i] = T[N - i - 1];
    }
    solve();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
package main

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

func main(){
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var N int
	fmt.Fscan(r, &N)
	var ans float64
	odd := (N+1)/2
	ans = float64(odd) / float64(N)
	fmt.Println(ans)
}

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

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

int main() {
	int h,w,n;cin>>h>>w>>n;
	
	int b[n];
	rep(i,n)cin>>b[i];
	
	vector<int>c;
	rep(i,n){
	    rep(j,b[i])c.push_back(i+1);
	}

	int a[h][w];
	rep(i,h){
	    rep(j,w){
	        a[i][j]=c[i*w + j];
	    }
	}
	
	int ar[h][w];
	rep(i,h){
	    rep(j,w){
	        if(i%2==0)ar[i][j]=a[i][j];
	        else ar[i][j]=a[i][w-1-j];
	    }
	}
	rep(i,h){
	    rep(j,w-1){
	        cout<<ar[i][j]<<" ";
	    }
	    cout<<ar[i][w-1]<<endl;
	}
	
	return 0;
}

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

using namespace std;

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
long long a[N];

bool read() {
    if (!(cin >> n))
        return false;

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

    return true;
}

void solve() {
    unordered_map<long long, int> cnt;
    unordered_map<long long, long long> E;
    cnt.rehash(4 * n);
    E.rehash(4 * n);

    for (int i = 0; i < n; ++i) {
        auto x = a[i];
        auto res = 1ll;
        auto enm = 1ll;

        for (auto d = 2ll; d * d * d <= x; ++d) {
            auto cnt = 0;
            for (; x % d == 0; x /= d, ++cnt) { }
            cnt %= 3;
            res *= (cnt == 0 ? 1ll : (cnt == 1 ? d : d * d));
            enm *= (cnt == 0 ? 1ll : (cnt == 1 ? d * d : d));
        }

        if (x > 1) {
            auto sq = static_cast<long long>(sqrtl((long double) x));
            for (; sq * sq < x; ++sq) { }
            for (; sq * sq > x; --sq) { }

            if (sq * sq == x) {
                res *= x;
                enm *= sq;
            } else {
                res *= x;
                enm *= x * x;
            }
        }

        ++cnt[res];

        if (!cnt.count(enm))
            cnt[enm] = 0;

        E[res] = enm;
        E[enm] = res;
    }

    int ans = 0;

    for (const auto& p : cnt)
        if (p.first == 1) {
            ans += min(1, p.second);
        } else if (p.first < E[p.first]) {
            ans += max(p.second, cnt[E[p.first]]);
        }

    cout << ans << endl;
}

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

    while (read())
        solve();

    return 0;
}



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

int main(){
    string s;
    cin>>s;
    int l=s.size();
    long long int sum=0;
    for(int i=0;i<(1<<(l-1));i++){
        long long int d=s[0]-'0';
        for(int j=0;j<l-1;j++){
            if(~i&(1<<j)){
                d*=10;
                d+=s[j+1]-'0';
            }else{
                sum+=d;
                d=s[j+1]-'0';
            }
        }
        sum+=d;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys

class Rect():
    def __init__(self,w,h):
        self.w = w
        self.h = h

    def draw(self):
        for i in range(self.w):
            for j in range(self.h):
                checked = (i+j) % 2 == 0
                if checked:
                    sys.stdout.write("#")
                else:
                    sys.stdout.write(".")
            sys.stdout.write("\n")
        sys.stdout.write("\n")

def main():
    data = []
    while 1:
        n = input().split()
        w = int(n[0])
        h = int(n[1])

        if w == 0 and h == 0:
            break

        data.append(Rect(w,h))

    for num in data:
        num.draw()

if __name__ == "__main__":
    main()

Measured memory_bytes: 6308