akhauriyash/Code-Regression huggingface dataset:
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}


 main()

{
    fast
    int ses=0;
    string s;
    cin>>s;
    int sz=s.size();
    int cnt=0;
    rf(i,sz-1,0)
    {
        if(s[i]=='W')
        {
            cnt++;
            continue;
        }
        else
        {
            ses+=cnt;
        }
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 3784
#include <iostream>

using namespace std;
int main()
{

	int N, i, ads = 0, ans = 0;

	cin >> N;

	int S[200];

	for (i = 0; i < N; i++) {
		S[i] = 0;
		cin >> S[i];
	}

	while (true) {

		ads = 0;
		for (i = 0; i < N; i++) {

			if (S[i] % 2 == 0) {
				ads++;
				continue;
			}
			else
				break;
		}

		if (ads == N) {
			for (i = 0; i < N; i++) {
				S[i] = S[i] / 2;
			}
			ans++;
		}
		else
			break;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <climits>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n, m;
  cin >> n >> m;
  vecint num(n, 1);
  vecint isred(n, 0);
  isred[0] = 1;
  REP(i, m) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    if (isred[x]) {
      if (num[x] == 1) {
        isred[x] = 0;
        isred[y] = 1;
      } else {
        isred[x] = isred[y] = 1;
      }
    }
    num[x]--;
    num[y]++;
  }
  int ans = 0;
  REP(i, n) {
    if (isred[i]) ans++;
  }
  cout << ans << endl;
}
//////////////////////////////////////////////


Measured memory_bytes: 1024
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n; cin>>n;
  int low_prime[12]={2,3,5,7,11,13,17,19,23,29,31,37};
  vector<int> primes;
  REP(i,12)primes.push_back(low_prime[i]);
  for(int i=2;i<=1000;i++){
    bool flag=true;
    REP(j,12){
      if(i%low_prime[j]==0)flag=false;
    }
    if(flag)primes.push_back(i);
  }
  // REP(i,(int)primes.size())P(primes[i]);
  int prime_counter[1000]={};
  REP(i,1000)prime_counter[i]++;
  ll sm=1;
  for(int i=1; i<=n; i++) {
    REP(j,(int)primes.size()){
      ll prime=primes[j];
      while(i%prime==0) {
        prime_counter[j]++;
        prime*=primes[j];
      }
    }
  }
  REP(i,1000){
    sm*=prime_counter[i];
    sm%=MOD;
  }
  P(sm);

  return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Infinite Coins
 */

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

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, a;
  scanf("%d%d", &n, &a);

  if (n % 500 <= a) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int h,w,n,ans;
	scanf("%d%d%d",&h,&w,&n);
	if(h<w){
		h=w;
	}
	ans=n/h;
	if(n%h!=0){
		ans++;
	}
	cout<<ans<<endl;
	return 0;
} 

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

int main(){
  int X;
  cin >> X;
  if (X >= 1800){
    cout << "1" << endl;
    return 0;
  }
  if (X >= 1600){
    cout << "2" << endl;
    return 0;
  }
  if (X >= 1400){
    cout << "3" << endl;
    return 0;
  }if (X >= 1200){
    cout << "4" << endl;
    return 0;
  }if (X >= 1000){
    cout << "5" << endl;
    return 0;
  }if (X >= 800){
    cout << "6" << endl;
    return 0;
  }
  if (X >= 600){
    cout << "7" << endl;
    return 0;
  }
  if (X >= 400){
    cout << "8" << endl;
    return 0;
  }
  
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <complex>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack> 
#include <bitset>
#include <queue>
#include <assert.h>
using namespace std;

const int N = 1000010;
vector<int> fac[N];
int a[N], cnt[N];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i < N; i++)
		for (int j = i * 2; j < N; j+=i)
		    fac[j].push_back(i);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		cnt[a[i]]++;
	}

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int x = a[i];
		if (cnt[x] > 1) {
			continue;
		}
		bool flag = true;
		for (int j = 0; j < fac[x].size(); j++)
			if (cnt[fac[x][j]]) {
				flag = false;
				break;
			}
		if (flag) ans++;
	}

	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 122100
#include <iostream>
#include <cmath>
#include <cassert>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <type_traits>
#include <fstream>
//#include <bits/stdc++.h>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}


int main(int argc, char* argv[])
{
  //std::ifstream ifs("input.txt");
  //std::cin.rdbuf(ifs.rdbuf());

  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  std::string s;
  ll K;
  std::cin >> s >> K;

  std::vector< std::string > vs;
  for (ll i = 0; i < (ll)s.size(); i++) {
    for (ll j = 1; j <= K; j++) {
      vs.push_back(s.substr(i, j));
    }
  }
  std::sort(vs.begin(), vs.end());
  vs.erase(std::unique(vs.begin(), vs.end()), vs.end());

  std::priority_queue< std::string, std::vector<std::string>, std::greater<> > que;
  for (auto s1 : vs) {
    que.push(s1);
  }

  for (ll i = 0; i < K; i++) {
    std::string s1 = que.top(); que.pop();
    if (i == K-1) print(s1);
  }

  return 0;
}


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

int main(){
	ll k, a, b;
	
	cin >> k;
	cin >> a >> b;
	
	for(int i=a; i<=b; i++){
	    if(i%k==0){ cout << "OK" << endl; return 0;}
	}
	cout << "NG" << endl;
	
	return 0;
}

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

const int MAXN = 20, MAXS = (1 << 18) + 20, INF = 0x3f3f3f3f;
int n, a[MAXN], b[MAXN], dp[MAXS][MAXN];

void umin(int &x, int y) { if(y < x) x = y; }
int main() {
    memset(dp, 0x3f, sizeof dp);
    scanf("%d", &n);
    for(int i = 0; i < n; ++i)
        scanf("%d", &a[i]);
    for(int i = 0; i < n; ++i)
        scanf("%d", &b[i]);
    a[n] = b[n] = 0;
    dp[0][n] = 0;
    int full = (1 << n) - 1;
    for(int S = 0; S < full; ++S) {
        int pp = __builtin_popcount(S), ptr1 = 0, ptr2 = pp;
        static int idx[MAXN];
        for(int i = 0; i < n; ++i) {
            if(S >> i & 1) idx[i] = ptr1++;
            else idx[i] = ptr2++;
        }
        for(int i = 0; i <= n; ++i) if(dp[S][i] != INF) {
            int las = ((pp & 1) ^ (i & 1)) ? a[i] : b[i];
            for(int j = 0; j < n; ++j) if(~S >> j & 1) {
                int cur = ((pp & 1) ^ (j & 1)) ? b[j] : a[j];
                if(cur < las) continue;
                umin(dp[S ^ (1 << j)][j], dp[S][i] + idx[j] - pp);
            }
        }
    }
    int ans = *min_element(dp[full], dp[full] + n);
    printf("%d\n", ans == INF ? -1 : ans);
    return 0;
}


Measured memory_bytes: 20736
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
long long int cou[2][70];
int main(){
    long long int N;
    cin>>N;
    for(long long int i=0;i<N;i++){
        long long int pa;
        cin>>pa;
        for(long long int i=0;i<61;i++){
            cou[pa%2][i]++;
            pa/=2;
        }
    }
    long long int ans=0;
    long long int rui2=1;
    for(long long int i=0;i<61;i++){
        ans+=((((cou[0][i]*cou[1][i])%1000000007)*rui2)%1000000007);
        ans%=1000000007;
        rui2*=2;
        rui2%=1000000007;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main(){
	
	int n,k,x[200],ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>x[i];
	for(int i=0;i<n;i++){
		if(x[i]>k-x[i])ans+=(k-x[i])*2;
		else ans+=x[i]*2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <stack>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << "=" << x << ", "
#define de(x) cout << #x << "=" << x << endl
#define ds() puts("---stop here---")
#define mset(a,i) memset(a,i,sizeof(a))
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define E 1e-6
#define INF 0x3f3f3f3f
void open(){freopen("data.txt","r",stdin);}
void out(){freopen("out.txt","w",stdout);}
const int maxn = 2e5+5;
const int MOD = 1e9 + 7;

int cnt[maxn] , arr[maxn];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    rep(i,1,n+1){
        int x;
        scanf("%d",&x);
        cnt[x]++;
    }
    int tot = 0;
    rep(i,1,n+1){
        if(!cnt[i]) continue;
        arr[++tot] = cnt[i];
    }
    sort(arr+1 , arr+1+tot);

    int ans = 0;
    rep(i,1,tot-k+1) ans+=arr[i];
    printf("%d\n",ans);
}


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

int N,M,Q;

//累積和
vector<vector<int>> sum;
int buildSumTable(vector<int>L, vector<int>R){
  sum=vector<vector<int>>(N+1,vector<int>(N+1,0));
  //大きい長方形を求めるときに長方形+長方形-被っているところ+四角形ってやるよねって式
  for (int i=0;i<M;++i){
    sum[L[i]][R[i]]++;
  }

  for (int i=1;i<=N;++i){
    for (int j=1;j<=N;++j){
      sum[i][j]+=sum[i-1][j];
      sum[i][j]+=sum[i][j-1];
      sum[i][j]-=sum[i-1][j-1];
    }
  } 
}

int getSumRange(int L, int R){
  //大きい長方形を求めるときに長方形+長方形-被っているところ+四角形ってやるよねって式
  int ans=sum[R][R]-sum[R][L-1]-sum[L-1][R]+sum[L-1][L-1];
  return ans;
}

int main(){
  cin >> N >> M >> Q;
  vector<int> L(M);
  vector<int> R(M);
  for (int i=0;i<M;++i) cin >> L[i] >> R[i];
  vector<int> p(Q);
  vector<int> q(Q);
  for (int i=0;i<Q;++i) cin >> p[i] >> q[i];
  buildSumTable(L,R);
  for (int i=0;i<Q;++i){
    int ans=getSumRange(p[i],q[i]);
    cout << ans << endl;
  }
}
//上級者はセグ木でやるらしい...
//この問題はLとRの軸を垂直に取って長方形を考えることができるかが肝

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define pb push_back
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define Max(x) max_element(all(x))
#define Min(x) min_element(all(x))
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,k,n) for(int i=k;i<n;i++)
#define reppp(i,k,n,m) for(int i=k;i<n;i+=m)
#define repv(i,n) for(int i=n-1;i=0;i--)
#define vi vector<int> 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> iv;
typedef pair<int,int> iip;
typedef map<int,int> mii;

int main(){
	int n, o=0,c=0;
	string s;
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]==')' ){
		if (o==0)c++;
		else o--;
		}
		else {o++;
		}
	}
		cout<<string(c,'(')+s+string(o,')')<<endl;
		return 0;
	}

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

using namespace std;

using ii = tuple<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvii = vector<vii>;

int n, u, v, w;
vi c;
vvii g;

void dfs(int u, int p) {
  for (ii &x : g[u]) {
    tie(v, w) = x;
    if (v != p) {
      if (w % 2) c[v] = !c[u];
      else c[v] = c[u];
      dfs(v, u);
    }
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  g = vvii(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v >> w;
    u--, v--;
    g[u].push_back(make_tuple(v, w));
    g[v].push_back(make_tuple(u, w));
  }
  c = vi(n);
  c[0] = 0;
  dfs(0, -1);
  for (int x : c) cout << x << "\n";
}


Measured memory_bytes: 8192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC086A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            if (a * b % 2 == 0)
                Console.WriteLine("Even");

            else
                Console.WriteLine("Odd");

            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n);
    cin >> a;
    
    int ans = 1'000'000'000;
    rep(yi, n) {
        int y = a[yi];
        vector<int> values;
        rep(i, n) {
            if (a[i] < y) continue;
            vector<int> v;
            {
                int j = i;
                while (j < n && a[j] >= y) v.push_back(a[j++]);
                i = j;
            }
            
            if ((int)v.size() >= k) {
                sort(v.begin(), v.end());
                rep(j, (int)v.size() - k + 1) values.push_back(v[j]);
            }
        }
        
        if ((int)values.size() >= q) {
            sort(values.begin(), values.end());
            int x = values[q - 1];
            chmin(ans, x - y);
        }
    }
    cout << ans << endl;
}

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

int main(void) {
  int n;
  int data[11][11];
  
  while(1) {
    cin >> n;
    if(n==0) break;
    for(int i=0; i<n; i++) for(int j=0; j<n; j++) cin >> data[i][j];
    
    int temp=0;
    for(int i=0; i<n; i++) {
      for(int j=0; j<n; j++) {
	temp+=data[i][j];
      }
      data[i][n] = temp;
      temp=0;
    }
    
    for(int i=0; i<n; i++) {
      for(int j=0; j<n; j++) {
	temp+=data[j][i];
      }
      data[n][i] = temp;
      temp=0;
    }
    
    for(int i=0; i<n; i++) temp+=data[i][n];
    data[n][n] = temp;
    
    for(int i=0; i<=n; i++) {
      for(int j=0; j<=n; j++) {
	printf("%5d", data[i][j]);
      }
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;


ll solve(bool sign, vi &a, int N)
{
    // initialize
    int S = a.at(0);
    ll ans = 0;
    if(sign) {    // make S positive
        if(S <= 0) {
            ans = -S + 1;
            S = 1;
        }
    } else {    // make S negative
        if(S >= 0) {
            ans = S + 1;
            S = -1;
        }
    }

    FOR(i, 1, N)  {
        if(S > 0) {
            S += a.at(i);
            if(S >= 0) {
                ans += (S+1);
                S = -1; 
            }
        } else {
            S += a.at(i);
            if(S <= 0) {
                ans += (-S+1);
                S = 1;
            }
        }
    }
    return ans;
}

int main()
{
    int N;
    cin >> N;
    vi a(N);
    REP(i, N) {
        cin >> a.at(i);
    }
    ll ans;
    ans = min(solve(false, a, N), solve(true, a, N));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
 
int main(){
  int N,A[100],i,k,j,key;
  scanf("%d",&N);
  
  for(i=0;i<N;i++) scanf("%d",&A[i]);
 for(i=0;i<N-1;i++) printf("%d ",A[i]);
 printf("%d\n",A[N-1]);
 for(j=1;j<N;j++){
   key=A[j];
  i=j-1;
  while (i>-1 && A[i]>key){
    A[i+1]=A[i];
i--;
}
  A[i+1]=key;
for(k=0;k<N-1;k++) 
printf("%d ",A[k]);
 printf("%d\n",A[N-1]);
}
 
return 0;
}

Measured memory_bytes: 600
H,W=map(int, input().split())
A=[list(input()) for _ in range(H)]

#dp[i][j]=最も近い黒マスまでの最小マンハッタン距離
INF=10**9
dp = [[INF] * W for _ in range(H)]

#右
for i in range(H):
    c = INF
    for j in range(W):
        if A[i][j] == '#': c = 0
        elif j>=1: c = dp[i][j-1] + 1
        dp[i][j] = min(dp[i][j], c)

#下
for j in range(W):
    c = INF
    for i in range(H):
        if A[i][j] == '#': c = 0
        elif i>=1: c = dp[i-1][j] + 1
        dp[i][j] = min(dp[i][j], c)

#左
for i in range(H):
    c = INF
    for j in range(W-1,-1,-1):
        if A[i][j] == '#': c = 0
        elif j<W-1: c = dp[i][j+1] + 1
        dp[i][j] = min(dp[i][j], c)

#上
for j in range(W):
    c = INF
    for i in range(H-1,-1,-1):
        if A[i][j] == '#': c = 0
        elif i<H-1: c = dp[i+1][j] + 1
        dp[i][j] = min(dp[i][j], c)

ans=0
for i in range(H):
    for j in range(W):
        ans = max(ans, dp[i][j])
print(ans)


Measured memory_bytes: 93660
from collections import Counter
N=int(input())
s=[str(sorted(input())) for i in range(N)]

ans=0
cnt={}

for i in range(N):
    if s[i] in cnt:
        ans+=cnt[s[i]]
        cnt[s[i]]+=1
    else:
        cnt[s[i]]=1
        
print(ans)

Measured memory_bytes: 28844
#include <iostream>
#include <stdlib.h>

using namespace std;

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}


int main() {
	int a[10];
	
	for(int i = 0;i < 10;i++)
		cin >> a[i];
	
	qsort(a,10,sizeof(int),compare_int);
	
	for(int i = 0;i < 3;i++){
		cout << a[i];
		cout << "\n";
	}
	
	// your code goes here
	return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int x[n],y[n],h[n],m=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>x[i]>>y[i]>>h[i];
		if (h[i]!=0)
		{
			m=i;
		}
	}
	for (int i = 0; i < 101; ++i)
	{
		for (int j = 0; j < 101; ++j)
		{
			int f=1,t=h[m]+abs(x[m]-i)+abs(y[m]-j);
			for (int k = 0; k < n; ++k)
			{
				if (h[k]!=max(t-abs(x[k]-i)-abs(y[k]-j),0))
				{
					f=0;
				}
			}
			if (f)
			{
				cout<<i<<" "<<j<<" "<<t<<endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
use std::collections::BinaryHeap;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let mut a: Vec<u64> = sc.vec(n);
    a.sort();
    a.reverse();
    let mut heap = BinaryHeap::new();
    heap.push(a[0]);
    let mut ans = 0;
    for i in 1..n {
        let a = a[i];
        let head = heap.pop().unwrap();
        ans += head;
        heap.push(a);
        heap.push(a);
    }
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ll long long
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
using namespace std;
const ll N = 5e5 + 100;
ll num[N << 2], sum[N << 2], s[N];
struct poll {
    ll flag;
    ll x, y;
    poll (){}
    poll (ll _x, ll _y, ll _flag) {
        x = _x, y = _y, flag = _flag;
    }
    void input () {
        scanf ("%lld %lld", &x, &y);
    }
    bool operator < (const poll &b) const {
        return x < b.x || (x == b.x && y < b.y);
    }
} ;
struct line {
    ll y, flag;
    poll s, e;
    void input () {
        s.input (), e.input ();
    }
} ps[N << 2];
ll cmp (line a, line b) {
    return a.y < b.y || (a.y == b.y && a.flag < b.flag);
}
inline void F (ll rt) {
    sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];
}
void update (ll pos, ll k, ll l, ll r, ll rt) {
    if (l == r) {
        sum[rt] += k;
        return;
    }
    ll mid = l + r >> 1;
    if (pos <= mid) update (pos, k, lson);
    else update (pos, k, rson);
    F (rt);
}
ll query (ll L, ll R, ll l, ll r, ll rt) {
    if (L <= l && r <= R) return sum[rt];
    ll mid = l + r >> 1, ans = 0;
    if (L <= mid) ans += query (L, R, lson);
    if (R > mid) ans += query (L, R, rson);
    return ans;
}
int main () {
//    freopen ("in.txt", "r", stdin);
    ll n, v = 0, ans = 0;
    cin >> n;
    ll temp = n;
    for (ll i = 0; i < n; i++) ps[i].input (), s[v++] = ps[i].s.x, s[v++] = ps[i].s.y, s[v++] = ps[i].e.x, s[v++] = ps[i].e.y;
    sort (s, s + v);
//    cout << endl;
    ll len = unique (s, s + v) - s;
    for (ll i = 0, flag; i < n; i++) {
        if (ps[i].e < ps[i].s) swap (ps[i].s, ps[i].e);
//        cout << ps[i].s.x << ' ' << ps[i].s.y << ' ' << ps[i].e.x << ' ' << ps[i].e.y << endl;
        if (ps[i].e.x == ps[i].s.x) {
            ps[i].flag = -1;
            ps[i].y = ps[i].s.y;

            ps[temp].flag = 1;
            ps[temp].s.x = ps[i].s.x;
            ps[temp].y = ps[i].e.y;
            temp++;
        } else {
            ps[i].flag = 0;
            ps[i].y = ps[i].s.y;
        }
    }
    sort (ps, ps + temp, cmp);
    for (ll i = 0; i < temp; i++) {
        if (ps[i].flag) {
            ll u = lower_bound(s, s + len, ps[i].s.x) - s + 1;
//            cout << "****" << ps[i].s.x << ' ' << ps[i].y << ' ' << u << ' ' << ps[i].flag << endl;
            if (ps[i].flag > 0) update (u, -1, 1, len, 1);
            else update (u, 1, 1, len, 1);
        } else {
//            cout << ps[i].s.x << ' ' << ps[i].e.x << endl;
            ll a = lower_bound(s, s + len, ps[i].s.x) - s + 1;
            ll b = lower_bound(s, s + len, ps[i].e.x) - s + 1;
            ans += query (a, b, 1, len, 1);
//        cout << ans << endl;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 19508
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,n) for(int i = 1;i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define PB push_back
#define MOD 10000007
#define PI 3.14159265359

using namespace std;

int main(){

    int r;
    cin >> r;

    cout << 2*r*PI <<"\n";

}


Measured memory_bytes: 3776
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


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

const int mod = 1000000007;


int main(){
  int n;
  cin >> n;
  int sum = 0;

  int tmp = n;

  for(; tmp > 0;){
    sum += tmp % 10;
    tmp /= 10;
  }
  
  if(n % sum == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
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();
    ArrayList<Integer> r = new ArrayList<>();
    ArrayList<Integer> w = new ArrayList<>();
    for(int i=0;i<s.length();i++){
      if(s.charAt(i)=='R'){
        r.add(i);
      }
      else{
        w.add(i);
      }
    }
    int i1=0;
    int j1=r.size()-1;
    int ans=0;
    while(i1<w.size() && j1>=0){
      if(w.get(i1)<r.get(j1)){
        ans++;
      }
      i1++;
      j1--;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 46296
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){

  int N, M; cin >> N >> M;

  vector <int> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i]; P[i]--;
  }

  vector < vector<int> > graph(N);
  for (int i = 0; i < M; i++){
    int X, Y; cin >> X >> Y;
    X--; Y--;
    graph[X].push_back(Y);
    graph[Y].push_back(X);
  }
  
  vector <bool> visited(N);

  queue <int> que;
  que.push(0); visited[0] = true;

  vector <int> group(N);
  int cnt = 0;
  group[0] = cnt;
  int notvisited = 1;
  while (!que.empty()){
    int start = que.front(); que.pop();

    for (int i = 0; i < graph[start].size(); i++){
      int next = graph[start][i];
      if (visited[next] == false){
        visited[next] = true;
        que.push(next);
        group[next] = cnt;
      }
    }
    if (que.empty()){
      cnt++;
      for (int i = notvisited; i < N; i++){
        if (visited[i] == false){
          visited[i] = true;
          que.push(i);
          group[i] = cnt;
          notvisited = i + 1;
          break;
        }
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++){
    if (group[i] == group[P[i]]){
      ans++;
    }
  }
  
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ctime>
#include <set>
#include <sstream>
#include <bitset>
#include <queue>
#define ll long long
using namespace std;

int main() {
    int n;
    cin>>n;
    unordered_map<string, int> mp;
    for (int i = 0; i < n; i++) {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<mp.size();
}


Measured memory_bytes: 17724
#include<iostream>
#include<queue>

using namespace std;

static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N]; // 距離で訪問状態(color)を管理する

void bfs(int s){
    queue<int> q;
    q.push(s);
    for(int i=0; i<n; i++) d[i] = INFTY;

    d[s] = 0;
    int u;

    while(!q.empty()){
        u = q.front();
        q.pop();

        for(int v=0; v<n; v++){
            if(M[u][v] == 0) continue;
            if(d[v] != INFTY) continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for(int i=0; i<n; i++){
        cout << i+1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
    }
}

int main(int argc, char const *argv[])
{
    int u, k, v;

    cin >> n;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++) M[i][j] = 0;
    }

    for(int i=0; i<n; i++){
        cin >> u >> k;
        u--;
        for(int j=0; j<k; j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }    

    bfs(0);

    return 0;
}



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

using namespace std;
using ll = long long int;
#define vll vector<ll>

#define FOR(i, b, e) for(int i = (b); i < (e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define REV(v) reverse((v).begin(), (v).end())
#define IN(v) cin >> (v);
#define VIN(v, n) REP(i, n) cin >> v[i];
#define OUT(v) cout << (v) << endl;
#define YN(b) OUT((b) ? "YES" : "NO")
#define Yn(b) OUT((b) ? "Yes" : "No")
#define yn(b) OUT((b) ? "yes" : "no")

const ll MOD = 1000000007;

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

  ll n, k, r = 0;
  cin >> n >> k;
  r = k;
  REP(i, n - 1)
    r *= k - 1;
  OUT(r);

  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c, x int
	fmt.Scan(&a, &b, &c, &x)

	count := 0
	for numA := 0; numA <= a && x-500*numA >= 0; numA++ {
		for numB := 0; numB <= b && x-500*numA-100*numB >= 0; numB++ {
			if (x-500*numA-100*numB)%50 == 0 &&
				(x-500*numA-100*numB) <= 50*c {
				count++
			}
		}
	}
	fmt.Println(count)
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,k;

signed main() {
    cin >> n >> k;
    if (k > 1) cout << n-k << endl;
    else cout << 0 << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int N;cin>>N;
  for(int t=0;t<N;t++){
    char s;cin>>s;
    if(s=='Y'){
      cout<<"Four"<<"\n";
      return 0;
    }
  }

  cout<<"Three"<<"\n";
  return 0;
}


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

ss = []
for s in range(n):
    ss.append(input())

print(f'AC x {ss.count("AC")}')
print(f'WA x {ss.count("WA")}')
print(f'TLE x {ss.count("TLE")}')
print(f'RE x {ss.count("RE")}')


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

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

    vector<double> v(N);
    rep(i,N) cin >> v[i];
    
    sort(v.begin(),v.end());

    repd(i,1,N){
        v[i]=(v[i]+v[i-1])/2;
    }
    printf("%g\n",v[N-1]);
    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++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int x; cin >> x;

  cout << ((x==3 || x==5 || x==7) ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int data[305][305], countData[305], isChoose[305];
int main()
{
    int n, m, result = INT_MAX, now, nowPos;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= m; ++j)
            scanf("%d", &data[i][j]);
    }
    for (int i = 1; i <= m; ++i)
        isChoose[i] = 1;

    do
    {
        now = 0;
        nowPos = 0;
        memset(countData, 0, sizeof(countData));
        for (int i = 1; i <= n; ++i)
        {
            for (int j = 1; j <= m; ++j)
            {
                if (isChoose[data[i][j]] == 1)
                {
                    ++countData[data[i][j]];
                    break;
                }
            }
        }
        for (int i = 1; i <= m; ++i)
        {
            if (now < countData[i])
            {
                now = countData[i];
                nowPos = i;
            }
        }
        if (now == 0)
        {
            break;
        }
        else
        {
            result = min(now, result);
            isChoose[nowPos] = 0;
        }
    }while(true);
    printf("%d\n", result);
    return 0;
}


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

int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> a(H);
	for (int i = 0; i < H; i++) {
		cin >> a[i];
	}
	vector<int> r, c;
	for (int i = 0; i < H; i++) {
		if (a[i] != string(W, '.')) r.push_back(i);
	}
	for (int j = 0; j < W; j++) {
		bool ok = false;
		for (int i = 0; i < H; i++) {
			ok |= a[i][j] != '.';
		}
		if (ok) c.push_back(j);
	}
	for (auto i : r) {
		for (auto j : c) {
			cout << a[i][j];
		}
		cout << endl;
	}
	return 0;
}


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

using namespace std;

int main() {
	string s;
	cin >> s;
	int n = s.length();
	int count = 0;
	for (int i = 0; i < n; i++) {
		count += (int) s[i] - 48;
	}
	string ans = (count % 9 == 0) ? "Yes" : "No";
	cout << ans;
}


Measured memory_bytes: 3760
#include <iostream>
using namespace std;
int main(){
	int n, a,d=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 2 == 0)
			if (a % 3 != 0 && a % 5 != 0)
				d++;
	}
	if (d > 0)
		cout << "DENIED";
	else
		cout << "APPROVED";
}

Measured memory_bytes: 3632
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/8/ITP2/2/ITP2_2_D
#include <iostream>
#include <vector>
#include <list>

int main()
{
    int n, q;
    std::cin >> n >> q;
    std::vector<std::list<int>> List(n);

    int m, s, t, x;
    for (int i = 0; i < q; i++)
    {
        std::cin >> m;
        if (m == 0)
        {
            std::cin >> t >> x;
            List[t].push_back(x);
        }
        else if (m == 1)
        {
            std::cin >> t;
            for (auto itr = List[t].begin(); itr != List[t].end(); itr++)
            {
                std::cout << *itr;
                if (next(itr) != List[t].end())
                    std::cout << " ";
            }
            std::cout << std::endl;
        }
        else if (m == 2)
        {
            std::cin >> s >> t;
            auto itr = List[t].end();
            List[t].splice(itr, List[s]);
        }
    }
    return 0;
}


Measured memory_bytes: 18656
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;



int MOD=1000000007;
int main(void){
	long long X,K=0;
	cin >> X;
	for(long long i=X; i<=MOD; i+=1){
		for(long long j=2; j<i; j++){
			if(i%j==0){
				K=1;
			}
		}
		if(K==0){
			cout << i << endl;
			return 0;
		}K=0;
	}
}


Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))}
const main=()=>{
  let [n,y]=tnn(2)
  for(let i=0;i*10000<=y&&i<=n;i++){
    for(let g=0;i*10000+g*5000<=y&&g+i<=n;g++){
      let s=n-g-i; 
      if(i*10000+g*5000+s*1000==y){
        to(`${i} ${g} ${s}`)
        return
      }
    }
  }
  to('-1 -1 -1')
}
main()


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int h, n;
int main() {
    cin >> h >> n;
    vector<int> a(n, 0);
    int sum = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i);
        sum += a.at(i);
    }

    if(h <= sum) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int N;
    cin >> N;
    vector<string> S(N);
    vector<int> num(4,0);
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
    }
    for(int i = 0; i < N; i++ )
    {
        if(S[i]=="AC"){
            num[0]++;
        }else if(S[i]=="WA"){
            num[1]++;
        }else if(S[i]=="TLE"){
            num[2]++;
        }else{
            num[3]++;
        }
    }
    cout << "AC x " << num[0] << endl;
    cout << "WA x " << num[1] << endl;
    cout << "TLE x " << num[2] << endl;
    cout << "RE x " << num[3] << endl;
    return 0;
}

Measured memory_bytes: 6344
#include "bits/stdc++.h"
    #define LF '\n'
    #define ALL(x) x.begin(), x.end()
    #define iostreamBooster() do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
    using namespace std;
    typedef int64_t i64;
    typedef pair<int,int> pii;
    template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
    template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
    constexpr int INF = 0x3f3f3f3f;
    constexpr i64 LINF = 0x3f3f3f3f'3f3f3f3fLL;
    signed main()
    {
    int N;
    vector<int> a;
    cin >> N;
    for (int i = 0; i < N; ++i) {
    int n;
    cin >> n;
    a.push_back(n);
    }
    sort(ALL(a));
    int sum = 0;
    for (int i = 0; i < N-1; ++i) sum += a[i];
    if (a.back() < sum) {
    puts("Yes");
    } else {
    puts("No");
    }
    return 0;
    }


Measured memory_bytes: 256
dic = {"0":"0", "1":"1", "2":"2", "3":"3",
       "4":"5", "5":"7", "6":"8", "7":"9"}
def trans(n):
  if n == 0:
    return "0"
  acc = ""
  while n:
    acc += dic[str(n % 8)]
    n //= 8
  return acc[::-1]

while True:
  n = int(input())
  if n == 0:
    break
  print(trans(n))



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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    int a;
    string s;
  cin>>a>>s;
  if(a<3200) cout<<"red";
  else cout<<s;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int a[N], b[N];
 
signed main() {
    IOS;
    int n;  cin >> n;
    for(int i = 1; i <= n; i++){
        int p;  cin >> p;
        a[p]++;
        b[i] = p;
    }
    int cur = 0;
    for(int i = 1; i < N; i++)
        cur += a[i]*(a[i]-1)/2;
    for(int i = 1; i <= n; i++){
        int x = a[b[i]];
        int ans = cur - x*(x-1)/2 + (x-1)*(x-2)/2;
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

#define _int64 long long

int main()
{
  _int64 ans,last;
  int i,n,t,x;
  scanf("%d%d",&n,&t);
  ans=0;
  last=-1;
  for (i=0;i<n;i++)
  {
    scanf("%d",&x);
    if (x<last)
    {
      ans+=t;
      ans-=last-x;
      last=x+t;
    }
    else
    {
      ans+=t;
      last=x+t;
    }
  }
  printf("%lld\n",ans);
  return 0;
}

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



void solve(){
    int a,b,c;
    cin >> a >> b >> c;
    string ans = "NO";
    if(a==5&&b==5&&c==7) ans = "YES";
    if(a==5&&b==7&&c==5) ans = "YES";
    if(a==7&&b==5&&c==5) ans = "YES";
    cout << ans << endl;
}

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

Measured memory_bytes: 256
n = input()
s = raw_input()
cnt = 0
for i in range(n):
    judge = False
    p = raw_input()
    for k in range(len(p)):
        for j in range(1, len(p)):
            for l in range(len(s)):
                if k+l*j < len(p) and p[k+l*j] == s[l]:
                    if l+1 >= len(s): judge = True
                    continue
                break
    if judge == True: cnt += 1
print cnt

Measured memory_bytes: 6436
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,m,q,ans,a[52],b[52],c[52],d[52],f[52];
inline void dfs(re int x){
	if(x>n){
		re int sum=0;
		for(re int i=1;i<=q;++i){
			if(f[b[i]]-f[a[i]]==c[i])sum+=d[i];
		}
		ans=max(ans,sum);
		return;
	}
	for(re int i=f[x-1];i<=m;++i){
		f[x]=i;
		dfs(x+1);
	}
}
signed main(){
	n=read(),m=read(),q=read();
	for(re int i=1;i<=q;++i){
		a[i]=read();
		b[i]=read();
		c[i]=read();
		d[i]=read();
	}
	f[0]=1;
	dfs(1);
	printf("%d",ans);
}


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

ans = [-1 for i in range(n)]
for i in range(n):
    if i % 2 == 0:
        ans[i // 2] = a[n - i - 1]
    else:
        ans[n - (i // 2 + 1)] = a[n - i - 1]
print(' '.join(map(str, ans)))


Measured memory_bytes: 29604
#include <iostream>
#include <queue>
using namespace std;
string s;
int a,b,t,f,cnt;
int x[2][32222],y[2][32222];
int main(){
    cin>>s>>a>>b;
    s+=" ";
    x[0][a+16000]++;
    y[0][b+16000]++;
    for(char c:s){
        if(c=='F'){
            cnt++;
        }
        else {
            if(t%2==0){
                for(int i=8000;i<=24000;i++){
                    if(!f)x[1][i]=x[0][i+cnt];
                    else x[1][i] = max(x[0][i-cnt],x[0][i+cnt]);
                }
                swap(x[0],x[1]);
            }
            else{
                for(int i=8000;i<=24000;i++){
                    y[1][i] = max(y[0][i-cnt],y[0][i+cnt]);
                }
                swap(y[0],y[1]);
            }
            t=1-t;
            f=1;
            cnt=0;
        }
    }
    if(x[0][16000]&&y[0][16000])puts("Yes");
    else puts("No");
    return 0;
}

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

int func(std::string str, int n)
{
	int cnt_min = n;
	std::vector<int> cnt_w(n), cnt_e(n);
	for (int i = 1; i < n; i++)
	{
		if (str[i - 1] == 'W')
			cnt_w[i] = cnt_w[i - 1] + 1;
		else
			cnt_w[i] = cnt_w[i - 1];

		if (str[n - i] == 'E')
			cnt_e[n - i - 1] = cnt_e[n - i] + 1;
		else
			cnt_e[n - i - 1] = cnt_e[n - i];
	}
	for (int i = 0; i < n; i++)
	{
		cnt_min = std::min(cnt_min, cnt_w[i] + cnt_e[i]);
	}
	return cnt_min;
}

int main()
{
	int n;
	std::string s;
	std::cin >> n >> s;

	std::cout << func(s, n) << std::endl;
	return 0;
}


Measured memory_bytes: 3332