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

int main(){
  int h,w;
  cin>>h>>w;
  char a[1000][1000],b[1000][1000];
  for(int i=1;i<=h+2;i++){
    for(int j=1;j<=w+2;j++){
      b[i][j]='#';
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>a[i][j];
    }
  }
  for(int i=2;i<=h+1;i++){
    for(int j=2;j<=w+1;j++){
      b[i][j]=a[i-1][j-1];
    }
  }
  for(int i=1;i<=h+2;i++){
    for(int j=1;j<=w+2;j++){
      cout<<b[i][j];
    }
    cout<<endl;
  }
  cout<<endl;
}
    


Measured memory_bytes: 512
package main

import (
	"fmt"
	"math"
	"sort"
)

var N int

func main() {
	fmt.Scan(&N)

	xxx := make(SortBy, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&xxx[i].rest, &xxx[i].rank)
		xxx[i].i = i + 1
	}

	sort.Sort(xxx)
	for _, x := range xxx {
		fmt.Println(x.i)
	}
}

/*  ----------------------------------------  */

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type restaurant struct {
	rest string
	rank int
	i    int
}
type SortBy []restaurant

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].rest == a[j].rest {
		return a[i].rank > a[j].rank
	}
	return a[i].rest < a[j].rest
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int mod = 1e9+7;

int main() {


  string a, b, c;
  cin >> a >> b >> c;
  if( a[a.size()-1] == b[0] && b[b.size()-1] == c[0] ) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


// EOF


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <cctype>
#include <string>
using namespace std;

int main(){
	string st, buf;
	int m,h;
	while (1){
		cin >> st;
		if (st == "-")
			break;
		cin >> m;
		for (int i = 0; i < m; i++){
			cin >> h;
			buf = st.substr(h, st.length() - h);
			buf += st.substr(0, h);
			st = buf;
		}
		cout << st << endl;
	}
}

Measured memory_bytes: 1216
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
template <typename T> T max(T, T);
int gcd(int a, int b);

int main() {
    // source
    int n, a;
    cin >> n >> a;
    int x[n];
    rep(i, n) {
        int temp;
        cin >> temp;
        x[i] = temp - a;
    }

    int minus_sum = 0, plus_sum = 0;
    rep(i, n) {
        if (x[i] > 0) {
            plus_sum += x[i];
        } else {
            minus_sum += x[i];
        }
    }

    ll dp[n][plus_sum - minus_sum + 1] = {};

    dp[0][x[0] - minus_sum] = 1;
    dp[0][-minus_sum] += 1;

    repd(l0, 1, n) {
        rep(l1, plus_sum - minus_sum + 1) {
            if (0 <= l1 - x[l0] && l1 - x[l0] < plus_sum - minus_sum + 1) {
                dp[l0][l1] = dp[l0 - 1][l1] + dp[l0 - 1][l1 - x[l0]];
            } else {
                dp[l0][l1] = dp[l0 - 1][l1];
            }
        }
    }

    cout << dp[n - 1][-minus_sum] - 1 << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T max(T a, T b) {

    if (a > b) {
        return a;
    } else {
        return b;
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


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

int main() {
    string S;
    cin >> S;
    int cnt=0;
    for(int i=1;i<S.length();i++){
    	if(S[i]!=S[i-1]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384626433832795

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

vi CountingSort(vi a ,int k) {
	int n = a.size();
	vi b(n), c(k);
	rep(i,n) {
		c[a[i]]++;
	}
	for (int i =1; i < k; i++) {
		c[i] += c[i-1];
	}
	//cout << c << endl;
	for (int i = n - 1; i >= 0; i--) {
		//cout << "i=" << i << "  b[" << c[a[i]]-1 << "]="<<a[i] << endl;
		b[c[a[i]]-1] = a[i];
		c[a[i]]--;
	}
	return b;
}

int main() {
	int n,in;
	vi a;
	cin >> n;
	rep(i, n) {
		cin >> in;
		a.push_back(in);
	}
	vi b=CountingSort(a, *max_element(all(a))+1);
	cout << b << endl;
}


Measured memory_bytes: 43132
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

using State = tuple<int, int, int>;
using P = pair<double, State>;
using D = long double;

const D INF = 1e8;
const D eps = 1e-8;

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

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

    int h, w, k;
    cin >> h >> w >> k;

    int sy, sx, gy, gx;
    cin >> sy >> sx >> gy >> gx;
    --sy;
    --sx;
    --gy;
    --gx;

    vector<string> c(h);
    rep(i, h) cin >> c[i];

    auto OK = [&](int y, int x) {
        return 0 <= y && y < h && 0 <= x && x < w && c[y][x] == '.';
    };

    vector<vector<vector<D>>> dp(h, vector<vector<D>>(w, vector<D>(4, INF)));
    priority_queue<P, vector<P>, greater<P>> pq;
    rep(i, 4) {
        dp[sy][sx][i] = 0;
        pq.push({0, {sy, sx, i}});
    }

    while (!pq.empty()) {
        P now = pq.top();
        pq.pop();

        State s = now.se;
        int y = get<0>(s), x = get<1>(s), d = get<2>(s);
        D val = dp[y][x][d];
        if (now.fi - eps > val) continue;

        int ny = y + dy[d], nx = x + dx[d];
        if (OK(ny, nx)) {
            D ndp = val + 1.0 / k;
            if (dp[ny][nx][d] - eps > ndp) {
                dp[ny][nx][d] = ndp;
                pq.push({ndp, {ny, nx, d}});
            }
        }

        rep(i, 4) {
            D ndp = ceil(val - eps);
            if (dp[y][x][i] - eps > ndp) {
                dp[y][x][i] = ndp;
                pq.push({ndp, {y, x, i}});
            }
        }
    }

    D mn = INF;
    rep(i, 4) mn = min(mn, dp[gy][gx][i]);

    int ans = (int)(ceil(mn - eps) + eps);
    if (abs(mn - INF) < eps) ans = -1;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 207216
N, W = list(map(lambda x: int(x), input().split()))
w = []
v = []
for i in range(N):
  line = input().split()
  w.append(int(line[0]))
  v.append(int(line[1]))
  
inf = 10**10
M = sum(v)+1
dp = [ [0] + [inf]*(M-1) for i in range(N) ]
dp[0][v[0]] = w[0] #最初の行

lim = v[0]+1
for i in range(1, N):
  lim += v[i]
  for val in range(1, lim):
    if val-v[i]>=0:
      dp[i][val] = dp[i-1][val-v[i]] + w[i]
    dp[i][val] = min(dp[i][val], dp[i-1][val])
    
#許されるvの最大値を見つける
for val in reversed(range(M)):
  if dp[N-1][val]<=W:
    print(val)
    break


Measured memory_bytes: 135964
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
const int N=1e9+7;
#define int long long
#define double long double

int32_t main()
{
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
 IOS;
string s;
cin>>s;
int p=s.size();
if(s[p-1]!='s')
	cout<<s+'s';
else
	cout<<s+"es";











 	



  
 




  
return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,n;cin>>n;
  pair<string,int> r[n];
  map<int,int> p_i;
  for(i=0;i<n;i++){
    cin>>r[i].first>>r[i].second;r[i].second*=-1;
    p_i[r[i].second]=i+1;
  }
  sort(r,r+n);
  for(i=0;i<n;i++){cout<<p_i[r[i].second]<<endl;}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <time.h>
#include <iomanip>
#include <bitset>

using namespace std;

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int a[100005] = {};

signed main() {
    int n, m;
    string s;
    cin >> n >> m >> s;
    bool f = false;
    vector<int> v;

    for(int i = n; i > 0;) {
        int iitk = 1145141919;
        int hks = i - m;
        if(hks < 0) hks = 0;
        dep(j, i - 1, hks) {
            if(s[j] == '0') {
                iitk = j;
            }
        }
        v.pb(i - iitk);
        i = iitk;

        if(iitk == 0) {
            break;
        }
        if(iitk == 1145141919) {
            cout << -1 << endl;
            f = true;
            break;
        }
    }

    if(f) return 0;

    dep(i, v.size() - 1, 0) {
        cout << v[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1480
import sys
input = sys.stdin.readline

def main():
    N, K, Q = map(int, input().split())

    scores = [K - Q] * N

    for _ in range(Q):
        A = int(input()) - 1
        scores[A] += 1

    for s in scores:
        if s > 0:
            print('Yes')
        else:
            print('No')


if __name__ == "__main__":
    main()


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

public class Main {

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();
		String strArray[] = str.split(" ", 0);
		int num[] = new int[strArray.length];

		for(int i=0; i<strArray.length; i++){
			num[i] = Integer.parseInt(strArray[i]);
		}

		if(num[0]<num[1] && num[1]<num[2])
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 17056
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 


int main() {
	int a,b; cin >> a >> b;
  if (a > 0 && b > 0) cout << "Positive" << endl;
  if (a < 0 && b < 0) {
    if ((b - a + 1)%2 == 0) cout << "Positive" << endl;
    else cout << "Negative" << endl;
  }
  if (a < 0 && b > 0) cout << "Zero" << endl;
	return 0;
}



Measured memory_bytes: 256
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln endl
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define dbg2(x,y) cerr<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it<<ln;} cerr<<endl
#define dbgstlp32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cerr<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inp freopen("input.txt", "r", stdin)
#define outp freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const ll MOD = 1e9+7, LIM = 1e5+5;
const ld EPS = 1e-9;

int main(){
	fastio;
	int n,k;
	cin>>n>>k;
	ll a[n];
	forn(i,n) cin>>a[i];
	ll dp[n][k+1];
	ll add[n][k+1];
	forn(i,n){
		forn(j,k+1){
			dp[i][j]=0;
			add[i][j]=0;
		} 
	}	
	forn(j,a[0]+1){
		dp[0][j]=1;
		add[0][j]=j+1;
	}
	forsn(j,a[0]+1,k+1) add[0][j]=a[0]+1;
	forsn(i,1,n){
		forn(j,k+1){
			if(a[i]>=j) dp[i][j] = add[i-1][j];
			else dp[i][j] = (MOD+add[i-1][j]-add[i-1][max(0LL,j-1-a[i])])%MOD;
		}
		forn(j,k+1){
			if(j==0) add[i][j]=dp[i][j];
			else add[i][j]=(add[i][j-1]+dp[i][j])%MOD;
			//cout<<i<<" "<<j<<" "<<dp[i][j]<<" "<<add[i][j]<<ln;
		}
	}
	cout<<dp[n-1][k]<<ln;
	return 0;
}

Measured memory_bytes: 156544
#include<bits/stdc++.h>
using namespace std;
int mod= 1e9 +7;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  for(int i=0; ; i++)
  {
  	if(i%2==0)
  	{
  		c-=b;
  		if(c<=0)
  		{
  			cout<<"Yes";
  			return 0;
		  }
	  }
	  else{
	  	a-=d;
  		if(a<=0)
  		{
  			cout<<"No";
  			return 0;
		  }
	  }
  }
}

Measured memory_bytes: 3632
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
ll powmod(ll a, ll b) {
    ll res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

void max_self(ll& a, ll b) {
    a = max(a, b);
}
int main() {
    int n = nxt();
    int base = 1;
    while (base <= n) {
        base *= 2;
    }
    vector<ll> tree(2 * base);
    VI h(n), a(n);
    generate(all(h), nxt);
    generate(all(a), nxt);
    vector<ll> dp(n + 1);
    // dp[i] - the max possible beauty so far if last take flower has height i
    REP(flower, n) {
        // max dp[i] for i in [0, h[flower]-1]
        int x = h[flower] + base;
        ll best = 0;
        while (x > 1) {
            if (x % 2 == 1) max_self(best, tree[x - 1]);
            x /= 2;
        }
        dp[h[flower]] = best + a[flower];
        for (int i = base + h[flower]; i >= 1; i /= 2) {
            max_self(tree[i], dp[h[flower]]);
        }
        // for (int i = 0; i < h[flower]; i++) {
        //     max_self(dp[h[flower]], dp[i] + a[flower]);
        // }
    }
    ll answer = 0;
    REP(i, n + 1)
    max_self(answer, dp[i]);
    printf("%lld\n", answer);
    return 0;
}


Measured memory_bytes: 10408
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)


int N;
vector<vector<int>> nex;
string S;
int LOG_MAX = 20; // floor(log(100000)/log(2)) よりちょいでかい 3つくらい

// 前処理 O(NlogN)
void before(){
    
    // 1回操作した時の座標を取得
    rep(i,N){
        if(S[i] == 'R')nex[0][i] = i+1;
        else nex[0][i] = i-1;
    }

    // ダブリングの前処理
    rep(k,LOG_MAX) rep(i,N){    
        if(nex[k][i] == -1)nex[k+1][i] = -1;  // 今回はいらなかったこれ
        else nex[k+1][i] = nex[k][nex[k][i]];
    }

    return;
}

// p番目の子どもの「Q回移動後の地点」を求める O(logN)
int move(int p,int q){
    for(int k = LOG_MAX -1;k >= 0;--k){
        if(p == -1)break;
        if(q >> k & 1)p = nex[k][p];
    }
    return p;
}


int main(){
    cin >> S;
    N = S.size();
    nex.resize(LOG_MAX + 1,vector<int>(N));

    // 前処理
    before();

    // 移動
    vector<int> ans(N);
    rep(i,N){
        int tmp = move(i,100000);
        ans[tmp]++;
    }

    // 出力
    rep(i,N)cout << ans[i] << " ";

}


Measured memory_bytes: 9336
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
num = 0
temp = abs(T-H[0]*0.006-A)
for i in range(N):
    if abs(T-H[i]*0.006-A) < temp:
        num = i
        temp = abs(T-H[i]*0.006-A)
print(num+1)

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

int main(){
    int flag=1;
    int a,b;
    int ans=0;

    cin >>a>>b;
    
    if(b >= a)cout << a << endl;
    else cout << a-1 << endl;

   // cout << ans <<endl;
    //cout <<fixed<<setprecision(16)<< ans <<endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

int LR[510][510];
int c[510][510];

int main() {
    int N, M, Q; cin >> N >> M >> Q;
    for (int i=0; i<M;i++){
        int L, R;
        cin >> L >> R;
        LR[L][R]++;
    }
    for (int i=0; i<=N;i++){
        for (int j=0; j<=N;j++){
            if(i==0||j==0) c[i][j]=0;
            else if (j==1) c[i][j]=LR[i][j];
            else c[i][j]=c[i][j-1]+LR[i][j];
        }
    }
    for (int i=0; i<Q;i++){
        int p,q;
        cin >>p >>q;
        int ans=0;
        for (int j=p; j<=q;j++){
            ans+=c[j][q]-c[j][p-1];
        }
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 2944
#include<stdio.h>
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
int main(){
  int n,m,x,y;
  int t;
  scanf("%d%d%d%d",&n,&m,&x,&y);
  for(int i=0;i<n;i++){
    scanf("%d",&t);
    x=max(x,t);
  }
  for(int i=0;i<m;i++){
    scanf("%d",&t);
    y=min(y,t);
  }
  if(x<y) printf("No ");
  printf("War");
  return 0;
}

Measured memory_bytes: 128
import math
x=int(input())
if x==1:
  print(1)
  exit()
  
ans = 0
for i in range(2,math.ceil(x**(0.5))):
  j=2
  tmp = i**j
  while tmp<=x:
    ans = max(ans, tmp)
    j+=1
    tmp = i**j
print(ans)

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

struct point{
	int x,y;
};

int main() {
	int N, M; cin >> N >> M;
	vector<point> stu(N), che(M);
	for( point &k : stu )cin >> k.x >> k.y;
	for( point &k : che )cin >> k.x >> k.y;
	
	int distant = 500000000, ans;
	for( int i = 0; i < N; i++ ){
		for( int j = M - 1; j >= 0; j-- ){
			if((abs(stu[i].x - che[j].x) + abs(stu[i].y - che[j].y)) <= distant){
				ans = j + 1;
				distant = abs(stu[i].x - che[j].x) + abs(stu[i].y - che[j].y);
			}
		}
		distant = 500000000;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int h,r;
    cin>>h>>r;
    if(h+r<0){
      cout<<-1<<endl;
    }
    if(h+r==0){
      cout<<0<<endl;
    }
    if(h+r>0){
      cout<<1<<endl;
    }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007
#define NINF -1e17

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n){
    cin >> s.at(i);
    sort(s.at(i).begin(),s.at(i).end());
  }
  sort(s.begin(),s.end());
  string str = "&";
  long cnt = 1;
  long ans = 0;
  rep(i,n+1){
    if(i == n){
      ans += (cnt-1)*cnt/2;
      break;
    }
    if(s.at(i) == str) cnt++;
    else{
      ans += (cnt-1)*cnt/2;
      cnt = 1;
    }
    str = s.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 7296
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
map<int,bool> F;
int main()
{
	int a,b,k;
	scanf("%d%d%d",&a,&b,&k);
	for(int i=0;i<k;i++)
	{
		if(a+i>b) break;
		printf("%d\n",a+i),F[a+i]=true;
	}
	for(int i=k-1;i>=0;i--)
	{
		if(F[b-i] || b-i<a) continue;
		printf("%d\n",b-i);
	}
	return 0;
}
//

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

using namespace std;
using ll = long long;
const int INF = 1e9 + 7;





int n;
vector<int> a;
vector<vector<int>> hen;
vector<int> ans;

void dfs(int v, int par, vector<int>& dp) {
    auto itr = lower_bound(dp.begin(), dp.end(), a[v]);
    int past = *itr;
    *itr = a[v];
    ans[v] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
    for(auto i : hen[v]) {
        if(i == par)continue;
        dfs(i, v, dp);
    }
    dp[itr - dp.begin()] = past;
}


int main()
{
    cin >> n;
    a.resize(n);
    hen.resize(n);
    ans.resize(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    for(int i = 0; i < n - 1; i++) {
        int s, t; cin >> s >> t; s-- ,t--;
        hen[s].push_back(t); hen[t].push_back(s);
    }
    vector<int> tmp(n + 1, INF);
    dfs(0, -1, tmp);
    for(auto i : ans)cout << i << endl;


}


Measured memory_bytes: 30920
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  while(1){
    int n,m,c=0; cin>>n>>m;
    if(n==0 && m==0) break;
    rep(i,1,n+1) rep(j,i+1,n+1) rep(k,j+1,n+1) if(i+j+k==m) if(i<j && j<k){
      c++;
    }
    co(c);
  }
  
    
  return 0;
}


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

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

  int l = 0;
  int r = 1e4;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    map<string, int> m;
    bool ok = false;
    rep(i, N) {
      string x = S.substr(i, mid);
      if (m.count(x)) {
        if (m.at(x) + mid <= i) {
          ok = true;
          break;
        }
      } else {
        m[x] = i;
      }
    }
    if (ok) {
      l = mid;
    } else {
      r = mid;
    }
  }
  cout << l << endl;
  return 0;
}

Measured memory_bytes: 16384
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <time.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n)
#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);

//---------------------------------------------------------------------------------------------//
int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

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

}

Measured memory_bytes: 256
import math

l, r = map(int, input().split())

ls = l % 2019
rs = r % 2019

dif = r // 2019 - l // 2019

#print("dif = {}".format(dif))

if (dif != 0):
    print(0)
elif (r - l == 1):
    print(ls*rs % 2019)
else:
    mini = []
    for i in range(ls, rs):
        mini.append(min(i * j % 2019 for j in range(ls + 1, rs+1)))
    print(min(mini))


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

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

constexpr int SIZE = 'z' - 'a' + 1;
std::vector<int> A(SIZE, 0);
int main(void){
    char c;
    while(scanf("%c", &c) != EOF){
        if('a' <= c and c <= 'z') A[c - 'a']++;
        else if('A' <= c and c <= 'Z') A[c - 'A']++;
    }
    rep(i, SIZE) printf("%c : %d\n", 'a' + i, A[i]);
    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

string L;
int constexpr N = 100009, MOD = 1000000007;
vector<int> p3(N);

int go(int i) {
    if(i == (int) L.size())
        return 1;
    
    int ret = 0;
    if(L[i] == '1') {
        ret = 2ll * go(i + 1) % MOD + p3[(int) L.size() - i - 1];
    }
    if(L[i] == '0') {
        ret = go(i + 1);
    }
    if(ret >= MOD)
        ret -= MOD;
    return ret;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> L;
    
    p3[0] = 1;
    for(int i = 1; i < N; ++i)
        p3[i] = 3ll * p3[i - 1] % MOD;
    cout << go(0) << '\n';
}

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

int main(void) {
    string w;cin>>w;
    map<char, int> mp;
    for (int i = 0; i < w.size(); i++) {
        char W = w[i];
        if (mp.find(W) != mp.end()) mp[W] += 1;
        else mp[W] = 1;
    }
    for (map<char, int>::iterator it = mp.begin(); it != mp.end(); ++it) {
        if (it->second % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

ll comb(ll a,ll b){
    static ll c[51][51] = {};

    if(c[a][b]>0) return c[a][b];
    else if(b==0) return 1;
    else if(a==b) return 1;
    else          return c[a][b] = comb(a-1,b-1)+comb(a-1,b);
}

int main(){
    int n,A,B,flag;
    cin >> n >> A >> B;
    vector<double> v(n);
    map<double,int> mp;
    double ave = 0;
    ll cnt = 0;
    bool single = true;
    for(int i = 0;i < n;i ++){
        cin >> v[i];
        mp[v[i]] ++;
    }
    sort(v.begin(),v.end(),greater<double>());
    for(int i = 0;i < A;i ++){
        ave += v[i];
        if(i && v[i]!=v[i-1]){
            single = false;
            flag = i;
        }
    }
    ave /= A;
    ll x = v[A-1],num = A-flag;
    if(single){
        for(int i = A;i <= min(B,mp[x]);i ++){
            cnt += comb(mp[x],i);
        }
    }else{
        cnt = comb(mp[x],num);
    }
    cout << setprecision(10) << ave << endl << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{int A,B;
 cin>>A>>B;
 if(A>=13)
 {cout<<B<<endl;
 }
 else if(A<13&&A>=6)
 {cout<<B/2<<endl;
 }
 else if(A<=5)
 {cout<<0<<endl;
 }
 return 0;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	if(m >= n){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
};

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

int main() {
	string s;
	int r = 0;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (i >= s.length() / 2) {
			break;
		}
		if (s[i] != s[s.length() - i - 1]) {
			r++;
		}
	}
	cout << r << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

const int N=52;
const int M=105;
struct edge{int to;ll c;edge*nxt;};edge*head[250005];
void add(int u,int v,ll cc)
{
	edge*a=new edge;a->to=v;a->c=cc;;a->nxt=head[u];head[u]=a;
	//printf("edge from %d to %d cost %lld\n",u,v,cc);
}
int tr(int u,int c){return c*50+u;}
ll dis[260005];
#include<queue>
#define mp make_pair
#define MX 5000
void dij(int s)
{
	memset(dis,0x3f,sizeof dis);
	//printf("start from %d\n",s);
	dis[s]=0x3f3f3f3f3f3f3f3f;
	priority_queue<pair<ll,int>,vector<pair<ll,int> >,greater<pair<ll,int> > >q;
	q.push(mp(0ll,s));
	while(!q.empty())
	{
		pair<ll,int> x=q.top();q.pop();
		//printf("now at %d\n",x.second);
		ll d=x.first;int u=x.second;
		if(dis[u]!=0x3f3f3f3f3f3f3f3f) continue;
		dis[u]=d;
		for(re edge*i=head[u];i;i=i->nxt)
		if(dis[i->to]==0x3f3f3f3f3f3f3f3f)
		q.push(mp(d+i->c,i->to));
		//for(re edge*i=head[u];i;i=i->nxt)
		//if(dis[i->to]==0x3f3f3f3f3f3f3f3f)
		//printf("edge from %d to %d cost %lld used\n",u,i->to,i->c);
	}
}
int u[105],v[105],c[105],t[105];
int g[55],gt[55];
int main()
{
	int n,m,s;
	cin>>n>>m>>s;
	F(i,1,m) cin>>u[i]>>v[i]>>c[i]>>t[i];
	F(i,1,n) cin>>g[i]>>gt[i];
	F(i,1,n) F(mo,0,MX) add(tr(i,mo),tr(i,min(mo+g[i],MX)),gt[i]);
	F(i,1,m)
	{
		F(mo,c[i],MX) add(tr(u[i],mo),tr(v[i],mo-c[i]),t[i]);
		F(mo,c[i],MX) add(tr(v[i],mo),tr(u[i],mo-c[i]),t[i]);
	}
	//system("pause");
	dij(tr(1,min(s,MX)));
	//system("pause");
	F(i,2,n)
	{
		ll mn=0x3f3f3f3f3f3f3f3f;
		F(mo,0,MX) mn=min(mn,dis[tr(i,mo)]);
		//F(mo,0,MX) printf("dis[%d]=%lld\n",tr(i,mo),dis[tr(i,mo)]);
		cout<<mn<<endl;
	}
	return 0;
}

Measured memory_bytes: 53824
S = input()

dm, dr, ee, er = 'dream', 'dreamer', 'erase', 'eraser'

word = [dm[::-1], dr[::-1], ee[::-1], er[::-1], ]

s = S[::-1]

while s:
    for i in range(4):
        if s.startswith(word[i]):
            s = s[len(word[i]):]
            break
    else:
        print('NO')
        break
else:
    print('YES')


Measured memory_bytes: 9328
#include<cstdio>
#include<cstring>
#include<cstdlib>

int main(void){
	int x;
	long long s = 1;
	scanf("%d", &x);
	for (int i = 0; i < x + 2; i++)s = s * 2;
	printf("%lld\n",s-2);
	return 0;
}

Measured memory_bytes: 128
// author:-*mdragneell*

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define pi  pair<int,int>
#define pl  pair<ll,ll>

int const N=500001;
ll min(ll x,ll y) { if(x<y) return x; else return y; }
ll max(ll x,ll y) { if(x>y) return x; else return y; }

ll dp[N][4],n;
vector<ll>a(N),b(N),c(N);

ll solve(ll x,ll last)
{

	if(x>=n) return 0;
	if(dp[x][last]!=-1) return dp[x][last];

	if(last==0)
		return dp[x][last]=max(a[x]+solve(x+1,1),max(b[x]+solve(x+1,2),c[x]+solve(x+1,3)));
	if(last==1)
		return dp[x][last]=max(b[x]+solve(x+1,2),c[x]+solve(x+1,3));
	if(last==2)
		return dp[x][last]=max(a[x]+solve(x+1,1),c[x]+solve(x+1,3));
	if(last==3)
		return dp[x][last]=max(b[x]+solve(x+1,2),a[x]+solve(x+1,1));

}

int main()
{
	ll i;
	cin>>n;
	memset(dp,-1,sizeof(dp));

	for(i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
	//for(i=0;i<n;i++) cin>>b[i];
	//for(i=0;i<n;i++) cin>>c[i];
	cout<<solve(0,0);

}


Measured memory_bytes: 32256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
// #include <bits/stdc++.h>

using namespace std;
typedef long long li;

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

    string s;
    cin >> s;

    li n = s.size();

    vector<li> ans(n);
    for (int i = 0; i < n - 1; ++i) {
        if (s[i] == 'R' && s[i + 1] == 'L') {
            {
                li p = i;
                li dest = i;
                while (p >= 0 && s[p] == 'R') {
                    ans[dest]++;

                    p--;
                    dest = i + i + 1 - dest;
                }
            }

            {
                li p = i + 1;
                li dest = i + 1;
                while (p < n && s[p] == 'L') {
                    ans[dest]++;

                    p++;
                    dest = i + i + 1 - dest;
                }
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        cout << ans[i];
        if (i == n - 1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 1488
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		double N = sc.nextDouble();

		double I = Math.ceil(N / 2);
		System.out.println((int)I);
		sc.close();

	}

}


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

int a[26];

int main()
{
    string s;

    cin >> s;

    for(int i = 0 ; i <s.size() ; i++)
    {
        a[s[i]-'a']=1;
    }

    for(int i = 0 ; i<26 ; i++)
    {
        if(a[i]==0)
        {
            char c = i + 'a';
            cout <<  c << endl;
            return 0;
        }
    }
    cout << "None";
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pii a, pii b)//true for a before b
{
	if(a.S < b.S)
		return 1;
	if(a.S > b.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (1e5) + 9;
const int M = (672*672) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 900;

int par[N], ht[N];
vi vx[N], vy[N];
set < int > st[N];

int root(int n)
{
	while(par[n] != n)
		n = par[n];
	return n;
}

void merge(int a, int b)
{
	a = root(a);
	b = root(b);
	if(a == b)
		return;
	if(ht[a] >= ht[b])
	{
		ht[a] = max(ht[a], ht[b]+1);
		par[b] = a;
	}
	else
	{
		ht[b] = max(ht[b], ht[a]+1);
		par[a] = b;
	}
	return;
}

void solve()
{
	int n, i, j, x, y, a;
	ll ans = 0;
	cin >> n;
	fo(i,1,N)
	{
		ht[i] = 1;
		par[i] = i;
	}
	fo(i,1,n+1)
	{
		cin >> x >> y;
		vx[x].pb(y);
		vy[y].pb(x);
	}
	fo(i,1,N)
		fo(j,1,sz(vy[i]))
			merge(vy[i][0],vy[i][j]);
	fo(i,1,N)
	{
		a = root(i);
		for(auto x : vx[i])
			st[a].insert(x);
	}
	fo(i,1,N)
	{
		a = root(i);
		ans += sz(st[a]);
	}
	ans -= n;
	cout << ans << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand(clock());

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(15);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int pre_e[MAX],pre_w[MAX],suf_w[MAX],suf_e[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);

    int len;
    string s;
    cin>>len;
    cin>>s;
    for(int i=1; i<=len; i++)
    {
        pre_e[i]=pre_e[i-1];
        pre_w[i]=pre_w[i-1];
        if(s[i-1]=='E')
            pre_e[i]++;
        else
            pre_w[i]++;
    }
    for(int i=len; i>=1; i--)
    {
        suf_e[i]=suf_e[i+1];
        suf_w[i]=suf_w[i+1];
        if(s[i-1]=='E')
            suf_e[i]++;
        else
            suf_w[i]++;
    }
    int mx=INT_MAX;
    for(int i=1;i<=len;i++){
        int x=pre_w[i-1]+suf_e[i+1];
        mx=min(x,mx);
    }
    cout<<mx<<endl;

    return 0;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define endl "\n"
#define what_is(x) cout<<#x<<" is "<<x<<endl;
#define F(i,a,b) for(int i = a; i < b; i++)
#define MAX(a,b,c) max(a,max(b,c))
#define MIN(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define inf 1e18
const double pi = 3.141592653589793238460;
#define debug false
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define mod 1000000007 

void solve()
{
    int A,B;
    cin>>A>>B;
    int ans = (B-A)*(B-A+1)/2-B;
    cout<<ans<<"\n";
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        // freopen("Test.txt","r",stdin);
        // freopen("Output.txt","w",stdout);
    #endif
    
     // if(debug){watch_is();}
    solve();   
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll& a, ll& b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;
ll n;
bool check(vector<ll> b) {
	auto bb = b;
	sort(all(b));
	if (bb == b) {
		return true;
	}
	else return false;
}
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n; vector<ll>a(n);
	for (ll i = 0; i < n; i++) cin >> a[i], a[i]--;
	auto bb = a;
	sort(all(bb));
	if (bb == a) {
		cout << "YES";
		return 0;
	}
	
	for (ll i = 0; i < n; i++) {
		for (ll j = i + 1; j < n; j++) {
			if (a[i] > a[j]) {
				auto b = a;
				swap(b[i], b[j]);
				if (check(b)) {
					cout << "YES";
					return 0;
				}
			}
		}
	}
	cout << "NO";
	return 0;
}
/*

*/

Measured memory_bytes: 256
n = int(input())
a=[]
for x in range(n):
    a.append(int(input()))
numlist = sorted(a)
t = a[0]
m = [0]
p = 0
for x in numlist:
    if t == x:
        m[-1] += 1
    else:
        m.append(1)
        t=x
for x in m:
    if x % 2 == 1:
        p += 1
print(p)

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

int main(){
int H,N;
cin >> H >> N;
for(int i = 0; i < N;i++){
  int A;
  cin >> A;
  H -= A;
} 
 if(H <= 0){
   cout << "Yes" << endl;
 }
 else{
   cout << "No" << endl;
 }
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N;
  ci(N);
  if(N / 100 == 7){
    co("Yes");
  }
  else if(N % 100 / 10 == 7){
    co("Yes");
  }
  else if(N % 10 == 7){
    co("Yes");
  }
  else{
    co("No");
  }
}


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

using namespace std;

const int MOD = 998244353;
const int MAX = 200020;
vector<int> fact(MAX);
vector<int> ifac(MAX);
	
int pwr(int a, int n){
	if(n==0) return 1;
	int q = pwr(a,n/2);
	q = q * 1ll * q % MOD;
	if(n&1)
		q = q * 1ll * a % MOD;
	return q;	
}


void init(){
	fact[0] = ifac[0] = 1;
	for(int i = 1; i < MAX; i++){
		fact[i] = fact[i-1] * 1ll * i % MOD; 
	}
	ifac[MAX - 1] = pwr(fact[MAX-1],MOD-2);
	for(int i = MAX - 2; i >= 0; i--){
		ifac[i] = ifac[i+1] * 1ll * (i+1) % MOD;
	}
	
}

int C(int n, int k){
	if(k > n) return 0;
	return fact[n] * 1ll * ifac[n-k] % MOD * ifac[k] % MOD; 
}

int main(){
	init();
	int n,m,k;
	cin >> n >> m >> k;
	int ans = 0;
	for(int i = 0; i <= k; ++i){
		int a = m;
		int b = C(n-1,i);
		int c = pwr(m-1,n-i-1);
		a = a * 1ll * b % MOD;
		a = a * 1ll * c % MOD;
		ans = (ans + a)% MOD;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 4692
import re
A, B = map(int, raw_input().split(' '))
S = raw_input()


if len(S) != A + B + 1 or '-' not in S or not re.match('[0-9\-]', S[-1]):
    print 'No'
else:
    a, b = map(len, S.split('-'))[:2]
    if a != A or b != B:
        print 'No'
    else:
        print 'Yes'



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

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

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

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v)                               \
  cerr << #v << ": ";                              \
  REP(__i, (v).size()) cerr << ((v)[__i]) << ", "; \
  cerr << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(), x.end()
#define MM << " " <<
int main() {
    int N;
    cin >> N;
    int cnt = 0;

    for(int i=0;i<N;i++){
        int a,b;
        cin>> a>> b;
        if( a==b ){
            cnt++;
            if(cnt==3)break;
        }else{
            cnt = 0;
        }
    }

    if (cnt == 3) cout<< "Yes"<< endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 3636