akhauriyash/Code-Regression huggingface dataset:
/*

                              Jai Shree Krishna !!
                                 Radhe Radhe !!
                                 
             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
             
*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vvi vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
#define ins insert
#define rep(i,s,e) int i; for(int i=s;i<=e;i++)
#define repd(i,s,e) int i; for(int i=e;i>=s;i--)
#define vb vector<bool>
#define read2(n,m) int n,m; cin >> n >> m;
#define range(v) v.begin(),v.end()
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define sorti(v) sort(v.begin(),v.end())

const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
 


signed main()
{
 
    fast;
    read2(n,m);
    int lcm = (n*m)/__gcd(n,m);
    cout<<lcm<<endl;
    return 0;
}

/* Pooja Yadav */

Measured memory_bytes: 256
//abc075_b.cpp
//Sat Jun  9 11:21:39 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;

int main(){
	int h,w;
	cin >> h >> w;

	string ans[h];
	for (int i=0;i<h;i++){
		cin >> ans[i];
	}

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


	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			if (ans[i][j] != '#'){
				int num = 0;
				for (int k=0;k<8;k++){
					int x = i+dx[k];
					int y = j+dy[k];
					if (x<0 || x>h-1){
						continue;
					}
					if (y<0 || y>w-1){
						continue;
					}
					if (ans[x][y] == '#'){
						num++;
					}
				}
				ans[i][j] = (char) num+'0';
			}
		}
	}


	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			cout << ans[i][j];
		}
		printf("\n");
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define iint int
#define pll std::pair<iint,iint>
#define rep(i,a,b) for(iint i=(iint)a;i<(iint)b;i++)
#define per(i,a,b) for(iint i=(iint)a;i>(iint)b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
	int n;
	std::cin >> n;
	std::string s;
	std::cin >> s;
	if(n%2 == 0){
		bool flag = true;
		for(int i=0;i<n/2;i++){
			if(s[i] != s[i+(n/2)])
				flag = false;
		}

		if(flag){
			std::cout << "Yes\n";
			return;
		}
	}
	std::cout << "No\n";
}

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

	// int t;
	// std::cin >> t;
	// while(t--){
	// 	solve();
	// }

	solve();
	return 0;
}

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

bool ch[26];
char str[100001];

int main(){
	scanf("%s",&str);

	for (int i = 0; i < 26; ++i) 	ch[i] = false;
	
	for (int i = 0; str[i] != '\0'; ++i) 
		ch[str[i] - 'a'] = true;
	
	for (int i = 0; i < 26; ++i) {
		if (!ch[i]) {
			printf("%c\n", (char)(i + 'a'));
			return 0;
		}
	}
	cout << "None\n";

	return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public class Prime
{
    // Sieve of Eratosthenes
    BitArray Sieve;
    int[] DivPrime;  // xを割り切る最大の素数

    public void Init(int max)
    {
        Sieve = new BitArray(max + 1);
        DivPrime = Enumerable.Range(0, max + 1).ToArray();
        var end = (int)(Math.Sqrt(max) + 0.1);
        Sieve.Set(1, true);
        for (int i = 2; i <= end; i++)
        {
            if (!Sieve.Get(i))
            {
                for (int j = i * 2; j <= max; j += i)
                {
                    Sieve.Set(j, true);
                    DivPrime[j] = i;
                }
            }
        }
    }

    public bool IsPrime(int n)
    {
        return !Sieve.Get(n);
    }

    public int[] GetPrimes(int n)
    {
        return Enumerable.Range(2, n - 1).Where(i => !Sieve.Get(i)).ToArray();
    }
    public int[] GetDivPrime()
    {
        return DivPrime;
    }
}

public class PrimeFactorize
{
    int[] DivPrime;

    public PrimeFactorize(int n)
    {
        var prime = new Prime();
        prime.Init(n);
        DivPrime = prime.GetDivPrime();
    }

    static List<int> Factorize(int n, int[] divPrime)
    {
        var factor = new List<int>();
        while (true)
        {
            var p = divPrime[n];
            if (p > 1)
            {
                factor.Add(p);
                n /= p;
            }
            else
            {
                break;
            }
        }

        return factor;
    }

    public List<int> Factorize(int n)
    {
        return Factorize(n, DivPrime);
    }
}

public static class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var pf = new PrimeFactorize((int)1e6);
        var factorCount = new int[(int)1e6];

        foreach (var a in A)
        {
            var fa = pf.Factorize(a);
            foreach (var f in fa.Distinct())
            {
                factorCount[f]++;
            }
        }

        var pairwise = factorCount.All(v => v <= 1);
        if (pairwise)
        {
            Console.WriteLine("pairwise coprime");
            return;
        }
        var setwise = factorCount.All(v => v != N);
        if (setwise)
        {
            Console.WriteLine("setwise coprime");
            return;
        }
        Console.WriteLine("not coprime");
    }
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    int n ;
    ll h ;
    cin >> n >> h ;
    bpqll a ;
    bpqll b;
    ll ans = 0 ;
    REP(i,n){
        ll aa, bb ;
        cin >> aa >> bb ;
        a.push(aa) ;
        b.push(bb) ;
    }
    ll k = a.top() ;
    while(h>0 && !b.empty() && b.top()>=k){
        ans++ ;
        ll l = b.top() ;
        b.pop() ; 
        h -= l ;
    }
    if(h>0){
        ans += (ll)ceil((double)h/(double)k) ;
    }
    cout << ans <<endl;




    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 2036
#include <stdio.h>
#define ll long long
#define mod 1000000007

ll dp[105][4][4][4] = {0};

bool pan(int a, int b, int c) {
    if (a == 0 && b == 2 && c == 1) return false;
    if (a == 0 && b == 1 && c == 2) return false;
    if (a == 2 && b == 0 && c == 1) return false;
    return true;
}

bool pan1(int a, int b, int c) {
    if (a == 0 && b == 2 && c == 1) return false;
    return true;
}

int main () {
    int n;
    scanf("%d", &n);
    if (n == 1) {
        printf("4\n");
    } else if(n == 2) {
        printf("16\n");
    } else {
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                for (int p = 0; p < 4; p++) {
                    if (pan(i, j, p)) {
                        dp[3][i][j][p] = 1;
                    }
                }
            }
        }

        for (int k = 4; k <= n; k++) {
            for (int i = 0; i < 4; i++) {
                for (int j = 0; j < 4; j++) {
                    for (int p = 0; p < 4; p++) {
                        //dp[k][i][j][p]
                        if (pan(i, j, p)) {
                            for (int q = 0; q < 4; q++) {
                                if (pan(q, i, j) && pan1(q, j, p) && pan1(q, i, p)) {
                                    dp[k][i][j][p] = (dp[k][i][j][p] + dp[k - 1][q][i][j]) % mod;
                                } 
                            }
                        }
                    }
                }
            }
        }

        ll ans = 0;
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                for (int p = 0; p < 4; p++) {
                    ans = (ans + dp[n][i][j][p]) % mod;
                }
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}

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

using namespace std;
const int INF = 1e9 + 5;

int main() {
    int n;
    cin >> n;
    vector<int> dp(3);
    for (int day = 0; day < n; day++) {
        vector<int> val(3);
        vector<int> dp2(3, -INF);

        for (int i = 0; i < 3; i++) cin >> val[i];

        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (i != j) {
                    dp2[j] = max(dp2[j], dp[i] + val[i]);
                }
            }
        }
        dp = dp2;
    }
    cout << max({dp[0], dp[1], dp[2]});
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
using namespace std;
static inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int pow(long x, int n, int m){
    long ret = 1;
    while (n > 0) {
        if (n & 1) ret *= x, ret %= m;
        x *= x, x %= m;
        n >>= 1; 
    }
    return ret % m;
}

int euler_phi(int n) {
   int ret = n;
   for(int i = 2; i * i <= n; ++i){
       if(n % i == 0) {
           ret -= ret / i;
           while(n % i == 0) n /= i;
       }
   }
   if(n > 1) ret -= ret / n;
   return ret;
}

int main()
{
    int K = 0, c = getchar();
    while(c > 47 && c < 58){
        K = K * 10 + c - 48;
        c = getchar();
    }

    K /= gcd(K, 7);
    if(K == 1){
        putchar('1');
        return 0;
    }
    
    K *= 9;

    if(gcd(K, 10) != 1) {
        putchar('-');
        putchar('1');
        return 0;
    }

    int res = euler_phi(K);

    int ans = 1000000;
    long now = 10;
    for(int i = 1; i * i <= res; ++i){
        if(res % i == 0) {
            if(now == 1){
                printf("%d\n", i);
                return 0;
            }
            int tmp = res / i;
            if(pow(10, tmp, K) == 1) if(tmp < ans) ans = tmp;
        }
        now *= 10, now %= K;
    }

    printf("%d\n", ans);

    return 0;
}

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

using namespace std;

int main (){
    ios_base::sync_with_stdio(false);
    int length, ascii[28]={0};
    bool beautiful=true;
    string nilam;
    cin >> nilam;
    length=nilam.size();
    for(int i=0; i<length; i++) ascii[(int)nilam[i]-97]++;
    for(int i=0; i<28; i++){
        if(ascii[i]&1){
            beautiful=false;
            break;
        }
    }
    cout << (beautiful? "Yes" : "No") << endl;
    return 0;
}


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

struct Node{
    int parent = -1;
    int left   = -1;
    int right  = -1;
};

class Tree{
    vector<Node> node;
    int root;
    void preorder(int p, vector<int>& pre){
        if (p == -1) return;
        pre.push_back(p);
        preorder(node[p].left , pre);
        preorder(node[p].right, pre);
    }
    void inorder(int p, vector<int>& in){
        if (p == -1) return;
        inorder(node[p].left , in);
        in.push_back(p);
        inorder(node[p].right, in);
    }
    void postorder(int p, vector<int>& post){
        if (p == -1) return;
        postorder(node[p].left , post);
        postorder(node[p].right, post);
        post.push_back(p);
    }
    void print_order(const vector<int> v){
        for (int i = 0; i < v.size(); i++) {
            cout << " " << v[i];
        }
        cout << endl;
    }
public:
    Tree(int n){
        node.resize(n);
    }
    void add_node(int id, int l, int r){
        node[id].left  = l;
        node[id].right = r;
        if (l != -1) node[l].parent = id;
        if (r != -1) node[r].parent = id;
    }
    void set_root(){
        for (int i = 0; i < node.size(); i++) {
            if (node[i].parent == -1) {
                root = i;
                return;
            }
        }
    }
    void Preorder(){
        vector<int> pre;
        cout << "Preorder" << endl;
        preorder(root, pre);
        print_order(pre);
    }
    void Inorder(){
        vector<int> in;
        cout << "Inorder" << endl;
        inorder(root, in);
        print_order(in);
    }
    void Postorder(){
        vector<int> post;
        cout << "Postorder" << endl;
        postorder(root, post);
        print_order(post);
    }
};

int main(){
    int n;
    cin >> n;
    Tree T(n);
    for (int i = 0; i < n; i++) {
        int id, left, right;
        cin >> id >> left >> right;
        T.add_node(id, left, right);
    }
    T.set_root();
    T.Preorder();
    T.Inorder();
    T.Postorder();
    return 0;
}

Measured memory_bytes: 3192
/******
author :- Mahmoud Tarek.
*******/

#include<bits/stdc++.h>

using namespace std ;

#define rg register
#define dbg(v) cerr << #v << " " << v ;
typedef long long ll ;

int n, k ;
vector<int> a, b ;
ll OO = 1e15 ;
ll dp[200][200000] ;

ll solve(int i, int val){
    if(i == n){
        if(val == 0) return 0 ;
        return OO;
    }
    ll & ret = dp[i][val] ;
    if(~ret) return ret ;
    ret = OO ;
    if(val - b[i] >= 0) ret = a[i] + solve(i + 1, val - b[i]) ;
    ret = min(ret, solve(i + 1, val)) ;
}

int main() {
//  freopen("in.txt", "r", stdin) ;
    cin >> n >> k ;
    a.resize(n);
    b.resize(n);
    int sum = 0 ;
    for(int i = 0 ; i < n ; i++){
      cin >> a[i] >> b[i] ;
      sum += b[i] ;
    }


    memset(dp, -1, sizeof dp) ;

    for(int i = sum ; i >= 0 ; i--){
        if(solve(0, i) <= k){
            cout << i << "\n" ;
            return 0 ;
        }
    }



}

/*
  Empty set of troubles.
*/


Measured memory_bytes: 312832
def par(a):
    L = []
    while P[a] != a:
        L.append(a)
        a = P[a]
    for l in L:
        P[l] = a
    return a
def unite(a, b):
    pa = par(a)
    pb = par(b)
    if pa == pb: return
    if LEN[pa] < LEN[pb]:
        a, b, pa, pb = b, a, pb, pa
    P[pb] = pa
    if LEN[pa] == LEN[pb]: LEN[pa] += 1
    CNT[pa] += CNT[pb]
def cnt(a):
    return CNT[par(a)]

N = int(input())
P = [i for i in range(N)]
LEN = [1] * N
CNT = [1] * N
FULL = [0] * N
A = [int(a) - 1 for a in input().split()]
for i, a in enumerate(A):
    if a < 0: continue
    if par(i) != par(a):
        unite(i, a)
    else:
        FULL[i] = 1
for i in range(N):
    if FULL[i]:
        FULL[par(i)] = 1
X = []
Y = []
for i in range(N):
    if par(i) == i:
        if FULL[i] == 0:
            X.append(CNT[i])
        else:
            Y.append(CNT[i])
M = len(X)
mod = 10 ** 9 + 7
K = 96
m = int(("1" * 32 + "0" * 64) * 5050, 2)
pa = (1 << 64) - ((1 << 64) % mod)
modP = lambda x: x - ((x & m) >> 64) * pa
ans = (sum(X) + sum(Y) - len(Y)) * pow(N - 1, M, mod) % mod
x = 1
for i, a in enumerate(X):
    x *= (a << K) + 1
    x = modP(x)

sx = bin(x)[2:] + "_"
L = [int(sx[-(i+1) * K - 1:-i * K - 1], 2) % mod for i in range((len(sx)+K-2) // K)]
fa = 1
ans = (ans + M * pow(N - 1, M - 1, mod)) % mod
for i, l in enumerate(L):
    if i == 0: continue
    ans = (ans - l * fa * pow(N - 1, M - i, mod)) % mod
    fa = fa * i % mod
print(ans)

Measured memory_bytes: 10612
// BEGINNING WITH NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
// ATCODER BEGINNERS PROBLEMS
//#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.flush();
   	int a,b;
    cin >> a >> b;
    b = 2*b;
    ((a-b)<=0) ? cout<<0: cout<<(a-b);
    return 0;
    // Bye Bye 2019
}



Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <limits>
#include <math.h>
#include <string>
#include <map>

using namespace std;
int getSum(int n) {
  string s = to_string(n);
  int res = 0;
  for (int i = 0; i < s.size(); ++i) {
    res += s[i] - '0';
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  int ans = 1e9;
  for (int a = 1; a <= ceil((double)n / 2); ++a) {
    int b = n - a;
    ans = min(ans, getSum(a) + getSum(b));
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

const int C = 100000;

ll a[C];
ll b[C];
ll x[C];
ll y[C];
ll t[C];
ll r[C];
ll g;

int main() {
  cin >> a[0] >> b[0];
  int n = 0;
  while (b[n] != 0) {
    r[n] = a[n]%b[n];
    t[n] = (a[n]-r[n])/b[n];
    a[n+1] = b[n];
    b[n+1] = r[n];
    n++;
  }
  ll g = a[n];
  x[n] = 1;
  y[n] = 0; // ここは適当
  n--;
  for ( ; n>=0; n--) {
    x[n] = y[n+1];
    y[n] = x[n+1] - t[n] * x[n];
  }
  // x[0], y[0] に解の1つが入っている。
  // a(-b) + b(a) = 0より、
  // x[0]-bk , y[0]+ak も解である。これで全部である。
  // 所望のものは、|x|+|y|を最小にするものである。
  // a, b \geq g >0 なので、必ず符号は異なる。
  // したがって、(x, y)と(x', y')が解ならば、
  // |x| > |x'| \Longrightarrow |y| > |y'|が「たいてい」従う。
  // 候補は x = x[0] % b または それからbを引いたもの
  ll X1, X2, Y1, Y2;
  X1 = x[0]%b[0];
  X2 = X1 - b[0];
  Y1 = (g - X1 * a[0])/b[0];
  Y2 = (g - X2 * a[0])/b[0];
  ll A1 = abs(X1) + abs(Y1);
  ll A2 = abs(X2) + abs(Y2);
  if (A1 > A2 || (A1 == A2 && X2 <= Y2) ) {
    cout << X2 << " " << Y2 << endl;
  } else {
    cout << X1 << " " << Y1 << endl;
  }
}

Measured memory_bytes: 3220
#include <stdio.h>

int main(void)
{
	int w,h,x,y,r;
	scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
	if((x+r<=w&&y+r<=h)&&(x>0&&y>0)){
		printf("Yes\n");
		
	}else{
		
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
n,k = map(int,input().split())
a = []
for i in range(k):
    d = int(input())
    f = input().split()
    #fはlen(f)=dの配列
    a.append(f)
b = []
for i in range(len(a)):
    for j in range(len(a[i])):
        b.append(int(a[i][j]))
c =set(b)

d = {i for i in range(1,n+1)}

print(len(d-c))

Measured memory_bytes: 9504
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

class UnionFind_size:
    def __init__(self, n):
        # 初期状態は全要素が根なので、親は自分自身
        self.par = [i for i in range(n+1)]
        # 集団の要素数(size)を格納する(初期は全て1)
        self.size = [1] * (n+1)
    
    # 根を検索する関数
    def find(self, x):
        # 根までたどったらその番号を返す
        if self.par[x] == x:
            return x
        # 根でないなら親の要素で再検索
        else:
            # 検索過程で親を書き換える(圧縮経路)
            self.par[x] = self.find(self.par[x])
            return self.find(self.par[x])
  
    # 結合(unite)する関数
    def unite(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        # サイズを比較し、小さい方を大きい方に繋げる
        if self.size[x] < self.size[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
           
    # 同じグループに属するかを判定する関数
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
    # 要素が属する木のサイズを返す関数
    def get_size(self, x):
        return self.size[self.find(x)]
    
    # グループ数を返す関数
    def group_sum(self):
        c = 0
        for i in range(len(self.par)):
            if self.find(i) == i:
                c += 1
        return c


def main():
    N,M,K = map(int, readline().split())

    uf = UnionFind_size(N+1)
    F = [[] for _ in range(N+1)]
    for _ in range(M):
        a,b = map(int, readline().split())
        F[a].append(b)
        F[b].append(a)
        uf.unite(a, b)
    
    B = [[] for _ in range(N+1)]
    for _ in range(K):
        c,d = map(int, readline().split())
        B[c].append(d)
        B[d].append(c)


    ans = []
    for i in range(1,N+1):
        tmp = 0
        tmp += uf.get_size(i) - 1
        tmp -= len(F[i])
        for j in B[i]:
            if uf.same_check(i, j):
                tmp -= 1
        ans.append(tmp)
    
    print(" ".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 52256
N = int(input())
A = list(map(int, input().split()))
 
sortA = sorted(set(A)) + [float('inf')]
 
def isOk(n):
    x = sortA[n]
    count = [0 for _ in range(2 * N + 1)]
    count[N + 1] = 1
 
    i = N + 1
    s = 1
    result = 0
 
    for a in A:
        if a >= x:
            i += 1
            s += count[i]
        else:
            s -= count[i]
            i -= 1
        result += s
        count[i] += 1
        s += 1
 
    if result >= N * (N + 1) // 4:
        return False
    else:
        return True
 
 
left = 0
right = len(sortA) - 1
 
while right - left > 1:
    mid = (left + right ) // 2
 
    if isOk(mid):
        right = mid
    else:
        left = mid
 
print(sortA[left])

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}

void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}

void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int main(){
    int N;
    cin >> N;
    vector<int64_t> num(60);
    for(int i=0; i<N; i++){
        int64_t a;
        cin >> a;
        for(int k=0; k<60; k++) num[k] += nth_bit(a, k);
    }

    int64_t ans = 0;
    for(int k=0; k<60; k++){
        int64_t res = num[k] * (N-num[k]) % MOD;
        mul(res, power_mod(2, k));
        add(ans, res);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    long n,ans=0;
    cin >> n;
    for(int i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0) ans += i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <cassert>
#include <deque>
#include <functional>
#include <utility>

template <typename Key, typename T, class Compare = std::greater<Key>>
class _01Heap {
public:
	using key_type = Key;
	using mapped_type = T;
	using value_type = std::pair<key_type, mapped_type>;
	using reference = value_type &;
	using const_reference = const value_type &;
	using key_compare = Compare;
	using container_type = std::deque<value_type>;
	using size_type = typename container_type::size_type;
	class value_compare {
		friend class _01Heap;
		const key_compare comp;
		value_compare() : comp() {}

	public:
		constexpr bool operator()(const_reference x, const_reference y) const {
			return comp(x.first, y.first);
		}
	};

private:
	const value_compare comp;
	container_type dq;
	size_type size_;

public:
	_01Heap() : comp(), dq(), size_(0) {}
	const_reference top() const {
		assert(size_);
		return dq.front();
	}
	void pop() {
		assert(size_);
		--size_;
		dq.pop_front();
	}
	void push(const_reference x) {
		if (!size_)
			dq.push_front(x);
		else {
			//assert(!comp(dq.front(), x));
			if (comp(x, dq.front())) {
				assert(!comp(dq.back(), x));
				dq.push_back(x);
			}
			else
				dq.push_front(x);
		}
		++size_;
	}
	size_type size() const noexcept { return size_; }
	bool empty() const noexcept { return !size_; }
};


struct edge {
	int to;
	int cost;
};
#include<iostream>
#include<vector>
#include<limits>
#include<tuple>
int main(void) {
	int k;
	std::cin >> k;
	std::vector<std::vector<edge>> G(k);
	for (int i = 0;i < k;++i) {
		G[i].push_back({ i * 10 % k,0 });
		G[i].push_back({ (i + 1) % k,1 });
	}
	_01Heap<int, int> Q;
	static constexpr int INF = std::numeric_limits<int>::max();
	std::vector<int> d(k, INF);
	Q.push({ 1,1 });
	d[1] = 1;
	int v, c;
	while (!Q.empty()) {
		std::tie(c, v) = Q.top();Q.pop();
		if (d[v] < c) continue;
		for (const auto &e : G[v]) {
			if (c + e.cost < d[e.to]) {
				d[e.to] = c + e.cost;
				Q.push({ d[e.to],e.to });
			}
		}
	}
	std::cout << d[0] << std::endl;
	return 0;
}

Measured memory_bytes: 6528
X, N = map(int,input().split())
if N == 0:
  print(X)
else:
  q = list(map(int,input().split()))
  q = list(set(q))
  p = [i for i in range(-2 , 102)]
  for i in range(len(q)):
    p.remove(q[i])

  S = 103
  for i in range(len(p)):
    if abs(X - p[i]) < S :
      ans = p[i]
      S = X - ans
    elif abs(X - p[i]) == S :
      if p[i] < ans :
        ans = p[i]
  print(ans)      

Measured memory_bytes: 9156
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include<map>
#include <utility>
#include <math.h>
using namespace std;
int a = 0, b = 0,c = 0, e[100010] = {}, f[100010];
double syo = 0, su = 0;
long long   mur=0, kmr=0, yju=0, counto[5003],counto1[5003];
char fir='z',sec='z',mado[5010];
string rik,tok[25003];
bool mazi[110], gi[110],zi,manji;
pair<int, int>n[110];
vector<int> aa[50] = {}, cc;
vector<string> bb;
map<int, int>pos;
int gcd(int a,int b) {
	int d;
	if (a > b) {
		int t = b;
		b = a;
		a = t;
	}
	while ((d = b % a) != 0) {
		b = a;
		a = d;
	}
	return a;
}
int main() 
{
	cin >> rik>>c;
	
	//cout << rik.length() << endl;
	for (int i = 0; i < rik.length(); i++) {
		for (int j = 1; j <=5; j++) {
			if (i+5 <rik.length()) {
				//cout << i << a << endl;
				bb.push_back(rik.substr(i, j));
				
				
			}
			else if (rik.length()  >= i+j) {
				bb.push_back(rik.substr(i, j));
				
			}
		}
	}
	//cout << a << endl;
	sort(bb.begin(), bb.end());
	//cout << bb.size() << endl;
	//cout << c - 1 << endl;
	//cout << bb[1] << endl;
	for (int i = 0; i < 25000; i++) {
		
		if (i > 0) {
			//cout << bb[i] <<bb[i-1]<< endl;
			if (bb[i] == bb[i - 1]) {
				
			}
			else { a++;
			//cout << '1' << endl;
			}
		}
		else { a++;
		//cout << '1' << endl;
		}
		if (a  == c) {
			cout << bb[i] << endl;
			return 0;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
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(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

template <typename T>
struct li_chao_tree {
    const T INF = numeric_limits<T>::max();
    struct line {
        T a, b;
        line(T a, T b) : a(a), b(b) {}
        T eval(T x) { return a*x + b;}
    };
    int n;
    vector<line> data;
    vector<T> pos;
    
    li_chao_tree(int n) {
        pos.resize(n);
        iota(pos.begin(), pos.end(), 0);
        init(n);
    }
    
    li_chao_tree(const vector<T>& pos_) : pos(pos_) {
        sort(pos.begin(), pos.end());
        pos.erase(unique(pos.begin(), pos.end()), pos.end());
        init(pos.size());
    }

    void init(int n_) {
        n = 1;
        while (n < n_) n <<= 1;
        while ((int)pos.size() < n) pos.emplace_back(pos.back() + 1);
        data.assign(n<<1, line(0, INF));
    }

    void add_line(T a, T b) {
        line x(a, b);
        update(1, 0, n-1, x);
    }

    inline bool over(line& a, line& b, T lb, T ub) {
        return a.eval(lb) >= b.eval(lb) && a.eval(ub) >= b.eval(ub);
    }
    
    void update(int k, int l, int r, line& x) {
        T lb = pos[l], ub = pos[r];
        if (over(x, data[k], lb, ub)) return;
        if (over(data[k], x, lb, ub)) {
            data[k] = x;
            return;
        }
        int c = (l+r) >> 1;
        if (x.eval(pos[c]) < data[k].eval(pos[c])) swap(x, data[k]);
        if (x.eval(lb) <= data[k].eval(lb)) update(k<<1|0, l, c, x);
        else update(k<<1|1, c+1, r, x);
    }

    T get_min(ll x) {
        int i = lower_bound(pos.begin(), pos.end(), x) - pos.begin();
        T res = INF;
        int k = i + n;
        while (k > 0) {
            res = min(res, data[k].eval(pos[i]));
            k >>= 1;
        }
        return res;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; ll c;
    cin >> n >> c;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    vector<ll> pos(n);
    rep(i, n) pos[i] = -2 * h[i];
    li_chao_tree<ll> seg(pos);
    
    vector<ll> dp(n);
    for (int i = 1; i < n; ++i) {
        seg.add_line(h[i-1], dp[i-1] + h[i-1] * h[i-1]);
        dp[i] = seg.get_min(-2 * h[i]) + h[i] * h[i] + c;
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 18080
#include <iostream>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int a[100000];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	
	int ans = 0;
	for (i = 0; i + 1 < n; i++) {
		if (a[i] % 2 == 0) {
			ans += a[i] / 2;
		}
		else if (a[i + 1] == 0) {
			ans += a[i] / 2;
		}
		else {
			a[i]--;
			a[i + 1]--;
			ans++;
			ans += a[i] / 2;
		}
	}
	ans += a[n - 1] / 2;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
//GRL_5A
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define INF (1<<30)
 
static const int MAX=100000;

class Edge{
public:
 int t,w;
 Edge(){}
 Edge(int t,int w): t(t),w(w) {}
};

vector<Edge> G[MAX];
int n,d[MAX];
bool vis[MAX];
int cnt;

void bfs(int s){
 for(int i=0;i<n;i++) d[i]=INF;
 queue<int> Q;
 Q.push(s);
 d[s]=0;
 int u;
 while(!Q.empty()){
  u=Q.front(); Q.pop();
  for(int i=0;i<G[u].size();i++){
   Edge e=G[u][i];
   if(d[e.t]==INF){
    d[e.t]=d[u]+e.w;
    Q.push(e.t);
   }
  }
 }
}

void solve(){
 bfs(0);
 int maxv=0;
 int tgt=0;
 for(int i=0;i<n;i++){
  if(d[i]==INF) continue;
  if(maxv<d[i]){
   maxv=d[i];
   tgt=i;
  }
 }
 bfs(tgt);
 maxv=0;
 for(int i=0;i<n;i++){
  if(d[i]==INF) continue;
  maxv=max(maxv,d[i]);
 }
 cout<<maxv<<endl;
}


int main(){
 int s,t,w;
 cin>>n;
 for(int i=0;i<n-1;i++){
  cin>>s>>t>>w;
  G[s].push_back(Edge(t,w));
  G[t].push_back(Edge(s,w));
 }
 solve();
 return 0;
}

Measured memory_bytes: 7996
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl '\n'
#define pb push_back
#define mod 10000007
#define mp make_pair
#define pi acos(-1)
#define line cout<<"----------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int n;
int ara[200009] ;
double ex[1009];
double sum[200009];
void pre()
{
    for(int i=1;i<=1000;i++)
    {
        double sum=0;
        for(int j=1;j<=i;j++)
        {
            sum+=j/(double)i;
        }
        ex[i]=sum;
    }
}
int  main()
{
    pre();
    int k;
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>ara[i];
    double maxi=0.0;
    for(int i=1;i<=n;i++)
    {
        sum[i]=sum[i-1]+ex[ara[i]];
    }
    for(int i=1;i<=n-k+1;i++)
    {
        double d=sum[i+k-1]-sum[i-1];
        //cout<<i<<' '<<d<<endl;
        maxi=max(maxi,d);
    }
    printf("%.10f\n",maxi);

}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MAX=17;
const int INF=0x3f3f3f3f;
ll n,m,conn[MAX][MAX],dist[MAX][MAX],dp[MAX][1<<MAX],visit[MAX][1<<MAX],calc[1<<MAX],trk[MAX],ans;
void calc_build(ll x,ll v,ll idx){
    //printf("%lld %lld %lld\n",x,v,idx);
    if(idx>=n) {
        calc[x]=v;
        return;
    }
    calc_build(x,v,idx+1);
    trk[idx]=1;
    for(ll i=0;i<idx;i++) if(trk[i]) v+=dist[i][idx];
    calc_build(x+(1<<idx),v,idx+1);
    trk[idx]=0;
}
ll dp_build(ll x,ll bit){
    if(x==n-1) return dp[x][bit]=calc[bit];
    if(visit[x][bit]==0){
        visit[x][bit]=1;
        dp[x][bit]=-INF;
        for(ll i=0;i<n;i++) if(((1<<i)&bit)&&conn[i][x]){
            ll cmp[MAX],cmp_cnt=0;
            for(ll j=0;j<n-1;j++) if(((1<<j)&bit)&&i!=j&&x!=j) cmp[cmp_cnt++]=j;
            for(ll j=0;j<(1<<(cmp_cnt));j++){
                ll g1=1<<x,g2;
                for(ll k=0;k<cmp_cnt;k++) if((1<<k)&j) g1+=(1<<cmp[k]);
                g2=bit-g1;
                dp[x][bit]=max(dp[x][bit],calc[g1]+dp_build(i,g2)+dist[x][i]);
            }
        }
    }
    return dp[x][bit];
}
int main()
{
    scanf("%lld%lld",&n,&m);
    for(ll i=0;i<m;i++){
        ll t1,t2,t;
        scanf("%lld%lld%lld",&t1,&t2,&t);
        t1--,t2--;
        conn[t1][t2]=1,dist[t1][t2]=t;
        conn[t2][t1]=1,dist[t2][t1]=t;
        ans+=t;
    }
    calc_build(0,0,0);
    printf("%lld\n",ans-dp_build(0,(1<<n)-1));
}


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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N,K; cin >> N >> K;
    vector<ll> A(N+1,0);
    for(int i = 1; i <= N; ++i) cin >> A[i];
    sort(ALL(A));
    int ng = 0, ok = N+1,md;
    const size_t M = 5000;
    while(ok-ng>1){
        md = (ok+ng)/2;
        bitset<M+1> dp;
        dp.set(0);
        for(int i = 0; i <= N; ++i) {
            if(i==md) continue;
            dp |= (dp<<A[i]);
        } 
        int flg = 0;
        for(int i = 0; i < K; ++i) {
            if(dp[i]&&i+A[md]>=K) flg = 1;
        }
        (flg?ok:ng)=md;
    }
    cout << ok-1 << endl;
    return 0;
}


Measured memory_bytes: 256
#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 x,a,b; cin >>x>>a>>b;
  int amade =max(a-x,x-a),bmade=max(b-x,x-b);
  if(min(amade,bmade) == amade) cout << 'A' << endl;
  else cout << 'B' << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define lf long double
#define F first
#define S second
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <pair <ll,ll> >vii;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin>>s;
    if(c==d)
    {
        cout<<"No\n";
        return 0;
    }
    if(c>d)
    {
        ll  flag=0;
        for(ll i=b-1;i<=d-1 && flag==0;i++)
        {
            if(s[i]=='.')
            {
                if(i+1<n && s[i+1]=='.')
                {
                    if(i-1>=0 && s[i-1]=='.')
                    {
                        flag=1;
                    }
                }
            }
        }
        if(flag==0)
        {
            cout<<"No\n";
            return 0;
        }
    }
    while(b<d)
    {
        if(s[b-1]=='#')
        {
            cout<<"No\n";
            return 0;
        }
        if(s[b]=='#')
        {
            b+=2;
        }
        else
        {
            b++;
        }
    }
    //b-1 to d-1
    if(b==d)
    {
        while(a<c)
        {
            if(s[a-1]=='#')
            {
                cout<<"No\n";
                return 0;
            }
            if(s[a]=='#')
            {
                a+=2;
            }
            else
            {
                a++;
            }
        }
    
    if(a==c)
    {
        cout<<"Yes\n";
        return 0;
    }
    }
    else
    {
        cout<<"No\n";
        return 0;
    }
}


Measured memory_bytes: 592
S=input()
S_list=list(S)
words=[chr(i) for i in range(97, 97+26)]

if S=='zyxwvutsrqponmlkjihgfedcba':
    print(-1)

else:
    if len(S)<=25:
        for word in words:
            if not word in S:
                S+=word
                break
        print(S)
    else:
        for n in range(1, 26):
            saisho = S_list[-n]
            N_f = words.index(saisho)
            saigo = S_list[-n - 1]
            N_l = words.index(saigo)
            if N_f < N_l:
                continue
            else:
                S_f = S_list[:-n - 1]
                S_l = S_list[-n:]
                S_l_new = sorted(S_l)
                new = []
                for number in S_l_new:
                    if words.index(number) > N_l:
                        new.append(number)
                        break
                S_f += new
                print(''.join(S_f))
                break


Measured memory_bytes: 81320
N = int(input())
S = input()
ans = 0
for i in range(N):
  cnt = 0
  l = list(set(S[:i]))
  r = list(set(S[i:]))
  for j in l:
    if(j in r):
      cnt += 1
  ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main() {
	int i;
	int N;
	int T;
	int tmp1;
	int tmp2;
	cin >> N;
	int W[100];
	int ans = -1; //解 

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

	for (T = 0; T < N; T++) {
		tmp1 = 0;
		tmp2 = 0;
		for (i = 0; i <= T; i++) {
			tmp1 += W[i];
		}
		for (i = T + 1; i < N; i++) {
			tmp2 += W[i];
		}
		if (abs(tmp1 - tmp2) < ans || T == 0) {
			ans = abs(tmp1 - tmp2);
		}
		else {
			cout << ans;
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int A, B;
    cin >> A >> B;

    int ret = 0;
    FOR(n, A, B + 1) {
        ostringstream os;
        os << n;
        string s = os.str();
        string s2(ALL(s));
        reverse(ALL(s2));
        if (s == s2)
            ret++;
    }

    cout << ret << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<int> (a)((n))
using namespace std;
signed main(){
	int a,b,c,k,ans=0,wa;
	cin >> a >> b >> c >> k;
	(k%2 == 0)? cout << a-b << endl : cout << b-a << endl;

    return 0;
}

Measured memory_bytes: 256
/*
  AtCoder Beginner Contest 100
  A - Happy Birthday!
*/

#include<iostream>
using namespace std;

int A, B;

int main() {
  scanf("%d%d", &A, &B);

  if (A <= 8 && B <= 8) printf("Yay!\n");
  else printf(":(\n");

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define INF 1LL << 55
#define MAX (1LL << 31) -1
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<pair<int,int>,ll> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};
//#define F function<T(T,T)>


signed main(){
    int N;
    cin>>N;
    vector<ll> a(1+N*3);
    vector<ll> pre(1+N*3),post(1+N*3);
    for(int i=1;i<=3*N;i++){
        cin>>a[i];
    }
    priority_queue<ll> que;
    ll sum=0;
    for(int i=1;i<=2*N;i++){
        que.push(-a[i]);
        sum+=a[i];
        if(N<i) sum+=que.top(),que.pop();
        pre[i]=sum;
    }
    priority_queue<ll> que2;
    sum=0;
    for(int i=3*N;i>=N+1;i--){
        que2.push(a[i]);
        sum+=a[i];
        if(2*N>=i) sum-=que2.top(),que2.pop();
        post[i]=sum;
    }
    ll ans=-INF;
    for(int i=N;i<=2*N;i++){
        chmax(ans,pre[i]-post[i+1]);
    }
    cout<<ans<<endl;


}

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

int main()
{
	int N;
	vector<int> p;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int x; cin >> x;
		p.push_back(x);
	}

	int max = 0; int imax = -1;
	for (int i = 0; i < (int)p.size(); i++) {
		if (p[i] > max) {
			imax = i; max = p[i];
		}
	}

	p[imax] /= 2;

	int s = 0;
	for(int i=0;i<(int)p.size();i++){
		s += p[i];
	}
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256