akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	Info(int arg_to,int arg_dist,int arg_delay){
		to = arg_to;
		dist = arg_dist;
		delay = arg_delay;
	}
	int to,dist,delay;
};

struct Data{
	Data(int arg_station,int arg_sum_time){
		station = arg_station;
		sum_time = arg_sum_time;
	}
	bool operator<(const struct Data &arg) const{
		return sum_time > arg.sum_time;
	};
	int station,sum_time;
};

int N,M,index;
char table[500][21];

char start[21],mid[21],goal[21];

bool strCmp(char* base, char* comp){
	int length1,length2;
	for(length1=0;base[length1] != '\0';length1++);
	for(length2=0;comp[length2] != '\0';length2++);
	if(length1 != length2)return false;

	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}

void strcpy(char* to,char* str){
	for(int i=0;str[i] != '\0';i++){
		to[i] = str[i];
		to[i+1] = '\0';
	}
}

void func(){
	scanf("%s %s %s",start,mid,goal);

	strcpy(table[0],start);
	strcpy(table[1],mid);
	strcpy(table[2],goal);

	vector<Info> V[N+1];

	index = 3;

	char left[21],right[21];
	int left_index,right_index,dist,delay;

	bool FLG;

	for(int loop = 0; loop < M; loop++){
		scanf("%s %s %d %d",left,right,&dist,&delay);

		FLG = false;
		for(int i = 0; i < index; i++){
			if(strCmp(table[i],left)){
				left_index = i;
				FLG = true;
				break;
			}
		}
		if(!FLG){
			left_index = index;
			strcpy(table[index++],left);
		}

		FLG = false;
		for(int i = 0; i < index; i++){
			if(strCmp(table[i],right)){
				right_index = i;
				FLG = true;
				break;
			}
		}
		if(!FLG){
			right_index = index;
			strcpy(table[index++],right);
		}

		V[left_index].push_back(Info(right_index,dist,delay));
		V[right_index].push_back(Info(left_index,dist,delay));
	}

	int min_time[N];
	int ans = 0;

	priority_queue<Data> Q;

	for(int loop = 0; loop < 2; loop++){
		for(int i = 0; i < N; i++)min_time[i] = BIG_NUM;
		if(loop == 0){
			min_time[0] = 0;
			Q.push(Data(0,0));
		}else{
			min_time[1] = 0;
			Q.push(Data(1,0));
		}

		while(!Q.empty()){

			if((loop == 0 && Q.top().station == 1) || (loop == 0 && Q.top().station == 1)){
				Q.pop();
			}else if(Q.top().sum_time > min_time[Q.top().station]){
				Q.pop();
			}else{
				for(int i = 0; i < V[Q.top().station].size(); i++){
					if(min_time[V[Q.top().station][i].to] > Q.top().sum_time+V[Q.top().station][i].dist/40+V[Q.top().station][i].delay){
						min_time[V[Q.top().station][i].to] = Q.top().sum_time+V[Q.top().station][i].dist/40+V[Q.top().station][i].delay;
						Q.push(Data(V[Q.top().station][i].to,min_time[V[Q.top().station][i].to]));
					}
				}
				Q.pop();
			}
		}

		if(loop == 0){
			ans += min_time[1];
		}else{
			ans += min_time[2];
		}
	}

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

int main(){

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}
	return 0;
}

Measured memory_bytes: 3328
n,k,q = (int(i) for i in input().split())
a = [k]*n
d = [0] + [a[i]-a[i-1] for i in range(1,n)]
for i in range(q):
	x = int(input())-1
	d[0]-=1
	d[x]+=1
	if x+1<n:d[x+1]-=1
a[0]+=d[0]
for i in range(1,n): a[i] = a[i-1]+d[i]
for i in range(n):print("Yes" if a[i]>0 else "No")


Measured memory_bytes: 8680
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(s,n) for(int i=s;i<n;i++)
#define inf 10000000000 //1e10
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int n,m;
void dfs(int i,vector<bool> &vis,vector<int> &s,vector<int> g[]){
    if(vis[i]){return;}
    vis[i]=true;
    for(int j=0;j<g[i].size();j++){
        dfs(g[i][j],vis,s,g);
    }
    s.pb(i);
}
int dp(vector<int> g[],vector<int> r[]){
    vector<int> tsorted;
    vector<bool> vis(n+1);
    for(int i=1;i<=n;i++)
        if(r[i].size()==0)
            dfs(i,vis,tsorted,g);
    
    reverse(tsorted.begin(),tsorted.end());

    int tab[n+1];
    int ans = 0;
    for(int i=0;i<n;i++){
        int at = tsorted[i];
        tab[at]=0;
        for(int j=0;j<r[at].size();j++)
            tab[at]=max(tab[at],tab[r[at][j]]+1);
        ans = max(ans,tab[at]);
    } 
    return ans;
}

int32_t main(){
    fastio;
    cin >> n >> m;
    vector<int> go[n+1],r[n+1];
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        go[a].pb(b);
        r[b].pb(a);
    }
    cout << dp(go,r) << endl;

}

Measured memory_bytes: 18556
N = int(input())
X = list(map(int,input().split()))
tmp = 0
ans = 10 ** 10
for i in range(1,101):
  tmp = 0
  for a in range(N):
    tmp = tmp + (abs(X[a] - i)) ** 2
  ans = min(ans,tmp)
print(str(ans))

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;

int main()
{
	int n;
	cin>>n;
	map<string,int> acList;
	acList["AC"] = 0;
	acList["WA"] = 0;
	acList["TLE"] = 0;
	acList["RE"] = 0;
	for(int i = 0; i < n; i++){
		string str;
		cin>>str;
		acList[str]++;
	}
	string strList[4] = {"AC","WA","TLE","RE"};
	for(int i = 0; i < 4; i++){
		cout<<strList[i]<<" x "<<acList[strList[i]]<<endl;
	}
	return 0;
}


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

int main(){
  ll n,m;
  cin>>n>>m;
  vector<ll> l(m);
  vector<ll> r(m);
  rep(i,m){
    cin>>l.at(i)>>r.at(i);
  }
  sort(l.begin(),l.end());
  sort(r.begin(),r.end());
  int lmax = l.at(m-1),rmin = r.at(0);
  if (lmax <= rmin){
    cout << r.at(0) - l.at(m-1) + 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
 
int main()
{ 
    long long int  n,d;
    cin>>n>>d;
    d=d*d;
    int count=0;
    while(n--){
        long long int x,y;
        cin>>x>>y;
        if((x*x + y*y)<= d) count++;
    }
    cout<<count;
}
            

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }

int main() {
    FAST_IO();
    int N, M; cin >> N >> M;
    vector<vector<pii>> adj(N);
    vector<int> indegree(N), outdegree(N);
    rep(i, M) {
        int L, R, D; cin >> L >> R >> D;
        adj[R-1].push_back({L-1, D});
        indegree[L-1]++;
        outdegree[R-1]++;
    }
    vector<int> dist(N, -1);
    rep(i, N) if(outdegree[i] == 0) dist[i] = 1e9;
    // Topology sort
    queue<int> Q;
    rep(i, N) if(indegree[i] == 0) {
        Q.push(i);
    }
    vector<int> sorted;
    rep(i, N) {
        if(Q.empty()) { // if exist cycle
            cout << "No\n";
            return 0;
        }
        int here = Q.front(); Q.pop();
        sorted.push_back(here);
        for(auto &e : adj[here]){
            int next = e.first;
            if(--indegree[next] == 0) {
                Q.push(next);
            }
        }
    }
    bool ans = true;
    rep(i, N) {
        int curr = sorted[N - 1 - i];
        if(dist[curr] != -1) continue;
        int minX = 1e9, maxX = 0;
        for(auto &e : adj[curr]) {
            int next = e.first, d = e.second;
            minX = min(minX, dist[next] - d);
            maxX = max(maxX, dist[next] - d);
        }
        if(minX == maxX) dist[curr] = minX;
        else {
            ans = false;
            break;
        }
    }
    if(ans) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 8264
#include <bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair <int, int>
#define iiii pair <int, pii >
#define mp make_pair
#define rep(i, x) for(int (i) = 0; (i) < (x); (i)++)
#define int ll
inline int getint() {
  int x = 0, p = 1; char c = getchar();
  while (c <= 32) c = getchar();
  if (c == 45) p = -p, c = getchar();
  while (c > 32) x = x * 10 + c - 48, c = getchar();
  return x * p;
}
using namespace std;
const ll INF = 2e18;
const int mod = 1e9 + 7;
inline void reduce(int &x) { x += x >> 31 & mod; }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
//ruogu_alter
const int N = 1e5 + 5;
int n, l[N], r[N], a[N];
//
signed main() {
  n = getint();
  rep(i, n + 1) a[i] = getint();
  if (!n) {
    if (a[0] == 1) printf("%d\n", 1);
    else printf("%d\n", -1);
    return 0;
  }
  l[0] = r[0] = 1; if (a[0]) return !printf("%d\n", -1);
  for (int i = 1; i <= n; i++) {
    if ((r[i - 1] - a[i - 1]) * 2 < a[i]) return !printf("%d\n", -1);
    l[i] = max(a[i], l[i - 1] - a[i - 1]); l[i] = min(l[i], INF);
    r[i] = min(INF, (r[i - 1] - a[i - 1]) * 2);
  }
  ll res = a[n]; int now = a[n];
  if (a[n] < l[n] || a[n] > r[n]) return !printf("%d\n", -1);
  for (int i = n - 1; i >= 0; i--) {
    now += a[i]; now = min(now, r[i]);
    res += now;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 5932
#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 < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

int main(){
  int a[3][3];
  rep(i,3)rep(j,3) cin >> a[i][j];

  int sum = a[0][0] + a[1][1] + a[2][2] ;
  if(a[0][1] + a[1][2] + a[2][0] == sum &&
     a[0][2] + a[1][0] + a[2][1] == sum &&
     a[0][0] + a[1][2] + a[2][1] == sum &&
     a[0][1] + a[1][0] + a[2][2] == sum &&
     a[0][2] + a[1][1] + a[2][0] == sum   ){
       cout << "Yes" << endl;
     }else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
 
int main(void) {
  int p, q, r;
  int tmp = 0;
  scanf("%d %d %d", &p, &q, &r);

  if ( p > q ) {
    tmp = p;
    p = q;
    q = tmp;
  }

  if ( q > r ) {
    tmp = q;
    q = r;
    r = tmp;
  }

  printf("%d", p + q);


return 0;
}

Measured memory_bytes: 128
tile_list = input()

ansfz = 0
ansfo = 0

for i,s in enumerate(tile_list):
    # print(i,':',s,i % 2,int(s) == (i % 2))
    if int(s) == (i % 2):
        ansfz += 1
    else :
        ansfo += 1

print(min(ansfz,ansfo))

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


int main() {
	double w, h, x, y;cin >> w >> h >> x >>y;
	cout << (w*h)/2;
	if(x == w/2 && y == h/2) cout << " " << 1;
	else cout << " " << 0;

}


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

int main()
{
        string S;
        cin >> S;

        string S1 = "";
        string S2 = "";

        for(ll i = 0; i < S.size(); ++i)
        {
                if(i % 2 == 0)
                {
                        S1 += "0";
                        S2 += "1";
                }
                else
                {
                        S1 += "1";
                        S2 += "0";
                }
        }

        ll cnt1 = 0;
        ll cnt2 = 0;
        for(ll i = 0; i < S.size(); ++i)
        {
                if(S[i] != S1[i]) ++cnt1;
                if(S[i] != S2[i]) ++cnt2;
        }

        cout << min(cnt1, cnt2) << endl;

        return 0;
}

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

using namespace std;

int main(){
int s;cin>>s;
  int s1=s/100,s2=s%100;
  if(s1<13&&s1>0)
  {
    if(s2<13&&s2>0)
      cout<<"AMBIGUOUS"<<endl;
    else
      cout<<"MMYY"<<endl;
  }
  else
  {
     if(s2<13&&s2>0)
       cout<<"YYMM"<<endl;
    else
      cout<<"NA"<<endl;
  }
}
       
    


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
long long c[200005];
int main()
{
	long long i,j,a,b,s=0;
	cin>>a>>b;
	for(i=1;i<=a;i++)
	{
		cin>>c[i];
		
	}
	sort(c+1,c+a+1);
if(b>=a) cout<<0;
else {
	for(i=1;i<=a-b;i++)
	s+=c[i];
	cout<<s;
}
 } 

Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<sstream>
#include<string>

int n, s;

int main()
{
	std::cin >> n;
	for( int i = 0; i != n; ++i )
	{
		std::cin >> s;

		std::cout << "Case " << i + 1 << ':' << std::endl;;
		for( int j = 0; j != 10; ++j )
		{
			int t = s * s;
			std::ostringstream oss;
			oss << std::setw( 8 ) << std::setfill( '0' ) << t;
			std::istringstream iss( oss.str().substr( 2, 4 ) );
			iss >> s;
			std::cout << s << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1232
import java.util.*;
import java.util.stream.*;

class Main {
	Scanner sc;
	int N;
	int[] L;
	
	Main() {
		sc = new Scanner(System.in);
	}
	
	void calc() {
		int N = sc.nextInt();
		L = new int[N];
		for (int i = 0; i < N; i++) L[i] = 2 * sc.nextInt();
		Arrays.sort(L);
		
		int cnt = 0;
		for (int i = 0; i < N-2; i++) {
			int a = L[i];
			for (int j = i+1; j < N-1; j++) {
				int b = L[j]; // b >= a
				
				// acceptable c .. b-a<c<b+a
				int li = Arrays.binarySearch(L, b-a+1);
				int ll = Math.max(j+1, -1-li);
				int ui = Arrays.binarySearch(L, b+a-1);
				int ul = Math.min(N, -1-ui);
				cnt += Math.max(0, ul-ll);
			}
		}
		System.out.println(cnt);
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}

Measured memory_bytes: 26368
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; ++i) cin >> d[i];
    sort(d.begin(), d.end(), greater<int>());
    int cnt = 0;
    int m = 101;

    for (int i = 0; i < n; ++i) {
        if (d[i] < m) {
            ++cnt;
            m = d[i];
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
cnt=[0]*(10**5+1)
for _ in range(n):
  a,b=map(int,input().split())
  cnt[a]+=b
tmp=0
for i in range(10**5+1):
  tmp+=cnt[i]
  if tmp>=k:
    print(i)
    break

Measured memory_bytes: 5736
x = int(input())

if x < 600:
    print(8)
elif x < 800:
    print(7)
elif x < 1000:
    print(6)
elif x < 1200:
    print(5)
elif x < 1400:
    print(4)
elif x < 1600:
    print(3)
elif x < 1800:
    print(2)
else:
    print(1)


Measured memory_bytes: 61628
#include <bits/stdc++.h>
#define BASE 1000000007
#define N_MAX 100000
using namespace std;

long mod_pow(long x, int k) {
    long ret = 1;
    while (k > 0) {
        if (k & 1) {
            ret = (ret * x) % BASE;
        }
        k >>= 1;
        x = (x * x) % BASE;
    }
    return ret;
}

inline long mod_inv(long x) {
    return mod_pow(x, BASE - 2);
}

long a_pow[N_MAX + 1], b_pow[N_MAX + 1], combi_n1[N_MAX + 1], ab_pow[N_MAX + 1];

int main() {
    long n, a, b, c;
    cin >> n >> a >> b >> c;
    a_pow[0] = b_pow[0] = combi_n1[0] = 1;
    ab_pow[0] = mod_pow(a + b, n + 1);
    for (int i = 1; i <= n; i++) {
        a_pow[i] = (a * a_pow[i - 1]) % BASE;
        b_pow[i] = (b * b_pow[i - 1]) % BASE;
        combi_n1[i] = (combi_n1[i - 1] * (n - 1 + i)) % BASE;
        combi_n1[i] = (combi_n1[i] * mod_inv(i)) % BASE;
        ab_pow[i] = (ab_pow[i - 1] * (a + b)) % BASE;
    }
    long r = 0;
    for (int i = 0; i < n; i++) {
        long em = ((a_pow[n] * b_pow[i]) % BASE + (a_pow[i] * b_pow[n]) % BASE) % BASE;
        em = (em * (n + i)) % BASE;
        em = (em * combi_n1[i]) % BASE;
        em = (em * 100) % BASE;
        em = (em * mod_inv(ab_pow[i])) % BASE;
        r = (r + em) % BASE;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <math.h>
#include <iostream>
using namespace std;

int main()
{
	long double x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << fixed << sqrt(pow(y2 - y1, 2) + pow(x2 - x1, 2)) << endl;
    return 0;
}

Measured memory_bytes: 3216
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a<b)
            System.out.println("0");
        else
            System.out.println("10");

    }
}


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

using namespace std;
#define ll long long

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    string str;

    map<string,int> hmap;

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

    cout<<"AC x "<<hmap["AC"]<<endl;
    cout<<"WA x "<<hmap["WA"]<<endl;
    cout<<"TLE x "<<hmap["TLE"]<<endl;
    cout<<"RE x "<<hmap["RE"]<<endl;

    return 0;
}


Measured memory_bytes: 3664
import Control.Monad
import Data.List

diff :: Int -> [Int] -> [Int]
diff k xs = map (\(a, b) -> b - a) l
    where
        l = zip xs (drop k xs)

main = do
    first <- fmap words getLine
    let n = read (first !! 0) :: Int
    let k = read (first !! 1) :: Int
    trees <- replicateM n getLine
    let trees' = fmap read trees :: [Int]
    let sorted = sort trees'
    putStrLn $ show . minimum $ diff (k-1) sorted
    

Measured memory_bytes: 64636
// mitsui_sumitomo_2019_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    REP(X, 100000){
        if (int(X * 1.08) == N){
            print(X);
            return 0;
        }
    }

    print(":(");


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, t;
    cin >> n;
    bool flag = true;
    for(int i = 0; i < n; ++i) {
        cin >> t;
        if(t % 2 == 0)
            if(t % 5 && t % 3) 
                flag = false;
    }
    if(flag) puts("APPROVED");
    else puts("DENIED");
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
#include<functional>
using namespace std;
int n,m;
int ans;
int par[100005];
vector<int> edge[100005];
vector<pair<int,int> > el;
pair<int,int> e[200005];
pair<pair<int,int>,int> a[100005],b[100005];
int find(int x)
{
	if(par[x]!=x)
		return par[x]=find(par[x]);
	else
		return par[x];
}
bool unite(int x,int y)
{
	x=find(x);
	y=find(y);
	if(x==y)
		return false;
	else
	{
		par[x]=y;
		return true;
	}
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].first.first>>a[i].first.second;
		b[i].first.first=a[i].first.second;
		b[i].first.second=a[i].first.first;
		a[i].second=b[i].second=i;
	}
	sort(a,a+n);
	sort(b,b+n);
	for(int i=1;i<n;i++)
	{
		edge[a[i].second].push_back(a[i-1].second);
		e[m]=make_pair(a[i].second,a[i-1].second);
		el.push_back(make_pair(a[i].first.first-a[i-1].first.first,m++));
	}
	for(int i=1;i<n;i++)
	{
		edge[b[i].second].push_back(b[i-1].second);
		e[m]=make_pair(b[i].second,b[i-1].second);
		el.push_back(make_pair(b[i].first.first-b[i-1].first.first,m++));
	}
	for(int i=0;i<n;i++)
		par[i]=i;
	sort(el.begin(),el.end());
	for(int i=0;i<m;i++)
	{
		int xx=e[el[i].second].first;
		int yy=e[el[i].second].second;
		if(unite(xx,yy))
			ans+=el[i].first;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 11764
/*
[abc117] C - Streamline
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_M = 1e5;

int N, M;
int X[MAX_M];

ll solve() {
    sort(X, X + M);

    int d[MAX_M];
    for (int i = 0; i < M - 1; i++) {
        d[i] = X[i + 1] - X[i];
    }
    sort(d, d + M - 1);

    ll ans = 0;
    for (int i = 0; i < M - N; i++) {
        ans += d[i];
    }

    return ans;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> X[i];
    }

    cout << solve() << endl;

    return 0;
}


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

int main(){
  string S, T;
  cin >> S >> T;
  int L=S.size();
  int Ans=0;
  for(int i=0; i<L; i++){
    int subans=1;
    for(int j=0; j<L; j++){
      if(S.at((i+j)%L)!=T.at(j)){
        subans=0;
        break;
      }
    }
    if(subans==1){
      Ans=1;
      break;
    }
  }  
  if(Ans==1){
    cout << "Yes" << endl;
  }    
  else{
    cout << "No" << endl;
  }    
}  

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,y,z,a;
	cin >> x >> y >> z;
	if (x >= y && x >= z )
	{
			a = x*10 + y + z;
	}else if (y >= z && y >= x )
	{
			a = y*10 + x + z;
	}else if (z >= y && z >= x )
	{
			a = z*10 + x + y;
	}
	cout << a << "\n";

}

Measured memory_bytes: 256
#include <iostream> 
using namespace std;
int main() {
  int n; cin >> n;
  int one = n%10;
  if (one == 2 || one == 4 || one ==5 || one == 7 || one == 9) {
    cout << "hon" << endl;
  }else if (one == 3) {
    cout << "bon" << endl;
  }else {
    cout << "pon" << endl;
  }
}

Measured memory_bytes: 3096
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char a, b, c, d;
    int aa, bb;
    aa = bb = 0;
    cin >> a;
    
    for(int i = 0; i < 3; ++i){
        cin >> b;
        if(b == a){
            ++aa;
        }
        else if(b == c){
            ++bb;
        }
        else{
            c = b;
        }
    }    
    
    if(aa == 1 && bb == 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3600
package main

import (
    "fmt"
    "os"
    "bufio"
)

func main() {
    var fp *os.File
    fp = os.Stdin
    reader := bufio.NewReaderSize(fp, 4096)
    X := readLine(reader)
    arr := []byte(X)
    length := len(arr)
    var del int = 0
    var cnt int = 0


    for i := length - 1; i >= 0; i-- {
        if string(arr[i]) == "T" {
            cnt++
        }

        if string(arr[i]) == "S" {
            if cnt > 0 {
                cnt--
                del++
            }
        }
    }

    fmt.Println(length - del*2)
}

func readLine(reader *bufio.Reader) string {
    buf := make([]byte, 0, 1024)

    for {
        l, p, _ := reader.ReadLine()

        buf = append(buf, l...)

        if !p {
            break
        }
    }

    return string(buf)
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//逆元mod(mを法とするaの逆元)//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nが大

ll com(ll n,ll m){
	if(n<=0 || m<=0 || n==m){
		return 1;
	}
	if(n<m){
		return 0;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}

	return k;
}


int main(){

int n;
string s;
cin>>n;
cin>>s;
int ans=0;
int now=0;
for(int i=0;i<s.size();i++){
if(s[i]=='I'){
	now++;}
	else{
		now--;
	}
	ans=max(ans,now);
}

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


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

int n;
int r;
int sum[100];

int main(){
	while (cin >> n && n != 0) {
		fill(sum, sum + 100, 0);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 5; j++) {
				cin >> r;
				sum[i] += r;
			}
		}
		sort(sum, sum + n);
		cout << sum[n-1] << " " << sum[0] << endl;
	}

	return 0;
}

Measured memory_bytes: 3124
import bisect


n, k = map(int, input().split())
v = list(map(int, input().split()))

res = 0
for toru in range(0, min(k, n) + 1):
    tumeru = k - toru
    for migi in range(0, toru + 1):
        hidari = toru - migi
        ans = v[0:hidari] + v[n - migi:n]        
        ans = sorted(ans)
        ind = bisect.bisect_left(ans, 0)
        res = max((sum(ans) - sum(ans[0:min(ind, tumeru)])), res)
print(res) 

Measured memory_bytes: 42600
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

#define rep(i, o) for (int i = 0; i < (o); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)

typedef long long ll;


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  int a, b, k;
  cin >> a >> b >> k;

  for (int i = a; i <= b; i++)
  {
      /* code */
      if (i >= a + k && i < b - k + 1) continue;
      cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 256
//幅優先探索 BFS bfs

#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};

vector <int> to[100100];  //グラフを格納（頂点数 x 0の二次元配列）

int main(void){
  int N, M;
  cin >> N >> M;
  rep(i,M){
    int a, b;
    cin >> a >> b;
    a --; b --;
    //to[i]にはiにつながっている頂点のリストが入る
    to[a].push_back(b);
    to[b].push_back(a);
  }

  queue <int> q;
  vector <int> dist(N, inf);  //入口からの距離（本当はこの問題では不要）
  vector <int> pre(N, -1);  //前の頂点

  //初期条件
  dist[0] = 0;
  q.push(0);

  while (!q.empty()){
    int v = q.front();  //queueから先頭頂点を取り出す
    q.pop();

    // vから辿れる頂点をすべて調べる
    for (int u : to[v]){
      if (dist[u] != inf) continue;  //すでに発見済みの頂点は探索しない
      dist[u] = dist[v] + 1;
      pre[u] = v;
      q.push(u);
    }
  }

  cout << "Yes" << endl;
  rep(i,N){
    if (i == 0) continue;
    int ans = pre[i];
    ans++;
    cout << ans << endl;
  }
  return 0;
}


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

int main(){
    double n,m,d;
    cin >> n >> m >> d;
    double ans;
    if(d==0){
        ans=n/(n*n)*(m-1);
    }
    else{
        ans=(2*(n-d))/(n*n)*(m-1);
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
}


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

using namespace std;

int calc(int a, int b, int c) {
    int biggest, answer;

    int bigger_ab = max(a, b);
    biggest = max(bigger_ab, c);

    if (a == biggest) {
        answer = a * 10 + b + c;
    } else if (b == biggest) {
        answer = b * 10 + c + a;
    } else if (c == biggest) {
        answer = c * 10 + a + b;
    }
    return answer;
}

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N=sc.nextInt();
		int[] time=new int[N];
		for(int i=0; i<N; i++) {
			time[i]=sc.nextInt()*2;
			if(i>0) {
				time[i]+=time[i-1];
			}
		}
		int[] v=new int[N];
		for(int i=0; i<N; i++) {
			v[i]=sc.nextInt()*2;
		}
		int[][] speedlimit=new int[N][time[N-1]+1];
		int[] skd=new int[time[N-1]+1];
		for(int i=0; i<N-1; i++) {
			Arrays.fill(speedlimit[i], 0);
		}
		for(int i=time[N-1]; i>=0; i--) {
			speedlimit[N-1][i]=time[N-1]-i;
		}
		Arrays.fill(skd, 0);
		for(int i=0; i<N; i++) {
			skd[time[i]]=v[i];
		}
		for(int i=time[N-1]; i>=0; i--) {
			if(skd[i]>0) {
				//
			}
			else {
				skd[i]=skd[i+1];
			}
		}
		for(int i=1; i<N; i++) {
			speedlimit[i-1][time[i-1]]=v[i];
		}
		for(int i=0; i<N-1; i++) {
			for(int j=time[i]; j>=0; j--) {
				speedlimit[i][j]=speedlimit[i][time[i]]+Math.abs(time[i]-j);
			}
			for(int j=time[i]+1; j<time[N-1]+1; j++) {
				speedlimit[i][j]=100000000;
			}
		}
		int[] s=new int[time[N-1]+1];
		s[0]=0;
		for(int i=1; i<=time[N-1]; i++) {
			int max=114514810;
			for(int j=0; j<N; j++) {
				max=Math.min(max, speedlimit[j][i]);
			}
			max=Math.min(max, skd[i]);
			if(s[i-1]+1<=max) {
				s[i]=s[i-1]+1;
			}
			else if(s[i-1]==max) {
				s[i]=s[i-1];
			}
			else {
				s[i]=s[i-1]-1;
			}
		}
		int sum=0;
		for(int i=1; i<=time[N-1]; i++) {
			sum+=s[i-1]+s[i];
		}
		pl(((double)sum)/8);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 52512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = in.readLine().split(" ");
      int[] arr = new int[lines.length];
      int k=0;
      for (String s : lines) {
        arr[k++] = Integer.parseInt(s); 
      }
      Arrays.sort(arr);
      int step=0;
      if(arr[2] - arr[1] > 2) {
        for(; arr[1]+2 < arr[2]; step++) {
          arr[1] += 2;
        }
      }
      if(arr[1] - arr[0] > 2) {
        for(; arr[0]+2 < arr[1]; step++) {
          arr[0] += 2;
        }
      }

      Tuple3 t = new Tuple3(arr[0], arr[1], arr[2]);
      t.step = step;

      bfs(t);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  private void bfs(Tuple3 t) {
    Deque<Tuple3> que = new ArrayDeque<>();

    que.offer(t);

    Tuple3 cur;
    while(!que.isEmpty()) {
      cur = que.poll();

      if(cur.isEq()) {
        System.out.println(cur.step);
        return;
      }

      if(cur.e[0] < cur.e[1] && cur.e[0] < cur.e[2]) {
        que.offer(new Tuple3(cur.e[0]+2, cur.e[1], cur.e[2]));
        que.peekLast().step = cur.step + 1;
      } else if(cur.e[1] < cur.e[2]) {
        que.offer(new Tuple3(cur.e[0], cur.e[1]+2, cur.e[2]));
        que.peekLast().step = cur.step + 1;
      } else {
        que.offer(new Tuple3(cur.e[0], cur.e[1], cur.e[2]+2));
        que.peekLast().step = cur.step + 1;
      }

      if(cur.e[0] < cur.e[2] && cur.e[1] < cur.e[2]) {
        que.offer(new Tuple3(cur.e[0]+1, cur.e[1]+1, cur.e[2]));
        que.peekLast().step = cur.step + 1;
      } else if(cur.e[1] < cur.e[0] && cur.e[2] < cur.e[0]) {
        que.offer(new Tuple3(cur.e[0], cur.e[1]+1, cur.e[2]+1));
        que.peekLast().step = cur.step + 1;
      } else {
        que.offer(new Tuple3(cur.e[0]+1, cur.e[1], cur.e[2]+1));
        que.peekLast().step = cur.step + 1;
      }
      
    }
  }

  class Tuple3 {
    int[] e;
    int step;

    public Tuple3(int a, int b, int c) {
      e = new int[3];
      e[0] = a;
      e[1] = b;
      e[2] = c;
      step = 0;
    }

    public boolean isEq() {
      return (e[0] == e[1]) && (e[1] == e[2]);
    }
  }
}

Measured memory_bytes: 21332
#include<stdio.h>

int main(void){
	int X, Y, Z;
	do{
			scanf("%d%d%d", &X, &Y, &Z);
	}while(X < 1 || X > 100000 || Y < 1 || Y > 100000  || Z < 1 || Z > 100000 || Y + Z * 2 > X);

	printf("%d\n", (X - Z) / (Y + Z));

	return 0;
}

Measured memory_bytes: 256
s = input()
l = len(s)
s = s+"RL"
flag = 0
point = 0
ans = [0]*l
tmpR = 0
tmpL = 0
for i in range(l+2):
    if(flag == 0):
        if(s[i] == "R"):
            tmpR += 1
        else:
            flag = 1
            point = i
            tmpL = 1
    else:
        if(s[i] == "L"):
            tmpL += 1
        else:
            flag = 0
            if(tmpR % 2 == 0):
                if(tmpL % 2 == 0):
                    ans[point-1] = int(tmpR/2) + int(tmpL/2)
                    ans[point] = int(tmpR/2) + int(tmpL/2)
                else:
                    ans[point-1] = int(tmpR/2) + int(tmpL/2)
                    ans[point] = int(tmpR/2) + int(tmpL/2) + 1
            else:
                if(tmpL % 2 == 0):
                    ans[point-1] = int(tmpR/2) + int(tmpL/2) + 1
                    ans[point] = int(tmpR/2) + int(tmpL/2)
                else:
                    ans[point-1] = int(tmpR/2) + int(tmpL/2) + 1
                    ans[point] = int(tmpR/2) + int(tmpL/2) + 1
            tmpR = 1
for i in ans:
    print(i, end=' ')


Measured memory_bytes: 4992
n = int(input())
k = 0
ans = []

def prime(p):
  j = 2
  while j * j <= p:
    if p % j == 0:
      return False
    j += 1
  return True

for i in range(6, 55556, 5):
  if k == n:
    break
  if prime(i):
    ans.append(i)
    k += 1

print(*ans)


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

using namespace std;
main(){
	int x,y,z;
	cin >> x >> y >> z;
	if(x==1&&y==0&&z==0){
		printf("Close\n");
	}else if(x==0&&y==1&&z==0){
		printf("Close\n");
	}else if(x==1&&y==1&&z==0){
		printf("Open\n");
	}else if(x==0&&y==0&&z==1){
		printf("Open\n");
	}else{
	printf("Close\n");}
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define ll long long
#define db double
using namespace std;
const int MOD=1e9+7;
ll n;
ll qp(ll x,ll y)
{
    ll re=1;
    while(y)
    {
        if(y&1) re=re*x%MOD;
        x=x*x%MOD,y>>=1;
    }
    return re;
}
int main()
{
    cin>>n;
    if(n==1) return puts("0"),0;
    //printf("%lld\n",qp(10,5));
    printf("%lld\n",((qp(10,n)-2*qp(9,n)%MOD+qp(8,n))%MOD+MOD)%MOD);
    return 0;
}


Measured memory_bytes: 3756
using System;

public class B
{
	public static void Main()
	{
		string[] s = Console.ReadLine().Split();
		int n, a, b;
		n = int.Parse(s[0]);
		a = int.Parse(s[1]);
		b = int.Parse(s[2]);
		int count = 0;
		for(int i = n; 0 < i; i--)
		{
			int num = 0;
			for(int j = i; 1 <= j; j /= 10)
			{
				num += j % 10;
			}
			if (a <= num && num <= b) count += i;
		}
		Console.WriteLine(count);
	}
}

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

using namespace std;

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

  int n;
  string s;
  cin >> n >> s;

  vector<int> left(n, 0), right(n, 0);
  for (int i = 0; i < n; ++i) 
    left[i] = (s[i] == 'W') + (i > 0 ? left[i-1] : 0);
  for (int i = n-1; i >= 0; --i) 
    right[i] = (s[i] == 'E') + (i+1 < n ? right[i+1] : 0);
  int res = 1e9;
  for (int i = 0; i < n; ++i) {
    int cur = (i > 0 ? left[i-1] : 0) + (i+1 < n ? right[i+1] : 0);
    if (cur < res ) res = cur;
  }
  cout << res << endl;

  return 0;
}



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

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define CeilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n;
    cin >> n;
    vector<int> arr(n);
    loop(n) {
        cin >> arr[i];
    }
    sort(all(arr), greater<>());
    ll ans = arr[0];
    int i = 1;
    int cnt = 2;
    while (cnt < n) {
        if (n - cnt == 1) {
            ans += arr[i];
            break;
        }
        ans += arr[i] + arr[i];
        ++i;
        cnt += 2;
    }
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define INF 1e8
#define EPS 1e-9
#define ALL(x) x.begin() , x.end()
#define ALLR(x) x.rbegin() , x.rend()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define PI acos(-1.0) // important constant; alternative #define PI (2.0 * acos(0.0))
bool is_palindrome(string s)
{
    string aux = s;
    reverse(ALL(aux));
    return aux == s;
}
int main()
{
    string s,a,b="al";
    cin>>s;
    int n = s.size();
    a = s.substr(0,(n-1)/2);
    b = s.substr((n+3)/2-1,n-(n+3)/2+1);
    if(is_palindrome(a)&&is_palindrome(b)&&is_palindrome(s))
       {
           cout<<"Yes";
       }
    else cout<<"No\n";
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()


int n,a,b;
int fo,now;
string s;

void input(){
	cin>>n>>a>>b>>s;
	return;
}

void solve(){
	for(int i=0;i<s.size();i++){
		if(s[i]=='a'){
			if(now<a+b){
				cout<<"Yes"<<endl;
				now++;
			}
			else cout<<"No"<<endl;
		}
		else if(s[i]=='b'){
			if(now<a+b&&fo<b){
				cout<<"Yes"<<endl;
				now++;
				fo++;
			}
			else{
				cout<<"No"<<endl;
			}
		}
		else cout<<"No"<<endl;
	}
	return;
}

int main(){
	input();
	solve();
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main()
{
    while(true){
        int M, T, P, R;
        cin >> M >> T >> P >> R;
        if(M==0 && T==0 && P==0 && R==0){
            break;
 		}
        int CP[50], TT[50], PT[50][10];
        for(int i=0; i<T; i++){
            CP[i] = TT[i] = 0;
            for(int j=0; j<P; j++)
                PT[i][j] = 0;
        }
        for(int i=0; i<R; i++){
            int m, t, p, j;
            cin >> m >> t >> p >> j;
            if(j==0){
                CP[t-1]++;
                TT[t-1] += (m+PT[t-1][p-1]);
            }
            else{
                PT[t-1][p-1] += 20;
            }
        }
        int tnow, tpre = -1;
        bool flg[50];
        for(int i=0; i<T; i++){
            flg[i] = false;
 		}
        for(int i=0; i<T; i++){
            tnow = -1;
            for(int j=0; j<T; j++){
                if(flg[j]){
                    continue;
				  }
                if(tnow==-1){
                    tnow = j;
                }
                else{
                    if(CP[j]>CP[tnow] || (CP[j]==CP[tnow] && TT[j]<=TT[tnow])){
                        tnow = j;
                    }
                }
            }
            if(tpre!=-1){
                if(CP[tnow]==CP[tpre] && TT[tnow]==TT[tpre])
                    cout << '=';
                else
                    cout << ',';
            }
            cout << tnow+1;
            flg[tnow] = true;
            tpre = tnow;
        }
        cout << endl;
    }
    return 0;
}



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

int main(){
    int n, m;
    cin >> n >> m;

    vector<int> a(n);
    float sum = 0;
    rep(i,n) {
        int x;
        cin >> x;
        a.push_back(x);
        sum += x;
    }

    sort(a.rbegin(), a.rend());
    bool ans = true;
    rep(i,m) {
        if ((float)a[i] < (float)sum/(4*m)) ans = false;
    }

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

    
    return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>) {
  val n = readLine()!!
  var xs = readLine()!!.split(" ").map(String::toInt)

  val quads = xs.filter { it%4 == 0 }.size
  xs = xs.filter { it%4 != 0 } 

  val twices = xs.filter { it%2 == 0 }.size
  xs = xs.filter { it%2 != 0 } 

  val noks = xs.size

  when { 
    (noks - quads) <= 1 && twices == 0  -> "Yes"
    noks <= quads && twices > 0  -> "Yes"
    else -> "No"
  }.run(::println)

  //println( noks -  quads )
}


Measured memory_bytes: 57272
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[110];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b+2;i++)printf("#");
		printf("\n");
	for(int i=0;i<a;i++){
		scanf("%s",in);
		printf("#%s#\n",in);
	}
	for(int i=0;i<b+2;i++)printf("#");
		printf("\n");
	
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
int l[100010];
int r[100010];

int main () {
  cin >> N;
  for (auto i = 0; i < N; ++i) {
    cin >> l[i] >> r[i];
    l[i]--;    
  }
  int imos[100010];
  fill(imos, imos+100010, 0);
  for (auto i = 0; i < N; ++i) {
    imos[l[i]]++;
    imos[r[i]]--;
  }
  for (auto i = 1; i < 100000; ++i) {
    imos[i] += imos[i-1];
  }
  int ans = 0;
  for (auto i = 0; i < 100000; ++i) {
    if (imos[i] > 0) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
    int arr[100] = {0};
int n;
int temp;
scanf("%d",&n);
for(int i=0;i<n;i++){
    scanf("%d",&arr[i]);
}
int i,j;
for(int i=0,j=(n-1);i<(n/2);i++,j--){
temp = arr[j];
arr[j] = arr[i];
arr[i] = temp;
}
for(int i=0;i<n;i++){
    if(i==(n-1)){
        printf("%d",arr[i]);
    }
    else{
    printf("%d ",arr[i]);
    }

}
printf("\n");


return 0;
}






Measured memory_bytes: 2068
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    string s;cin>>s;
    cout<<s.rfind('Z')-s.find('A')+1<<endl;
}


Measured memory_bytes: 3756
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef tuple<int, int, int> ituple;

// const int INF = INT_MAX;
// const ll INF = LLONG_MAX;
// const int MOD = ((int)1e9 + 7);
// const ld EPS = (1e-10);
#define PI acosl(-1)
#define MAX_N (100000 + 2)

void exec(){
  int a[2][102], dp[2][102];
  int n;

  cin >> n;
  for (int i = 0; i < 2; i++){
    for (int j = 0; j < n; j++){
      scanf("%d", &a[i][j]);
    }
  }

  for (int i = 0; i < 2; i++){
    for (int j = 0; j < n; j++){
      dp[i][j] = 0;
      if (j > 0) {
        dp[i][j] = dp[i][j-1];
      }
      if (i > 0) {
        dp[i][j] = max(dp[i-1][j], dp[i][j]);
      }
      dp[i][j] += a[i][j];
    }
  }

  cout << dp[1][n-1] << endl;

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256