akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
//const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    int n,m;cin>>n>>m;
    typedef vector<vector<ll>> VLL;
    VLL c(n);
    rep(i,n){
        ll x,y,z;
        c[i].resize(3);
        cin>>x>>y>>z;
        c[i][0]=x;
        c[i][1]=y;
        c[i][2]=z;
        
    }
    
    ll ans = 0;
    
    rep(i,8){
        vector<ll> sgn(3);
        sgn[0] = pow(-1,i%2);
        sgn[1] = pow(-1,(i>>1)%2);
        sgn[2] = pow(-1,(i>>2)%2);
        
        sort(all(c),[&](vector<ll> p1, vector<ll> p2){return sgn[0]*p1[0]+sgn[1]*p1[1]+sgn[2]*p1[2] >  sgn[0]*p2[0]+sgn[1]*p2[1]+sgn[2]*p2[2];});
        vector<ll> temp(3);
        rep(j,m){
            
            temp[0] += (ll)c[j][0];
            temp[1] += (ll)c[j][1];
            temp[2] += (ll)c[j][2];
            
        }
        ans = max(ans,abs(temp[0])+abs(temp[1])+abs(temp[2]));
    }


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


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

using namespace std;

int main() {
    constexpr long MOD = 1e9 + 7;

    int n, m;
    cin >> n >> m;
    
    vector<int> s(n), t(m);
    for(auto &x: s) cin >> x;
    for(auto &x: t) cin >> x;

    vector<vector<long>> dp(n+1, vector<long>(m+1));
    dp[0][0] = 1;

    for(int i=1; i<=n; i++)
        dp[i][0] = 1;
    for(int i=1; i<=m; i++)
        dp[0][i] = 1;

    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++) {
            dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1];
            dp[i][j] %= MOD;
            if(s[i-1] == t[j-1])
                dp[i][j] += dp[i-1][j-1];
            dp[i][j] %= MOD;
        }

    cout << (dp[n][m] + MOD) % MOD << endl;
}


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

const int MAX = 1e5+10;
int cnt[MAX];

int main(){
	int n; cin>>n;
	ll sum = 0;
	for(int i=0; i<n; i++){
		int x; cin>>x;
		sum+=x; 
		cnt[x-1]++;
	}	
	int c,u,v; cin>>c;
	while(c--){
		cin>>u>>v;
		sum+=(v*cnt[u-1])-(u*cnt[u-1]);
		cnt[v-1] += cnt[u-1];
		cnt[u-1] = 0;
		cout<<sum<<endl;
	}
}


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

int main(){
  int N;
  cin >> N;
  map<string, int> S;
  string tmp;
  for(int i=0;i<N;i++){
    cin >> tmp;
    S[tmp] = 1;
  }

  cout << S.size() << endl;

  return 0;
}

Measured memory_bytes: 19204
// Problem : A - +-x
// Contest : AtCoder Beginner Contest 137
// URL : https://atcoder.jp/contests/abc137/tasks/abc137_a
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcount(x)
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int a,b;
cin>>a>>b;
cout<<max(a+b,max(a*b,a-b));
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t;
//cin>>t;
t=1;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

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

int main(int argc, const char * argv[]) {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a, 0);
  vector<ll> q(b, 0);
  vector<ll> r(c, 0);
  rep(i, a){
    cin >> p[i];
  }
  rep(i, b){
    cin >> q[i];
  }
  rep(i, c){
    cin >> r[i];
  }
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  sort(r.rbegin(), r.rend());

  // int count_x = 1;
  // int count_y = 1;
  // while(count_x<)

  int p_index = x-1;
  int q_index = y-1;
  bool p_little_flag;
  if(p[p_index] < q[q_index]){
    p_little_flag = true;
  }else{
    p_little_flag = false;
  }
  int c_index = 0;
  rep(i, c){
    if(p_little_flag){
      if(r[i] < p[p_index]){
        
        break;
      }
      p_index--;
    }else{
      if(r[i] < q[q_index]){
        break;
      }
      q_index--;
    }
    c_index++;
    // cout << "test" << endl;
    // cout << p_index << " " << q_index << endl;
    if(p_index < 0 && q_index < 0){
      break;
    }else if(p_index < 0){
      p_little_flag = false;
    }else if(q_index < 0){
      p_little_flag = true;
    }else{
      if(p[p_index] < q[q_index]){
        p_little_flag = true;
      }else{
        p_little_flag = false;
      }
    }
  }

  unsigned long long ans = 0;
  rep(i, p_index+1){
    ans+=p[i];
  }
  rep(i, q_index+1){
    ans+=q[i];
  }

  rep(i, c_index){
    ans+=r[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
N = int(input())
S = input()
ctr = ptr = 0

def count_ABC(pos, count):
    if (S[pos]=='A' and S[pos+1]=='B' and S[pos+2]=='C'):
        count += 1
        pos += 3
    else :
        pos += 1
    
    return(pos, count)

while (ptr < (N-2)):
    ptr, ctr = count_ABC(ptr, ctr)

print(ctr)    

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

#define min(X, Y) ((X)<(Y)?(X):(Y))
#define max(X, Y) ((X)>(Y)?(X):(Y))
#define f(X, Y) (((X)-(Y))*((X)-(Y)))
unsigned dp[20001][256];
int C[16];
const unsigned inf=1u<<30;

int main(void)
{
    int n, m;
    while (scanf("%d%d", &n, &m), n) {
        int i;
        unsigned *prev, *curr, res;
        for(i=0;i<m;++i) scanf("%d", C+i);
        memset(dp, -1, sizeof(dp));
        dp[0][128]=0;
        for(i=0;i<n;++i) {
            int x, j, k;
            scanf("%d", &x);
            prev=dp[i], curr=dp[i+1];
            for(j=0;j<256;++j) if (prev[j]<inf) {
                for(k=0;k<m;++k) {
                    int t=min(255, max(0, j+C[k]));
                    unsigned y=prev[j]+f(x, t);
                    curr[t]=min(curr[t], y);
                }
            }
        }
        res=inf;
        for(i=0;i<256;++i) res=min(res, curr[i]);
        printf("%u\n", res);
    }
    return 0;
}

Measured memory_bytes: 20612
#include <stdio.h>
  
int main(){
    int a,b,op;
    while (1){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?')break;
        if(op=='+'){
            printf("%d\n",a+b);
            }
            else if(op=='-'){
                printf("%d\n",a-b);
                }
                else if(op=='*'){
                    printf("%d\n",a*b);
                    }
                    else if(op=='/'){
                        printf("%d\n",a/b);
                        }
                        }
                         
     
    return 0;
}


Measured memory_bytes: 2104
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val ps = readLine()!!.split(' ').map { it.toInt() }
    val ps2 = ps.sorted()
    var swap = 0
    ps.zip(ps2).forEach { ab ->
        swap += if(ab.first != ab.second) 1 else 0
    }
    println(if(swap <= 2) "YES" else "NO")
}

Measured memory_bytes: 36324
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int masu = N-K;
          
        if(K<2){System.out.println("0");}
        else{ System.out.println(masu);}


      
    }
}

Measured memory_bytes: 23636
MOD = 1000000007
n, k = gets.chomp.split.map(&:to_i)
path = Array.new(n+1){ [] }
(n-1).times do
  a, b = gets.chomp.split.map(&:to_i)
  path[a] << b
  path[b] << a
end

queue = [[1,0,0]]
done = []

ans = 1
while q = queue.shift do
  node, dist1, dist2 = q
  done[node] = true
  ans = ans * (k - dist1 - dist2) % MOD
  path[node].each do |nextnode|
    next if done[nextnode]
    queue.push([nextnode,1,dist1])
    dist1 += 1
  end
end

puts(ans)

Measured memory_bytes: 13692
mod = 10**9+7
N,K = map(int,input().split())
A = list(map(int,input().split()))
canPositive = 0
Positive = 0
ans = 1
def inv(arg):
    return pow(arg,mod-2,mod)
for i in range(N):
    if A[i] >= 0:
        Positive += 1
if N - K >= 1 and Positive >= 1:
    canPositive = 1
if Positive == 0 and K % 2 == 0:
    canPositive = 1
anslist = []
if canPositive:
    A.sort(key=lambda x:abs(x),reverse=True)
    n = 0
    for a in A[:K]:
        anslist.append(a)
        if a < 0:
           n += 1
    if n % 2 == 1:
        minpos = 0
        minneg = 0
        maxpos = 0
        maxneg = 0
        for i in anslist[::-1]:
            if i > 0:
                minpos = i
                break
        for i in anslist[::-1]:
            if i < 0:
                minneg = i
                break
        for i in A[K:]:
            if i < 0:
                maxneg = i
                break
        for i in A[K:]:
            if i > 0:
                maxpos = i
                break
        if maxneg == 0 or minpos == 0:
            ans *= maxpos*inv(minneg) 
        elif maxpos == 0 or minneg == 0:
            ans *= maxneg*inv(minpos) 
        else:
            if abs(minpos*maxpos) > abs(maxneg*minneg):
                ans *= maxpos*inv(minneg) 
            else:
                ans *= maxneg*inv(minpos) 
else:
    A.sort(key=lambda x:abs(x))
    for a in A[:K]:
        anslist.append(a)
for i in anslist:
    ans *= i
    ans %= mod
print(ans)

Measured memory_bytes: 119020
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fast std::ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);

 /*ll solve(ll n )
 {
     if(n<12)
        return n;
     if(mp[n]==0)
            mp[n]=max(solve(n/2)+solve(n/3)+solve(n/4),n);
     return mp[n];
        
 }
 */

int main()
{
    ll n;
    cin>>n;
    ll ac=0,tle=0,wa=0,re=0;
    while(n--)
    {
        string s;
        cin>>s;
        if(s=="AC")
            ac++;
        if(s=="TLE")
            tle++;
        if(s=="WA")
            wa++; 
        if(s=="RE")
            re++;    
    }
    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";
}

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

using namespace std;

#define int long long

signed main()
{
  int N, L, T, X[100000], W[100000];

  cin >> N >> L >> T;
  for(int i = 0; i < N; i++) {
    cin >> X[i] >> W[i];
  }
  vector< int > ans;
  int diff = 0;
  for(int i = 0; i < N; i++) {
    int vv;
    if(W[i] == 1) {
      vv = (X[i] + T) % L;
      diff += (X[i] + T) / L;
    } else {
      vv = ((X[i] - T) % L + L) % L;
      diff -= (T - X[i] + L - 1) / L;
    }
    ans.push_back(vv);
  }
  sort(begin(ans), end(ans));
  diff = (diff % N + N) % N;
  for(int i = 0; i < N; i++) cout << ans[(diff + i) % N] << endl;
}

Measured memory_bytes: 3700
/*Author: Gautam*/
 
 
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define MOD 1000000007
#define ull unsigned long long int
#define newline cout<<endl
 
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}
 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
void solve()
{
	ll n;
	cin>>n;
	if(n%2==0)
	{
	n/=2;
	ll x=5;
	ll ans=0;
	while(n/x>0)
	{
		ans+=n/x;
		x*=5;
	}
	cout<<ans<<endl;
	}
	else
	{
		cout<<0;
	}	

}
 
int main()
{
    FastIO;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char c[200000];
	cin>>c;
	int s=0;
	for(int i=0;i<strlen(c)-1;i++)
	{
		if(c[i]==c[i+1])
		{
		c[i+1]='1'-c[i+1]+'0';
		s++;
		}
	}
	cout<<s;
}


Measured memory_bytes: 384
//*******Abhijit Burman***********//
//Jalpaiguri Government Engineering College//

// Taken From Striver_79
// Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts 
// Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure. 


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define MAXX (1000000000000000000+7)
#define mod 1000000007
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
ll dx1[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll dy1[] = {0, 1, 1, 1, 0, -1, -1, -1};

ll dx2[] = {1, 0, -1, 0};
ll dy2[] = {0, 1, 0, -1};

ll mul(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
ll power(ll x,ll y,ll p = mod) 
{ 
    ll res = 1;
    x = x % p;
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p;
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p = mod)
{
    return power(n, p - 2, p);
}
ll ncrMod(ll n, ll r, ll p = mod)
{
    if (r == 0)
        return 1;
    ll fac[n + 1];
    fac[0] = 1;
    for (ll i = 1 ; i <= n; i++)
        fac[i] = fac[i - 1] * i % p;
    return (fac[n] * modInverse(fac[r], p) % p *
            modInverse(fac[n - r], p) % p) % p;
}
// a+b=xor(a,b)+2*(a&b)//

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


void solve()
{
    ll n;
    cin>>n;
    
    string s;
    cin>>s;
    
    ll l=0,r=n-1;
    ll cnt=0;
    while(l<=r){
        if(s[l]=='W' and s[r]=='R'){
            s[l]='R';
            s[r]='W';
            cnt++;
        }
        if(s[l]=='R'){
            l++;
        }
        if(s[r]=='W'){
            r--;
        }
    }
    cout<<cnt<<endl;
}


int main()
{
	fio;
// 	#ifndef ONLINE_JUDGE
//     // for getting input from input.txt
//     freopen("input.txt", "r", stdin);
//     // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
// 	#endif
 

	ll t=1;
// 	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3736
n, h = gets.split.map(&:to_i)

a = []
b = []
n.times do 
    x, y = gets.split.map(&:to_i)
    a << x
    b << y
end


a = a.max
b.sort_by!{|e| -e} << a

ans = 0
while a < b[0]
    ans += 1
    h -= b.shift
    break if h <= 0
end

puts ans + [h.fdiv(a).ceil, 0].max

Measured memory_bytes: 6732
#include<iostream>

#include<string>

void test();

using namespace std;
int main()
{

    unsigned int nubmerIng = 0, peaper1 = 0, peaper2 = 0;;

    cin >> nubmerIng;

    peaper1 = nubmerIng / 2;
    peaper2 = nubmerIng % 2;

    if (peaper2 == 0) {
        cout << peaper1 << endl;
    }
    else {
        cout << (peaper1+1) << endl;
    }



}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k<=a){
        cout << k << endl;
    }else if(k<=a+b){
        cout << a << endl;
    }else{
        cout << a-(k-(a+b)) << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
def resolve():
    S, T = map(str, input().split())
    A, B = map(int, input().split())
    U = input()
 
    if S == U:
        A -= 1
        print(str(A) + ' ' + str(B))
        return
    B -= 1
    print(str(A) + ' ' + str(B))


resolve()

Measured memory_bytes: 3064
N=int(input())

pt=0
px=0
py=0

flag=1

for i in range(N):
    t,x,y=map(int,input().split())
    lt=t-pt
    lxy=abs(x-px)+abs(y-py)
    if lxy>lt or abs(lxy%2-lt%2) >0:
        flag=-1

if flag==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]
tf = [3 for _ in range(n)]
for i in ab:
    if h[i[0] - 1] > h[i[-1] - 1]:
        if tf[i[0] - 1] == 3:
            tf[i[0] - 1] = True
            tf[i[-1] - 1] = False
        else:
            tf[i[-1] - 1] = False
    elif h[i[0] - 1] < h[i[-1] - 1]:
        if tf[i[-1] - 1] == 3:
            tf[i[-1] - 1] = True
            tf[i[0] - 1] = False
        else:
            tf[i[0] - 1] = False
    elif h[i[0] - 1] == h[i[-1] - 1]:
        tf[i[0] - 1] = False
        tf[i[-1] - 1] = False
cnt = 0
for j in tf:
    if j == True:
        cnt += 1
    elif j == 3:
        cnt += 1
print(cnt)

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

int main(){

    int N, T;
    int c[1000], t[1000];
    cin >> N >> T;
    for( int i = 0; i < N; i++ ) cin >> c[i] >> t[i];


    int cost = 1000;
    bool can = false; // T以内に帰宅できる経路があるかどうか

    for( int i = 0; i < N; i++ ){
        if( t[i] <= T ){
            cost = min( c[i], cost );
            can = true;
        }
    }

    if( can ) cout << cost << endl;
    else cout << "TLE" << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);    
int x;
cin>>x;
if(x>=2100){
    cout<<1;
    return 0;
}
for(int i=1;i<21;i++){
    if(x>=100*i&&x<=105*i){
        cout<<1;
        return 0;
    }
}
cout<<0;

}

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

#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 

using namespace std;                    

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = 3010, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;

int n, m, ans, a[N], s[N], t[N], dp[N][N], nxt[N][N], last[N][N], timer, pw2[N];
bool was[N][N];
vector< pii > v;
void add(int i, int j, int val){
	nxt[i][j] += val;
	if(nxt[i][j] >= mod)
		nxt[i][j] -= mod;
	if(was[i][j])
		return;
	was[i][j] = 1;
	v.pb({i, j});
}
void relax(int i, int j){
	dp[i][j] = 1ll * dp[i][j] * pw2[timer - last[i][j]] % mod;
	last[i][j] = timer;
}
void relax(){
	for(auto it : v){
		int i = it.f;
		int j = it.s;
		relax(i, j);
		dp[i][j] += nxt[i][j];
		if(dp[i][j] >= mod)
			dp[i][j] -= mod;
		was[i][j] = 0;
		nxt[i][j] = 0;
	}
	v.clear();
}
void upd(int x, int y){
	timer++;
	for(int i = 1; i <= n; i++){
		last[i][x]++;
		last[x][i]++;
		last[i][y]++;
		last[y][i]++;
	}
	last[x][y] -= 1;
	last[y][x] -= 1;
}
int main(){
	pw2[0] = 1;
	for(int i = 1; i < N; i++)
		pw2[i] = pw2[i - 1] * 2 % mod;	
	cin >> n >> m;  
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			if(a[i] > a[j])
            	add(i, j, 1);
	relax();
	
	for(int i = 1; i <= m; i++){
		int x, y;
		cin >> x >> y;
		for(int j = 1; j <= n; j++){
			relax(j, x);
            relax(j, y);
            relax(x, j);
            relax(y, j);
            if(j != y){
				add(j, y, dp[j][x]);
				add(y, j, dp[x][j]);
			}
			if(j != x){
				add(x, j, dp[y][j]);
				add(j, x, dp[j][y]);
			}
		}                       
		add(x, y, dp[y][x]);
		add(y, x, dp[x][y]);
		relax();
		upd(x, y);
	}

	for(int i = 1; i <= n; i++)
		for(int j = i + 1; j <= n; j++){
			relax(i, j);
			ans += dp[i][j];
			if(ans >= mod)
				ans -= mod;
		}
	cout << ans;
	return 0;
}


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

int main() {
    int N; cin >> N;
    string s[N];
    int t[N];
    for (int i=0; i<N; i++) cin >> s[i] >> t[i];
    string X; cin >> X;
    int ans = 0;
    bool flag = false;
    
    for (int i=0; i<N; i++) {
        if (flag) ans += t[i];
        if (s[i]==X) flag = true;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
typedef long long ll;
const int N = 1e5+10 , OO = 0x3f3f3f3f , mod = 1e9 + 7;

#define PI acos(-1) 
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define xloop(i,a,b) for(int i = int(a);i <= int(b);i++)
#define range(vec) for(auto &x : vec) cin >> x;
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
 
char grid[1005][1005];
int n , k , w[105] , v[105];
ll dp[105][N];


int main()
{
  //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  
  scanf("%d %d", &n,  &k);
  for(int i = 0 ; i < n ; ++i)
    scanf("%d %d", &w[i], &v[i]);
  
  for(int idx = n-1 ; idx >= 0 ; --idx){
    for(int remW = 0 ; remW <= k ; ++remW){
      ll leave = dp[idx + 1][remW];
			ll take = (remW - w[idx]) < 0 ? (-OO*1LL*OO) : (v[idx] + dp[idx + 1][remW - w[idx]]);
      dp[idx][remW] = max(leave , take);
    }
  } 
  printf("%lld\n", dp[0][k]);

  return 0;
}

Measured memory_bytes: 81828
#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 = 3.14159265359;

int main() {
    int a, b, c;
    double s, l, h, deg;
    cin >> a >> b >> c;

    deg = (acos(-1.0)*c)/180.0;
    s = a*b*sin(deg)/2.0;
    l = a + b + sqrt(a*a + b*b - 2*a*b*cos(deg));
    h = b*sin(deg);

    printf("%lf\n%lf\n%lf\n", s, l, h);
}


Measured memory_bytes: 3556
#include <stdio.h>

int main(){

  int S[100000], T[50000], n, q, i, j, left, right, mid, count = 0;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &S[i]);
  }

  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &T[i]);
  }

  for(i = 0; i < q; i++){
    left = 0;
    right = n;

    while(left < right){
      mid = (left + right)/2;

      if(S[mid] == T[i]){
	count++;
	break;
      }else if(T[i] < S[mid]){
	right = mid;
      }else{
	left = mid + 1;
      }
    }
  }
  printf("%d\n", count);
      

  return 0;
}



Measured memory_bytes: 2316
N,K = map(int,input().split())
S = list(input())

if S[K-1] == "A": S[K-1] = "a"
elif S[K-1] == "B": S[K-1] = "b"
elif S[K-1] == "C": S[K-1] = "c"
print("".join(S))

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
inline void read(int&x)
{
	register bool t=0;register char c=getchar();for(;c<'0'||'9'<c;t|=c=='-',c=getchar());
	for(x=0;'0'<=c&&c<='9';x=(x<<3)+(x<<1)+(c^48),c=getchar());if(t)x=-x;
}
int n,d,x,y,ans;
main()
{
	for(read(n),read(d);n--;)
	{
		read(x);read(y);
		if(sqrt(1ll*x*x+1ll*y*y)<=d)++ans;
	}
	printf("%d",ans);
}

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

using namespace std;
int main(){
	int ans=0;
	int n,x;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		ans^=x;
	}
	cout<<(ans?"No":"Yes")<<endl;
	return 0;
}

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

using namespace std;


int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int l, r; cin >> l >> r;

	long long ans = 2019;
	for (int i = l; i < r; ++i) {
		for (int j = i + 1; j <= r; ++j) {
			long long tmp = 1LL * i * j;
			ans = min(ans, tmp % 2019);
			if (ans == 0) {
				cout << "0\n";
				return 0;
			}
		}
	}
	cout << ans << "\n";
	
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    if(S == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(S == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
}

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

signed main(){
  
  int n;
  string s;
  
  cin>>n>>s;
  
  for(int i=0;i<(int)s.size();i++){
    
    int nsi = ( s[i] - 'A' + n ) % 26;
    
    nsi += 'A';
    
    s[i] = (char)nsi;
    
  }
  
  cout<<s<<endl;
  
  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include<random>
#include<iostream>
using namespace std;

int o[10];
int oo[100];
int ooo[1000];

int main() {
	int N;
	char S[30001];
	cin >> N;
	cin >> S;
	for(int i=0;i<10;i++){
		o[i] = 0;
	}
	for(int i=0;i<100;i++){
		oo[i] = 0;
	}
	for(int i=0;i<1000;i++){
		ooo[i] = 0;
	}

	for(int i=0;i<N;i++){
		int p = S[i]-'0';
		for(int i=0;i<100;i++){
			if(oo[i] == 1){
				ooo[i*10+p] = 1;
			}
		}
		for(int i=0;i<10;i++){
			if(o[i] == 1){
				oo[i*10+p] = 1;
			}
		}
				o[p] = 1;
	}

	int ans = 0;
	for(int i=0;i<1000;i++){
		if(ooo[i] == 1){
			ans += 1;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 384
def dp(n):
    d=[0]*(n+1)
    if n==1:
        return 1
    else:
         d[0]=1
         if a[1]==0:
            d[1]=1
         else:
            d[1]=0
         for i in range(2,n+1):
            if a[i]==0:
                d[i]=d[i-1]+d[i-2]
            else:
                d[i]=0
         return d[n]

n,m=map(int, input().split())
a=[0]*(n+1)
for i in range(0,m):
    k=int(input())
    a[k]=1
print(dp(n)%1000000007)

Measured memory_bytes: 460788
import heapq
N, M = map(int, input().split())
A = [int(_)*(-1) for _ in input().split()]
heapq.heapify(A)

while M != 0:
  max_ = -heapq.heappop(A) // 2
  heapq.heappush(A, -max_)
  M -= 1
  
print(-sum(A))

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

int main(void){
  int N;
  cin>>N;
  int cnt=0;
  N--;
  while(N>=1){
    for(int A=1;A*A<=N;A++){
      if(N%A==0){
        int B=N/A;
        cnt+=2;
        //cout<<"(A,B)=("<<A<<","<<B<<")"<<endl;
        if(A==B){
          cnt--;
        }
      }
    }
    N--;
  }
  cout<<cnt<<endl;
  return 0; 
}

Measured memory_bytes: 3592
import java.io.*;
import java.util.*;

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int a = reader.nextInt();
    out.println(n * n - a);
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

template<class Monoid>
class SegmentTree {

public:
    /**
     * @param N size
     * @param e identity element
     * @param operation operation to merge `data`
     * @param updater operation to update `data`
     */
    SegmentTree(size_t N, Monoid e, function<Monoid(Monoid, Monoid)> operation,
                function<Monoid(Monoid, Monoid)> updater)
            : e(e), operation(operation), updater(move(updater)) {
        n = 1;
        while (n < N) {
            n *= 2;
        }
        data = vector<Monoid>(2 * n - 1, e);
        for (int i = n - 2; i >= 0; i--) {
            data[i] = operation(data[2 * i + 1], data[2 * i + 2]);
        }
    }

    /**
     * iの値をxに更新 ( 0-indexed )
     */
    void update(int i, Monoid x) {
        i += n - 1;
        data[i] = updater(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    /**
     * [a, b)の区間でクエリを実行
     */
    Monoid query(int a, int b) {
        return query(a, b, 0, 0, n);
    }

    /**
     * 添字でアクセス( 0-indexed )
     */
    Monoid operator[](int i) {
        return data[i + n - 1];
    }

private:
    int n;
    vector<Monoid> data;
    Monoid e;
    function<Monoid(Monoid, Monoid)> operation;
    function<Monoid(Monoid, Monoid)> updater;

    Monoid query(int a, int b, int k, int l, int r) {
        // 交差しない
        if (r <= a || b <= l) return e;
        // 区間 [a, b) に l, r が含まれる
        if (a <= l && r <= b) return data[k];
        // 左の子
        Monoid c1 = query(a, b, 2 * k + 1, l, (l + r) / 2);
        // 右の子
        Monoid c2 = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return operation(c1, c2);
    }
};

void solve() {
    ll N;
    cin >> N;
    vector<ll> H(N), A(N);
    rep(i, N) cin >> H[i];
    rep(i, N) cin >> A[i];
    SegmentTree<ll> segmentTree(N + 1, 0, [](ll a, ll b) {
        return max(a, b);
    }, [](ll a, ll b){
        return a + b;
    });
    rep(i, N) {
        ll h = H[i];
        ll a = A[i];
        ll v = segmentTree.query(0, h);
        segmentTree.update(h, v + a);
    }
    cout << segmentTree.query(0, N + 1)<< '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 10588
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int; //任意長整数 
using Real32 = mp::number<mp::cpp_dec_float<32>>;
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
using Rat = boost::rational<Bint>;//有理数
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    int n;
    ll ans=0;
    cin>>n;
    vector<int> v(n+1,0);
    for(int i=0;i < n;i++)
    {
        int x;
        cin>>x;
        if(x>n){
            ans++;
            continue;
        }

        v.at(x)++;
        if(v.at(x)>x){
            ans++;
        }
    }

    for(int i=0;i <= n;i++)
    {
        if(v.at(i)<i && v.at(i)>0){
            ans+=v.at(i);
        }
    }
    cout << ans << endl;
}

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

int main()
{
	string s;
	getline(cin, s);
	string::iterator it;
	int a[26]={0};

	for(it=s.begin();it<s.end();it++){
		a[*it-97]++;
	}

	for(int i=0;i<26;i++){
		if(a[i]==0){
			printf("%c\n", i+97);
			return 0;
		}
	}

	cout << "None" << endl;	
}

Measured memory_bytes: 512
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def ufinit(n):
  global ufsz, ufances
  ufsz = [1] * n
  ufances = [0] * n
  for i in range(n):
    ufances[i] = i

def ufroot(x):
  global ufances
  a = []
  y = x
  while ufances[y] != y:
    a.append(y)
    y = ufances[y]
  for z in a:
    ufances[z] = y
  return y

def ufconn(x,y):
  global ufsz, ufances
  i = ufroot(x)
  j = ufroot(y)
  if i==j:
    return
  #k  = [i,j].min
  k  = j if (ufsz[i]<ufsz[j]) else i
  if k==j:
    ufances[i] = j
  else:
    ufances[j] = i
  ufsz[k] = ufsz[i] + ufsz[j]

n = inn()
x = []
y = []
for i in range(n):
    xx,yy = inm()
    x.append((xx,i))
    y.append((yy,i))
x.sort()
y.sort()
dx = []
dy = []
for i in range(n-1):
    dx.append((abs(x[i][0]-x[i+1][0]), x[i][1], x[i+1][1]))
    dy.append((abs(y[i][0]-y[i+1][0]), y[i][1], y[i+1][1]))
dx.sort(reverse=True)
dy.sort(reverse=True)
ufinit(n)
dxt = dx.pop()
dyt = dy.pop()
sm = 0
while dxt and dyt:
    #print(dxt)
    #print(dyt)
    if dxt[0]<dyt[0]:
        if ufroot(dxt[1])!=ufroot(dxt[2]):
            sm += dxt[0]
            ufconn(dxt[1],dxt[2])
        dxt = False if len(dx)==0 else dx.pop()
    else:
        if ufroot(dyt[1])!=ufroot(dyt[2]):
            sm += dyt[0]
            ufconn(dyt[1],dyt[2])
        dyt = False if len(dy)==0 else dy.pop()
print(sm)


Measured memory_bytes: 109556
#include <bits/stdc++.h>
#define ll long long
#define maxn 45 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
ll dp[maxn][maxn][maxn];
int a[maxn][maxn]; 
ll work(int l, int r, int pl) {
	if (l == r && pl == l) return 1;
	if (dp[l][r][pl] != -1) return dp[l][r][pl];
	dp[l][r][pl] = 0;
	for (int j = l; j < pl; j++)
		for (int k = pl + 1; k <= r; k++) {
			if (!a[j][k]) continue;
			for (int s = j; s < pl; s++)
				for (int m = k; m > pl; m--)
					dp[l][r][pl] += work(l, s, j) * work(m, r, k) * work(s + 1, m - 1, pl);
		}
//	cout << l << ' ' << r << ' ' << pl << ' ' << dp[l][r][pl] << endl;
	return dp[l][r][pl];
}
char inp[maxn];
int main() {
	memset(dp, -1, sizeof(dp));
	int n;
	cin >> n;
	int x = 2 * n;
	for (int i = 1; i <= x; i++) {
		scanf("%s", inp);
		for (int j = 1; j <= x; j++) 
			a[i][j] = inp[j - 1] - '0';
	}
	ll ans = 0;
	for (int i = 2; i <= x; i++)
		if (a[1][i]) ans += work(2, x, i);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    char[] c = s.toCharArray();
    int count = 0;
    int min = 100000000;
    for(int i = 1;i<n;i++){
      if(c[i]=='E')count++;
    }
    min = Math.min(min,count);
    for(int i = 1;i<n;i++){
      if(c[i-1]=='W')count++;
      if(c[i]=='E')count--;
      min = Math.min(min,count);
    }
    System.out.println(min);
  }
}


Measured memory_bytes: 42808
import numpy as np
w,h,n=map(int,input().split())
l=np.ones((w,h))
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        l[:x,:] = 0
    elif a==2:
        l[x:,:] = 0
    elif a==3:
        l[:,:y] = 0
    else:
        l[:,y:] = 0
print(int(np.sum(l)))

Measured memory_bytes: 12532
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        long[] A = new long[N];
        long[] A_sum = new long[N];
        string[] input = Console.ReadLine().Split();
        for (int i = 0; i < N; i++)
        {
            A[i] = long.Parse(input[i])-1;
            A_sum[A[i]]++;
        }
        long total = 0;
        for(int i = 0; i < N; i++)
        {
            total += A_sum[i] * (A_sum[i] - 1) / 2;
        }
        for(int i = 0; i < N; i++)
        {
            Console.WriteLine(total - (A_sum[A[i]] - 1));
        }
    }
}

Measured memory_bytes: 34524
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

n = getN()
a, b = getMN()
points = getlist()

x ,y, z = 0,0,0
for p in points:
    if p <= a:
        x += 1
    if a < p <= b:
        y += 1
    if p > b:
        z += 1

print(min([x,y,z]))


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
int a,b;
int main()
{
	cin>>a>>b;
	if(a>b)swap(a,b);
	if(a==1&&b==2)puts("3");
	if(a==1&&b==3)puts("2");
	if(a==2&&b==3)puts("1");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

vector<int> g[100000];
deque<int> ans;
map<int, bool> mp;

int check_front() {
    int ret = -1;
    for(auto&& s : g[ans.front()]) {
        if(mp[s]) continue;

        ret = s;
        break;
    }
    return ret;
}

int check_back() {
    int ret = -1;
    for(auto&& s : g[ans.back()]) {
        if(mp[s]) continue;

        ret = s;
        break;
    }
    return ret;
}


int main(){
    int N, M;
    cin >> N >> M;

    REP(i, M) {
        int a, b;
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    ans.push_front(0);
    ans.push_back(g[0][0]);
    mp[0] = true;
    mp[g[0][0]] = true;

    while(true) {
        int c1 = check_front();
        if(c1 != -1){
            ans.push_front(c1);
            mp[c1] = true;
            continue;
        }

        int c2 = check_back();
        if(c2 != -1){
            ans.push_back(c2);
            mp[c2] = true;
            continue;
        }

        break;
    }

    int n = ans.size();
    cout << n << endl;
    for(int i = 0; i < n; i++){
        cout << (i == 0 ? "" : " ") << ans.front() + 1;
        ans.pop_front();
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 11392
A=list(map(int,input().split()))
ans=A[1]
I,J,L=A[0],A[3],A[4]
odd_cnt=I%2+J%2+L%2
if odd_cnt==0 or odd_cnt==3:
    ans+=I+J+L
elif odd_cnt==1:
    ans+=I+J+L-1
else:
    if I*J*L:
        ans+=I+J+L-1
    else:
        ans+=I+J+L-2
print(ans)

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

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

int main() {
	int x;
	cin >> x;
	if(x >= 30)
		cout << "Yes" << '\n';
	else
		cout << "No" << '\n';
}


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

int main(void){
    int n,m,k;
    cin >> n >> m >> k;
    vector<int> ar(n+1), br(m+1);
    ar.at(0) = 0;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ar.at(i+1) = ar.at(i) + a;
    }
    br.at(0) = 0;
    for(int i = 0; i < m; i++) {
        int b;
        cin >> b;
        br.at(i+1) = br.at(i) + b;
        if(br.at(i+1) > k) br.at(i+1) = k+1;
    }
    br.push_back(k+1);
    
    int ans = 0;
    for(int i = 0; i <= n; i++) {
        if(ar.at(i) > k) break;
        int l = 0;
        int r = m+1;
        int mid = (l+r)/2;
        while(r-l > 1) {
            if(ar.at(i) + br.at(mid) <= k) l = mid;
            else r = mid;
            mid = (l+r)/2;
        }
        ans = max(ans, i+l);
        
    }
    cout << ans << endl;
}


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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
    int S;
    cin >> S;
    long long ans = 0;
    for (int i = 1; 3 * i <= S; i++) {
      ans = (ans + COM(S - 2 * i - 1, i - 1)) % MOD;
    }
    if (ans < 0) ans += MOD;
    cout << ans << endl;
}

Measured memory_bytes: 15584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	if ((int)s.size() > n) {
		cout << s.substr(0,n) + "...";
	} else {
		cout << s;
	}
	return 0;
}


Measured memory_bytes: 3632
n = int(input())
lis = [0]+list(map(int, input().split())) +[0]

total = 0

for i in range(1, n+1):
    if i == lis[i]:
        t = lis[i]
        lis[i] = lis[i+1]
        lis[i+1] = t
        total += 1

print(total)

Measured memory_bytes: 20480
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<numeric>
#include<climits>
#include<queue>
 
using namespace std;

int s(long long n) {
	if (n < 10)return n;
	return n % 10 + s(n/10);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long n;
	cin >> n;
	vector<long long> a(n);
	for (auto&e : a)cin >> e;
	long long sum = 0;
	for (const auto&e : a) sum += e;
	long long b = n * (n + 1) / 2;
	if (sum%b != 0) {
		cout << "NO" << endl;
		return 0;
	}
	long long c = sum / b;
	a.push_back(a[0]);
	for (int i = 0; i < n; ++i) {
		long long d = a[i + 1] - a[i] - c;
		if (d > 0 || d % n != 0) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 1792