akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll k,x;
cin>>k>>x;
for(int i=x-k+1;i<=x+k-1;i++){
    cout<<i<<" ";
}
}










Measured memory_bytes: 256
open Printf
open Scanf

let solve k =
  let v = [|1; 1; 1; 2; 1; 2; 1; 5; 2; 2; 1; 5; 1; 2; 1; 14; 1; 5; 1; 5; 2; 2; 1; 15; 2; 2; 5; 4; 1; 4; 1; 51|]
  in v.(k - 1)

let () =
  scanf "%d " solve |> printf "%d\n"


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

const double PI=acos(-1.0);

int main() {
    ll a, b, x;
    cin >> a >> b >> x;

    ll fb = b / x + 1;
    ll fa = (a == 0 ? 0 : (a - 1) / x + 1);

    cout << fb - fa << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const long long INF = (1 << 30);
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n, k;
  cin >> n >> k;

  ll ans = 0;
  for(ll i = k; i <= n+1; i++){
    ans = (ans +  i*(2*n-i+1)/2 - i*(i-1)/2 + 1) % mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
import itertools
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = list(itertools.chain.from_iterable([a1, a2, a3]))

n = int(input())
b = [int(input()) for _ in range(n)]

for i in b:
    a = [x if x != i else 0 for x in a]

if a[0] == 0 and a[1] == 0 and a[2] == 0:
    print("Yes")
elif a[3] == 0 and a[4] == 0 and a[5] == 0:
    print("Yes")
elif a[6] == 0 and a[7] == 0 and a[8] == 0:
    print("Yes")
elif a[0] == 0 and a[3] == 0 and a[6] == 0:
    print("Yes")
elif a[1] == 0 and a[4] == 0 and a[7] == 0:
    print("Yes")
elif a[2] == 0 and a[5] == 0 and a[8] == 0:
    print("Yes")
elif a[0] == 0 and a[4] == 0 and a[8] == 0:
    print("Yes")
elif a[2] == 0 and a[4] == 0 and a[6] == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9120
#include <stdio.h>

int main()
{
  int n, m, s, a, b, c, d, e, sum;

  while (1){
    scanf("%d",&n);
    if (n == 0) break;

    m = 1000 - n;
    s = m /500;
    a = m % 500 / 100;
    b = m % 500 % 100 /50;
    c = m % 500 % 100 % 50 /10;
    d = m % 500 % 100 % 50 % 10 /5;
    e = m % 500 % 100 % 50 % 10 % 5 / 1;
    sum = s + a + b + c + d + e;

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

  }
  return 0;

}
   

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A; int B; int C; int D;
  cin>>A>>B>>C>>D;
  int X=0; int Y=0;
  while(A>0){
    X++;
   A-=D;
  }
  while(C>0){
    Y++;
    C-=B;
  }
  if(X>=Y)
    cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
    

Measured memory_bytes: 3636
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const s = input[0];

let result = 0;
for(const c of s) {
  switch(c) {
    case "+":
      result++;
      break;
    case "-":
      result--;
      break;
    default:
  }
}

console.log(result);



Measured memory_bytes: 7372
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		ArrayList<Pair2> atcoder = new ArrayList<Pair2>();

		for(int i=0; i<N; i++){
			Pair2 pair = new Pair2(false, 0);
			atcoder.add(pair);
		}
		int count=0;
		int error=0;
		for(int i=0; i<M; i++){
			int p = sc.nextInt();
			String ans = sc.next();
			if(atcoder.get(p-1).ac==false){
				if(ans.equals("AC")){
					atcoder.get(p-1).ac=true;
					count++;
					error += atcoder.get(p-1).wa;
				}else{
					atcoder.get(p-1).wa++;
				}
			}
		}
		System.out.println(count+" "+error);
    }
}

class Pair2 {
	public boolean ac;
	public int wa;

	Pair2(boolean ac, int wa){
		this.ac = ac;
		this.wa = wa;
	}
}

Measured memory_bytes: 62668
import math
n = int(input())
cnt = 0
for i in range(1, n+1, 2):
    divisor_num = 0
    for j in range(1, i+1):
        if i % j == 0:
            divisor_num += 1
    if divisor_num == 8:
        cnt += 1      
print(cnt)

Measured memory_bytes: 8920
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

int main(void){
	ll d, g;
	cin >> d >> g;
	g /= 100;
	Vec p(d), c(d);
	rep(i, d) cin >> p[i] >> c[i];
	rep(i, d) c[i] /= 100;

	Vec2<ll> dp(d + 1, Vec(g + 1, LINF));
	dp[0][0] = 0;
	rep(i, d){
		rep(j, g + 1) dp[i + 1][j] = dp[i][j];
		repn(k, p[i]){
			ll t = (i + 1) * k;
			if(k == p[i]) t += c[i];
			rep(j, g + 1){
				chmin(dp[i + 1][j], dp[i][max(0LL, j - t)] + k);
			}
		}
	}
	co(dp[d][g]);

	return 0;
}


Measured memory_bytes: 10112
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007



vector<pair<int, int> > getstep(string s)
{
	vector<pair<int, int> > v;
	int fnum = 0, tnum = 0;
	bool isf = true;
	for(int i = 0; i < s.length(); i++){
		if(s[i] == 'F'){
			if(isf){
				fnum++;
			} else {
				v.push_back(make_pair(fnum, tnum));
				fnum = 1;
				tnum = 0;
				isf = true;
			}
		} else {
			if(isf){
				isf = false;
				tnum++;
			} else {
				tnum++;
			}
		}
	}
	v.push_back(make_pair(fnum, tnum));
	return v;
}

set<int> getreach(vector<int> v)
{
	vector<set<int> > result(5010, set<int>());
	result[0].insert(0);
	for(int i = 0; i < v.size(); i++){
		for(auto j = result[i].begin(); j != result[i].end(); j++){
			result[i + 1].insert((*j) - v[i]);
			result[i + 1].insert((*j) + v[i]);
		}
	}
	return result[v.size()];
}

int main()
{
	string s;
	int x, y;
	cin >> s >> x >> y;
	int firststep = 0;
	while(firststep < s.length() && s[firststep] == 'F') firststep++;
	s = s.substr(firststep);
	// cout << s << endl;
	x -= firststep;
	vector<pair<int, int> > step = getstep(s);
	bool isx = true;
	vector<int> vx, vy;
	for(int i = 0; i < step.size(); i++){
		int f = step[i].first;
		int t = step[i].second;
		if(isx) vx.push_back(f);
		else vy.push_back(f);
		if(t % 2 == 1) isx = !isx;
	}
	// cout << "vx  : " << endl;
	// for(int i = 0; i < vx.size(); i++){
	// 	cout << vx[i] << endl;
	// }
	// cout << "vy ; " << endl;
	// for(int i = 0; i < vy.size(); i++){
	// 	cout << vy[i] << endl;
	// }
	set<int> x_canreach = getreach(vx);
	set<int> y_canreach = getreach(vy);
	if(x_canreach.find(x) != x_canreach.end() && y_canreach.find(y) != y_canreach.end()) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

using namespace std;

int main()
{
	vector<int> vc;
	for (int i = 0; i < 3; i++){
		int a;
		cin >> a;
		vc.push_back(a);
	}
	std::sort(vc.begin(), vc.end());

/*
	for(auto i: vc)
		cout << i << " ";
	cout << endl;
*/
	for (int i = 0; i < 2; i++)
		cout << vc[i] << " ";
	cout << vc[2] << endl;

	return 0;
}




Measured memory_bytes: 3156
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	ll n;cin >> n;
	vector<ll> ar1,ar2;
	
	for(ll i=0;i<n;i++){
		ll a,b;cin >> a >> b;
		ar1.emplace_back(b);
		ar2.emplace_back(a);
	}
	sort(ar1.begin(),ar1.end());
	sort(ar2.begin(),ar2.end());
	ll ans = 1;
	ans += ar1[n/2]-ar2[n/2];
	if(n%2 == 0) ans += ar1[n/2-1]-ar2[n/2-1];
	cout << ans << '\n';
}


Measured memory_bytes: 6696
N,A,B=map(int,input().split())
ans=0
for i in range(N+1):
    #numlst=list(str(i))
    #sumofdigit=sum(map(int,numlst))
    #if A<=sumofdigit<=B:
    if A<=sum(list(map(int,list(str(i)))))<=B:
        ans+=i
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a[3]; cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    cout << a[0] + a[1] << endl;

    return 0;
}

Measured memory_bytes: 256
// AOJ DSL_2_F Range Query - RMQ and RUQ
// 2019.3.27 bal4u

#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()  // 非負整数の入力
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n)  // 非負整数の表示（出力）
{
	int i;
	char ob[20];

	if (!n) pc('0');
	else {
		i = 0; while (n) ob[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(ob[i]);
	}
	pc('\n');
}

#define MAX (1<<17) //segment tree のサイズ。この実装では2べきにする必要がある
#define MIN(a, b)  ((a)<=(b)?(a):(b))
#define INF  0x7fffffff
int segVal[2*MAX], segLazy[2*MAX];

void lazy(int k)
{
	if (segLazy[k] != -1) {
		segVal[k] = segLazy[k];
		if (k < MAX - 1) {
			segLazy[(k << 1) + 1] = segLazy[k];
			segLazy[(k << 1) + 2] = segLazy[k];
		}
		segLazy[k] = -1;
	}
}

void update(int a, int b, int x, int k, int l, int r)
{
	if (r <= a || b <= l) {
		lazy(k);
		return;
	}
	if (a <= l && r <= b) {
		segLazy[k] = x;
		lazy(k);
		return;
	}
	lazy(k);
	update(a, b, x, (k << 1) + 1, l, (l + r) >> 1);
	update(a, b, x, (k << 1) + 2, (l + r) >> 1, r);
	segVal[k] = MIN(segVal[(k << 1) + 1], segVal[(k << 1) + 2]);
}

int getMin(int a, int b, int k, int l, int r)
{
	int le, ri;

	if (r <= a || b <= l) return INF;
	if (a <= l && r <= b) {
		lazy(k);
		return segVal[k];
	}
	lazy(k);
	le = getMin(a, b, (k<<1)+1, l, (l+r) >> 1);
	ri = getMin(a, b, (k<<1)+2, (l+r) >> 1, r);
	return MIN(le, ri);
}

int main()
{
	int N, Q, cmd, s, t, x;

	N = in(), Q = in();
	update(0, N, INF, 0, 0, N);
	while (Q--) {
		cmd = in(), s = in(), t = in() + 1;
		if (cmd == 0) {
			x = in();
			update(s, t, x, 0, 0, N);
		}
		else out(getMin(s, t, 0, 0, N));
	}
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;
const ll MOD=998244353;

string S;
int N;
void input(){
	cin>>S;
  	S.pb('W');
	N=sz(S);
}


int ans;
void solve(){
	char tmp=S[0];
	ans=1;
	rep1(i,N-1){
		if(S[i]!=tmp){
			ans++;
			tmp=S[i];
		}
		else{
			ans++;
			tmp='Z';
			i++;
		}
	}
  	ans--;
}

void output(){
	cout<<ans<<endl;
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 640
#pragma GCC optimize(2)
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)

const int maxn = 1 << 19;
int mx[maxn << 1], siz;

inline int Max(int a, int b) {return a < b ? b : a;}

void init(int n) {
	for (siz = 1; siz < n; siz <<= 1) ;
	memset(mx, 0, sizeof(mx));
}

void upd(int i, int a, int b, int x, int v) {
	if (a + 1 == b) {mx[i] = v; return ;}
	int m = (a + b) >> 1;
	if (x < m) upd(i << 1, a, m, x, v);
	else upd(i << 1 | 1, m, b, x, v);
	mx[i] = Max(mx[i << 1], mx[i << 1 | 1]);
}

int qry(int i, int a, int b, int v, vector <int> &vec) {
	if (a + 1 == b) {vec.pb(a); return mx[i];}
	int m = (a + b) >> 1;
	if (v < mx[i << 1]) v = qry(i << 1, a, m, v, vec);
	if (v < mx[i << 1 | 1]) v = qry(i << 1 | 1, m, b, v, vec);
	return v;
}

struct T {
	int val, fix;
	T *ls, *rs;
	T(int v) {val = v; fix = rand(); ls = rs = NULL;}
};

void split(T *x, int v, T *&a, T *&b) {
	if (!x) {a = b = NULL; return ;}
	if (x->val <= v) a = x, split(x->rs, v, a->rs, b);
	else b = x, split(x->ls, v, a, b->ls);
}

T *merge(T *a, T *b) {
	if (!a || !b) return a ? a : b;
	if (a->fix < b->fix) {a->rs = merge(a->rs, b); return a;}
	else {b->ls = merge(a, b->ls); return b;}
}

int mxv(T *x) {if (x) while (x->rs) x = x->rs; return x ? x->val : 0;}
void prt(T *x) {if (x) prt(x->ls), printf("%d ", x->val), prt(x->rs);}

int n, a[maxn];
T *rt[maxn];
int lst[maxn];

int main() {
//	freopen("in", "r", stdin);
	srand(19260817);
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i) scanf("%d", &a[i]);
	int m = 0;
	for (int i = 0; i < n; ++ i) {
		if (a[i] < a[i - 1]) m ++;
		rt[m] = merge(rt[m], new T(a[i])); lst[m] = a[i];
	}
	int n2 = n + m; init(n2);
	for (int i = 0; i <= m; ++ i) upd(1, 0, n2, i, lst[i]);
	int nw = n;
	for (int i = 0; i <= n; ++ i) {
		vector <int> vec;
		qry(1, 0, n2, 0, vec);
		++ m;
		int v = 0;
		for (int j = 0; j < vec.size(); ++ j) {
			T *a, *b;
			split(rt[vec[j]], v, a, b);
			rt[vec[j]] = a;
			upd(1, 0, n2, vec[j], mxv(a));
			v = mxv(b);
			rt[m] = merge(rt[m], b);
		}
		while (nw && mxv(rt[m]) == nw) {
			T *d; split(rt[m], nw - 1, rt[m], d); -- nw;
		}
		if (!nw) {printf("%d\n", i); break;}
		upd(1, 0, n2, m, mxv(rt[m]));
//		for (int j = 0; j <= m; ++ j)
//			prt(rt[j]); puts("");
	}
//	printf("%.3f\n", clock() * 1.0 / CLOCKS_PER_SEC);
	return 0;
}


Measured memory_bytes: 17536
A, B, K = map(int, input().split())

if A - K >= 0:
  res_A = A - K
  res_B = B
else:
  if B - abs(A - K) >= 0:
    res_A = 0
    res_B = B - abs(A - K)
  else:
    res_A = 0
    res_B = 0
print(res_A, res_B)

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

int main()
{
  int H, N;
  cin>>H>>N;
  
  if (H%N == 0){
  	cout<<(H / N)<<endl;
  }
  else{
  	cout<<(H / N) + 1<<endl;
  }
 
  
  return 0;
}

Measured memory_bytes: 256
N,X,Y = map(int,input().split())

ans = [0]*N

for i in range(1,N):
    for j in range(i+1,N+1):
        road = min(abs(j-i),abs(X-i)+abs(j-Y)+1,abs(Y-i)+abs(j-X)+1)
        ans[road] += 1

for i in range(1,N):
    print(ans[i])

Measured memory_bytes: 3444
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

void debug(vec &v) {
	int n = v.size();
	rep(i, n) {
		if (i > 0)cout << " ";
		cout << v[i];
	}
	cout << endl;
}

int n, m, t;

bool used[1 << 16];
bitset<50000> bt[50000];
bitset<50000> al;
bitset<50000> ori;
void solve1() {
	vector<int> a(m), b(m);
	rep(i, m) {
		cin >> a[i] >> b[i]; a[i]--; b[i]--;
	}
	string ans; ans.resize(m);
	rep(i, n)bt[i][i] = 1;
	per(j, m) {
		bt[a[j]] |= bt[b[j]];
		bt[b[j]] = bt[a[j]];
	}
	rep(i, n)al[i] = 1;
	rep(i, n) {
		al &= bt[i];
	}

	rep(i, n) {
		if (al[i]) {
			ori = 0; ori[i] = true;
			per(j, m) {
				if (ori[a[j]])ans[j] = '^';
				else ans[j] = 'v';
				ori[a[j]] = ori[b[j]] = ori[a[j]] | ori[b[j]];
			}
			cout << ans << endl; return;
		}
	}
	cout << -1 << endl;
}

vector<string> s3 = { "vv^","vv^","v^v" };
void solve2() {
	if (n == 2) {
		cout << -1 << endl; return;
	}
	vector<int> a(m), b(m);
	rep(i, m) {
		cin >> a[i] >> b[i]; a[i]--; b[i]--;
	}
	string ans; ans.resize(m);
	vector<int> ids;
	vector<int> t;
	rep(i, m) {
		if (b[i] > 2) {
			ans[i] = '^';
		}
		else {
			t.push_back(a[i] + b[i] - 1);
			ids.push_back(i);
		}
	}
	rep(i, ids.size()) {
		if (i + 1 < ids.size()) {
			ans[ids[i]] = s3[t[i]][t[i + 1]];
		}
		else {
			ans[ids[i]] = 'v';
		}
	}
	cout << ans << endl;
}

void solve() {
	cin >> n >> m >> t;
	if (t == 2)solve2();
	else solve1();
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(12);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 306688
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var s = o.a(1);
  var ans = 1, t = s[0];
  for(var i = 1; i < n; i++){
    if(s[i] !== t){
      t = s[i];
      ans++;
    }
  }
  return ans;
}

Measured memory_bytes: 21956
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{
	int total, N500;
	cin >> total >> N500;
	cout << (total % 500 <= N500 ? "Yes" : "No") << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '#') {
                bool flag = false;
                rep(k, 4) {
                    int ny = i + dy[k];
                    int nx = j + dx[k];
                    if (ny >= 0 && ny < h && nx >= 0 && nx < w && s[ny][nx] == '#')
                        flag = true;
                }
                if (!flag) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

int bitsum(int a) {//aの10進数での各桁の和を返す
	int ans = 0;
	string s = to_string(a);
	const int N = s.size();
	for (char x : s) ans += x - '0';
	return ans;
}

int main() {
	int ans = 0;
	makes(s);
	for (char x : s) {
		if (x == '+')++ans;
		else --ans;
	}
	say(ans);
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
x = 1
y = 1
for _ in range(N):
  t, a = map(int, input().split())
  if x * a != y * t:
    z = -(-(x + y) // (a + t))
    z = max(z, -(-x // t), -(-y // a))
    x = t * z
    y = a * z
  #print(x, y)
print(x + y)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    string U;
    cin >> S >> T >> A >> B >> U;
    if (S == U)
        cout << A - 1 << " " << B << endl;
    else
        cout << A << " " << B - 1 << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(void)
{
    int n, b, f, r, v;

    vector<vector<vector <int>>> buildings
        = vector<vector <vector <int>>>(4, vector<vector <int>>(3, vector<int>(10, 0)));

    cin >> n;
    while (cin >> b >> f >> r >> v && n--)
        buildings[b - 1][f - 1][r - 1] += v;

    for (int i = 0; i < 4; i++) {
        if (i)
            cout << string(20, '#') << endl;
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++)
                cout << " " << buildings[i][j][k];
            cout << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3108
#include <stdio.h>

int main()
{
    int n, k, a[101] = {0}, count = 0;

    scanf("%d %d", &n, &k);
    for (int i = 0; i < k; i++)
    {
        int d;
        scanf("%d", &d);
        for (int j = 0; j < d; j++)
        {
            int a_;
            scanf("%d", &a_);
            a[a_ - 1]++;
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (a[i] == 0)
            count++;
    }

    printf("%d", count);
    return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return x*f;
}
const int N=110;
char s[N],a[N]="keyence";
int pre[N],suf[N],n;
inline bool judge(){
	for (int i=0;i<=7;++i)
	if(pre[7-i]&&suf[n+1-i])
	return 1;
	return 0;
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	pre[0]=suf[n+1]=1;
	for (int i=1;i<=7;++i) if(pre[i-1]&&s[i]==a[i-1]) pre[i]=1;
	for (int i=n;i>n-7;--i) if(suf[i+1]&&s[i]==a[6-(n-i)]) suf[i]=1;
	if (judge()) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	int H,W;
	cin >> H >> W;
	
	vector<vector<char>> a(H+2, vector<char>(W+2));
	rep(i, H) {
		rep(j, W) {
			cin >> a[i][j];
		}
	}

	rep(i, W + 2) {
		cout << "#";
	}
	cout << "\n";

	rep(i, H) {
		rep(j, W + 2) {
			if (j == 0 || j == W + 1) {
				cout << "#";
			}
			else{
				cout << a[i][j-1];
			}
		}
		cout << endl;
	}

	rep(i, W + 2) {
		cout << "#";
	}
	cout << "\n";
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
ll se=0;
ll sume(vector<int> a,int n){

}
int main(){
    ll n,k;cin>>n>>k;
    ll ans;

      ans=(n/k)*(n/k)*(n/k);

    if(k%2==0){
        ans+=(n/(k/2)-n/k)*(n/(k/2)-n/k)*(n/(k/2)-n/k);
    }
    cout<<ans<<endl;
}

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

using namespace std;

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

	int n;
	vector<int> d;
	cin >> n;
	for( int i = 0; i < n; i++ )
	{
		int tmp;
		cin >> tmp;
		d.push_back(tmp);
	}
	bool check = true;
	int ju = d[0];
	for( int i = 1; i < n - 1; i++ )
	{
		if( i * 10 <= ju )ju = max(ju, i * 10 + d[i]);
	}
	if( ju < ( n - 1 ) * 10 )check = false;
	reverse(d.begin(), d.end());
	ju = d[0];
	for( int i = 1; i < n - 1; i++ )
	{
		if( i * 10 <= ju )ju = max(ju, i * 10 + d[i]);
	}
	if( ju < ( n - 1 ) * 10 || !check )cout << "no" << endl;
	else cout << "yes" << endl;

	return 0;
}



Measured memory_bytes: 5008
//LOL
//LOL
//LOL
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int n,c=0,ans=0,p=1e9;
int a[103];
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a[i];
		c+=a[i];
	}
	for (int i=0;i<n;i++){
		if (abs(a[i]*n-c)<p){
			ans=i;
			p=abs(a[i]*n-c);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <vector>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define in insert
#define er erase
#define fi first
#define se second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int) x.size()
using namespace std;
typedef vector <int> vi;
typedef vector <vector<int>> vii;
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
typedef long double ld;

const long double PI=3.141592653589793238462643383279502884;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main(){
    fast;
    ll n,i,j;
    string s0;
    cin>>s0;
    ll s=0,k=0;
    for (i=0;i<s0.length();i++){
        if (s0[i]=='W'){
            k++;
            s+=i;
        }
    }
    cout<<s-(k-1)*k/2;
    return 0;
}





Measured memory_bytes: 720
/*  -*- coding: utf-8 -*-
 *
 * 1370.cc: Hidden Anagrams
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 4000;
const int MAX_Q = MAX_N * (MAX_N + 1) / 2;
const int K = 26;
const int P0 = 3499;
const int P1 = 4703;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;
typedef vector<ll> vl;
typedef int vec[K];

/* global variables */

char sa[MAX_N + 4], sb[MAX_N + 4];
int ep0[MAX_N + 1], ep1[MAX_N + 1];
vl ahs[MAX_N + 1];
vec v;

/* subroutines */

inline int powmod(int a, int n) {  // a^n % MOD
  int pm = 1;
  while (n > 0) {
    if (n & 1) pm = (ll)pm * a % MOD;
    a = (ll)a * a % MOD;
    n >>= 1;
  }
  return pm;
}

inline ll calchash(vec as) {
  int h0 = 0, h1 = 0;
  for (int i = 0; i < K; i++) {
    h0 = (h0 + (ll)as[i] * ep0[i] % MOD) % MOD;
    h1 = (h1 + (ll)as[i] * ep1[i] % MOD) % MOD;
  }
  return ((ll)h0 << 32) | h1;
}

/* main */

int main() {
  ep0[0] = ep1[0] = 1;
  for (int j = 0; j < MAX_N; j++) {
    ep0[j + 1] = (ll)ep0[j] * P0 % MOD;
    ep1[j + 1] = (ll)ep1[j] * P1 % MOD;
  }

  scanf("%s%s", sa, sb);
  int n = strlen(sa), m = strlen(sb);
  int minnm = min(n, m);
  //printf("n=%d, m=%d\n", n, m);

  for (int l = 1; l <= minnm; l++) {
    memset(v, 0, sizeof(v));
    for (int i = 0; i < l - 1; i++) v[sa[i] - 'a']++;

    vl &ahl = ahs[l];
    for (int i = 0, j = l - 1; j < n; i++, j++) {
      v[sa[j] - 'a']++;
      ahl.push_back(calchash(v));
      v[sa[i] - 'a']--;
    }
    sort(ahl.begin(), ahl.end());
  }

  for (int l = minnm; l > 0; l--) {
    memset(v, 0, sizeof(v));
    for (int i = 0; i < l - 1; i++) v[sb[i] - 'a']++;

    vl &ahl = ahs[l];
    for (int i = 0, j = l - 1; j < m; i++, j++) {
      v[sb[j] - 'a']++;

      ll h = calchash(v);
      vl::iterator vit = lower_bound(ahl.begin(), ahl.end(), h);
      if (vit != ahl.end() && *vit == h) {
	printf("%d\n", l);
	return 0;
      }

      v[sb[i] - 'a']--;
    }
  }

  puts("0");
  return 0;
}



Measured memory_bytes: 77332
#include<stdio.h>

int main(){

  int a,b,c,d;

  scanf("%d %d %d %d", &a,&b,&c,&d);

while(a > 0){
  c-=b;
  if(c <= 0) break;
  a-=d;
}
if(a > 0) printf("Yes\n");
else printf("No\n");

  return 0;
}

Measured memory_bytes: 1660
//Array-Official House
//??¬????????\?±??????????

#include<stdio.h>

int main(void){
    int n;
    int b, f, r, v;
    int i, j, k, l;
    int field[5][4][11] = {0};
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &b);
        scanf("%d", &f);
        scanf("%d", &r);
        scanf("%d", &v);
        
        field[b][f][r] += v;
    }
    
    for(i = 1; i <= 4; i++){
        for(j = 1; j <= 3; j++){
            for(k = 1; k <= 10; k++){
                printf(" %d", field[i][j][k]);
            }
            putchar('\n');
        }
        if(i != 4){
            for(l = 0; l < 20; l++) putchar('#');
            putchar('\n');
        }
    }
    return 0;
}

Measured memory_bytes: 600
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

//0-indexed 
template<class T = int>
struct CumulativeSum1D
{
	bool builded;
	vector<T> data;
	CumulativeSum1D(int N) { builded = false; data.resize(N + 1, 0); }
	inline void add(int i, T x)
	{
		data[i + 1] = x;
		builded = false;
	}

	void build()
	{
		int n = data.size();
		for (int i = 1; i < n; i++) {
			data[i] += data[i - 1];
		}
		builded = true;
	}
	//0-indexed [l, r]
	inline T query(int l, int r) { assert(builded); return data[r + 1] - data[l]; }
};

int main(void) {
	int N;
	string S;
	cin >> N >> S;
	CumulativeSum1D<int> csW(N), csE(N);
	REP(i, N) {
		if (S[i] == 'W') {
			csW.add(i, 1);
			csE.add(i, 0);
		}
		else {
			csW.add(i, 0);
			csE.add(i, 1);
		}
	}
	csW.build();
	csE.build();
	int ans = N;
	REP(i, N) {
		int W = i == 0 ? 0 : csW.query(0, i - 1);
		int E = i == N - 1 ? 0 : csE.query(i + 1, N - 1);
		ans = min(ans, W + E);
	}
	cout << ans << endl;
}

Measured memory_bytes: 2964
#include<stdio.h>

int max(int a, int b){
    if(a>b){
        return a;
    }
    return b;
}

int main(){
    int n;
    scanf("%d", &n);
    int a[100000][3];
    for(int i=0;i<n;i++){
        scanf("%d %d %d", &a[i][0], &a[i][1], &a[i][2]);
    }
    int dp[100000][3];
    for(int i=0;i<3;i++){
        dp[n-1][i]=a[n-1][i];
    }
    for(int i=n-2;i>=0;i--){
        for(int j=0;j<3;j++){
            int x, y;
            if(j==0){
                x=1;
                y=2;
            }
            if(j==1){
                x=0;
                y=2;
            }
            if(j==2){
                x=0;
                y=1;
            }
            dp[i][j]=a[i][j]+max(dp[i+1][x], dp[i+1][y]);
        }
    }
    printf("%d", max(max(dp[0][0], dp[0][1]), dp[0][2]));
    return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  string answer = "CODEFESTIVAL2016";
  string problem;
  cin >> problem;
  int count = 0;
  for (int i = 0; i < 16; i++)
    if (answer[i] != problem[i])
      count++;
  cout << count <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <array>
#include <cmath>
#include <random>
#include <climits>
using namespace std;
using lint=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  if(n<1000) cout<<"ABC"<<endl;
  else cout<<"ABD"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x; cin >> x;
    if(400 <= x && x <= 599) cout << 8;
    else if(600 <= x && x <= 799) cout << 7;
    else if(800 <= x && x <= 999) cout << 6;
    else if(1000 <= x && x <= 1199) cout << 5;
    else if(1200 <= x && x <= 1399) cout << 4;
    else if(1400 <= x && x <= 1599) cout << 3;
    else if(1600 <= x && x <= 1799) cout << 2;
    else if(1800 <= x && x <= 1999) cout << 1;
    cout << endl;
    return 0;
}

Measured memory_bytes: 3648
s = input()
t = input()
slen, tlen = len(s), len(t)

dp = [[-1 for i in range(tlen + 1)] for j in range(slen + 1)]

for i in range(slen, -1, -1):
    for j in range(tlen, -1, -1):
        if i == slen or j == tlen:
            dp[i][j] = 0
        else:
            if s[i] == t[j]:
                dp[i][j] = 1 + dp[i + 1][j + 1]
            else:
                dp[i][j] = max(dp[i][j + 1], dp[i + 1][j])


ans = ""
i, j = 0, 0

while i < slen and j < tlen:
    if dp[i][j] == dp[i + 1][j]:
        i += 1
    elif dp[i][j] == dp[i][j + 1]:
        j += 1
    else:
        ans += s[i]
        i += 1
        j += 1

print(ans)


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int H,A;
    Scd2(H,A);

    printf ("%d\n", (H+A-1)/A );

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifndef _LOCAL_DEBUG
#define endl '\n'
#endif
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  static Scanner scan=new Scanner(System.in);
  public static void main(String[] args) {
    int n = scan.nextInt();

    int[] a = new int[n];
    int[] b = new int[n];
    int[] c = new int[n-1];
    for (int i = 0; i < n; ++i) {
      a[i] = scan.nextInt();
      --a[i];
    }
    for (int i = 0; i < n; ++i) {
      b[i] = scan.nextInt();
    }
    for (int i = 0; i < n-1; ++i) {
      c[i] = scan.nextInt();
    }

    int ans = b[a[0]];
    for (int i = 0; i < n-1; ++i) {
      if (a[i]+1 == a[i+1]) {
        ans += c[a[i]];
      }
      ans += b[a[i+1]];
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 23252
n, k = map(int, input().split())
N = [i%k for i in range(1,n+1)]
if k%2==0:
    print(pow(sum([1 for i in N if i==0]), 3)+pow(sum([1 for i in N if i==k//2]),3))
else:
    print(pow(sum([1 for i in N if i==0]), 3))

Measured memory_bytes: 15952
n =int(input())

num = list(map(int, input().split()))

box =[0]*n
sum=0
for i in reversed(range (n)):
  sum=0
  for j in (range(int(n/(i+1))-1)):
    sum +=box[i+(i+1)*(j+1)]
  box[i]=(sum+num[i])%2


ans = []
for i in range(n):
  if box[i]==1:
    ans.append(i+1)
print(len(ans))
ans=[str(a) for a in ans]
ans=" ".join(ans)
print(ans)

Measured memory_bytes: 19004
# ANSHUL GAUTAM
# IIIT-D

N = int(input())
S = input()

ans = 0

for i in range(1,N):
	curr = 0
	s = S[:i]
	r = S[i:]
	for j in range(97,123):
		char = chr(j)
		if(char in s and char in r):
			curr += 1
	ans = max(ans, curr)

print(ans)



Measured memory_bytes: 3060
#include <math.h>
#include <stdio.h>
int n, sqrtN;
long long ans, d;
char buf[8], out[20];
k;
i;
s;
X;
int main() {
    s = read(0, buf, 8);
    for(;;) {
        k = buf[i++];
        if(k < '0') break;
        n = n * 10 + k - '0';
    }
    const int sqrtN = sqrt(n);
    ans = -(long long)(sqrtN) * (sqrtN + 1) * (2 * sqrtN + 1) / 6;
    for(int i = 1; i <= sqrtN; ++i) {
        const int a = n / i;
        ans += ((long long)i * (i + a) * (a + 1 - i));
    }
    i = 20;
    do {
        out[--i] = ans % 10 + '0';
        ans /= 10;
    } while(ans);
    write(1, out + i, 20 - i);
}


Measured memory_bytes: 1792
let split s =
  Str.split (Str.regexp_string " ") s |> List.map (fun x -> float_of_string x);;

let rec read () =
  try let l = read_line () |> split |> Array.of_list in
      let (a, b) = (l.(2)-.l.(0), l.(3)-.l.(1)) and
          (c, d) = (l.(6)-.l.(4), l.(7)-.l.(5)) in
      if abs_float ((a*.c) +. (b*.d)) < 0.0000000001 then
        print_endline "YES"
      else
        print_endline "NO"
      ; read ()
  with End_of_file -> ();;

let () = read ();;

Measured memory_bytes: 2200
import java.util.Scanner;
public class Main {
    private static final int[] BASE = {1, 100, 10000};
    public static void main(String[] str) {
        Scanner scan = new Scanner(System.in);
        int D = scan.nextInt();
        int N = scan.nextInt();
        N = N == 100? 101: N;
        System.out.println(BASE[D] * N);
    }
}


Measured memory_bytes: 23380
s=input()
n=len(s)
index = -1
cut=[-1]
while True:
    index = s.find("LR", index + 1)
    if index == -1:
        break
    cut.append(index)
cut.append(len(s))

ans=[]
for i in range(len(cut)-1):
    t = s[cut[i]+1:cut[i+1]+1]
    rlposi = t.find("RL")
    num = [0]*len(t)
    nR=t.count("R")
    nL=t.count("L")
    if (nR+nL)%2==0:
        num[rlposi]   = (nR+nL)//2
        num[rlposi+1] = (nR+nL)//2
    elif nR%2==1:
        num[rlposi]   = (nR+nL+1)//2
        num[rlposi+1] = (nR+nL-1)//2
    else:
        num[rlposi]   = (nR+nL-1)//2
        num[rlposi+1] = (nR+nL+1)//2
    ans.extend(num)

print(*ans)

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int m;
    m = max({a,b,c});
    cout << a+b+c-m << endl;
}

Measured memory_bytes: 256