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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using ld = long double;

template <typename T>
int sz(T &x) {
  return (int)(x.size());
}

int power(int x, int y, int mod) {
  if (y == 0) {
    return 1;
  }
  int z = power(x, y >> 1, mod);
  z = z * 1ll * z % mod;
  if (y & 1) {
    z = z * 1ll * x % mod;
  }
  return z;
}

const int mod = 998244353;
const int inf = 1'000'000'007;

vector<int> p;

int find9(int x) {
  return p[x] == x ? x : p[x] = find9(p[x]);
}

void merge9(int x, int y) {
  x = find9(x);
  y = find9(y);
  if (x == y) {
    return;
  }
  p[x] = y;
}

void solve() {
  int n, k;
  ll m;
  cin >> n >> m >> k;

  p.clear(), p.resize(n), iota(p.begin(), p.end(), 0);
  vector<int> a(k), b(k), c(k);
  for (int i = 0; i < k; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    if (c[i] == 0) {
      merge9(a[i], b[i]);
    }
  }

  for (int i = 0; i < k; ++i) {
    if (c[i] == 1) {
      if (m == n - 1) {
        cout << "No\n";
        return;
      }
      if (find9(a[i]) == find9(b[i])) {
        cout << "No\n";
        return;
      }
    }
  }

  set<int> s;
  for (int i = 0; i < n; ++i) {
    s.insert(find9(i));
  }

  ll ans = n - 1;

  ll total = 0;
  for (int i = 1; i <= sz(s); ++i) {
    total += max(0, i - 2);
    total += max(0, sz(s) - i - 1);
  }

  total /= 2;
  ans += total;


  if (ans < m) {
    cout << "No\n";
  } else {
    cout << "Yes\n";
  }
}

int main() {
  #ifndef LOCAL58
    // don't forget to remove if interactive
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
  #endif

  int t;
  t = 1;
  while (t--) {
    solve();
  }

  return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

ll modpow(ll n,ll r){
  ll res = 1;
  while(r){
    if(r & 1)res = res*n%MOD;
    n = n*n%MOD;
    r >>= 1;
  }
  return res;
}

int main(){
  
  ll n,K;
  cin >> n >> K;
  vector<ll> v(K+1,0);
  ll res = 0;
  for(ll i = K;i > 0;i--){
    v[i] = modpow(K/i,n);
    for(ll j = 2;i*j <= K;j++)v[i] = (v[i]-v[i*j]+MOD)%MOD;
    (res += v[i]*i)%= MOD;
  }
  cout << res << endl;


  return 0;
}

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

int main(){ 
    int a,b,k;
    cin>>a>>b>>k;
    int totblack=0;
    int ans=0;
    
    char mat[7][7];
    char mcp[7][7];
    char mcp2[7][7];
    
    for(int i=0;i<a;i++) cin>>mat[i];
    
    for(int i=0;i<1<<a;i++){
        
        memcpy(mcp,mat,sizeof mcp);
        for(int d=0;d<a;d++){
            if(i>>d&1) {
                for(int e=0;e<b;e++) mcp[d][e]='.';
            }
        }
        for(int j=0;j<1<<b;j++){
            memcpy(mcp2,mcp,sizeof mcp);
            for(int d=0;d<b;d++){
                if(j>>d&1) {
                    for(int e=0;e<a;e++) mcp2[e][d]='.';
                }
            }
            for(int y=0;y<a;y++){
                for(int x=0;x<b;x++){
                    if(mcp2[y][x]=='#') totblack++;
                }
            }
            if(totblack==k) {
                ans++;
            }
            totblack=0;
        }
    }
   
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3580
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

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

//1-indexed
class BIT {
public:
    ll n; //データの長さ
    vector<ll> bit; //データの格納先
    BIT(ll n):n(n),bit(n+1,0){} //コンストラクタ

    //k & -kはLSB

    //bit_iにxをO(log(n))で加算する
    void add(ll i,ll x){
        if(i==0) return;
        for(ll k=i;k<=n;k+=(k & -k)){
            bit[k]+=x;
        }
    }

    //bit_1 + bit_2 + …  + bit_n をO(log(n))で求める
    ll sum(ll i){
        ll s=0;
        if(i==0) return s;
        for(ll k=i;k>0;k-=(k & -k)){
            s+=bit[k];
        }
        return s;
    }

    //a_1 + a_2 + … + a_i >= x となるような最小のiを求める(a_k >= 0)
    //xが0以下の場合は該当するものなし→0を返す
    ll lower_bound(ll x){
        if(x<=0){
            return 0;
        }else{
            ll i=0;ll r=1;
            //最大としてありうる区間の長さを取得する
            //n以下の最小の二乗のべき(BITで管理する数列の区間で最大のもの)を求める
            while(r<n) r=r<<1;
            //区間の長さは調べるごとに半分になる
            for(int len=r;len>0;len=len>>1) {
                //その区間を採用する場合
                if(i+len<n && bit[i+len]<x){
                    x-=bit[i+len];
                    i+=len;
                }
            }
            return i+1;
        }
    }
};

template< typename T >
struct Compress {
  vector< T > xs;

  Compress() = default;

  Compress(const vector< T > &vs) {
    add(vs);
  }

  Compress(const initializer_list< vector< T > > &vs) {
    for(auto &p : vs) add(p);
  }

  void add(const vector< T > &vs) {
    copy(begin(vs), end(vs), back_inserter(xs));
  }

  void add(const T &x) {
    xs.emplace_back(x);
  }

  void build() {
    sort(begin(xs), end(xs));
    xs.erase(unique(begin(xs), end(xs)), end(xs));
  }

  vector< int > get(const vector< T > &vs) const {
    vector< int > ret;
    transform(begin(vs), end(vs), back_inserter(ret), [&](const T &x) {
      return lower_bound(begin(xs), end(xs), x) - begin(xs);
    });
    return ret;
  }

  int get(const T &x) const {
    return lower_bound(begin(xs), end(xs), x) - begin(xs);
  }

  const T &operator[](int k) const {
    return xs[k];
  }
};


int main(){
  ll N; cin >> N;
  vector<ll> a(N); rep(i,N) cin >> a[i];
  Compress<ll> comp(a);
  comp.build();
  vector<ll> b;
  for(auto &p : comp.get(a)) b.pb(p + 1);

  BIT bit(N);
  ll ans = 0;
  rep(i,N){
    ans += i - bit.sum(b[i]);
    bit.add(b[i] , 1);
  }
  cout << ans << endl;
}



Measured memory_bytes: 10420
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
  int N,temp;
  int arr[100001];
  
  scanf("%d",&N);
  for(temp=1;temp<=N;temp++){
    scanf(" %d",&arr[temp]);
  }
  for(temp=N;temp>1;temp--){
    if(arr[temp]<arr[temp-1]){
      arr[temp-1]-=1;
    }
  }
  for(temp=1;temp<N;temp++){
    if(arr[temp]>arr[temp+1]){
      printf("No");
      return 0;
    }
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
ll INF=2000000000;
ll Sum=1;
ll MAX_N=100100;
ll K=0;
vector<vector<ll>> Child(MAX_N, vector<ll>(0));
//vector<vector<ll>> Parent(MAX_N, vector<ll>(0));

void Calc(ll X){
    if(Sum==0){
        return;
    }
    if(X==0){
            ll ChildNum=Child.at(0).size();
        ll i=0;
        while(ChildNum>0){
            Sum*=(K-1-i);//ここが１
            Sum%=MOD;
            ChildNum --;
            i ++;
        }
        ChildNum=Child.at(0).size();
        for(ll j=0; j<ChildNum; j++){
            Calc(Child.at(0).at(j));
        }
        return;
    }
    if(Child.at(X).size()==0){
        return;
    }
    ll ChildNum=Child.at(X).size();
    ll i=0;
    while(ChildNum>0){
        Sum*=(K-2-i);
        Sum%=MOD;
        ChildNum --;
        i ++;
    }
    ChildNum=Child.at(X).size();
    for(ll j=0; j<ChildNum; j++){
        Calc(Child.at(X).at(j));
    }
    return;
}


int main(){
    ll N;
    cin>>N>>K;
    vector<ll> A(N-1), B(N-1);
    vector<vector<ll>> Way(N, vector<ll>(0));
    for(ll i=0; i<N-1; i++){
        cin>>A[i]>>B[i];
        A[i]--;
        B[i]--;
        Way.at(A[i]).push_back(B[i]);
        Way.at(B[i]).push_back(A[i]);
    }
    queue<ll> Q;
    vector<bool> Use(N, false);
    Use[0]=true;
    Q.push(0);
    while(!(Q.empty())){
        ll Now=Q.front();
        Q.pop();
        ll Sz=Way.at(Now).size();
        for(ll i=0; i<Sz; i++){
            if(Use[Way[Now][i]]){
                continue;
            }
            Q.push(Way[Now][i]);
            Child.at(Now).push_back(Way[Now][i]);
            Use[Way[Now][i]]=true;
        }
    }



    Sum *= K;
    Calc(0);
    cout<<Sum<<endl;

}

Measured memory_bytes: 16256
import java.util.Scanner;

class Main{
	int[] ele=new int[4];

  public static void main(String[] ar){
    new Main();
  }
  public Main(){
  	Scanner sc=new Scanner(System.in);
  	String line=sc.nextLine();
  	String[] elestr=line.split(" ");
  	for(int i=0;i<4;i++) ele[i]=Integer.parseInt(elestr[i]);  	
  	//for(int outs:ele) System.out.println(outs);
  	
  	if(isCOMable()){
  		System.out.println("Yes");
  	}else{
			System.out.println("No");
  	}
  }
	public boolean isCOMable(){
			return ((Math.abs(ele[0]-ele[1])<=ele[3]
			 			&& Math.abs(ele[1]-ele[2])<=ele[3])
			 			|| Math.abs(ele[0]-ele[2])<=ele[3]);
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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



int main(int argc, const char * argv[]) {
    
    
    int a,b; cin >> a >> b;
    cout << max({a+b,a-b,a*b}) << endl;
    
}


Measured memory_bytes: 256
def solve():
    N = int(input())
    A = list(map(int, input().split()))

    sortedA = sorted(A)
    prev = sortedA[0]
    for i in range(1, N):
        if sortedA[i] == prev:
            print('NO')
            break
        
        prev = sortedA[i]
    else:
        print('YES')


if __name__ == '__main__':
    solve()

Measured memory_bytes: 88916
int main()
{
	int h;
	int m;
	int s;
	int input;
	
	/* ????????? */
	h = 0;
	m = 0;
	s = 0;
	input = 0;
	
	scanf("%d", &input );
	
	h = input / 3600;
	m = ( input % 3600 ) / 60;
	s = ( input % 3600 ) % 60;
	
	printf( "%d:%d:%d\n", h, m, s );
	
	return 0;
}

Measured memory_bytes: 592
import sys


class Line:
    def __init__(self, xa, ya, xb, yb):
        self.vx = xa - xb
        self.vy = ya - yb

    def orthogonal(self, other):
        if self.vx * other.vx + self.vy * other.vy == 0.0:
            return 'YES'
        else:
            return 'NO'


for line in sys.stdin:
    xa, ya, xb, yb, xc, yc, xd, yd = tuple(map(float, line.split(' ')))
    line_a = Line(xa, ya, xb, yb)
    line_b = Line(xc, yc, xd, yd)
    print line_a.orthogonal(line_b)

Measured memory_bytes: 4256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        
        int A[] = new int[N+1];
        for(int i = 1; i <= M; i++) {
            A[sc.nextInt()] = 1;
        }
        
        int min = Integer.MAX_VALUE;
        
        int right = 0;
        for(int i = X; i <= N; i++) {
            if( A[i] > 0 ) {
                right++;
            }
        }
        min = Math.min(min, right);
        
        int left = 0;
        for(int i = X; 0 <= i; i--) {
            if( A[i] > 0 ) {
                left++;
            }
        }
        min = Math.min(min, left);
        
        System.out.println( min );
        
    }
}


Measured memory_bytes: 35872
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int H,N,ma=0;
  cin>>H>>N;
  vector<pair<int,int>> A(N);
  for(pair<int,int> &p:A){
    cin>>p.first>>p.second;
    ma=max(ma,p.first);
  }
  vector<int> B(H+ma,1000000000);
  B[0]=0;
  for(int i=1;i<H+ma;i++)
    for(pair<int,int> p:A)
      if(i-p.first>=0)
        B[i]=min(B[i],B[i-p.first]+p.second);
  int ans=1000000000;
  for(int i=0;i<ma;i++)
    ans=min(ans,B[H+i]);
  cout<<ans<<endl;
}

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

int main(){
  int N;
  cin>>N;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  int count=0;
  for(int i=1;i<N;i++){
    if(vec.at(i)==vec.at(i-1)){
      count++;
    }
  }
  
  cout<<N-count<<endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>


int main() {
	int H[50] = {};
	int W[50] = {};
	int n = 0;
	for (;;) {
		scanf("%d %d", &H[n], &W[n]);
		if (H[n] == 0)break;
		n++;
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < H[k]; i++) {
			for (int j = 1; j < W[k]; j++) {
				printf("#");
			}
			printf("#\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 2584
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>

using namespace std;

long long result;
int len;

char orin[100];
long long temp[100];

void dfs(int x, long long sum,int cnt)
{
	if (x == len)
	{
		temp[cnt] = sum;
		for (int i = 1; i <= cnt; ++i)
			result += temp[i];
		return;
	}
	temp[cnt] = sum;
	dfs(x + 1, orin[x] - '0',cnt+1);
	if (sum)
		dfs(x + 1, sum * 10 + orin[x] - '0',cnt);
}


int main(void)
{
	scanf("%s", orin);
	len = strlen(orin);
	dfs(0, 0,0);
	printf("%lld", result);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int N;
  cin >> N;
  if(N < 1200){
    cout << "ABC" << endl;
  }
  else{
    cout << "ARC" << endl;
  }
}

Measured memory_bytes: 256
#D問題
import math
def isprime(n):
    nroot=int(math.sqrt(n))
    flag=0
    for i in range(2,nroot+1):
        if n%i == 0:
            flag=1
            break
    return flag
Q=int(input())
L=[]
R=[]
for i in range(Q):
    l,r=map(int,input().split())
    L.append(l)
    R.append(r)
Rmax=max(R)
pcount=[]
for i in range(Rmax):
    I=i+1
    if I == 1:
        pcount.append(0)
    elif I%2 == 1:
        pf=pcount[-2]
        if isprime(I) == 0 and isprime(int((I+1)/2)) == 0:
            pf+=1
        pcount.append(pf)
    else:
        pcount.append(0)
for i in range(Q):
    ans=pcount[R[i]-1]-pcount[L[i]-3]
    print(ans)

Measured memory_bytes: 12584
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <sstream>
#include <iterator>
 
using namespace std;
 
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
 
int main()
{
    int a, b, c, x, y;
 
    scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
 
    int ans = max({ a,b,c }) * (x + y) + 1;
 
    for (int ab = 0; ab <= max(x, y); ab++)
    {
        int now = c * 2 * ab + max(0, x - ab) * a + max(0, y - ab) * b;
 
        ans = min(now, ans);
    }
 
    printf("%d\n", ans);
 
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))
template<typename T> inline bool __max__(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool __min__(T &x, const T &y) { return x > y ? x = y, 1 : 0; }

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;

    cin >> n;

    ll prev = 2;
    ll cur = 1;
    ll temp;

    int i;

    for (i = 2; i <= n; i++) {
        temp = prev + cur;
        prev = cur;
        cur = temp;
    }

    cout << cur << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array);



int main(){
	std::vector<ll> v{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  ll k;
  cin>>k;
  cout<<v[k-1]<<endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから

void solve(){
  int a,b;
  cin>>a>>b;
  if(b%a==0)cout<<a+b;
  else cout<<b-a;
}

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


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>

using namespace std;

char s[] = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string t[] = {
"101",
"000000",
"000011",
"10010001",
"010001",
"000001",
"100101",
"10011010",
"0101",
"0001",
"110",
"01001",
"10011011",
"010000",
"0111",
"10011000",
"0110",
"00100",
"10011001",
"10011110",
"00101",
"111",
"10011111",
"1000",
"00110",
"00111",
"10011100",
"10011101",
"000010",
"10010010",
"10010011",
"10010000"};
char r[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";

int main()
{
	string a;
	while(getline(cin,a)){
		string out;
		for (int i = 0; i < (int)a.size(); i++)
			out.append(t[find(s,s+sizeof(s),a[i]) - s]);
		while(out.size() % 5 != 0)
			out.push_back('0');
		for (int i = 0; i < (int)out.size() / 5; i++){
			int x = 0;
			for (int j = 0; j < 5; j++)
				x = (x << 1) + (out[i*5+j] == '1');
			putchar(r[x]);
		}
		putchar('\n');
	}

	return 0;
}

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

int main(){
    int X;
    cin >> X;
    if(X>29){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    
    if (A <= 8 && B <= 8) {
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const ll MOD = 1e9 + 7;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

ll ans = 0;

void rec(ll n, ll m){
    ll tmp = m;
    ll flag[3] = {false,false,false};
    if(m > n) return;
    while(m != 0){
        if(m%10 == 3) flag[0] = true;
        if(m%10 == 5) flag[1] = true;
        if(m%10 == 7) flag[2] = true;
        m /= 10;
    }
    if(flag[0] && flag[1] && flag[2]) ans ++;

    rec(n,tmp*10 + 3);
    rec(n,tmp*10 + 5);
    rec(n,tmp*10 + 7);
}

int main(){
    ll n; cin >> n;
    rec(n,0);
    cout << ans;
}

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


int main(){
    int a;
    cin >>a;
    int ans;
    ans = a*a*a+a*a+a;
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define ll long long
#define ar array


int x , y ;

void solve(){

    cin >> x >> y;

    bool ans = false;


    int tmp;
    while(x > 0){
        if(y % 4 == 0 && y/4 == x || y % 2 == 0 && y/2 == x){
            ans = true;
            break;
        }

        x--;
        y = y-2;
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

}





int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();

}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<pair<ll, ll> > v(n+1);
    for(ll i=1; i<=n; i++){
        cin >> v[i].first;
        v[i].second=i;
    }
    sort(v.begin()+1, v.end(), greater<pair<ll, ll> >());
    ll dp[n+1][n+1];
    memset(dp, (ll)0, sizeof(dp));
    for(ll i=1; i<=n; i++){
        for(ll j=0; j<=i-1; j++){
            ll L=j, R=i-1-j;
            dp[L+1][R]=max(dp[L+1][R], dp[L][R]+(ll)abs(L+1-v[i].second)*v[i].first);
            R=j, L=i-1-j;
            dp[L][R+1]=max(dp[L][R+1], dp[L][R]+(ll)abs(n-R-v[i].second)*v[i].first);
        }
    }
    ll ans=-1;
    for(ll j=0; j<=n; j++)
        ans=max(ans, dp[j][n-j]);
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 34928
#include <bits/stdc++.h>
using namespace std;
long long a,b,c;
int main(){
	cin>>a>>b>>c;
	if (a+b>=c){
		cout<<"No";return 0;
	}
	long long num=c-a-b;
	if (4*a*b<num*num) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long int ll;

ll mod=1e9+7;

//繰り返し二乗法
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b&1)res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}

struct perm{
private:
    int sz;
    vector<ll> p,invp;
public:
    perm(int n){
        sz=n+1;
        p.resize(sz),invp.resize(sz);
        p[0]=1;
        for(int i=1;i<=sz-1;i++){
            p[i]=p[i-1]*i%mod;
        }
        invp[sz-1]=power(p[sz-1],mod-2);
        for(int i=sz-2;i>=0;i--){
            invp[i]=invp[i+1]*(i+1)%mod;
        }
    }
    ll comb(ll x,ll y){
        if(x<y||y<0)return 0;
        return (p[x]*invp[x-y]%mod)*invp[y]%mod;
    }
};
perm p(1<<20);
int cnt[101000];
int main(){
    int n; cin >> n;
    vector<int> a(n+1);
    int l=0,r=0;
    int cp=0;
    for(int i=0;i<n+1;i++){
        cin >> a[i];
        cnt[a[i]]++;
        if(cnt[a[i]]==2){
            cp=a[i];
            r=i;
        }
    }
    for(int i=0;i<n;i++){
        if(a[i]==cp){
            l=i;
            break;
        }
    }
    for(int i=1;i<=n+1;i++){
        cout << (p.comb(n+1,i)-p.comb(n-r+l,i-1)+mod)%mod << endl;
    }
}

Measured memory_bytes: 18432
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
 static void Main(string[] args)
 {
  Console.ReadLine();
  List<int> A = new List<int>();
  string[] S = Console.ReadLine().Split(' ');
  for (int i = 0; i < S.Length; i++) { A.Add(int.Parse(S[i])); }
  Console.WriteLine((A.Max() - A.Min()).ToString());
 }
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
   cin >> a[i]; 
  }
  rep(i,n){
   if(a[i]%2 != 0) a[i] =0; 
  }
  int counts =0;
  int countsA =0;
  rep(i,n){
   if(a[i]){
     countsA++;
    if(a[i]%3 == 0 || a[i]%5 ==0) counts++; 
   }
  }
  if(counts != countsA) cout << "DENIED" << endl;
  else cout << "APPROVED" << endl;
  
 // cout << counts << endl;
}


Measured memory_bytes: 3604
# -*- coding: utf-8 -*-
import sys
from collections import deque

N,M,Q=map(int, sys.stdin.readline().split())
X=[ map(int, sys.stdin.readline().split()) for _ in range(Q) ]

qq=deque()
for m in range(1,M+1):
    q=deque()
    q.append([m])
    while q:
        if N<len(q[0]):
            qq+=q
            break
        fro=q.popleft()
        last=fro[-1]
        for to in range(last,M+1):
            q.append(fro+[to])

ans=float("-inf")
for L in qq:
    temp_ans=0
    for a,b,c,d in X:
        if L[b-1]-L[a-1]==c:
            temp_ans+=d
    ans=max(ans,temp_ans)
print ans


Measured memory_bytes: 136260
def main():
    N, K = map(int, input().split())
    x = [0] * N
    y = [0] * N
    for i in range(N):
        x[i], y[i] = map(int, input().split())
        
    ans = float('inf')

    for i in range(N):
        for j in range(N):
            for k in range(N):
                for l in range(N):
                    if x[i] < x[j] and y[k] < y[l]:
                        right = x[j]
                        left = x[i]
                        bottom = y[k]
                        top = y[l]

                        cnt = 0

                        for n in range(N):
                            if left <= x[n] <= right and bottom <= y[n] <= top:
                                cnt += 1

                        if cnt >= K:
                            ans = min(ans, (top - bottom) * (right - left))
    print(ans)



if __name__ == "__main__":
    main()

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(int i = (int)k; i < (int)n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(int i = (int)n; i > (int)k; i--)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl;

typedef long long ll;

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

ll r[200000 +1];

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

    int N;
    cin >> N;
    int a[200000 +1];
    REP(i,1,N+1) cin >> a[i];

    r[N] = a[N];
    RREP(i,N-1,0) r[i] = r[i+1] + a[i];

    ll base = r[1] / 2;
    ll diff = INT_MAX;
    ll y = r[N];
    RREP(i,N,1) {
        if (abs(base - r[i]) < diff) {
            diff = abs(base - r[i]);
            y = r[i];
        }
    }

    ll x = r[1] - y;

    cout << abs(x - y) << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int d=1e9+7;
long long a[2222];
int main()
{
	int n;
	cin>>n;
	a[0]=a[1]=a[2]=0;
	a[3]=a[4]=a[5]=1;
	for(int i=6;i<=2000;i++)
	{
		int sum=1;
		for(int j=3;j<=i-3;j++)
		{
			sum+=a[i-j];
			sum=sum%d;
		}
		a[i]=sum;
	}
	cout<<a[n];
	return 0;
}

Measured memory_bytes: 3612
package main

import (
	"fmt"
	"math"
)

func main() {

	var n int
	for {
		fmt.Scan(&n)
		if n==0 {
			break
		}
		s := make([]float64, n)
		for i:=0; i<n; i++ {
			fmt.Scan(&s[i])
		}

		mean := 0.0
		for i:=0; i<n; i++ {
			mean += s[i]/float64(n)
		}
		sdv := 0.0
		for i:=0; i<n; i++ {
			sdv += (s[i]-mean)*(s[i]-mean) / float64(n)
		}

		fmt.Println(math.Sqrt(sdv))
	}

}


Measured memory_bytes: 1268
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n;i>0;i--)
#define rep1(i,s,n) for(int i=s;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    string s;
    cin>>s;
    if(s=="SUN")cout<<7;
    if(s=="MON")cout<<6;
    if(s=="TUE")cout<<5;
    if(s=="WED")cout<<4;
    if(s=="THU")cout<<3;
    if(s=="FRI")cout<<2;
    if(s=="SAT")cout<<1;
}

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

int main(){
 int n, x;
 cin>>n>>x;
 int min=x;
 vector<int> m(n);
 for(int i=0; i<n; i++){
  cin>>m[i];
  x-=m[i];
  if(m[i]<min)min=m[i];
 }
 cout<<n+x/min<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int x=0,k=1; char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')k=-1;c=getchar();}
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*k;
}
string s;
int main(){
	int lst=-1,f=0;
	cin>>s;
	for(int i=1;i<4;i++){
		if(s[i]==s[i-1])f=1;
	}
	if(f)puts("Bad");
	else puts("Good");
}

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

signed main(){
  int n,q;
  cin >> n >> q;

  string s;
  cin >> s;

  vector<int> st;

  for(int i = 0;i<n-1;i++){
    if(s[i]=='A' && s[i+1]=='C'){
      st.push_back(i+1);
    }
  }  
  
  while(q--){
    int l,r;
    cin >> l >> r;

    auto L = lower_bound(st.begin(), st.end(), l) - st.begin();
    auto R = lower_bound(st.begin(), st.end(), r) - st.begin();

    cout << R-L << endl;
    //cout << L << endl;
  }
  return 0;
}
    
  


Measured memory_bytes: 1656
#include <cstdio>
#include <algorithm>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int vs[10];
int main(void) {
  REP(i, 3) {
    cin >> vs[i];
  }
  sort(vs, vs + 3);
  cout << vs[0] + vs[1] << endl;
  
  return 0;
}


Measured memory_bytes: 256
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length === 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function solve() {
    const sc = new Scanner();
    const [A, B, X]: number[] = (await sc.getLine()).split(' ').map((x) => +x);
    if (A > X || A + B < X) {
      console.log('NO');
    } else {
      console.log('YES');
    }
    sc.close();
  }
  solve();
}


Measured memory_bytes: 7628
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
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);
        BBiteEating solver = new BBiteEating();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBiteEating {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int n = s.nextInt(), l = s.nextInt();
            int sum = 0;
            for (int i = 1; i <= n; i++)
                sum += l + i - 1;
            int res = Integer.MAX_VALUE;
            for (int i = 1; i <= n; i++)
                if (Math.abs(l + i - 1) < Math.abs(res))
                    res = l + i - 1;
            w.println(sum - res);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#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>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int w, h, n;
    cin >> w >> h >> n;
    VI x(n), y(n), a(n);
    REP(i, n) {
        cin >> x[i] >> y[i] >> a[i];
    }

    vector<vector<bool>> map(w, vector<bool>(h, false));
    REP(i, n) {
        switch (a[i]) {
            case 1:
                FOR(j, 0, x[i]) {
                    REP(k, h) {
                        map[j][k] = true;
                    }
                }
                break;
            case 2:
                FOR(j, x[i], w) {
                    REP(k, h) {
                        map[j][k] = true;
                    }
                }
                break;
            case 3:
                REP(j, w) {
                    FOR(k, 0, y[i]) {
                        map[j][k] = true;
                    }
                }
                break;
            case 4:
                REP(j, w) {
                    FOR(k, y[i], h) {
                        map[j][k] = true;
                    }
                }
        }
    }

    int ans = 0;
    REP(i,w){
        REP(j,h){
            if(map[i][j] == false){
                ans++;
            }
        }
    }

    cout << ans << ENDL;

    return 0;
}

Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

struct td{
    int t;
    int d;
};

bool cmp_d   (struct td& lhs, struct td& rhs){ return lhs.d < rhs.d; }
bool cmp_gr_d(struct td& lhs, struct td& rhs){ return lhs.d > rhs.d; }

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    uint N, K; cin >> N >> K;
    vector<struct td> vTD(N); for(uint i=0; i<N; ++i){ cin >> vTD[i].t >> vTD[i].d; }
    sort(vTD.begin(), vTD.end(), cmp_gr_d);
    
    unordered_map<int, int> htUN; // a hash table for counting number of used types
    vector<struct td> vTD_rm;     // for remove
    vector<struct td> vTD_add;    // for add
    
    int64 sum =0ll;
    for(uint i=0; i<K; ++i){
        sum += vTD[i].d;
        ++htUN[ vTD[i].t ];
        if(htUN[ vTD[i].t ]>=2){ vTD_rm.push_back( vTD[i] ); }
    }
//    sort(vTD_rm.begin(), vTD_rm.end(), cmp_d); // dont need to sort. By reversing the iteration to vTD_rm.
    
    for(uint i=K; i<N; ++i){
        if( htUN[ vTD[i].t ] != 0 ){ continue; }
        vTD_add.push_back( vTD[i] );
    }
//    sort(vTD_add.begin(), vTD_add.end(), cmp_gr_d); // dont need to sort. Because of the vTD is already sorted.
    
    int64 numT = K - vTD_rm.size(); // num of type
    int64 point = sum + numT*numT;
    int ri=vTD_rm.size()-1;
    int ai=0;
    while( ri>=0 && ai<vTD_add.size() ){
        if( htUN[ vTD_rm [ri].t ] == 1 ){ --ri; continue; }
        if( htUN[ vTD_add[ai].t ] >= 1 ){ ++ai; continue; }
        
        sum -= vTD_rm [ri].d; --htUN[ vTD_rm [ri].t ]; --ri;
        sum += vTD_add[ai].d; ++htUN[ vTD_add[ai].t ]; ++ai;
        
        ++numT;
        
        int64 tmp = sum + numT * numT;
        point = max(point, tmp);
    }
    cout << point << endl;
    
    return 0;
}


Measured memory_bytes: 5540
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll A, B;
  cin >> A >> B;
  if (A <= 8 && B <= 8) {
    COUT("Yay!");
  } else {
    COUT(":(");
  }
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N; cin >> N;
    LL cnt[5];

    REP(i,5)
    {
        dump(cnt[i])
    }

    memset(cnt, 0, sizeof(cnt));
    dump("memset")

    REP(i,N)
    {
        string S; cin >> S;
        dump(S)
        if(S[0] == 'M') cnt[0]++;
        if(S[0] == 'A') cnt[1]++;
        if(S[0] == 'R') cnt[2]++;
        if(S[0] == 'C') cnt[3]++;
        if(S[0] == 'H') cnt[4]++;

        REP(i,5)
        {
            dump(cnt[i])
        }


    }
    dump("output")

    REP(i,5)
    {
        dump(cnt[i])
    }
    LL ans = 0;
    FOR(i,0,3)
    {
        FOR(j,i+1,4)
        {
            FOR(k,j+1,5)
            {

                ans += cnt[i]  * cnt[j] * cnt[k];
            }
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def io_generator():
	return input()

#+++++++++++++++++++
	
def main(io):
	n=int(io())
	s=io()[:n]
	
	nw=len([c for c in list(s) if c=='.'])
	ret=min(nw, n-nw)
	cnw=0
	cnb=0
	nnw=nw
	nnb=n-nw
	for i in list(s):
		if i=='.':
			cnw+=1
			nnw-=1
			ret = min(cnb+nnw, ret)
		if i =='#':
			cnb+=1
			nnb-=1
			ret = min(cnb+nnw, ret)
	return ret

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Measured memory_bytes: 6632