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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int cnt = 0;
        for (int x = 1; x*x <= i; x++)
        {
            for (int y = 1; y * y <= i; y++)
            {
                int b = x + y, c = i - x*x - y*y - x*y;
                if(c > 0)
                {
                    double z = (-b + sqrt(b * b + 4 * c)) / 2;
                    if (ceil(z) == floor(z)) cnt++;
                }
            }
        }
        cout << cnt << '\n';
    }
    return 0;
}

Measured memory_bytes: 3508
# -*- coding: utf-8 -*-
import sys


def main():
    N = int( sys.stdin.readline() )
    c_list = list(sys.stdin.readline().rstrip())
    

    num_R = c_list.count("R")
    cnt = 0

    for i in range(num_R):
        if c_list[i] == "W":
            cnt += 1
    
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10740
#include<stdio.h>


int main(void){

        int a[3][3],n,b[10],check[3][3];

        for(int i = 0 ; i < 3 ; i++ )
                scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
    
        scanf("%d",&n);
    
        for(int j = 0 ; j < n ; j++ ){
                scanf("%d",&b[j]);

                for(int  l = 0 ; l < 3 ; l++ )
                        for(int k = 0 ; k < 3 ; k++ ){
                                if( b[j] == a[l][k] )
                                        check[l][k] = 1;
    
    
                        }   
        }   


//      for( int f = 0 ; f < 3 ; f++ )
//              for(int d = 0 ; d < 3 ; d++ ){  
//                      printf("%d",check[f][d]);
//                      printf("\n");
//              }
    
                if( (check[1][1] == 1 && check[2][2] == 1 && check[0][0] == 1  )
                        || (check[2][0] == 1 && check[1][1] == 1 && check[0][2] == 1  )
                        || (check[0][0] == 1 && check[0][1] == 1 && check[0][2] == 1  )
                        || (check[1][0] == 1 && check[1][1] == 1 && check[1][2] == 1  )
                        || (check[2][0] == 1 && check[2][1] == 1 && check[2][2] == 1  )
                        || (check[0][0] == 1 && check[1][0] == 1 && check[2][0] == 1  )
                        || (check[0][1] == 1 && check[1][1] == 1 && check[2][1] == 1  )
                        || (check[0][2] == 1 && check[1][2] == 1 && check[2][2] == 1  )
                  )   
                        printf("Yes\n");
                else 
                        printf("No\n");

        return 0;
}

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

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

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

  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += A.at(i);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3628
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define ins insert
#define er erase
#define f(i,a,b) for(i=a;i<b;++i)
#define rf(i,a,b) for(i=a;i>=b;--i)
#define tc int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int> 
#define vll vector<ll> 
#define vull vector<ull>
#define vc vector<char>
#define vst vector<string>
#define bs bitset
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b) 
#define lb lower_bound
#define ub upper_bound
#define nl "\n" 
#define sp " "
using namespace std;

//LET'S PLAY THE GAME!!

int main(){
    fast;
    
    ll a,b,c,d;cin>>a>>b>>c>>d;
    ll l=lcm(c,d);
    
    ll cmp=(b/c-a/c)+(b/d-a/d)-(b/l-a/l);
    if(a%c==0)cmp++;
    if(a%d==0)cmp++;
    if(a%l==0)cmp--;
    
    cout<<(b-a+1)-cmp;
    
    return 0;
}
// AND THE GAME IS OVER!!

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
#define debug(a,b) cerr << #a<<" = "<<a<<"   |   "<<#b<<" = "<<b<<'\n'
#define endl '\n'
#define SZ(a) ((int)a.size())
using namespace std;
typedef pair<int, int> pi32;
typedef pair<ll, ll> pi64;
typedef vector<int> vi32;
typedef vector<ll> vi64;
typedef vector<pi32> vp32;
typedef vector<pi64> vp64;
const ll mod = 1e9 + 7;
const int MX = 1e7+7;

//ll prime[MX+10];

//void sieve(){
	//prime[0]=prime[1]=1;
	//for(ll i=4;i<=MX;i+=2)prime[i]=1;
	//for(ll i=3;i*i<=MX;i+=2){
		//if(!prime[i]){
			//for(ll j=i*i;j<=MX;j+=i)prime[j]=1;
		//}
	//}
//}

ll a[MX+10];

void sieve1(){
	a[0]=a[1]=1;
	for(ll i=2;i<=MX;i++){
		a[i]=i;
	}
	
	for(ll i=4;i<=MX;i+=2)a[i]=2;
	for(ll i=3;i*i<=MX;i+=2){
		if(a[i]==i){
			for(ll j=i*i;j<=MX;j+=i){
				if(a[j]==j)a[j]=i;
			}
		}
	}
}

ll Prime_Factor(ll n){
	vi64 ans;
	while(n!=1){
		ans.pb(a[n]);
		n/=a[n];
	}
	map<ll,ll>mp;
	for(ll x:ans)mp[x]++;
	ll tmp=1;
	for(auto it:mp)tmp*=(it.ss+1);
	return tmp;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//sieve();
	sieve1();
	ll n;
	cin>>n;
	
	ll sum=1;
	for(ll i=2;i<=n;i++)
	{
		ll x=Prime_Factor(i)*i*1LL;
		sum+=x;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 81744
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "D:\C++\test_lib_projects\testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)

bool debug=true;

/*    *************************************
	  * Written in New Computer           *
	  * The following code belongs to     *
	  * XiaoGeNintendo of HellHoleStudios *
	  *************************************
	  
	  Solution Idea From MonkeyKing(chinauser)
*/
template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
	os<<ptt.first<<","<<ptt.second;
	return os;
}
template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
	os<<"{";
	for(int i=0;i<vt.size();i++){
		os<<vt[i]<<" ";
	}
	os<<"}";
	return os;
}

int n;
string s;

vector<string> parts;

bool poss[7000];
void solve(int l,int r){
	if(s[l]=='a'){
		
		string ans;
		
		int a=0,b=0,c=0; 
		for(int i=l;i<=r;i++){
			if(s[i]=='a'){
				a++;
			}else{
				b++;
			}
			if(b>c){
				c=a;
				ans+="ab";
			}
		}
		
		parts.push_back(ans);
	}else{
		vector<string> all;
		for(int i=l;i<=r;i++){
			poss[i]=true;
		}
		
		for(int i=0;i<(r-l+1)/2;i++){
			string t="";
			for(int j=l;j<=r;j++){
				if(poss[j]){
					t+=s[j];
				}
			}
			
			all.push_back(t);
			
			for(int j=l;j<=r;j++){
				if(s[j]=='a' && poss[j]){
					poss[j]=false;
					break;
				}
			}
			for(int j=l;j<=r;j++){
				if(s[j]=='b' && poss[j]){
					poss[j]=false;
					break;
				}
			}
		}
		
		sort(all.begin(),all.end());
		parts.push_back(all.back());
	}
}
int main(int argc,char* argv[]){
	cin>>n>>s;
	n*=2;
	
	int delta=0,last=0;
	
	for(int i=0;i<n;i++){
		if(s[i]=='a'){
			delta++;
		}else{
			delta--;
		}
		if(delta==0){
			solve(last,i);
			last=i+1;
		}
	}
	
	string ans=parts.back();
	for(int i=parts.size()-2;i>=0;i--){
		bool ok=false;
		for(int j=0;j<min(ans.size(),parts[i].size());j++){
			if(parts[i][j]!=ans[j]){
				if(parts[i][j]<ans[j]){
					ok=true;
				}
				break;
			}
		}
		
		if(!ok){
			ans=parts[i]+ans;	
		}
	}
	
	cout<<ans;
	return 0;
}



Measured memory_bytes: 16128
import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str

isdelim(x::UInt8, xs::Set{UInt8}) = x in xs

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        if !isdelim(c, delims)
            break
        end
    end
    push!(out, c)
    if eof(s)
        return out
    end
    while !eof(s)
        c = read(s, UInt8)
        if isdelim(c, delims)
            break
        end
        push!(out, c)
    end
    return out
end

delimset = Set([0x0a, 0x20])

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

readvec(tys::Tuple , len::Signed)::Vector{Tuple{tys...}} = @inbounds Tuple{tys...}[reads(tys...) for i in 1:len]

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i = 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

function main()
    a,b = reads(Int,Int)
    println(a*b)
end

main()


Measured memory_bytes: 188624
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,count=0,mn=INF;
  cin>>N;
  vector<ll> A;
  for(int i=0; i<N; ++i){
    ll a;
    cin>>a;
    if(a<0) count++;
    if(mn>abs(a)) mn=abs(a);
    A.push_back(abs(a));
  }
  
  ll ans=0;
  for(int i=0; i<N; ++i){
    ans+=A[i];
  }
  if(count%2==1) ans-=mn*2;
  
  cout<<ans<<endl;
}

Measured memory_bytes: 4284
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long ul;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef set<int> si;
typedef multiset<int> mi;
 
const ll INF = 1e18;
const int MOD = 1e9+7;
 
int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	//ofstream cout ("fileName.txt");
	//ifstream cin ("fileName.txt");
	
	map<int,ll> m;
	int N, Q;
	ll sum=0;
	cin >> N;
	
	vl A(N);
	
	for(int i=0; i<N; ++i) cin >> A[i], sum+=A[i], ++m[A[i]];
	
	cin >> Q;
	
	for(int i=0; i<Q; ++i) {
		
		ll B, C;
		cin >> B >> C;
		
		sum-=m[B]*B;
		sum+=m[B]*C;
		m[C]+=m[B];
		m[B]=0;
		
		//for(auto x: m) cout<<x.f<<" - "<<x.s<<"\n";
		
		cout<<sum<<"\n";
	}
	
	return 0;
}


Measured memory_bytes: 9948
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}


const int INF = 0x3f3f3f3f;
const int inf = INF;
typedef long long LL;
typedef pair<int, int> pii;
typedef long double LD;

const int N = 1e5 + 10;
int a[N], b[N];

int main() {
	int ans = 0;
	int n;
	RD(n);
	for(int i = 1; i <= n; i ++) RD(a[i]), b[i] = a[i];
	sort(b + 1, b + 1 + n);
	for(int i = 1; i <= n; i ++) {
		int pos = lower_bound(b + 1, b + 1 + n, a[i]) - b;
		ans += (pos % 2 != i % 2);
	}
	printf("%d\n", ans / 2);
}




Measured memory_bytes: 1024
N, K = map(int, input().split())
X = list(map(int, input().split()))
ret = 10 ** 9
for i in range(N-K+1):
    width = X[i+K-1] - X[i]
    mi = min(abs(X[i+K-1]), abs(X[i]))
    ret = min(ret, width+mi)

print(ret)


Measured memory_bytes: 62576
#include<bits/stdc++.h>
using namespace std;
int main(){
  int b;
  char a[1000];
  cin>>b>>a;
  if(b%2==1){
    cout<<"No"<<endl;
    return(0);
  }
  for(int i=0;i<b/2;i++){
	if(a[i]!=a[i+b/2]){
      cout<<"No"<<endl;
      return(0);
    }
  }
  cout<<"Yes"<<endl;
  return(0);
}

Measured memory_bytes: 256
R, G, B, N = map(int, input().split())

score = 0

for g in range(3001):
    for b in range(3001):
        if g + b > 3000:
            break
        if (N - (g * G + b * B)) >= 0 and (N - (g * G + b * B)) % R == 0:
            score += 1

print(score)

Measured memory_bytes: 42716
import math 
c = math.cos(math.radians(60))
s = math.sin(math.radians(60))

def koch(d,p1,p2):
    if d == 0:
        return 
    sx = (2 * p1[0] + p2[0]) / 3
    sy = (2 * p1[1] + p2[1]) / 3

    tx = (p1[0] + p2[0] * 2) / 3
    ty = (p1[1] + p2[1] * 2) / 3

    dx = tx - sx
    dy = ty - sy

    ux = dx * c - dy * s + sx
    uy = dx * s + dy * c + sy

    koch(d-1,p1,(sx,sy))
    print("{0:.8f} {1:.8f}".format(sx,sy))

    koch(d-1,(sx,sy),(ux,uy))
    print("{0:.8f} {1:.8f}".format(ux,uy))

    koch(d-1,(ux,uy),(tx,ty))
    print("{0:.8f} {1:.8f}".format(tx,ty))

    koch(d-1,(tx,ty),p2)

n = int(input())
print("{0:.8f} {1:.8f}".format(0,0))
koch(n,(0,0),(100,0))
print("{0:.8f} {1:.8f}".format(100,0))


Measured memory_bytes: 5768
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math



def dev(an):
  ret = 0
  while True:
    for i in range(len(an)):
      if an[i]&1 == 1 or an[i] < 2:
        return ret
      else:
        an[i] //= 2
    ret += 1
    

if __name__ == "__main__":
  input()
  An = list(map(int, input().split()))  
  print(dev(An))

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

using namespace std;
const int MAXN=110;
const int MAXK=110000;
int N,K;
const long long int MOD = 1e9+7;
int A[MAXN];
long long int cont=0;
long long int sol[MAXN][MAXK];
void dp(int index, int remaining){
	if(index>=N && remaining!=0)
		sol[index][remaining]=0;
	else if(remaining==0)
		sol[index][remaining]=(sol[index][remaining+1]+1)%MOD;
	else 
		sol[index][remaining]=(sol[index][remaining+1]+(sol[index+1][max(0,remaining-A[index])]+MOD-sol[index+1][remaining+1])%MOD)%MOD;	
}

int main(){
	cin>>N>>K;
	for(int i=0;i<N;i++)
		cin>>A[i];
	for(int i=0;i<=N;i++)
		sol[i][K+1]=0;
	for(int i=N;i>=0;i--)
		for(int j=K;j>=0;j--)
			dp(i,j);
	cout<<sol[0][K];
}

Measured memory_bytes: 88192
#include<bits/stdc++.h>
using namespace std;
const int MAXX = 500000;

struct Node {
    int cnt;
    Node *bam, *dan;
    Node(int c = 0, Node *b = NULL, Node *d = NULL) :  cnt(c), bam(b), dan(d) {}

    void build(int l, int r) {
        if (l==r) return;
        int mid = (l+r)/2;
        bam = new Node();
        dan = new Node();
        bam->build(l, mid);
        dan->build(mid+1, r);
    }

    Node* update(int l, int r, int idx, int v) {
        if (idx < l || r < idx) return this;
        if (l==r) {
            Node *ret = new Node(cnt);
            ret->cnt += v;
            return ret;
        }

        Node* ret = new Node();
        int mid = (l+r)/2;
        ret->bam = bam->update(l, mid, idx, v);
        ret->dan = dan->update(mid+1, r, idx, v);
        ret->cnt = ret->bam->cnt + ret->dan->cnt;
        return ret;
    }

    int query(int l, int r, int x, int y) {
        if (r < x || y < l) return 0;
        if (x <= l && r <= y) return cnt;
        int mid = (l+r)/2;
        return bam->query(l, mid, x, y)+dan->query(mid+1, r, x, y);
    }
}* root[MAXX+7];

int last[MAXX+7];

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

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

    root[0] = new Node();
    root[0]->build(1, n);

    for (int i = 1; i <= n; i++) {
        int c;
        cin >> c;

        root[i] = root[i-1]->update(1, n, i, 1);
        if (last[c] > 0) {
            root[i] = root[i]->update(1, n, last[c], -1);
        }
        last[c] = i;
    }

    while (q--) {
        int l, r;
        cin >> l >> r;
        cout << root[r]->query(1, n, l, n) << "\n";
    }


    return 0;
}


Measured memory_bytes: 663200
#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(){
    ll n;
    cin >> n;
    ll ans;
    
    ans=n*(n-1)/2;
    

    cout << ans << endl;

    

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>

using namespace std;
typedef long long int ll;

int n,y;
ll mn=-1,sm;

int main(){
    scanf("%d %d",&n,&y);
    y/=1000;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            sm=10*i+5*j;
            if(y>=sm and i+j+y-sm==n){
                printf("%d %d %d\n",i,j,y-sm);
                return 0;
            }
        }
    }
    printf("%d %d %d\n",-1,-1,-1);
    
}

Measured memory_bytes: 768
s = input()

flag = [0, 0]

if ("N" in s and "S" in s) or ("N" not in s and "S" not in s):
    flag[0] = 1
if ("W" in s and "E" in s) or ("W" not in s and "E" not in s):
    flag[1] = 1

if sum(flag) == 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  
  int keta = 0;
  int n = N;
  while(n>0){
    keta++;
    n = n / 10;
  }
  
  int ans = 0;
  for(int i = 1; i < keta;i++){
    if(i %2 ==1){
      ans += pow(10,i) - pow(10,i-1);
    }
  }
  
  if(keta %2 == 1){
    ans += N - pow(10,keta-1) + 1;
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
vector<long long> a;
long long f(long long b) {
  long long ret = 0;
  for (int i = 0; i < a.size(); i++)
    ret += abs(a[i] - b - i - 1);
  return ret;
}
int main() {
  int n;
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  map<long long, int> mp;
  for (int i = 0; i < n; i++)
    mp[a[i] - i - 1]++;
  long long ans = f(mp.begin()->first);
  long long cnt = mp.begin()->second;
  long long sum = ans;
  long long bef = mp.begin()->first;
  auto it = mp.begin();
  for (it++; it != mp.end(); it++) {
    sum += (-n + 2 * cnt) * (it->first - bef);
    ans = min(ans, sum);
    bef = it->first;
    cnt += it->second;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 14336
#include <stdio.h>
#include <string.h>
 
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
 
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
char buf[20];
void mypr(int n)
{
    int w;
    if (!n) { pc('0'); return; }
    w = 0; while (n) buf[w++] = n%10 + '0', n/=10;
    while (w--) pc(buf[w]);
}
 
#define MAX_N 500002
#define INF   0x7f7f7f7f
 
int a[MAX_N];
int w[MAX_N/2+2];
int cnt;
 
void merge_sort(int low, int high) 
{ 
    int i, j, k, p, mid; 
 
    if (low < high) {
        mid = (low + high) >> 1;
        merge_sort(low,   mid);
        merge_sort(mid+1, high);
 
cnt += high-low+1;
 
        p = mid-low+1;
        memcpy(w, a+low, p << 2);
        i = mid+1, j = 0; k = low;
 
        w[p] = INF;
        while (i <= high) {
            if (w[j] <= a[i]) a[k++] = w[j++];
            else              a[k++] = a[i++];
        }
        memcpy(a+k, w+j, (p-j) << 2);
    }
}
 
int main()
{
    int n, i;
     
    n = in(); for (i = 0; i < n; i++) a[i] = in();
 
    cnt = 0;
    merge_sort(0, n-1);
 
    mypr(a[0]); for (i = 1; i < n; i++) pc(' '), mypr(a[i]); pc('\n');
    mypr(cnt); pc('\n');
    return 0;
}


Measured memory_bytes: 4460
s=list(input())
kisu=["R","U","D"]
gusu=["L","U","D"]
bool = True
for i in range(len(s)):
    if i%2==0:
        if s[i] not in kisu:
            bool=False
    else:
        if s[i] not in gusu:
            bool=False
print("Yes" if bool else "No")

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

bool in(int x) {
  return (x >= 1 && x <= 12);
}

int main() {
  int x, y;
  scanf("%02d%02d", &x, &y);
  if (in(x) && in(y)) {
    puts("AMBIGUOUS");
  } else if (!in(x) && !in(y)) {
    puts("NA");
  } else if (!in(x)) {
    puts("YYMM");
  } else {
    puts("MMYY");
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    static final long MOD = 1000000007;

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        
        long ans = 1;
        long a = 0;
        long b = 0;
        for(int i = 0; i < k; i++){
            a += n-i;
            b += i;
        }
        for(int i = k; i <= n; i++){
            ans += a-b+1;
            ans %= MOD;
            a += n-i;
            b += i;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 27240
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	long long k;
	cin>>k;
	long long tot=0;
	for(int i=0;i<s.size();i++){	
		if(s[i]=='1'){
			tot++;
		}	
		else{
			cout<<s[i];
			return 0;
		}
		if(tot==k){
			cout<<s[i];
			return 0;
		}
	}
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 200003, M = N << 1;

int T, n, m;
int a[N], b[N];
char s[N];

int main()
{
	//File("");
	scanf("%s", s + 1);
	for (int i = 1; i <= strlen(s + 1); i+=1)
	{
	    if (s[i] == '?')
	    {
	        s[i] = 'D';
	    }
	}
	printf("%s\n", s + 1);
	return 0;
}

Measured memory_bytes: 3956
#!python3

MOD = int(1e9 + 7)

# input
N, K = list(map(int, input().split()))


def main():
    ans = 0
    s = N * (N + 1) // 2
    for i in range(K, N + 2):
        a = i * (i - 1) // 2
        b = s - (N - i) * (N - i + 1) // 2
        ans = (ans + b - a + 1) % MOD

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
#define Jewel ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    Jewel;
    int n, i, sum=0;
    string s;
    cin>>s;
    n = s.size();
    vector<int>a(n+1);
    reverse(s.begin(), s.end());
    i=0;
    for(auto c : s)
    {
        a[i++] = (c-'0');
    }
    a[i]=0;
    for(i=0; i<n; i++)
    {
        if(a[i]==5 && a[i+1]>=5)
        {
            a[i+1]++;
        }
        else if(a[i]>5)
        {
            a[i] = 10 - a[i];
            a[i+1]++;
        }
    }
    for(auto c : a)
        sum += c;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 5276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n), f(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> f[i];
  sorti(a);
  sortd(f);

  ll left = -1, right = 10e18 + 1;
  while (left + 1 < right) {
    ll res = 0;
    ll mid = (left + right) / 2;
    // cout << left << " " << right << endl;
    for (int i = 0; i < n; ++i) {
      ll cost = mid / f[i];
      if (a[i] > cost) res += a[i] - cost;
    }
    if (res > k) {
      left = mid;
    } else {
      right = mid;
    }
  }

  cout << left + 1 << endl;
}

Measured memory_bytes: 3328
N,M=gets.split.map(&:to_i)
A=gets.split.map(&:to_i)
ma=[100,2,5,5,4,5,6,3,7,6]
dp=Array.new(N+7,-100)
dp[6]=0
for i in 7..N+6
	max=-100
	A.each{|e|
		max=[max,dp[i-ma[e]]+1].max
	}
	dp[i]=max
end
A.sort!.reverse!
j=N+6
while j>6
	for i in 0..A.size-1
		if dp[j]==dp[j-ma[A[i]]]+1
			j-=ma[A[i]]
			print A[i]
			break
		end
	end
end

Measured memory_bytes: 1916
#include <iostream>
using namespace std;
bool OK(int n)
{
	int num=0;
	for (int i=1;i<=n;i+=2){
		if (n%i==0){
			num++;
		}
	}
	if (num==8){
		return true;
	}else{
		return false;
	}
}
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	int ans=0;
	for (int i=9;i<=N;i+=2){
		if (OK(i)){
			ans++;
		}
	}
	cout<<ans<<endl;	
	return 0;
}

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

if n == 1:
    print(0)
    exit()

tmp = n
ans = 0
for i in range(2, int(-(-n**0.5//1)+1)):
    if tmp % i == 0:
        cnt = 0
        while tmp % i == 0:
            cnt += 1
            tmp //= i
        i_cnt = int((cnt*2)**0.5//1)
        if i_cnt * (i_cnt+1) //2 <= cnt and (i_cnt+1) * (i_cnt+2) //2 > cnt:
            ans += i_cnt
        elif (i_cnt-1) * i_cnt //2 <= cnt and i_cnt * (i_cnt+1) //2 > cnt:
            ans += i_cnt - 1

if tmp != 1:
    ans += 1

print(ans)

Measured memory_bytes: 9476
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N, M;
  cin >> N >> M;
  vector<i64> A(N);
  rep(i,0,N) cin >> A[i];
  sort(all(A));
  

  // a[i] + a[j] >= ok となるような組み合わせがM通り以上
  i64 ok = 0;
  i64 ng = 202020;

  while(abs(ok - ng) > 1) {
    i64 m = (ok + ng) / 2;

    i64 cnt = 0;
    i64 r = N;
    rep(i,0,N) {
      while(r > 0 && A[i] + A[r - 1] >= m) {
        r--;
      }
      cnt += N - r;
    }
    if(cnt >= M) {
      ok = m;
    }
    else {
      ng = m;
    }
  }

  i64 ans = 0;
  {
    i64 cnt = 0;
    i64 sum = 0;
    i64 r = N;
    rep(i,0,N) {
      while(r > 0 && A[i] + A[r - 1] >= ok) {
        sum += A[r - 1];
        r--;
      }
      cnt += N - r;
      ans += sum + A[i] * (N - r);
    }
    ans -= (cnt - M) * ok;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
//                                ** ALLAH **
//                        who is Hussain? -> whoishussain.org

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1000000007;
inline int in(){ int x; scanf("%d",&x); return x; }
const int N = 401, M = 1e5 + 100;
int ok[N][N], no[N];
vector<pii> q;
int n, m;
int32_t main(){
        n = in(), m = in();
        for(int i = 0;i < m; i++){
                int u = in()-1, v = in()-1;
                q.push_back(pii(u, v)); 
        }
        reverse(q.begin(), q.end() );
        for(int i = 0;i < n;i ++){
                ok[i][i] = true;
                for(pii c : q){
                        if( ok[i][c.fi] && ok[i][c.se] ) no[i] = true;
                        else if( ok[i][c.fi] ) ok[i][c.se] = true;
                        else if( ok[i][c.se] ) ok[i][c.fi] = true;
                }
        } 

        int ans = 0, oo;
        for(int i = 0; i < n;i ++){
                for(int j = i+1;j < n; j++){
                        oo = 1;
                        if( no[i] || no[j] ) continue;
                        for(int k = 0;k < n; k++) 
                                if( ok[i][k] && ok[j][k] ){ oo = 0; break; } 
                        ans += oo;
                }
        }
        cout << ans << endl;
}


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

string divide[4]={"dream","dreamer","erase","eraser"};

int main() {
	string s;
  	cin>>s;
  
  	//左右に反転すればよいのですね
   reverse (s.begin(),s.end());
  
  for(int i=0;i<4;i++)reverse(divide[i].begin(), divide[i].end());//string divideを最初から逆に書いてもいいんだな
  
  //端から切る
  bool can=true;
  for(int i=0;i < s.size();){//iはどの文字列と一致したかで増やす数が変わるから設定しないんですね
    bool can2=false;
    for(int j=0;j < 4;j++){
    string d=divide[j];
      if(s.substr(i,d.size())==d){
      	can2=true;
        i+=d.size();
      }
    }
  	if(!can2){
    	can=false;
      break;
    }
    
  }
  
  if(can)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
  
}


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

int main(void){
  long int n;
  long int cnt_a0pos = 0, cnt_a0neg = 0;
  long int a[100000];
  //i-1までの数値の和
  long int sum[100000] = {0};
  cin >> n;
  for(long int i = 0; i < n; i++){
    cin >> a[i];
  }
  //a[0] > 0とした時, i oddの時-，i evenの時+
  //iまでのsumを持っておく。
  for(long int i = 0; i < n; i++){
    //そこまでの和を計算
    if(i == 0) sum[i] = a[i];
    else sum[i] = sum[i - 1] + a[i];
    if(i % 2 == 0){
      if(sum[i] <= 0){
        cnt_a0pos += abs(sum[i]) + 1;
        sum[i] = 1;
      }
    }
    if(i % 2 == 1){
      if(sum[i] >= 0){
        cnt_a0pos += abs(sum[i]) + 1;
        sum[i] = -1;
      }
    }
  }
  //a[0] < 0とした時，i evenの時-，i oddの時+
  for(long int i = 0; i < n; i++){
    //そこまでの和を計算
    if(i == 0) sum[i] = a[i];
    else sum[i] = sum[i - 1] + a[i];
    if(i % 2 == 0){
      if(sum[i] >= 0){
        cnt_a0neg += abs(sum[i]) + 1;
        sum[i] = -1;
      }
    }
    if(i % 2 == 1){
      if(sum[i] <= 0){
        cnt_a0neg += abs(sum[i]) + 1;
        sum[i] = 1;
      }
    }
  }
  cout << min(cnt_a0pos, cnt_a0neg) << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] c = new int[3][3];
		int ans = 0;

		for(int i=0; i<3; i++) {
			for(int j=0; j<3; j++) {
				c[i][j] = sc.nextInt();
			}
		}

		if(c[0][2]-c[0][1] == c[1][2]-c[1][1]
				&& c[0][2]-c[0][1] == c[2][2]-c[2][1]) {
			ans += 1;
		}if(c[0][0]-c[0][1] == c[1][0]-c[1][1]
				&& c[0][0]-c[0][1] == c[2][0]-c[2][1]) {
			ans += 1;
		}if(c[2][0]-c[1][0] == c[2][1]-c[1][1]
				&& c[2][0]-c[1][0] == c[2][2]-c[1][2]) {
			ans += 1;
		}if(c[0][0]-c[1][0] == c[0][1]-c[1][1]
				&& c[0][0]-c[1][0] == c[0][2]-c[1][2]) {
			ans += 1;
		}

		if(ans == 4) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int Mod = 1e9 + 7;

const int maxn = 2e5 + 10;
LL fact[maxn];

LL ModPow(LL a, LL b)
{
    LL ans = 1;
    while(b)
    {
        if(b & 1) ans = ans * a % Mod;
        a = a * a % Mod;
        b >>= 1;
    }
    return ans;
}

LL nCr(LL a, LL b)
{
    LL ans = fact[a] * ModPow(fact[b], Mod - 2) % Mod;
    ans = ans * ModPow( (fact[a -b] + Mod) % Mod, Mod - 2) % Mod;
    return ans;
}

void init()
{
    fact[0] = 1;
    for(int i = 1; i < maxn; i++) fact[i] = fact[i - 1] * i % Mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    init();
    LL n,m,k;
    cin >> n >> m >> k;
    LL ans = nCr(n*m, k) * nCr(k, 2) % Mod * ModPow(3, Mod - 2) % Mod;
    ans = ans * (n + m) % Mod;
    ans %= Mod;
    cout << ans << endl;
    return 0;
}


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

ll gcd(ll a, ll b){
    if (a < b) swap(a, b);
    if (!b) return a;
    return gcd(b, a%b);
}

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

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

    int N, M;
    cin >> N >> M;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    ll l = 1;
    for(int i=0;i<N;i++){ 
        l = lcm(l, A[i]/2);
        if (l > M){
            cout << 0 << endl;
            return 0;
        }
    }

    for(int i=0;i<N;i++){
        if ((l / (A[i]/2)) % 2 == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (M/l+1)/2 << endl;
}

Measured memory_bytes: 1024
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var d = Console.ReadLine().Split().Select(int.Parse).ToLookup(x => x);
		Console.WriteLine(string.Join("\n", Enumerable.Range(1, n).Select(i => d[i].Count())));
	}
}


Measured memory_bytes: 65848
#include <iostream>
#include <vector>
 
using namespace std;
 
int main()
{
  int N, M;
  cin >> N >> M;
  vector<vector<int>> v(N);

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }

  for (int i = 0; i < N; i++) {
    cout << v[i].size() << endl;
  }
  
  return 0;
}


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

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

//pow(llpow,modpow)
template <class T>
ll llpow(T x, T n)
{
    ll ans = 1;
    if (x == 0)
        ans = 0;
    while (n)
    {
        if (n & 1)
            ans *= x;
        x *= x;
        n >>= 1;
    }
    return ans;
}
long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
template <class T>
inline T gcd(T x, T y)
{
    if (y == 0)
        return x;
    else
    {
        return gcd(y, x % y);
    }
}
//最小公倍数
template <class T>
inline T lcm(T x, T y) { return x / gcd(x, y) * y; }
//逆元
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL << 60;
int main()
{
    int h, w;
    cin >> h >> w;
    string s[h];
    rep(i, 0, h) cin >> s[i];
    rep(i, 0, h)
    {
        rep(j, 0, w)
        {
            if (s[i][j] == '#')
            {
                int x[4] = {-1, 0, 1, 0};
                int y[4] = {0, 1, 0, -1};
                bool check = false;
                rep(way, 0, 4)
                {
                    int nx=j + x[way];
                    int ny=i + y[way];
                    if (nx >= 0 && nx<w)
                    {
                        if ( ny>=0 && ny<h)
                        {
                            if (s[ny][nx] == '#')
                                check = true;
                        }
                    }
                }
                if (!check)
                    {
                        cout << "No" << endl;
                        return 0;
                    }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  rep(i, N){
    cin >> S.at(i);
  }
  
  map<string, int> count;
  
  rep(i, N){
    count[S.at(i)] += 1;
  }
  
  int max_num = 0;
  vector<string> max_str;
  for (auto p : count){
    max_num = max(p.second, max_num);
  }
  
  for (auto p: count){
    if (p.second == max_num){
      max_str.push_back(p.first);
    }
  }
  
  sort(max_str.begin(), max_str.end());
  rep(i, max_str.size()){
    cout << max_str.at(i) << endl;
  }
  
}


Measured memory_bytes: 28404
#include<iostream>
using namespace std;
int main()
{
	int h,n,z=0;
	cin>>h>>n;
	int a;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		z+=a;
	}
	if(z>=h)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    loop {
        let a:u32 = sc.read();
        let b:u32 = sc.read();
        if a == 0 && b == 0 {
            break;
        }
        for i in 0..a {
            for j in 0..b {
                if (i != 0 && i != a-1) && (j != 0 && j != b-1 ){
                    print!(".");
                }else {
                    print!("#");
                }
            }
            println!("");
        }
        println!("");
    }
    
}

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
 
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 5020
A, B, C, X, Y = map(int, input().split())

if X < Y:
    temp = A
    A = B
    B = temp
    temp = X
    X = Y
    Y = temp

# Aピザを購入する
lower_price = 0

# 0 - X枚まで
for i in range(0, X + 1, 1):
    # Aピザ i枚と、Cピザ 2(X-i)枚を購入する
    price_a = A * i + C * 2 * (X - i)
    price_b = 0
    # Bピザの枚数が多い場合、不足分Bピザを購入する
    if X - i < Y:
        price_b = B * (Y - (X - i))
    price = price_a + price_b
    if lower_price == 0 or price < lower_price:
        lower_price = price

print(lower_price)


Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>//"geometry.cpp"
//#include <iostream>
//#include <cstdio>
//#include <iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
//#include <queue>
//#include <string>//"reverse((s's iterator), (s's iterator))"
//#include <vector>
//#include <utility>
//#include <set>
//#include <map>
//#include <algorithm>//"lower_bound(it,it,v)", "next_permutation(a,a+n)"
//#include <functional>//"greater<T>" Ex. sort(a,a+n,greater<int>());
//#include <cmath>//"abs", "sqrt"
using namespace std;
#define pb push_back//Can be used for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert
typedef pair<int,int> pii;//Add other types in the same way.

int main(){
	int n,e[3];
	cin>>n;
	fill(e,e+3,0);
	for(;n>0;--n){
		int a;
		cin>>a;
		if(a%4==0) ++e[2];
		else if(a%2==0) ++e[1];
		else ++e[0];
	}
	if(e[0]<=e[2]) cout<<"Yes"<<endl;
	else if(e[0]==e[2]+1&&e[1]==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] values = new int[w];
        for(int i=0; i<values.length; i++){
            values[i] = i + 1;
        }
        for(int i=0; i<n; i++){
            String str = sc.next();
            String[] ab = str.split(",");
            int a = Integer.parseInt(ab[0]) - 1;
            int b = Integer.parseInt(ab[1]) - 1;
            int value = values[a];
            values[a] = values[b];
            values[b] = value;
        }
        for(int i=0; i<values.length; i++){
            System.out.println(values[i]);
        }
        sc.close();
    }
}


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

int main(){
  int h,n;
  cin >> h >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int sum = 0;
  rep(i,n) sum += a[i];
  if (sum >= h) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

typedef long long i64;
typedef pair<i64, i64> pii;

const int INF = 0x3f3f3f3f;
const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  while (cin >> n, n) {
    ++n;
    int h[110];
    int diff[110];

    rep(i, n) {
      cin >> h[i];
      if (i >= 1) diff[i] = h[i] - h[i-1];
    }

    int ans;
    bool found = false;
    int tmp;
    int samecount;

    for (int i = 1; i < n; ++i) {
      samecount = 0;
      if (i < n - 1) tmp = h[i+1] - h[i-1];
      else tmp = diff[i-1];
      for (int j = 1; j < n; ++j) {

        if (i != j) {
          if (tmp == diff[j]) ++samecount;
          else if (j == i + 1) ++samecount;
        }
      }

      if (samecount == n - 2) {
        ans = h[i];
        found = true;
        break;
      }
    }

    if (found) cout << ans << '\n';
    else cout << h[0] << '\n';

  }
  return 0;
}



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

public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int	cnt = parseCnt();

		while(cnt-- > 0) {
			int	scr = 0;
			int	hit = 0;
			int out = 0;

			while(out < 3) {
				String	str = parseStdin();
				if (str.endsWith("OUT")) {
					out++;
				}
				else if (str.endsWith("HIT")) {
					if (hit == 3) {
						scr++;
					} else {
						hit++;
					}
				}
				else if (str.endsWith("HOMERUN")) {
					scr += (hit + 1);
					hit  = 0;
				}
			}

			System.out.println(scr);
		}
	}

	private static int parseCnt() {
		int		cnt = 0;
		String	str = null;

		if ((str = parseStdin()) != null) {
			cnt = Integer.parseInt(str);
		}

		return cnt;
	}

	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (tmp != null) {
            	if (!tmp.isEmpty()) {
            		stdin = tmp;
            	}
        	}
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 17036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    deque<ll> deq;
    if (N % 2 == 0) {
        reps(i, N) {
            if (i % 2 == 0) deq.push_front(A[i - 1]);
            else deq.push_back(A[i - 1]);
        }
    } else {
        reps(i, N) {
            if (i % 2 == 0) deq.push_back(A[i - 1]);
            else deq.push_front(A[i - 1]);
        }
    }

    rep(i, N) {
        if (i > 0) cout << " ";
        cout << deq[i];
    }
    cout << endl;
}

Measured memory_bytes: 6396
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        APair solver = new APair();
        solver.solve(1, in, out);
        out.close();
    }

    static class APair {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int k = in.nextInt();

            int answer = (k / 2) * ((k + 1) / 2);
            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22868