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

int dp[1005][1005];

void ExtendedEditDistance(vector<string> s1, vector<string> s2){
  
  const int INF = 1e9;
  
  for(int i=0;i<1005;i++)
    for(int j=0;j<1005;j++) dp[i][j] = INF;
  
  dp[0][0] = 0;
  
  int sum1 = 0, sum2;
  
  for(int i=0;i<(int)s1.size();i++){
    
    for(int j=0;j<(int)s1[i].size();j++){
      
      int idx1 = sum1 + j;
      
      sum2 = 0;
            
      for(int k=0;k<(int)s2.size();k++){
	
	for(int l=0;l<(int)s2[k].size();l++){
	  
	  int idx2 = sum2 + l;
	  
	  if( s1[i][j] == s2[k][l] ) dp[idx1+1][idx2+1] = min( dp[idx1+1][idx2+1], dp[idx1][idx2] );
	  else{
	    
	    dp[idx1+1][idx2] = min( dp[idx1+1][idx2], dp[idx1][idx2] + 1 );
	    
	    dp[idx1][idx2+1] = min( dp[idx1][idx2+1], dp[idx1][idx2] + 1 );
	    
	    dp[idx1+1][idx2+1] = min( dp[idx1+1][idx2+1], dp[idx1][idx2] + 1 );
	    
	  }
	  
	  /*
	    if( j == 0 ) dp[idx1+s1[i].size()][idx2] = min( dp[idx1+s1[i].size()][idx2], dp[idx1][idx2] + 1 );
	  
	  if( l == 0 ) dp[idx1][idx2+s2[k].size()] = min( dp[idx1][idx2+s2[k].size()], dp[idx1][idx2] + 1 );
	  */
	}
	
	sum2 += s2[k].size();
	
      }
      
    }
    
    sum1 += s1[i].size();
    
  }
  
  int ans = dp[sum1][sum2];
  
  for(int i=0;i<1005;i++) ans = min( ans, dp[sum1][i] + sum2 - i );
  
  for(int i=0;i<1005;i++) ans = min( ans, dp[i][sum2] + sum1 - i );
  
  cout<<ans<<endl;
  
}

signed main(){
  
  vector<string> s1, s2;
  
  string A, B;
  cin>>A>>B;
  
  s1.push_back( A );
  
  s2.push_back( B );
  
  ExtendedEditDistance(s1,s2);
  
  return 0;
}



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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    long long  n;
    cin>>n;

    cout<<((n)*(n-1))/2<<"\n";
    return 0;

}
/*


*/


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  l64 mat[H][W];
  l64 p_cnt = 0, m_cnt = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (i%h == 0 && j%w == 0) {
        mat[i][j] = 999999999;
        p_cnt++;
      } else if (i%h == h-1 && j%w == w-1) {
        mat[i][j] = -1000000000;
        m_cnt++;
      } else {
        mat[i][j] = 0;
      }
    }
  }
  //if (p_cnt * 999999999 > m_cnt * 1000000000) {
  if (H%h != 0 || W%w != 0) {
    cout << "Yes" << endl;
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
        cout << mat[i][j] << " ";
      }
      cout << endl;
    }
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 4864
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

int main(){
  string s;
  int n;
  cin >> s;
  n = s.length();
  long long d[n+10][13];
  int c;

  for(int i=0;i<n+10;i++){
    for(int j=0;j<13;j++){
      d[i][j] = 0;
    }
  }

  d[0][0] = 1;

  for(int i=0;i<n;i++){
    if(s[i] == '?') c = -1;
    else c = s[i] - '0';

    for(int j=0;j<10;j++){
      if(c != -1 && c != j) continue;
      for(int ki=0;ki<13;ki++){
        d[i+1][(ki*10+j)%13] += d[i][ki];
      }
    }
    for(int j=0;j<13;j++) d[i+1][j] %= 1000000007;
  }

  cout << d[n][5] << endl;

  return 0;
}

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

struct block {
    int l, r, x;
};

const int N = 2e5+7;
int ans[N];

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

    int n, q;
    cin>>n>>q;

    vector<block> blocks;
    for (int i=0; i<n; i++) {
        int l, r, x;
        cin>>l>>r>>x;
        blocks.push_back({l-x, r-x-1, x});
    }

    map<int, int> queries;
    for (int i=0; i<q; i++) {
        int x;
        cin>>x;
        queries[x] = i;
    }

    memset(ans, -1, sizeof ans);
    sort(blocks.begin(), blocks.end(), [](block a, block b) {return a.x < b.x;});
    for (block b: blocks) {
//        cout<<"---> "<<b.l<<" "<<b.r<<" "<<b.x<<endl;
        while (true) {
            auto it = queries.lower_bound(b.l);
            if (it == queries.end() || it->first > b.r)  break;
            ans[it->second] = b.x;
            //cout<<it->second<<" "<<it->first<<" "<<b.x<<endl;
            queries.erase(it);
        }
    }

    for (int i=0; i<q; i++) cout<<ans[i]<<"\n";
}


Measured memory_bytes: 14448
#include <stdio.h>
#include <ctype.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int res = 0;
  int tmp = 0;

  for ( ; ; )
  {
    const int ch = getchar ( );

    if ( isdigit ( ch ) )
    {
      tmp = tmp * 10 + ch - '0';
    }
    else if ( ch )
    {
      res += tmp;
      tmp  = 0;
    }
    if ( ch == EOF )  break ;
  }

  printf ( "%d\n", res );

  return ( 0 );
}

Measured memory_bytes: 0
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;



int main()
{
    ll L,R,res;

    cin >> L >> R;

    ll iMin = 2020;

    if(R - L >= 2019)
    {
        cout << 0 << endl;
        return 0;
    }
    for(ll i = L; i <= R; ++i)
    {
        if(i % 2019 == 0)
        {
            cout << 0 << endl;
            return 0;
        }

    }


    for(ll i = L; i <= R-1; ++i)
    {
        for(ll j = L+1; j <=R; ++j)
        {
            iMin = min(iMin, (i*j) % 2019);
        }
    }
    cout << iMin << endl;
    return 0;
}



Measured memory_bytes: 256
def main():
  ## IMPORT MODULE
  #import sys

  #sys.setrecursionlimit(100000)
  #input=lambda :sys.stdin.readline().rstrip()

  #f_inf=float("inf")
  #MOD=10**9+7
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    n, k = 4, 5
    A = [3, 2, 4, 1]

  else:
    ##INPUT 
    #n = input()
    n, k = map(int, input().split())
    A = list(map(int, input().split()))

  ## SUBMITION CODES HERE
  Town = []
  rec = [-1] * (n+1) # The town we haven't visited yet is -1
  idx = 1

  # Loop to the cycle
  while (rec[idx] == -1):
    rec[idx] = len(Town)
    Town.append(idx)
    idx = A[idx-1]

  # Pre-cycle
  Exce = rec[idx]
  # Intra-cycle
  Cycl = len(Town) - Exce

  if Exce > k:
    print(Town[k])
  else:
    Warp = (k - Exce) % Cycl
    print(Town[Exce+Warp])
  
main()

Measured memory_bytes: 33364
using System;

class Program {
  static void Main(string[] args) {
    string[] val = Console.ReadLine().Split();
    int a = int.Parse(val[0]);
    int b = int.Parse(val[1]);
    int c = int.Parse(val[2]);
    int diff = Math.Max(a, Math.Max(b, c)) * 3 - (a + b + c);
    int ans = (diff + 1) / 2 + (diff % 2);

    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
    long long int n;
    cin>>n;

    long long int ans=0;

    for(long long int i=1;i<=n;i++){
        if((i%3!=0)&&(i%5!=0))ans=ans+i;
    }
    cout<<ans<<endl;
 
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N;
	cin >> N;
	vector<int>v(N);
	for (int i = 0; i < N; ++i)cin >> v[i];
	vector<int>counteven(100100, 0), countodd(100100, 0);
	for (int i = 0; i < N; i += 2) {
		counteven[v[i]]++;
	}
	for (int i = 1; i < N; i += 2) {
		countodd[v[i]]++;
	}
	vector<pii>CE, CO;
	for (int i = 0; i < 100100; ++i) {
		CE.push_back({ counteven[i],i });
		CO.push_back({ countodd[i],i });
	}
	sort(CE.begin(), CE.end(),greater<pii>());
	sort(CO.begin(), CO.end(), greater<pii>());
	if (CE[0].second != CO[0].second) {
		cout << N - CE[0].first - CO[0].first << endl;
	}
	else {
		cout << min(N - CE[0].first - CO[1].first, N - CE[1].first - CO[0].first) << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
#define ll long long
int n,A[20];
ll f(int l,int r,ll a,ll b){if(l>r)return 0;ll R=1e18;for(int m=l;m<=r;m++)R=min(R,f(l,m-1,a,a+b)+f(m+1,r,a+b,b)+A[m]*(a+b));return R;}
int main(){cin>>n;for(int i=1;i<=n;i++)cin>>A[i];cout<<A[1]+A[n]+f(2,n-1,1,1)<<endl;return 0;}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const LL mod = 1e9 + 7;
const int MC = 3010;
int N,M;
LL dp[MC][MC][2];

int main(){
	scanf("%d%d" , &N , &M);
	dp[0][0][1] = 1;
	repp(i,1,N+1) dp[0][i][0] = 1;
	repp(i,0,M){
		(dp[i+1][0][1] += dp[i][0][1]) %= mod;
		(dp[i+1][1][1] += dp[i][0][1]) %= mod;
		if(N==1){
			(dp[i+1][1][1] += dp[i][1][0] + dp[i][1][1]) %= mod;
			(dp[i+1][0][1] += dp[i][1][0] + dp[i][1][1]) %= mod;
		} else {
			(dp[i+1][N][0] += dp[i][N][0]) %= mod;
			(dp[i+1][N][1] += dp[i][N][1]) %= mod;
			(dp[i+1][N-1][0] += dp[i][N][0]) %= mod;
			(dp[i+1][N-1][1] += dp[i][N][1]) %= mod;
			(dp[i+1][0][1] += dp[i][1][0] + dp[i][1][1]) %= mod;
			(dp[i+1][1][0] += dp[i][1][0]) %= mod;
			(dp[i+1][1][1] += dp[i][1][0] + dp[i][1][1] * 2) %= mod;
			(dp[i+1][2][0] += dp[i][1][0]) %= mod;
			(dp[i+1][2][1] += dp[i][1][1]) %= mod;
		}
		repp(j,2,N){
			(dp[i+1][j][0] += dp[i][j][0] * 2) %= mod;
			(dp[i+1][j+1][0] += dp[i][j][0]) %= mod;
			(dp[i+1][j-1][0] += dp[i][j][0]) %= mod;
			(dp[i+1][j][1] += dp[i][j][1] * 2) %= mod;
			(dp[i+1][j+1][1] += dp[i][j][1]) %= mod;
			(dp[i+1][j-1][1] += dp[i][j][1]) %= mod;
		}
	}
	LL ans = 0;
	repp(i,0,N+1){
		(ans += dp[M][i][1]) %= mod;
	}
	printf("%lld\n" , ans);
	return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

// クエリあたりO(lonN)で処理できる
// 1-indexedなので注意
template <class Abel> struct BIT {
    const Abel UNITY_SUM = 0;                       // to be set
    vector<Abel> dat;
    
    /* [1, n] */
    BIT(int n) : dat(n + 1, UNITY_SUM) { }
    void init(int n) { dat.assign(n + 1, UNITY_SUM); }
    
    /* a is 1-indexed */
    inline void add(int a, Abel x) {
        for (int i = a; i < (int)dat.size(); i += i & -i)
            dat[i] = dat[i] + x;
    }
    
    /* [1, a], a is 1-indexed */
    inline Abel sum(int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i)
            res = res + dat[i];
        return res;
    }
    
    /* [a, b), a and b are 1-indexed */
    inline Abel sum(int a, int b) {
        return sum(b - 1) - sum(a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat.size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

signed main()
{   
    gearup;
    int n,q;string s;
    cin >> n >> s >> q;
    vector<BIT<int> > bit(26,BIT<int>(n+10));
    rep(j,n)bit[s[j]-'a'].add(j+1,1);

    rep(i,q){
        int type; cin >> type;
        if(type == 1){
            int idx;char c;
            cin >> idx >> c; idx--;
            char pc = s[idx];
            s[idx] = c;
            bit[pc - 'a'].add(idx+1,-1);
            bit[c - 'a'].add(idx+1,1);
        }
        else{
            int l,r; cin >> l >> r;
            ll res = 0;
            rep(j,26) if(bit[j].sum(l,r+1))res++;
            out(res);
        }
    }
    
}

Measured memory_bytes: 53660
#include <bits/stdc++.h> 
using namespace std; 
  
// Function to return the probability when 
// number of heads is greater than the number of tails 
long double Probability(long double p[], int n) 
{ 
  
    // Declaring the DP table 
    long double dp[n + 1][n + 1]; 
    memset(dp, 0.000000000, sizeof(dp)); 
  
    // Base case 
    dp[0][0] = 1.000000000; 
  
    // Iterating for every coin 
    for (int i = 1; i <= n; i += 1) { 
  
        // j represents the numbers of heads 
        for (int j = 0; j <= i; j += 1) { 
  
            // If number of heads is equal to zero 
            // there there is only one possiblity 
            if (j == 0) 
                dp[i][j] = dp[i - 1][j] 
                           * (1.00000000 - p[i]); 
            else
                dp[i][j] = dp[i - 1][j] 
                               * (1.000000000 - p[i]) 
                           + dp[i - 1][j - 1] * p[i]; 
        } 
    } 
  
    long double ans = 0.000000000; 
  
    // When the number of heads is greater than (n+1)/2 
    // it means that heads are greater than tails as 
    // no of tails + no of heads is equal to n for 
    // any permuation of heads and tails 
    for (int i = (n + 1) / 2; i <= n; i += 1) 
        ans += dp[n][i]; 
  
    return ans; 
} 
  
// Driver Code 
int main() 
{ 
  	int N;
    cin >> N;
  	
    // 1 based indexing 
    long double p[N+1] ; 
    p[0]=0.000000000;
    for(int i=1;i<=N;i++){
      cin >> p[i];
      p[i]+=0.000000000;
    }
  
    // Number of coins 
    //int n = sizeof(p) / sizeof(p[0]) - 1; 
  
    // Function call 
    cout << setprecision(10)<<Probability(p, N); 
  
    return 0; 
} 

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

typedef long long ll;
using namespace std;

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

	char c[8][8];

	for (int i = 0;i < 8;i++){
		for (int j = 0;j < 8;j++){
			cin >> c[i][j];
		}
	}

	cout << 90 << endl;	

	for (int i = 0;i < 8;i++){
		for (int j = 0;j < 8;j++){
			cout << c[7-j][i];
		}
		cout << endl;
	}

	cout << 180 << endl;

	for (int i = 0;i < 8;i++){
		for (int j = 0;j < 8;j++){
			cout << c[7-i][7-j];
		}
		cout << endl;
	}

	cout << 270 << endl;

	for (int i = 0;i < 8;i++){
		for (int j = 0;j < 8;j++){
			cout << c[j][7-i];
		}
		cout << endl;
	}

	return 0;

}



Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<utility>

typedef long long ll;
#define INF 1000000000
#define MOD 1000000007

using namespace std;

ll dp[100001];

int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll> x(m);
	for (ll i = 0; i < m; i++) {
	    cin >> x[i];
	}
	sort(x.begin(), x.end());

	vector<ll> diff(m);
	for (int i = 1; i < m; i++) {
	    diff[i] = x[i] - x[i - 1];
	}
	sort(diff.begin(), diff.end());

	/*for (int i = 0; i < m; i++)
		cout << x[i] << " " ;
	cout << endl;
	for (int i = 1; i < m; i++)
		cout << diff[i] << " ";
	cout << endl;*/

	ll ans = 0;
	for (int i = 1; i < m - n + 1; i++)
		ans += diff[i];
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  char b;
  cin >> b;
  if (b == 'A') {
    cout << 'T' << endl;
  } else if (b == 'T') {
    cout << 'A' << endl;
  } else if (b == 'C') {
    cout << 'G' << endl;
  } else {
    cout << 'C' << endl;
  }
  return 0;
}

Measured memory_bytes: 3580
import sys
sys.setrecursionlimit(10**6)

def dfs(v, p, c):
    res[v] = c
    for next in link[v]:
        if next[0] == p:
            continue
        if next[1] % 2:
            dfs(next[0], v, 1-c)
        else:
            dfs(next[0], v, c)


N = int(input())
link = [[] * N for _ in range(N)]
res = [0] * N
for i in range(N-1):
    u, v, w = map(int, input().split())
    link[u-1].append([v-1, w])
    link[v-1].append([u-1, w])
    
dfs(0, -1, 1)

for i in range(N):
    print(res[i])

Measured memory_bytes: 85212
#include <cstdio>
#include <memory.h>
#include <string.h>

using namespace std;

long long MOD = 1000000007;

int N;
char S[5005];

int len;
long long cache[5005][5005];

inline long long madd(long long a, long long b) { return (a+b) % MOD; }

long long rec(int p, int n) {
    long long& ret = cache[p][n];
    if (ret != -1) return ret;
    if (p == len && n == 0) return ret = 1;
    if (n == 0) return ret = 0;
    ret = rec(p+1, n-1);
    if (p >= 1) ret = madd(ret, 2LL*rec(p-1, n-1));
    else ret = madd(ret, rec(0, n-1));
    return ret;
}

long long solve() {
    len = strlen(S);
    memset(cache, -1, sizeof(cache));
    return rec(0, N);
}

int main() {
    scanf("%d", &N);
    scanf("%s", S);
    long long ans = solve();
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 196096
#include <stdio.h>
#include <stdlib.h>
#include<math.h>

int main()
{
  int N;
  scanf("%d",&N);
  int a[6];
  for(int i=4;i>=1;i--)
  {
  	a[i]=N%10;
  	N=N/10;
  }
  if(a[1]==a[2]&&a[2]==a[3])
  printf("Yes");
  else if(a[2]==a[3]&&a[3]==a[4])
  printf("Yes");  
  else
printf("No");
	
	return 0;
}


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


int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    int count=0;
    rep(i,n){
        if((i+1)%2==0){
            continue;
        }
        if(a[i]%2==1){
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3624
p = input().split()
n, m, c = int(p[0]), int(p[1]), int(p[2])
b = input().split()
q = 0
for i in range(n):
    a = input().split()
    s = 0
    for j in range(m):
        s += int(a[j])*int(b[j])
    if s > -c:
        q += 1
print(q)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std ;
#define int long long
#define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;
#define endl '\n' 

void solve() {
    int n ;
    cin >> n ;
    int ans = 0 ;
    for (int i = 1 ; i <= n ; i++) {
        ans += i ;
    }
    cout << ans << endl ;
}

int32_t main() 
{
    fast ;
    int testcases = 1 ;
    // cin >> testcases ;
    while(testcases--) {
        solve() ;
    }
    return 0  ;
}
/*  CODED BY:-
 ___________________________________
|                       ___         |
|  /\   /\  \ /  |  |  |___   |__|  |        
| /~~\ /~~\  |   |__|   ___|  |  |  |
|___________________________________|
 
*/

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

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

using f64 = double;
using f128 = long double;

template <typename T> using Vec = vector<T>;
template <typename K, typename V> using HashMap = unordered_map<K, V>;
template <typename T> using HashSet = unordered_set<T>;
template <typename T> using PQueue = priority_queue<T>;

using StrView = string_view;

auto solve(i64 const N, i64 const M, i64 const Q, Vec<i64> const a,
           Vec<i64> const b, Vec<i64> const c, Vec<i64> const d) -> void {
  Vec<Vec<i64>> vA;
  for (i64 i1 = 1; i1 <= M; ++i1) {
    for (i64 i2 = i1; i2 <= M; ++i2) {
      for (i64 i3 = i2; i3 <= M; ++i3) {
        for (i64 i4 = i3; i4 <= M; ++i4) {
          for (i64 i5 = i4; i5 <= M; ++i5) {
            for (i64 i6 = i5; i6 <= M; ++i6) {
              for (i64 i7 = i6; i7 <= M; ++i7) {
                for (i64 i8 = i7; i8 <= M; ++i8) {
                  for (i64 i9 = i8; i9 <= M; ++i9) {
                    for (i64 i10 = i9; i10 <= M; ++i10) {
                      Vec<i64> A{i1, i2, i3, i4, i5, i6, i7, i8, i9, i10};
                      vA.push_back(move(A));
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }

  i64 maxScore = -1;

  for (auto &A : vA) {
    i64 score = 0;
    for (i64 i = 0; i < Q; ++i) {
      if (A[b[i] - 1] - A[a[i] - 1] == c[i]) {
        score += d[i];
      }
    }

    if (maxScore < score) {
      maxScore = score;
    }
  }

  cout << maxScore << "\n";
}

auto main() -> int {
  i64 N;
  scanf("%" SCNd64, &N);
  i64 M;
  scanf("%" SCNd64, &M);
  i64 Q;
  scanf("%" SCNd64, &Q);
  Vec<i64> a(Q);
  Vec<i64> b(Q);
  Vec<i64> c(Q);
  Vec<i64> d(Q);
  for (i64 i = 0; i < Q; ++i) {
    scanf("%" SCNd64, &a[i]);
    scanf("%" SCNd64, &b[i]);
    scanf("%" SCNd64, &c[i]);
    scanf("%" SCNd64, &d[i]);
  }
  solve(N, M, Q, move(a), move(b), move(c), move(d));
  return 0;
}


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

using namespace std;

int H, W;
int A[85][85], B[85][85];
const int max_unbalance = 160 * 80 + 10;
bool U[85][85][max_unbalance];

int main() {
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> B[i][j];
    }
  }
  U[0][0][abs(A[0][0] - B[0][0])] = true;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int diff = A[i][j] - B[i][j];
      for (int k = 0; k < max_unbalance; k++) {
        if (i > 0 and U[i - 1][j][k]) {
          U[i][j][abs(k + diff)] = true;
          U[i][j][abs(k - diff)] = true;
        }
        if (j > 0 and U[i][j - 1][k]) {
          U[i][j][abs(k + diff)] = true;
          U[i][j][abs(k - diff)] = true;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < max_unbalance; i++) {
    if (U[H - 1][W - 1][i]) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 85376
#include<iostream>
#include<cstdio>
#include<cstring>
const int N=100100;
int a[N];
int n,L;
int main()
{
	scanf("%d%d",&n,&L);
	int flag=0,p=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",a+i);
		if(i>1 && a[i]+a[i-1]>=L)flag=1,p=i-1;
	}
	if(!flag)printf("Impossible\n");
	else 
	{
		printf("Possible\n");
		for(int i=1;i<p;i++)
			printf("%d\n",i);
		for(int i=n-1;i>p;i--)
			printf("%d\n",i);
		printf("%d\n",p);
	}
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
ll a[10000000];
int main() {

	ll i, j, k, l, test, n;
	cin >> n;

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

	for (i = 0; i < n; i++) {
		a[i] -= (i + 1);
	}
	ll sum = 0;
	sort(a, a + n);
	for (i = 0; i < n; i++) {
		sum += abs(a[i] - a[n / 2]);
		//cout << a[i] << "\n";
	}
	cout << sum;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

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

	int a, b; cin >> a >> b;
	bool flag = false;
	for (int i = 1; i <= 1000 && !flag; i++) {
		if ((i * 8) / 100 == a && i / 10 == b) {
			cout << i << endl;
			flag = true;
		}
	}
	if (!flag) cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static Deque<String> list = new ArrayDeque<String>();

    public static void main(String[] args) {
        StringBuilder ans = new StringBuilder();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] sp = new String[2];
        try {
            int n = Integer.parseInt(br.readLine());
            for (int i = 0; i < n; i++) {
                sp = br.readLine().split(" ");
                if (sp[0].equals("insert")) {
                    list.addFirst(sp[1]);
                } else if (sp[0].equals("delete")) {
                    list.remove(sp[1]);
                } else if (sp[0].equals("deleteFirst")) {
                    list.removeFirst();
                } else if (sp[0].equals("deleteLast")) {
                    list.removeLast();
                }
            }
            if (!list.isEmpty()) {
                ans.append(list.getFirst());
                list.removeFirst();
            }
            while (!list.isEmpty()) {
                ans.append(" ").append(list.getFirst());
                list.removeFirst();
            }
            System.out.println(ans.toString());
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }catch (IOException e) {
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 229764
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=1;i<=(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
  int n,val=0;
  cin>>n;
  rep(i,n){
    rep(j,n){
      int a=gcd(i,j);
      rep(k,n)val+=gcd(a,k);
    }
  }

  cout<<val;
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  long long N, P;
  cin >> N >> P;

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

  long long n_even = 0;
  long long n_odd = 0;
  for (int i = 0; i < N; ++i) {
    if (a[i] % 2 == 0)
      ++n_even;
    else
      ++n_odd;
  }

  if (P == 0) {
    long long ret = pow(2, n_even);
    long long comb = 0;
    for (long long i = 0; 2 * i <= n_odd; ++i) {
      long long tmp = 1;
      long long c = min(2 * i, n_odd - 2 * i);
      for (long long j = 0; j < c; ++j) {
        tmp *= n_odd - j;
      }
      for (long long j = 0; j < c; ++j) {
        tmp /= j + 1;
      }
      comb += tmp;
    }
    ret *= comb;
    cout << ret << endl;
   } else {
    long long ret = pow(2, n_even);
    long long comb = 0;
    for (long long i = 0; 2 * i + 1 <= n_odd; ++i) {
      long long tmp = 1;
      long long c = min(2 * i + 1, n_odd - 2 * i - 1);
      for (long long j = 0; j < c; ++j) {
        tmp *= n_odd - j;
      }
      for (long long j = 0; j < c; ++j) {
        tmp /= j + 1;
      }
      comb += tmp;
    }
    ret *= comb;
    cout << ret << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdlib.h>

using namespace std;

const int N=123456;
int a[N];
int b[N];

int main() {
    int n;
    int h=0;
    scanf("%d",&n);
    int s=0;
    for(int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
        if(a[i]!=a[i-1] ) {
            b[s++]=a[i];
        }
    }
    for(int i=0;i<s;i++) {
        if(i==n-1){
            h++;
            break;
        }
        int flag1=0;
        int flag2=0;
        while(b[i]>=b[i+1] && i+1<s) {
            i++;
            flag1=1;
        }
        if(flag1) {
            h++;
            i++;
        }
        while(b[i]<=b[i+1] && i+1<s) {
            i++;
            flag2=1;
        }
        if(flag2) {
            h++;
        } else if(flag1) {
            i--;
        }
    }
    printf("%d\n",h);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int c[100] = {0};
  int j=1;
  int count0 = 0;
  int count1 = 0;
  
  for(int i=0; i<S.length(); i++){
    if(S.at(i) == '0') count0++;
    else count1++;
  }
  int a;
  a = abs(count0 - count1);
  cout << S.length() - a << endl;
  return 0;
}
    

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	int s1 , s2 , diag;
	char c;
	int rect , rhom;
	rect=rhom=0;
	while(cin>>s1>>c>>s2>>c>>diag){
		if((s1*s1)+(s2*s2)==diag*diag && s1==s2){
			rect++; rhom++;
		} else if((s1*s1)+(s2*s2)==diag*diag) {
			rect++;
		} else if(s1==s2){
			rhom++;
		}
	}
	cout << rect << endl << rhom << endl;
	return 0; 
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a[111111];
ll s, r;

int main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	rept(i,n) {
		s += a[i];
		if (a[i]==0) r += s/2, s = 0;
	}
	cout << r << ln;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cstdlib>
#include <ctime>
#include <cstdint>
#include <cmath>

#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define EACH(i,x)   for(auto & i : x)
#define ALL(x)      begin(x),end(x)

using namespace std;

typedef vector<int> vecint;

int c(int n){
  if (n <= 1)
    return 0;
  else
    return c(ceil(n/3.0))+1;
}

int main()
{
  int n;cin>>n;
  cout<<c(n)<<endl;
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
int a[10005];
vector<int>v;
int search(int n)
{
	bool flag=false;
	for(int i=0;i<v.size();i++)
	{
		if(v[i]==n)
			flag=true;
	}
	if(flag)
		return 0;
	else
		return 1;
}
int main()
{
	int x,n,cnt=1e9,sum=1e9;
	cin>>x>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		v.push_back(a[i]);
	}
	for(int i=0;i<=x;i++)
	{
		if(search(i))
			sum=i;
	}
	cnt=abs(x-sum);
	for(int i=x+(x-sum)-1;i>=x;i--)
	{
		if(search(i))
			sum=i;
	}
	cout<<sum;

	return 0;
}

Measured memory_bytes: 3644
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())

class UnionFind():
    def __init__(self, n):
        self.n = 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

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

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

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

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def solve():
    N, M, K = MAP()
    F = [[] for _ in range(N)]
    B = [[] for _ in range(N)]

    uf = UnionFind(N) # 初期化

    for i in range(M):
        a, b = MAP()
        F[a-1].append(b-1)
        F[b-1].append(a-1)
        uf.union(a-1, b-1) # グループを併合

    for i in range(K):
        c, d = MAP()
        B[c-1].append(d-1)
        B[d-1].append(c-1)

    for i in range(N):
        ans = uf.size(i) - len(F[i]) - 1
        for x in B[i]:
            if uf.same(i, x):
                ans -= 1
        print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 47976
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

const int MOD = 1e9 + 7;

int main() {

    string s;
    cin >> s;
    s = " " + s + " ";

    int ans = s.size()+1;
    for (char c = 'a'; c <= 'z'; c++) {
        s[0] = s.back() = c;
        size_t pos = 0;
        int maxx = 0;
        int before = -1;
        while (1) {
            pos = s.find(c, pos);
            if (pos == s.npos)
                break;
            maxx = max(maxx, (int)pos - before - 1);
            before = pos;
            pos++;
        }
        ans = min(ans, maxx);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

N = int(input())
S = np.array([ord(x) for x in input().rstrip()],dtype=np.int64)

MOD = 10**9 + 7
base = 1234

def cumprod(arr):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

x = np.full(N,base,np.int64); x[0] = 1
power = cumprod(x)
x = np.full(N,pow(base,MOD-2,MOD),np.int64); x[0] = 1
power_inv = cumprod(x)

# rolling hash
H = S * power % MOD
Hcum = H.cumsum() % MOD

def test(n):
    # 長さnの文字列で2回現れるものが存在する
    x = (Hcum[n-1:N] - Hcum[:N-n+1] + H[:N-n+1]) % MOD
    x *= power_inv[:N-n+1]
    x %= MOD
    # 距離n以上離れたところで連番が存在しないといけない
    ind = np.lexsort((np.arange(N-n+1),x))
    x = x[ind]
    is_left_end = np.zeros(N-n+1,np.bool)
    is_left_end[1:] = (x[1:] != x[:-1])
    is_left_end[0] = 1
    is_right_end = np.zeros(N-n+1,np.bool)
    is_right_end[:-1] = (x[:-1] != x[1:])
    is_right_end[-1] = 1
    gap = ind[is_right_end] - ind[is_left_end]
    return gap.max() >= n

left = 0 # 存在
right = N+1 # 非存在
while left + 1 < right:
    mid = (left + right)//2
    if test(mid):
        left = mid
    else:
        right = mid

answer = left
print(answer)


Measured memory_bytes: 12932
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	string S;
	cin >> S;
	ll sl = S.length(), lw = -1;
	ll ans = 0;
	REP(i, sl) {
		if (S[i] == 'W') {
			ans += (i - lw -1);
			lw++;
		}
	}

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

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

using namespace std;

using ll = long long;
ll MOD = 1e9 + 7;

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

    string s;

    cin >> s;
    const int n = s.size();
    vector<vector<ll>> dp(n + 1, vector<ll>(4));
    dp[0][0] = 1;

    for (int i = 0; i < n; ++i) {
        if (s[i] == 'A') {
            dp[i + 1][1] += (dp[i][0] + dp[i][1]) % MOD;
            dp[i + 1][0] += dp[i][0];
            dp[i + 1][2] += dp[i][2];
            dp[i + 1][3] += dp[i][3];
        }
        else if (s[i] == 'B') {
            dp[i + 1][2] += (dp[i][1] + dp[i][2]) % MOD;
            dp[i + 1][0] += dp[i][0];
            dp[i + 1][1] += dp[i][1];
            dp[i + 1][3] += dp[i][3];
        }
        else if (s[i] == 'C') {
            dp[i + 1][3] += (dp[i][2] + dp[i][3]) % MOD;
            dp[i + 1][0] += dp[i][0];
            dp[i + 1][1] += dp[i][1];
            dp[i + 1][2] += dp[i][2];
        }
        else if (s[i] == '?') {
            dp[i + 1][0] += (3 * dp[i][0]) % MOD;
            dp[i + 1][1] += (dp[i][0] + 3 * dp[i][1]) % MOD;
            dp[i + 1][2] += (dp[i][1] + 3 * dp[i][2]) % MOD;
            dp[i + 1][3] += (dp[i][2] + 3 * dp[i][3]) % MOD;
        }
    }

    cout << dp[n][3] << endl;

    return 0;
}


Measured memory_bytes: 7376
#include <iostream>
typedef long long ll;
using namespace std;

ll dp[100];

ll getLucas(int n) {
    if (dp[n] >= 0) return dp[n];
    
    ll result;
    if (n == 0) result = 2;
    if (n == 1) result = 1;
    if (n >= 2) result = getLucas(n - 1) + getLucas(n - 2);

    dp[n] = result;

    return result;
}

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

    // メモを初期化
    for (int i = 0; i < 100; i++) dp[i] = -1;
    
    cout << getLucas(N) << endl;
    return 0;
}

Measured memory_bytes: 888
#include <cstdio>
#define swp(a,b) a ^= b,b ^= a,a ^= b;
int main()
{
	int cups[3] = {1, 0, 0};
	unsigned char a, b;
	while(~scanf("%c,%c\n", &a, &b))
		swp(cups[a - 'A'], cups[b - 'A']);
	printf("%c\n", cups[0] * 'A' + cups[1] * 'B' + cups[2] * 'C');
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    cout << min({abs(a1-a2)+abs(a2-a3), abs(a2-a3) + abs(a3-a1), abs(a1-a3)+abs(a1-a2)}) << endl;
}


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

public class Main {
	public void maain(){

	}

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		//?????????????¨?????????£?¨?
		boolean[] S = new boolean[13];
		boolean[] H = new boolean[13];
		boolean[] C = new boolean[13];
		boolean[] D = new boolean[13];

		//1???????????\????????¢
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);

        String[] input = br.readLine().split(" ");
        int n = Integer.parseInt(input[0]);

        //2???????????\????????¢
        for(int set = 0;set < n; set++ ){
        	String[] input2 = br.readLine().split(" ");
        	String mark = input2[0];
        	int num = Integer.parseInt(input2[1]);

        	//?????£?????????????????????true???????????????
        	if(mark.equals("S")){
        		S[num - 1] = true;
        	}else if(mark.equals("H")){
        		H[num - 1] = true;
         	}else if(mark.equals("C")){
        		C[num - 1] = true;
        	}else if(mark.equals("D")){
        		D[num - 1] = true;
      		}
        }

        //?????£?????????????????????????????¢?????¨???????????????
    	for(int set = 0;set < 13; set++){
    		if(S[set] == false){
    			System.out.println("S" + " " + (set + 1));
    		}
    	}
    	for(int set = 0;set < 13; set++){
    		if(H[set] == false){
    			System.out.println("H" + " " + (set + 1));
    		}
    	}
    	for(int set = 0;set < 13; set++){
    		if(C[set] == false){
    			System.out.println("C" + " " + (set + 1));
    		}
    	}
    	for(int set = 0;set < 13; set++){
    		if(D[set] == false){
    			System.out.println("D" + " " + (set + 1));
    		}
    	}
	}
}

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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

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

int main(){
    int n;
    cin >> n;
    vector<int>A(1e5 + 5, 0);
    vector<int>B(1e5 + 5, 0);
    REP(i, n){
        int x;
        cin >> x;
        if(i % 2 != 0) A.at(x)++;
        else B.at(x)++;
    }
    int odd = 0, odd2 = 0, even = 0, even2 = 0;
    int x, y;
    REP(i, 1e5 + 5){
        if(odd < A.at(i)) x = i;
        if(even < B.at(i)) y = i;
        odd = max(odd, A.at(i));
        even = max(even, B.at(i));
    }
    sort(all(A));
    reverse(all(A));
    sort(all(B));
    reverse(all(B));
    int ans;
    if(x != y) ans = n - A[0] - B[0];
    else ans = min(n - A[1] - B[0], n - A[0] - B[1]); 
    print(ans);

    // if(x != y) ans = n - odd - even;
    // else {
    //     REP(i, 1e5 + 5){
    //         if(odd != A.at(i)) odd2 = max(odd2, A.at(i));
    //         if(even != B.at(i)) even2 = max(even2, B.at(i));
    //     }
    //     if(odd == n / 4) odd2 = odd;
    //     if(even == n / 4) even2 = even;
    //     ans = min(n - odd - even2, n - odd2 - even);

    // }
    // print(ans);
}

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

int n, k;
int A[200005];
set <int> originale;

void veziGataSortate()
{
    int cnt = 0;

    int prostii = 0;
    for (int i = 1; i < k; i++)
        if (A[i] > A[i + 1])
            prostii++;
    if (prostii == 0)
        cnt++;

    for (int i = 2; i + k - 1 <= n; i++)
    {
        if (A[i - 1] > A[i])
            prostii--;
        if (A[i + k - 2] > A[i + k - 1])
            prostii++;
        if (prostii == 0)
        {
            cnt++;
            if (cnt >= 2)
                originale.erase(i);
        }
    }
}

int main()
{
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> A[i];

  for (int i = 1; i + k - 1 <= n; i++)
    originale.insert(i);

  set <int> S1, S2;
  for (int i = 1; i <= k; i++)
    S1.insert(A[i]);
  for (int i = 2; i <= k + 1; i++)
    S2.insert(-A[i]);

  if (*S1.begin() == A[1] && *S2.begin() == -A[k + 1])
    originale.erase(2);

  for (int st = 2; st + k <= n; st++)
  {
      S1.erase(A[st - 1]);
      S1.insert(A[st + k - 1]);
      S2.erase(-A[st]);
      S2.insert(-A[st + k]);

      if (*S1.begin() == A[st] && *S2.begin() == -A[st + k])
        originale.erase(st + 1);
  }

  veziGataSortate();

  cout << originale.size();

  return 0;
}


Measured memory_bytes: 19840
n = int(input())
X = list(map(int, input().split()))
X2 = sorted(X)
m1 = X2[(n-1)//2]
m2 = X2[n//2]
for i in range(n):
    if X[i] <= m1:
        print (m2)
    else:
        print (m1)

Measured memory_bytes: 25228