akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>


using namespace std;

int main()
{
    int N,A[200000],max1st=0,max2nd=0,maxidx;
    for(int i=0;i<N;i++) A[i] = 0;

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

    for(int i=0;i<N;i++)
    {
        if(A[i]>max1st)
        {
            max1st = A[i];
            maxidx = i;
        }
    }

    A[maxidx] = 0;

    for(int i=0;i<N;i++)
    {
        if(A[i]>max2nd)
        {
            max2nd = A[i];
            //cout << "max2nd = " << max2nd << endl;
        }
    }

    for(int i=0;i<N;i++)
    {
        if(i == maxidx)
        {
            cout << max2nd << endl;
        }
        else
        {
            cout << max1st << endl;
        }

    }

    
    

}

Measured memory_bytes: 2432
A=int(input())
B=int(input())
C=int(input())
X=int(input())
cnt=0
for i in range(A+1):
  for j in range(B+1):
    s=i*500+j*100
    if (X-s)%50==0 and (X-s)/50<=C and (X-s)/50>=0:
      cnt+=1
print(cnt)

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

int main(){//main_program
  int X,Y;
  int a;
  cin >> X >> Y;
  a = X * 4 - Y;
  if(( a >= 0 )&& (a % 2 == 0) &&( a / 2 <= X) ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main()
{
	char A;
	char B;

	cin >> A >> B;

	if (A > B) {
		cout << ">";
	} else if (A < B){
		cout << "<";
	} else {
		cout << "=";
    }

	return 0;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#define fi first
#define se second
#define debug printf(" I am here\n");
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int maxn=1000+5,inf=0x3f3f3f3f;
const double eps=1e-10;
int n;
signed main(){
    scanf("%d",&n);
    int ma1=-inf,mi1=inf,ma2=-inf,mi2=inf;
    for(int i=1,x,y;i<=n;i++){
        scanf("%d%d",&x,&y);
        ma1=max(ma1,x-y);
        mi1=min(mi1,x-y);
        ma2=max(ma2,x+y);
        mi2=min(mi2,x+y);
    }
    printf("%d\n",max(ma1-mi1,ma2-mi2));
    return 0;
}




Measured memory_bytes: 3780
import Data.Int

main = do
    [n,x] <- map read . words <$> getLine :: IO [Int] 
    print $ eat x $ mkBurgerNum n

-- (total，pate)
mkBurgerNum :: Int -> [[Int]]
mkBurgerNum n 
    | n == 0 = [[1,1]]
    | otherwise = [2*m+3, 2*l+1]:x
    where 
        x = mkBurgerNum (n-1)
        m = x !! 0 !! 0
        l = x !! 0 !! 1

-- x mkBurgerNum 
eat :: Int -> [[Int]] -> Int 
eat x (berger:[]) = 1
eat x (berger:child_berger:xs)
    | x == 1 = 0
    | x > child_berger_num + 2 = child_pate_num + 1 + eat (x - 2 - child_berger_num) (child_berger:xs)
    | x == child_berger_num + 2 = 1 + child_pate_num
    | otherwise = eat (x-1) $ child_berger:xs
    where 
        child_berger_num = child_berger !! 0 
        child_pate_num = child_berger !! 1

Measured memory_bytes: 508
#include <tuple>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;
const long MOD = 1e9 + 7;
#define ll int64_t
string S;


string ls = "";
string rs = "";

ll ans = 0;
long N;

int lsize = 0;
int rsize = 0;
ll nowbit = 0;


map< pair<string, string>, ll > hashmap2;

map< pair<string, string>, ll > hashmap3;

map< pair<string, ll>, string > hashmap4;

void dfs(int pos, bool isleft) {

  if (pos > N - 1) {
    hashmap2[make_pair(ls, rs)] = nowbit;
    hashmap3[make_pair(ls, rs)] += 1;

    hashmap4[make_pair(ls, nowbit)] = rs;

    if (isleft == true) {
      if (pos > 0)ls.erase(ls.end() - 1);
    } else {
      if (pos > 0)rs.erase(rs.end() - 1);
    }
    nowbit = nowbit >> 1;
    return;
  }

  nowbit = (nowbit << 1 ) + 1;
  ls += S[pos];
  dfs( (pos + 1 ), true);


  nowbit = nowbit << 1;
  rs += S[pos];
  dfs((pos + 1 ), false);


  if (isleft == true) {
    if (pos > 0)ls.erase(ls.end() - 1);
  } else {
    if (pos > 0)rs.erase(rs.end() - 1);
  }
  nowbit = nowbit >> 1;



}


void dfs2(int pos, bool isleft) {

  if (pos > N - 1) {
    // if (hashmap2[make_pair(rs, ls)] == nowbit) {
    //   ans++;
    // }
    if (hashmap3[make_pair(rs, ls)] >0){
      ans+=hashmap3[make_pair(rs, ls)];
      // cout << " key1 = " << rs ;
      // cout << " key2 = " << ls ;
      // cout << ", val = " << hashmap3[make_pair(rs, ls)] << "\n";
    }
    // if (hashmap4[make_pair(rs, nowbit)] == ls) {
    //   ans++;
    // }
    // cout << " key1 = " << ls ;
    // cout << " key2 = " << rs ;
    // cout << ", val = " << nowbit << "\n";

    if (isleft == true) {
      if (pos > 0)ls.erase(ls.end() - 1);
    } else {
      if (pos > 0)rs.erase(rs.end() - 1);
    }
    nowbit = nowbit >> 1;
    return;
  }

  nowbit = (nowbit << 1 ) + 1;
  ls += S[pos];
  dfs2( (pos + 1 ), true);


  nowbit = nowbit << 1;
  rs += S[pos];
  dfs2((pos + 1 ), false);

  if (isleft == true) {
    if (pos > 0)ls.erase(ls.end() - 1);
  } else {
    if (pos > 0)rs.erase(rs.end() - 1);
  }
  nowbit = nowbit >> 1;

}




int main()
{


  cin >> N;
  cin >> S;


  dfs(0, false);

  ls = "";
  rs = "";
  nowbit = 0;
  S = S.substr(N, 2 * N );
  reverse(S.begin(), S.end());

  // for (auto itr = hashmap4.begin(); itr != hashmap4.end(); ++itr) {

  //   cout << " key1 = " << itr->first.first ;
  //   cout << " key2 = " << itr->first.second ;
  //   cout << ", val = " << itr->second << "\n";    // 値を表示
  // }cout <<endl;

  // cout << S <<endl;
  // cout << hashmap4.size() << endl;
  // cout << hashmap4.max_size() << endl;

  dfs2(0, false);


  // ans *= 2;

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 129536
n,s=map(x->parse(Int,x),readlines())
A=3n
f(b,n)=n<b?n:f(b,div(n,b))+n%b
g(b)=b>1&&f(b,n)==s?min(A,b):A
A=g(n+1)
for b=1:isqrt(n);A=g(b);A=g(div(n-s,b)+1);end
println(A>2n?-1:A)

Measured memory_bytes: 154876
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<=s.size();i++){
		for(int j=0;j<=s.size();j++){
			bool ok=true;
			for(int k=i;k<j;k++)
				ok&=524357>>s[k]-'A'&1;
			ans=max(ans,ok*(j-i));
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
const int mod = 1e9 + 7;
typedef pair<lint, lint> pi;

int n, k;
struct bit{
	int tree[300005];
	void add(int x, int v){
		while(x <= n+1){
			tree[x] += v;
			x += x & -x;
		}
	}
	int query(int x){
		int ret = 0;
		while(x){
			ret += tree[x];
			x -= x & -x;
		}
		return ret;
	}
}bit;

vector<lint> v;
lint a[300005];

int main(){
	scanf("%d %d",&n,&k);
	for(int i=1; i<=n; i++){
		scanf("%lld", &a[i]); 
		a[i] -= k;
	}
	for(int i=1; i<=n; i++) a[i] += a[i-1];
	for(int i=0; i<=n; i++) v.push_back(a[i]);
	sort(v.begin(), v.end());
	v.resize(unique(v.begin(), v.end()) - v.begin());
	for(int i=0; i<=n; i++) a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1;
	lint ans = 0;
	for(int i=1; i<=n; i++){
		bit.add(a[i-1], 1);
		ans += bit.query(a[i]);
	}
	cout << ans << endl;
}



Measured memory_bytes: 4336
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e18 + 100;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}

const int M = 1e5 + 10;
vector<int> N, P, a;

int g(int x){
   return (x * (x - 1)) / 2;
}




int k;
void solveneg(){
   int low = -mod;
   int high = -1;

   int bst = inf;
   while(low <= high){
      int mid = (low + high) >> 1;

      int ans = 0;
      for (int i = 0; i < (int)(N.size()); ++i)
      {
         int x = (mid + N[i] + 1) / N[i];
         int it = (int)(P.size()) - (lower_bound(P.begin(), P.end(), x) - P.begin());
         tr(i, it, x, N[i], mid);
         ans += it;
      }

      tr(low, mid, high, ans);
      if (ans >= k){
         bst = mid;
         high = mid - 1;
      }
      else{
         low = mid + 1;
      }
   }

   cout<<bst;
}

void solvepos(){  

   int low = 1, high = mod, bst = 1234;

   for(auto &it: N){
      it = abs(it);
   }

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

   while(low <= high){
      
      int mid = (low + high) >> 1;

      int ans = 0;
      for (int i = 0; i < (int)(P.size()); ++i)
      {
         int x = (mid) / P[i];
         int idx = upper_bound(P.begin(), P.end(), x) - P.begin();
         --idx;
         ans += max(0LL, idx - i);
      }

      for (int i = 0; i < (int)(N.size()); ++i)
      {
         int x = (mid) / N[i];
         int idx = upper_bound(N.begin(), N.end(), x) - N.begin();
         --idx;
         ans += max(0LL, idx - i);
      }

      tr(low, mid, high, ans);
      if (ans >= k){
         bst = mid;
         high = mid - 1;
      }
      else{
         low = mid + 1;
      }
   }

   cout << bst;
}


int32_t main(){_
   
   int n, neg = 0, zero = 0, pos = 0;
   cin>>n>>k;

   for (int i = 0; i < n; ++i)
   {
      int x;
      cin >> x;
      a.push_back(x);
      if(a[i] < 0){
         neg++;
         N.push_back(a[i]);
      }
      else if(a[i] == 0)zero++;
      else{
        pos++; 
        P.push_back(a[i]);
     }
   }

   sort(a.begin(), a.end());
   sort(N.begin(), N.end());
   sort(P.begin(), P.end());

   int cn = neg * pos;
   int cz = g(zero) + zero * (n - zero);


   if (k <= cn){
   // tr(cn, cz);
      solveneg();
   }
   else if (k <= cn + cz){
      cout<<0;
      exit(0);
   }
   else{
      k -= (cn + cz);
      tr(cn, cz, k);
      solvepos();
   }
   

   return 0;
}

Measured memory_bytes: 4468
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d,e, H, W;
long long A[200005] = {};
long long B[201][201] = {};
long long C[200005] = {};
bool f, ff;
string S;
set <long long>sll;
pl bufpl;
vector <long long>vl;
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;

char ch[100][100];

bool fs[200005] = {};

int main() {


	cin >> N>>M;
	

	a = 0;
	for (int i = 0; i < M; i++) {
		cin >> A[i];
		fs[A[i]] = true;
	}

	b = 0;
	d = 10000000000;
	C[0] = 1;
	C[1] = 1;
	if (fs[1] == 1) {
		C[1] = 0;
	}
	for (int i = 2; i <= N; i++) {
		
		if (fs[i] == true) {
			C[i] = 0;
		}
		else {
			C[i] = C[i - 1] + C[i - 2];
		}
		C[i] %= modd;

	}

	cout << C[N] << endl;
	
	return 0;

}


Measured memory_bytes: 4480
class FenwickTree():
    def __init__(self, n):
        self.n = n
        self.data = [0] * n

    def add(self, p, x):
        #assert 0 <= p < self.n
        p += 1
        while p <= self.n:
            self.data[p - 1] += x
            p += p & -p

    def sum(self, r):
        s = 0
        while r:
            s += self.data[r - 1]
            r -= r & -r
        return s

    def range_sum(self, l, r):
        #assert 0 <= l <= r <= self.n
        return self.sum(r) - self.sum(l)

import sys
input = sys.stdin.buffer.readline

N, Q = map(int, input().split())
A = tuple(map(int, input().split()))

ft = FenwickTree(N)
res = []

for i in range(N):
    ft.add(i, A[i])

for _ in range(Q):
    q, x, y = map(int, input().split())
    if q:
        res.append(str(ft.range_sum(x, y)))

    else:
        ft.add(x, y)

print('\n'.join(res))

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

#define CO const
#define IN inline
typedef long long int64;

template<class T> IN T read(){
	T x=0,w=1;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-') w=-w;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*w;
}
template<class T> IN T read(T&x){
	return x=read<T>();
}

CO int N=400;
CO int64 inf=1e18;
namespace flow{
	int n,S,T;
	struct edge {int v,c;int64 w;int a;};
	vector<edge> to[N];
	int64 dis[N];int vis[N];

	IN void init(int n){
		flow::n=n,S=n-1,T=n;
		for(int i=1;i<=n;++i) to[i].clear();
	}
	IN void link(int u,int v,int c,int64 w){
		to[u].push_back({v,c,w}),to[v].push_back({u,0,-w});
		to[u].back().a=to[v].size()-1,to[v].back().a=to[u].size()-1;
	}
	bool bfs(){
		fill(dis+1,dis+n+1,-inf),dis[T]=0;
		deque<int> Q={T};vis[T]=1;
		while(Q.size()){
			int u=Q.front();
			Q.pop_front(),vis[u]=0;
			for(CO edge&e:to[u])if(to[e.v][e.a].c){
				if(dis[e.v]<dis[u]-e.w){ // edit 1: -w
					dis[e.v]=dis[u]-e.w;
					if(vis[e.v]) continue;
					if(Q.size() and dis[e.v]>=dis[Q.front()])
						Q.push_front(e.v);
					else Q.push_back(e.v);
					vis[e.v]=1;
				}
			}
		}
		return dis[S]>-inf;
	}
	int dfs(int u,int lim){
		if(u==T) return lim;
		vis[u]=1;
		int rest=lim;
		for(edge&e:to[u])if(!vis[e.v] and e.c and dis[e.v]==dis[u]-e.w){
			int delta=dfs(e.v,min(e.c,rest));
			if(!delta) {dis[e.v]=-inf;continue;}
			rest-=delta,e.c-=delta,to[e.v][e.a].c+=delta;
			if(!rest) break;
		}
		vis[u]=0;
		return lim-rest;
	}
	int64 main(){
		int64 ans=0;
		while(bfs()) ans+=dfs(S,1e9)*dis[S];
		return ans;
	}
}

int n,X[N],Y[N];int64 V[N];
int m,O[N],A[N],B[N];
int L[N],R[N],D[N],U[N];

int64 solve(int s){
	fill(L+1,L+s+1,0),fill(D+1,D+s+1,0);
	fill(R+1,R+s+1,233),fill(U+1,U+s+1,233);
	for(int i=1;i<=m;++i)if(B[i]<s){
		if(O[i]=='L') L[B[i]+1]=A[i]+1;
		else if(O[i]=='R') R[s-B[i]]=A[i]-1;
		else if(O[i]=='D') D[B[i]+1]=A[i]+1;
		else U[s-B[i]]=A[i]-1;
	}
	for(int i=2;i<=s;++i){
		L[i]=max(L[i],L[i-1]);
		D[i]=max(D[i],D[i-1]);
	}
	for(int i=s-1;i>=1;--i){
		R[i]=min(R[i],R[i+1]);
		U[i]=min(U[i],U[i+1]);
	}
	flow::init(2*n+2*s+2);
	for(int i=1;i<=n;++i) flow::link(i,i+n,1,V[i]);
	for(int i=1;i<=s;++i){
		flow::link(flow::S,i+2*n,1,0),flow::link(i+2*n+s,flow::T,1,0);
		for(int j=1;j<=n;++j){
			if(L[i]<=X[j] and X[j]<=R[i]) flow::link(i+2*n,j,1,0);
			if(D[i]<=Y[j] and Y[j]<=U[i]) flow::link(j+n,i+2*n+s,1,0);
		}
	}
	return flow::main();
}
int main(){
	read(n);
	for(int i=1;i<=n;++i) read(X[i]),read(Y[i]),read(V[i]);
	read(m);
	for(int i=1;i<=m;++i){
		char opt[2];scanf("%s",opt);
		O[i]=opt[0],read(A[i]),read(B[i]);
	}
	int64 ans=0;
	for(int i=1;i<=n;++i) ans=max(ans,solve(i));
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    vector <int> n;
    int N;

    cin >> N;

    int p;
    bool flag = 0;
    int cnt = 0;
    for(int i = 1; i < N + 1; i++)
    {
        cin >> p;
        if(p == i)
        {
            if(!flag)
            {
                ++cnt;
                flag = 1;
            }
            else
            {
                flag = 0;
            }
        }
        else
        {
            flag = 0;
        }
    }

    cout << cnt << endl;
    return 0;
}

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

#define int long long

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

int N;

signed main() {
    cin >> N;
    cout << (int)sqrt(N) * (int)sqrt(N) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <climits>
#include <iostream>
#include <vector>

int main(int argc, char *argv[]) {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> h(n);
  for (int i = 0; i < n; ++i)
    std::cin >> h.at(i);

  std::vector<int> dp(n, INT_MAX);
  dp.at(0) = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j <= k; ++j)
      if (i + j < n)
        dp.at(i + j) =
            std::min(dp.at(i + j), dp.at(i) + std::abs(h.at(i) - h.at(i + j)));
  }

  std::cout << dp.at(n - 1) << std::endl;
}


Measured memory_bytes: 1024
import sys

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = []
    for _ in range(N):
        a, b = map(int, input().split())
        A.append((a, b))

    A = sorted(A, key=lambda x: x[0])

    cnt = 0
    for x in A:
        cnt += x[1]
        if cnt >= K:
            return x[0]


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 18984
#include<iostream>
#include<vector>

using namespace std;

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

vector<string> turn(vector<string> board) {
  vector<string> next(8);
  rep (i, 8) {
    rep (j, 8) {
      switch (board[7 - i][7 - j]) {
      case 'o':
	next[i] += "x";
	break;
      case 'x':
	next[i] += "o";
	break;
      case '.':
	next[i] += ".";
	break;
      }
    }
  }
  return next;
}

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

vector<string> move(vector<string> board) {
  int ii = -1, jj = -1, mx = 0, mb;
  rep (i, 8) rep (j, 8) if (board[i][j] == '.') {
    int c = 0, bit = 0;
    rep (k, 8) {
      int cc = 0;
      for (int l = 1; l < 8; ++l) {
	if (i + l * dy[k] < 0 || 8 <= i + l * dy[k]) break;
	if (j + l * dx[k] < 0 || 8 <= j + l * dx[k]) break;
	if (board[i + l * dy[k]][j + l * dx[k]] == 'o') {
	  c += cc;
	  bit |= 1 << k;
	  break;
	}
	if (board[i + l * dy[k]][j + l * dx[k]] == 'x') {
	  ++cc;
	}
	if (board[i + l * dy[k]][j + l * dx[k]] == '.') {
	  break;
	}
      }
    }
    if (mx < c) {
      mx = c;
      mb = bit;
      ii = i;
      jj = j;
    }
  }
  if (ii == -1 && jj == -1) return board;
  board[ii][jj] = 'o';
  rep (k, 8) if (mb & (1 << k)) {
    for (int l = 1; l < 8; ++l) {
      if (board[ii + l * dy[k]][jj + l * dx[k]] == 'o') break;
      board[ii + l * dy[k]][jj + l * dx[k]] = 'o';
    }
  }
  return board;
}

int main() {
  vector<string> board(8);
  rep (i, 8) cin >> board[i];
  rep (iii, 100) {
    board = move(board);
    board = turn(board);
    board = move(board);
    board = turn(board);
  }
  rep (i, 8) cout << board[i] << endl;
  return 0;
}

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

void solve()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b)
        cout << c << endl;
    else if (a == c)
        cout << b << endl;
    else if (b == c)
        cout << a << endl;
}

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

Measured memory_bytes: 3628
A, B, K = (int(i) for i in input().split())

ans = []

for i in range(A, A+K):
    ans.append(i)
    if i == B:
        break

for j in range(B, B-K, -1):
    ans.append(j)
    if j == A:
        break

ans = list(set(ans))
ans.sort()
for x in ans:
    print(x)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


ll n, a, b, now;
bool rev = false;
vector<ll> ans;
int main() {
	cin >> n >> a >> b;
	if (a + b - 1 > n) {
		cout << -1 << endl;
		return 0;
	}
	if (a < b) {
		swap(a, b);
		rev = true;
	}
	if (b == 1) {
		if(a != n) cout << -1 << endl;
		else {
			REP(i, n)ans.push_back(i + 1);
			if (rev)reverse(ALL(ans));
			REP(i, ans.size()) {
				if (i != 0)cout << " ";
				cout << ans[i];
			}
		}
		return 0;
	}
	if ((n - a + b - 2) / (b - 1) > a) {
		cout << -1 << endl;
		return 0;
	}
	now = n - a;
	FOR(i, n - a + 1, n + 1)ans.push_back(i);
	REP(i, b - 1) {
		ll s = (n - a) / (b - 1);
		if ((n - a) % (b - 1) > i)s++;
		FOR(j, now - s + 1, now + 1)ans.push_back(j);
		now -= s;
	}
	if (rev)reverse(ALL(ans));
	REP(i, ans.size()) {
		if (i != 0)cout << " ";
		cout << ans[i];
	}
	cout << endl;
}




Measured memory_bytes: 6384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    vector<string> s(h); for (auto &e : s) cin >> e;
    vector<vector<int> > ans(h, vector<int>(w));
    rep (i, h) rep (j, w) ans[i][j] = 100000;
    ans[0][0] = (s[0][0] == '#');
    rep (i, h) {
        rep (j, w) {
            if (i > 0) chmin(ans[i][j], ans[i - 1][j] + (s[i][j] == '#' && s[i - 1][j] == '.'));
            if (j > 0) chmin(ans[i][j], ans[i][j - 1] + (s[i][j] == '#' && s[i][j - 1] == '.'));
            eprintf("%d ", ans[i][j]);
        }
        eprintf("\n");
    }
    cout << ans[h - 1][w - 1] << "\n";
    return 0;
}

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

#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ll long long
#define pb push_back
#define zoom                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pl pair<ll, ll>
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl
#define trace(v)                                   \
    for (auto it = v.begin(); it != v.end(); it++) \
        cerr << *it << " ";                        \
    cerr << endl;
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;

void solve()
{
    int n;
    cin>>n;
    string s;
    cin>>s;

    int i=0,j=n-1;
    int ans=0;
    while(i<n){
        int prev=i;
        while(i<n && s[i]=='W'){
            i++;
        }
        if(i==n){   
            break;
        }else{
            for(int k=prev;k<i;k++){
                while(j>k && s[j]=='W'){
                    j--;
                }
                if(j>k){
                    s[k]='R';
                    s[j]='W';
                    ans++;
                    j--;
                }
            }

            i++;
        }
    }

    cout<<ans<<endl;
}

int main()
{
    zoom;
    ll t=1;
    //cin >> t;

    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3772
// 15/06/20 // 4:46 PM //

#include <bits/stdc++.h>

using namespace std;

#define endl "\n"
#define pb push_back
#define int long long

const int MAXN = (3e3) + 10;
const int MOD  = (1e9) + 7;

int n, memo[MAXN][MAXN], prefix[MAXN];
string cond;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> cond;	
		
	memo[1][1] = 1;
	for(int i=2; i<=n; i++){
		
		for(int k=1; k<=n; k++){
			prefix[k] = prefix[k-1] + memo[i-1][k];
			prefix[k] %= MOD;
		}
		
		for(int j=1; j<=i; j++){
			if(cond[i-2]=='<')
				memo[i][j] = prefix[j-1];
			else
				memo[i][j] = (MOD + prefix[i] - prefix[j-1])%MOD;
		}
	}
	
	int resp = 0;
	for(int k=1; k<=n; k++){
		resp += memo[n][k];
		resp %= MOD;
	}
	
	cout << resp << endl;
	
	return 0;
}


Measured memory_bytes: 69248
var
  n,k,i,j:longint;
  a:array[0..1000] of longint;
begin
  readln(n);
  a[1]:=1;
  j:=1;
  k:=1;
  while k<=100 do
  begin
    j:=j+1;
    k:=k*2;
    a[j]:=k;
  end;
  for i:=j downto 1 do
  begin
    if a[i]<=n then begin write(a[i]);exit;end;
  end;
end.

Measured memory_bytes: 128
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

use std::collections::{BTreeSet, VecDeque};

fn main() {
    input!(l: usize);

    let graph = solve(l);
    validate(&graph, l);

    let num = graph.iter().map(|edges| edges.len()).sum::<usize>();
    println!("{} {}", graph.len(), num);

    for from in 0..graph.len() {
        for &(to, cost) in graph[from].iter() {
            println!("{} {} {}", from + 1, to + 1, cost);
        }
    }
}

fn validate(graph: &Vec<Vec<(usize, usize)>>, l: usize) {
    let mut q = VecDeque::new();
    q.push_back((0, 0));
    let goal = graph.len() - 1;
    let mut set = BTreeSet::new();
    while let Some((v, dist)) = q.pop_front() {
        if v == goal {
            assert!(!set.contains(&dist));
            assert!(dist < l);
            set.insert(dist);
            continue;
        }
        for &(next, cost) in graph[v].iter() {
            q.push_back((next, cost + dist));
        }
    }
    assert!(set.len() == l);
}

fn solve(l: usize) -> Vec<Vec<(usize, usize)>> {
    let mut r = 0;
    while (1 << (r + 1)) <= l {
        r += 1;
    }
    assert!(r <= 19);
    let mut graph = vec![vec![]; r + 1];
    for i in 0..r {
        graph[i].push((i + 1, 1 << i));
        graph[i].push((i + 1, 0));
    }

    let n = graph.len();
    if (1 << (n - 1)) - 1 == l - 1 {
        graph
    } else {
        let mut l = l;
        for i in (0..(n - 1)).rev() {
            if l >= (1 << r) + (1 << i) {
                graph[i].push((n - 1, l - (1 << i)));
                l -= 1 << i;
            }
        }

        graph
    }
}


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

#define int long long
#define all(V) (V).begin(),(V).end()
#define umap unordered_map
#define uset unordered_set
#define br cout<<"\n";

const int MAXN=1e5+10, MOD=1e9+7;
int n,m;
int arr[MAXN];
int t[5*MAXN],lazy[5*MAXN];

int doit(int a,int b){
	return a+b;
}

void build(int start,int end,int index=1){
	if(start==end){
		t[index]=0;
		return ;
	}
	int mid = start+end >> 1;
	build(start,mid,index << 1);
	build(mid+1,end,index<<1|1);
	t[index] = doit(t[index<<1], t[index<<1|1]);
}
int pQuery(int start,int end,int l,int r,int index=1){
	// out range
	if(r<start or end<l){
		return 0;
	}
	// in Raange
	if( l<=start and end<=r){
		return t[index];
	}
	int mid = start+end >>1;
	return doit(pQuery(start,mid,l,r,index<<1), pQuery(mid+1,end,l,r,index<<1|1));
}

void pUpdate(int start,int end,int point,int val,int index=1){
	if(start==end){
		t[index]+=val;
		return ;
	}
	int mid = start+end>>1;
	if(point <= mid){
		pUpdate(start,mid,point,val,index<<1);
	}
	else{
		pUpdate(mid+1,end,point,val,index<<1|1);
	}
	t[index] = doit(t[index <<  1] , t[index << 1 | 1]);
}




signed main()
{
// 	#ifndef ONLINE_JUDGE
// 		freopen("./input.txt","r",stdin);
// 		freopen("./output.txt","w",stdout);
// 	#endif
	ios::sync_with_stdio(false); cin.tie(nullptr);
	cin>>n>>m;
	build(0,n-1);
	for(int i=1; i<=m; i++){
		int q; cin>>q;
		int x,y; cin>>x>>y;
		if(q==1){
			cout<<pQuery(0,n-1,x-1,y-1,1); br;
		}
		else{
			pUpdate(0,n-1,x-1,y,1);
		}
	}	

}


Measured memory_bytes: 5168
// #include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

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

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

using namespace std;

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

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

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

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

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

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

int n, m, x;
vector<int> c;
vector<vector<int>> a;
ll ans = INF;
vector<int> buy(20, 0);
void dfs(int now){
  if (now == n){
vector<ll> rikai(20, 0);
    ll val = 0;
    REP(i, n){
      REP(j, m){
        if (buy[i+1] == 1){
          rikai[j] += a[i][j];
        }
      }
    }
    /*
    bool flag = true;
    REP(i, m){
      if (rikai[i] < x) flag = false;
    }
    */
    ll min_val = INF;
    REP(i, m){
      min_val = min(min_val, rikai[i]);
    }
    if (min_val >= x){
      REP(i, n){
        val += c[i] * buy[i+1];
      }
    ans = min(ans, val);
    }
  }
  else{
    for (int i=0; i<=1;i++){
      buy[now+1] = i;
      dfs(now+1);
    }
  }
}


int main(void){
  ios::sync_with_stdio(false);
  cin >> n >> m >> x;
  c = vector<int>(n+10);
  a = vector<vector<int>> (n+10, vector<int>(m+10));
  REP(i, n){
    cin >> c[i];
    REP(j, m){
      cin >> a[i][j];
    }
  }
  dfs(0);
  if (ans != INF) cout << ans << endl;
  else cout << -1 << endl;
  return 0;
}



Measured memory_bytes: 3668
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=1;i<=(n);++i)
#define ALL(v) v.begin(), v.end()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

class B0Or1Swap {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    in>>N;
	    vector<int> P(N);
	    REP(i, N)in>>P[i];
	    int cnt = 0;
	    REP(i, N){
	        for(int j=i+1;j<N;j++) {
                swap(P[i], P[j]);
                bool ok = true;
                for (int k = 1; k < N; k++) if (P[k - 1] > P[k]) ok = false;
                if(ok){out<<"YES"<<endl; return;}
                swap(P[i], P[j]);
            }
	    }
        bool ok = true;
	    for(int i=1;i<N;i++) if(P[i-1]>P[i]) ok = false;
	    if(ok){out<<"YES"<<endl;}
	    else out<<"NO"<<endl;
	}
};


int main() {
	B0Or1Swap solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
num = input()
li = input().split()
judge = True

for li_num in li :
 if int(li_num) % 2 == 0:
  if not(int(li_num) % 3 == 0) and not(int(li_num) % 5 == 0) :
   judge = False
   break

if judge :
  print("APPROVED")
else :
  print("DENIED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define FOR(i, start, stop) for (int i = start; i < stop; i++)
using namespace std;

ll N,Q;
ll a;
vector< vector<ll> > G(200005);
vector<bool> B(200005,1);
vector<ll> cost(200005);
vector<ll> ans(200005);
stack<ll> s;
 
void dfs(){
    if(s.empty()==false){
        a=s.top();
        if(G[a].size()==0) s.pop();
        else{
            if(B[G[a].back()]){
                s.push(G[a].back());
                B[G[a].back()]=false;
                ans[G[a].back()]=cost[G[a].back()]+ans[a];
                G[a].pop_back();
            }else if(G[a].size()>1){
                swap(G[a].back(),G[a].front());
            }else{
                G[a].pop_back();
            }
        }
        dfs();
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>Q;
    ll aa,bb;
    for(int i=0;i<N-1;++i){
        aa,bb;cin>>aa>>bb;aa--;bb--;
        G[aa].push_back(bb);
        G[bb].push_back(aa);
    }

    ll p,x;
    vector<bool> cB(200005,0);
    for(int i=0;i<Q;++i){
        ll p,x;cin>>p>>x;p--;
        if(!(cB[p])){
            cost[p]=x;
            cB[p]=true;
        }else cost[p]+=x;
    }

    s.push(0);
    B[0]=false;
    ans[0]=cost[0];
    dfs();

    FOR(i,0,N){
        cout<<ans[i]<<' ';
    }

}

Measured memory_bytes: 18384
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	long long int A,B,V,W,T;
	bool res=false;
	cin>>A>>V>>B>>W>>T;
	if(A<B){
		res=(A+V*T)>=(B+W*T);
	}else if(A==B){
		res=true;
	}else if(B<A){
		res=(B-W*T)>=(A-V*T);
	}
	if(res)cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, u, v;
long long ans;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		ans += i * 1LL * (n - i + 1);
	}
	for (int i = 0; i < n - 1; i++) {
		cin >> u >> v;
		if (u > v) swap(u, v);
		ans -= u * 1LL * (n - v + 1);
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3656
N = int(input())
a = list(map(int, input().split()))
rate = [399+(400)*i for i in range(8)]
rate = rate + [4801]
len_ = len(rate)
count = [0] * len_
for i in range(N):
    for j in range(len_):
        if a[i] <= rate[j]:
            count[j] += 1
            break
colors = 0
for i in range(len_-1):
    if count[i] > 0:
        colors += 1
if colors == 0:
    print(1, count[-1])
else:
    print(colors, colors+count[-1])


Measured memory_bytes: 3064
n,m=map(int,input().split())
a=list(map(int,input().split()))

a=sorted(a)
b=[]

for x in range(m-1):
  c=a[x+1]-a[x]
  b.append(c)
  

b=sorted(b)
if n>=m:
  print(0)
  
else:
  nn=m-n
  ans=0
  for u in range(nn):
    ans+=b[u]
    
  print(ans)

Measured memory_bytes: 20488
#define George_Plover
#include <queue>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define MAXN
#define MAXM
#define INF
using namespace std;
int n,m;
int a[10];
int main()
{
    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+4);
    
    if(a[1]==a[2]&&a[2]!=a[3])
    {
        printf("Yes\n");
        return 0;
    }
    if(a[2]==a[3]&&a[2]!=a[1])
    {
        printf("Yes\n");
        return 0;
    }
    cout<<"No"<<endl;
    
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> wf(n);
    for(int i = 0; i < n; i++){
        if(s[i] == 'W') wf[i]++;
    }
    for(int i = 0; i < n - 1; i++){
        wf[i+1] += wf[i];
    }
    vector<int> eb(n);
    for(int i = n - 1; i >= 0; i--){
        if(s[i] == 'E') eb[i]++;
    }
    for(int i = n - 1; i > 0; i--){
        eb[i-1] += eb[i];
    }
    int ans = eb[1];
    for(int i = 1; i < n - 1; i++){
        ans = min(ans, wf[i-1] + eb[i+1]);
    }
    ans = min(ans, wf[n-2]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
using namespace std;
int n;
int a, b, c, d;
int main(void) {
	string s; cin >> s;
	a = s[0] - '0';
	b = s[1] - '0';
	c = s[2] - '0';
	d = s[3] - '0';
	char op1, op2, op3;
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 2; ++j) {
			for (int k = 0; k < 2; ++k) {
				int sum = a;
				sum += i == 0 ? b : -b;
				sum += j == 0 ? c : -c;
				sum += k == 0 ? d : -d;
				if (sum == 7) {
					op1 = i == 0 ? '+' : '-';
					op2 = j == 0 ? '+' : '-';
					op3 = k == 0 ? '+' : '-';
				}
			}
		}
	}
	printf("%d%c%d%c%d%c%d=7", a, op1, b, op2, c, op3, d);
}

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

int main()
{
    //freopen("test.in","r",stdin);
    //freopen("test.ok","w",stdout);
    int64_t a,b,c,x=0;
    cin >> a >> b >> c;
    if (a==b) x++;
    if (a==c) x++;
    if (b==c) x++;
    if (x==1) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
from collections import deque

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

now = deque(a[0:k])
next = deque(a[k:])

for i in range(n-k):
    if now[0]<next[0]:
        print('Yes')
    else:
        print('No')
    now.append(next[0])
    now.popleft()
    next.popleft()

Measured memory_bytes: 32512
import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int m = s.nextInt();
		int abeck[][] = new int[n][m];
		int bbeck[] = new int[m];
		int ancebeck[] = new int[n];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				abeck[i][j] = s.nextInt();
			}
		}
		for(int i = 0; i < m ; i++){
			bbeck[i] = s.nextInt();
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				ancebeck[i] += abeck[i][j] * bbeck[j];
			}
			System.out.println(ancebeck[i]);
		}
		
	}

	public static void main(String[] args) {
		/* 
		 * Main x;
		 * x = new Main();
		 * x.run();
		 * ??¨????????????
		 */
		new Main().run();
		
	}
}

Measured memory_bytes: 40788
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>

using namespace std;

int main() {
    int a,b,c;
    cin >>a>>b>>c;
    if(a<b && b<c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://msdn.microsoft.com/library/3bstk3k5.aspx
//   http://www.cplusplus.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   http://www.boost.org/doc/



Measured memory_bytes: 3100
S = input()

def unique_list(seq):
    seen = set()
    seen_add = seen.add
    return [x for x in seq if x not in seen and not seen_add(x)]


def solve():
    ul = unique_list(S)
    for w in ul:
        if not S.count(w) % 2 == 0:
            return "No"

    return "Yes"


res = solve()
print(res)


Measured memory_bytes: 2940
def isok(x):
    res=0
    for i in range(n):
        res+=max(a[i]-x//f[i],0)
        if res>k:
            return False
    if res>k:
        return False
    else:
        return True

n,k=map(int,input().split())
a=sorted(map(int,input().split()))
f=sorted(map(int,input().split()),reverse=True)

ng,ok=-1,10**18
while(ok-ng>1):
    mid=(ok+ng)//2
    if isok(mid):
        ok=mid
    else:
        ng=mid
print(ok)

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  cout << (n - 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long[64] t;
    string s = sread();
    foreach (c; s)
    {
        t[c - 'a']++;
    }
    writeln(t.reduce!((a, b) => (a & 1) | (b & 1)) == 0 ? "Yes" : "No");
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<bitset>
using namespace std;

const int MAX = 8000;
const char FORWARD = 'F';
const char TURN = 'T';

int main() {
	string s;
	int x, y;
	cin >> s >> x >> y;
	
	const char *S = s.c_str();
	
	for (;*S == FORWARD;++ S) -- x; // 最初の文字数だけxを減らす
	x = x < 0 ? -x : x;
	y = y < 0 ? -y : y;
	
	bitset<MAX> dpX(1), dpY(1); // 部分和問題はdpで解けるよ
	int xSum = 0, ySum = 0;
	
	for (++ S;*S != '\0';++ S) {
		int xGo = 0, yGo = 0; // 連続した移動の長さ
		for (;*S == FORWARD;++ S) ++ yGo; // y軸方向
		dpY |= dpY << yGo;
		ySum += yGo;
		
		if (*S == '\0') break;
		for (++ S;*S == FORWARD;++ S) ++ xGo; // x軸方向
		dpX |= dpX << xGo;
		xSum += xGo;
	}
	
	if (xSum >= x && (xSum - x & 1) == 0 && dpX[xSum - x >> 1] && ySum >= y && (ySum - y & 1) == 0 && dpY[ySum - y >> 1]) cout << "Yes"; // 例えば左右に合計100マス動けるとして、目的地が20なら丁度60動けるような部分和があれば移動可能、と考えるよ
	else cout << "No";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、x方向とy方向はそれぞれ独立に求めることができる
最初に、Tが出てくるまで自分を動かしてしまう
そうすると、残りはどちらの方向にも動けるので、左右か上下ということさえ分かっていれば左と右および上と下の区別をつける必要はない
この時、部分和問題を解けば答えが分かる
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i=0; i<(int64_t)(n); i++)
#define rep2(i, n, m) for (int64_t i=(int64_t)(n); i<=(int64_t)(m); i++)
#define all(v) v.begin(), v.end()
//c
int main(){
  
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<int> A(Q), B(Q), C(Q), D(Q);
  rep(i, Q) cin >> A[i] >> B[i] >> C[i] >> D[i];
  
  int ans = 0;
  int a[11] = {};
  
  rep2(a1, 1, M){
    a[1] = a1;
    rep2(a2, a1, M){
      a[2] = a2;
      rep2(a3, a2, M){
        a[3] = a3;
        rep2(a4, a3, M){
          a[4] = a4;
          rep2(a5, a4, M){
            a[5] = a5;
            rep2(a6, a5, M){
              a[6] = a6;
              rep2(a7, a6, M){
                a[7] = a7;
                rep2(a8, a7, M){
                  a[8] = a8;
                  rep2(a9, a8, M){
                    a[9] = a9;
                    rep2(a10, a9, M){
                      a[10] = a10;
                      int x = 0;
                      rep(i, Q) if(a[B[i]] - a[A[i]] == C[i]) x += D[i];
                      if(x > ans) ans = x;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  
  cout << ans << endl;
  
}

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

int n,counter=0;

vector<int>adj[10];

bool Check(int n,int pos)
{
    return (n & (1<<pos));
}
int Set(int n,int pos)
{
    return (n | (1<<pos));
}

bool yo(int mask)
{
    int flag=0;
    for(int i=0;i<n;i++)
    {
        if(!Check(mask,i))flag++;
    }
    if(flag==0)return true;
    else return false;
}

void f(int mask,int pos)
{
  //  cout<<mask<<endl;
   if(yo(mask))
    {
        counter++;
        return ;
    }


    for(int i=0;i<adj[pos].size();i++)
    {
        if(!Check(mask,adj[pos][i]))
        {
            f(Set(mask,adj[pos][i]),adj[pos][i]);
        }
    }

}

int main()
{
    int m;
    cin>>n>>m;
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        adj[a-1].push_back(b-1);
        adj[b-1].push_back(a-1);
    }
    f(1,0);
    cout<<counter<<endl;


}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long A = (long)Integer.parseInt(sc.next());
        long B = (long)Integer.parseInt(sc.next());
        long C = A * B;
        if(B > A){
            long tmp = B;
            B = A;
            A = tmp;
        }
        long tmp2 = 0;
        while((tmp2 = A % B) != 0){
            A = B;
            B = tmp2;
        }
        long ans = C / B;
        System.out.println(ans); 
    }

}

Measured memory_bytes: 23252
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin>>n;
  if(n==1) cout<<"1.000000000";
  else if(n%2==0) cout<<"0.5000000000";
  else{
    double ans;
    ans=(double)((n+1)/2)/n;
    printf("%.10f",ans);
  }
  return 0;
}

Measured memory_bytes: 256