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

#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 INF 2e9
#define ll long long
#define MOD 1e9+7
#define MAX_V 20005

/* 辺を表す構造体 */
struct edge {int to, cap ,rev; };

/* グラフの隣接リスト表現 */
vector<edge> G[MAX_V];
/* DFSですべに調べたかのグラフ */
bool used[MAX_V];

/* fromからtoへ向かう容量capの辺をグラフに追加する */
void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size()-1});    
}


/* 増加パスをdfsで探す */
int dfs(int v, int t, int f){
    if(v==t) return f;
    used[v] = true;
    for(int i=0; i<G[v].size(); i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap>0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d>0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f==0) return flow;
        flow += f;
    }
}

int main(){
    int n, m;
    cin>>n>>m;
    for(int i=1; i<=n; i++){
        /* add_edge(0, i, 1); */
        add_edge(i, 0, 1);
    }
    for(int i=n+1; i<=n+m; i++){
        /* add_edge(i, n+m+1, 1); */
        add_edge(n+m+1, i, 1);
    }
    rep(i, n){
        int k;
        cin>>k;
        rep(j, k){
            int l;
            cin>>l;
            add_edge(n+l, i+1, 1);
        }
    }

    if(max_flow(m+n+1, 0) == m){
        cout<<"Bob"<<endl;
    }
    else{
        cout<<"Alice"<<endl;
    }

    return 0;
}


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

const int MAX_V=200;
const int INF=1001001001;
const int S=MAX_V-2,T=MAX_V-1;
struct edge{
    int to,cap,cost,rev;
    edge(int to,int cap,int cost,int rev)
        :to(to),cap(cap),cost(cost),rev(rev){}
};

vector<edge>G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void add_edge(int from,int to,int cap,int cost){
    G[from].push_back(edge(to,cap,cost,G[to].size()));
    G[to].push_back(edge(from,0,-cost,G[from].size()-1));
}

void init(){fill_n(G,MAX_V,vector<edge>());}
int min_cost_flow(int f){
    int res=0;
    while(f>0){
        fill_n(dist,MAX_V,INF);
        dist[S]=0;
        bool update=true;
        while(update){
            update=false;
            for(int v=0;v<MAX_V;v++){
                if(dist[v]==INF)continue;
                for(int i=0;i<G[v].size();i++){
                    edge &e=G[v][i];
                    if(e.cap>0&&dist[e.to]>dist[v]+e.cost){
                        dist[e.to]=dist[v]+e.cost;
                        prevv[e.to]=v;
                        preve[e.to]=i;
                        update=true;
                    }
                }
            }
        }

        if(dist[T]==INF)return -1;

        int d=f;
        for(int v=T;v!=S;v=prevv[v]){
            edge &e=G[prevv[v]][preve[v]];
            d=min(d,e.cap);
        }

        f-=d;
        res+=dist[T]*d;
        for(int v=T;v!=S;v=prevv[v]){
            edge &e=G[prevv[v]][preve[v]];
            e.cap-=d;
            G[v][e.rev].cap+=d;
        }
    }

    return res;
}

int N,M,B;
int ax[100],ay[100];
int bx[5],by[5],c[5],f[5];

void make(int bit,int D){
    init();
    for(int i=0;i<N;i++){
        add_edge(S,i,1,0);
        for(int j=0;j<M;j++){
            if((bit>>j&1)==0)continue;
            int d=abs(ax[i]-bx[j])+abs(ay[i]-by[j]);
            add_edge(i,N+j,1,max(0,d-D));
        }
    }

    for(int i=0;i<M;i++){
        if((bit>>i&1)==0)continue;
        add_edge(N+i,T,c[i],0);
    }
}

int Latteing(int bit){
    int ret=0;
    int cnt=0;
    for(int i=0;i<M;i++)if(bit>>i&1)ret+=f[i],cnt++;

    int lb=0,ub=100000;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        make(bit,mid);
        int val1=min_cost_flow(N)+mid*B*cnt;
        make(bit,mid-1);
        int val2=min_cost_flow(N)+(mid-1)*B*cnt;
        if(val1==-1||val2==-1)return INF;
        if(val1<val2)lb=mid;
        else ub=mid;
    }
    make(bit,lb);
    return ret+min_cost_flow(N)+lb*B*cnt;
}

int main(){
    while(cin>>N>>M>>B,N||M||B){
        for(int i=0;i<N;i++)cin>>ax[i]>>ay[i];
        for(int i=0;i<M;i++)cin>>bx[i]>>by[i]>>c[i]>>f[i];

        int mi=INF;
        for(int i=1;i<(1<<M);i++)mi=min(mi,Latteing(i));
        cout<<mi<<endl;
    }
    return 0;
}

Measured memory_bytes: 1240
#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>;

const double PI = acos(-1);

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

        int a, b, h, m;
        cin >> a >> b >> h >> m;
        double th = double(h*60+m)/720 * 2*PI;
        double tm = double(m)/60 * 2*PI;
        double xh = a*cos(th),
                                 yh = a*sin(th);
        double xm = b*cos(tm),
                                 ym = b*sin(tm);
        double dx = xh-xm,
                                 dy = yh-ym;
        double ans = sqrt(dx*dx + dy*dy);
        printf("%.10f\n", ans);

        return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a < b){
        if (b < c){
            cout << a << " " << b << " " << c << endl;
        }else if(a < c){
            cout << a << " " << c << " " << b << endl;
        }else{
            cout << c << " " << a << " " << b << endl;
        }
    }else{
        if (a < c){
            cout << b << " " << a << " " << c << endl;
        }else if(b < c){
            cout << b << " " << c << " " << a << endl;
        }else{
            cout << c << " " << b << " " << a << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W,N;
  cin >> H >> W >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  vector<vector<int>> ans(H,vector<int>(W));
  
  int h = 0;
  int w = 0;
  bool right = true;
  
  for(int i=0; i<N; i++){
    for(int j=0; j<vec.at(i); j++){
     if(right){
       ans.at(h).at(w) = i+1;
       w++;
       if(w == W){
         right = false;
         h++;
         w--;
       }
     }
     else{
       ans.at(h).at(w) = i+1;
       w--;
       if(w == -1){
         right = true;
         h++;
         w++;
       }
     }
    }
  }
  
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cout << ans.at(i).at(j);
      if(j != W-1){
        cout << " " ;
      }
    }
    cout << endl;
  }

}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    string a,s;cin>>a>>s;
    ll ans=0;
    REP(i, s.size()){
        if (s[i] != a[i]) ans++; 
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()

//アリとぶつかる=隣のアリに変身

int main() {
	ll N, L, T, W, W1, X, X1, X2 = 0, X3, V = 0, V1 = 0;
	cin >> N >> L >> T;
	ll a, b, c, d;
	a = T % L; b = T / L;
	int j;
	if (a * 2 >= L) {
		j = 1; //ぶつかってくるアリが余計に一周分あり
		c = a * 2 - L;
	}
	else {
		c = a * 2;
		j = 0;
	}
	vector<ll> fir(N);
	vector<ll> las(N);

	cin >> X1 >> W1;
	if (W1 == 1)
		X3 = (X1 + a) % L;
	else
		X3 = (X1 - a + L) % L;
	las[0] = X3;

	for (ll i = 1;i < N;i++) {
		cin >> X >> W;
		//向かってくる奴との距離の差がc未満か否か
		if (W != W1) {
			V++; //ここを忘れていた どうかこの修正でACしてくれ
			if (W == 1) { //自分は反時計回り
				d = L - (X - X1);
				if (d <= c) V1++;
			}
			else {
				d = X - X1;
				if (d < c) V1++;
			}
		}
		if (W == 1) las[i] = (X + a) % L;
		else las[i] = (X + L - a) % L;
	}

	sort(all(las));
	ll col = (b * 2 * V + V * j + V1) % N; //回アリとぶつかる
	if (W1 == 2) col = N - col;
	//最初X1にいたアリはcol個先のアリに変身している
	//つまり、点 X3 にcol番目のアリがいる

	auto it = lower_bound(all(las), X3);

	vector<ll> ans(N);
	for (ll i = 0;i < N;i++) {
		if (it == las.end()) it = las.begin();
		ans[(col + i) % N] = *it;
		it++;
	}
	for (ll i = 0;i < N;i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
	vector<int> v;
	int n;
	cin>>n;
	int count = 0;
	for(int i = 0;i < n; ++i)
	{
		int cur;
		cin>>cur;
		if(i < n - 2)
		{
			//printf("hi2\n");
			int cur2;
			cin>>cur2;
			v.push_back(cur);
			v.insert(v.begin(),cur2);
			++i;
		}
		else
		{
			//printf("hi1\n");
			v.push_back(cur);
			reverse(v.begin(),v.end());
		}
	}
	for(int i = 0;i < n; ++i)
	{
		cout<<v[i]<<" ";
	}
	cout<<endl;
	return 0;
}

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

#define readv(v) for(auto& pepito : v) cin >> pepito;
#define printv(v) for (int pepo = 0; pepo < v.size(); pepo++) cout << (pepo==0 ? "": " ") << v[pepo]; cout << endl;
#define queries(maria) int maria; cin >> maria; while (maria--) 
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//for (int i = 0; i < n; i++) 

using ll = long long int;
using vi = vector<ll>;
using vvi = vector<vi>;

int used[18], red[18], blue[18], perm[18], g[18][2];
int ans = 1e5, n;

bool valid(int i, int idx){
    if (g[i][abs((i-idx)%2)] < n-idx-1) return false;
    if (idx == 0) return true;

    int next;
    if ((i-idx)%2) next = blue[i];
    else next = red[i];

    int last;
    if ((idx - perm[idx-1])%2) last = red[perm[idx-1]];
    else last = blue[perm[idx-1]];

    return next >= last;
}

// k: inversiones que se llevan
void solve(int idx, int k){
    if (idx == n) {
        ans = min(ans, k);
    } else if (k < ans){
        int iv = 0;
        for (int i = 0; i < n; i++) {
            if (not used[i]) {
                if (valid(i, idx)) {
                    used[i] = true;
                    perm[idx] = i;
                    solve(idx+1, k + iv);
                    used[i] = false;
                }
                iv++;
            }
        }
    }
}

int main(){
    use_fast;

    cin >> n;
    for (int i = 0; i < n; i++) cin >> red[i];
    for (int i = 0; i < n; i++) {
        cin >> blue[i];
        used[i] = 0;
    }

    for (int i = 0; i < n; i++) {
        g[i][0] = g[i][1] = 0;
        for (int j = 0; j < n; j++) {
            if (i != j and (red[j] >= red[i] or blue[j] >= red[i]))
                g[i][0]++;
            if (i != j and (red[j] >= blue[i] or blue[j] >= blue[i]))
                g[i][1]++;
        }
    }

    solve(0, 0);
    cout << (ans == 1e5 ? -1 : ans) << "\n";
}


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

#define endl '\n'
#define ll long long

using namespace std;

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

	string t;
	cin >> t;

	if (t == "ABC") cout << "ARC";
	else cout << "ABC";

	return 0;
}

Measured memory_bytes: 3652
# coding: utf-8
# Your code here!

N,M = map(int,input().split())
A = [list(map(int,input().split())) for i in range(N)]
A.sort()
drink = 0
yen = 0
for i in A:
    if drink + i[1] >= M:
        yen += (M - drink) * i[0]
        print(yen)
        exit()
    else:
        yen += i[1] * i[0]
        drink += i[1]
    #print(yen,drink)
print(A)

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

int main()
{
	int a, b, c;
	int r = 0;
	int l = 0;
	while (scanf("%d,%d,%d", &a, &b, &c) == 3 ) {
		if (a*a + b*b == c*c) {//??´?§?????§???¢
			r++;
		}
		else if (a == b) {//?????????????§???¢
			l++;
		}
	}
	cout << r << endl;
	cout << l << endl;
	
    return 0;
}

Measured memory_bytes: 1208
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/priank/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    if(n%2)
    {
        cout<<0<<endl;
        return 0;
    }

    cnt=n/10;
    n/=10;
    while(n)
    {
        n/=5;
        cnt+=n;
    }
    cout<<cnt<<endl;
}   aryanc403();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;
//using namespace atcoder;

int main(){
    ll S;
    cin >> S; // a*1e9 - 1*b = S
    ll q = (S+ll(1e9)-1)/ll(1e9);
    ll r = S%ll(1e9);
    r = (ll(1e9) - r) % ll(1e9);
    vector<ll> a(6);
    a[0] = q;
    a[1] = r;
    a[2] = 1;
    a[3] = 1e9;
    a[4] = 0;
    a[5] = 0;
    PR(a,6);
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	long long int n, m;
	cin >> n >> m;
	if (n == 1 && m == 1) {
		cout << 1;
		return 0;
	}
	if (n == 1 || m == 1) {
		cout << n*m-2;
		return 0;
	}
	if (n == 2 || m == 2) {
		cout << 0;
		return 0;
	}
	cout << n * m - (n + n) - (m + m) + 4;

}

Measured memory_bytes: 256
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024
var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n, a, b := nextInt(), nextInt(), nextInt()
	s := next()

	passed, foreign := 0, 1

	for i := 0; i < n; i++ {
		if s[i] == 'a' && passed < a+b {
			passed++
			fmt.Println("Yes")
		} else if s[i] == 'b' && passed < a+b && foreign <= b {
			passed++
			foreign++
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
			continue
		}
	}
}

Measured memory_bytes: 2816
/*
  Author : lifehappy
*/
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>

#define mp make_pair
#define pb push_back
#define endl '\n'
#define mid (l + r >> 1)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define ls rt << 1
#define rs rt << 1 | 1

using namespace std;

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

const double pi = acos(-1.0);
const double eps = 1e-7;
const int inf = 0x3f3f3f3f;

inline ll read() {
    ll f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-')    f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        x = (x << 1) + (x << 3) + (c ^ 48);
        c = getchar();
    }
    return f * x;
}

int main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    ll n = read(), x = read();
    printf("%lld\n", 3 * (n - __gcd(n, x)));
    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <utility>
static int bsort(int *a, int n) {
    bool f = true;
    int c = 0;
    while (f) {
        f = false;
        for (int i = n - 1; i > 0; --i) {
            if (a[i] < a[i - 1]) {
                std::swap(a[i], a[i - 1]);
                f = true;
                ++c;
            }
        }
    }
    return c;
}
int main() {
    int n, a[100];
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
    }
    int c = bsort(a, n);
    for (int i = 0; i < n; ++i) {
        std::cout << ((i == 0) ? "" : " ") << a[i];
    }
    std::cout << std::endl << c << std::endl;
}



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

#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
typedef long long ll;
typedef int64_t i6;
//π M_PI
//deg = rad*180/M_PI

int main() {
    int n;
    string s;
    cin >> n >> s;
    bool flag = false;
    int ans = 0;
    if ( s.length()%2 == 0 ) {
        for (int i = 0; i < s.length()/2; ++i) {
            if ( s[i] == s[i+(s.length()/2)]) {
                ans++;
            }
        }

        if ( ans == (s.length()/2)) {
            flag = true;
        }
    }

    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右下左上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, -1 };
constexpr int dy[] = { 0, 1, 0, -1, 1, 1 };

namespace {
    template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
    template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

    // 標準出力
    void Out(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Out(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Out(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }
    template <typename T> void Out(const std::vector<std::vector<T>>& x, const char* sep = " ", const char* end = "\n") { for (auto v : x) Out(v, sep, end); }

    // 標準入力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };

    inp inp1;
}

int main() {

    int n, x;
    cin >> n >> x;
    vector<ll> a = inp(n);

    ll ans = 0;
    rep(i, n) if (a[i] > x) {
        ans += a[i] - x;
        a[i] = x;
    }
    rep(i, n - 1) {
        ll sum = a[i] + a[i + 1];
        if (sum > x) {
            ll add = sum - x;
            if (add > a[i + 1]) {
                a[i + 1] = 0;
            }
            a[i + 1] -= add;
            ans += add;
        }
    }

    Out(ans);

    return 0;
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	string s[n],X;
	int a[n];
	for(int i = 0;i < n;i++){
		cin >> s[i] >> a[i];
	}
	cin >> X;
	int vt,sum = 0;
	for(int i = 0;i < n;i++){
		if(s[i] == X){
			vt = i;
			break;
		}
	}
	for(int i = vt+1;i < n;i++){
		sum += a[i];
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back

ll n,m,l;

ll solve() {
	vector<vector<P>> adj(n);
	vector<vector<ll>> atk(n,vector<ll>(n,-1));
	REP(i,m) {
		ll a,b,d,e;
		cin>>a>>b>>d>>e;
		a--;
		b--;
		adj[a].pb(P(b,d));
		adj[b].pb(P(a,d));
		atk[a][b]=e;
		atk[b][a]=e;
	}
	vector<vector<ll>> cost(n,vector<ll>(l+1,INF*INF));
	cost[0][l]=0;
	priority_queue<pair<ll,P>,vector<pair<ll,P>>,greater<pair<ll,P>>> q;
	q.push(make_pair(cost[0][l],P(0,l)));
	while(!q.empty()) {
		ll c=q.top().first;
		ll p=q.top().second.first;
		ll mon=q.top().second.second;
		q.pop();
		if(cost[p][mon]!=c) continue;
		REP(i,(ll)adj[p].size()) {
			ll d=adj[p][i].second;
			ll np=adj[p][i].first;
			ll e=atk[p][np];
			if(cost[np][mon]>c+e) {
				cost[np][mon]=c+e;
				q.push(make_pair(cost[np][mon],P(np,mon)));
			}
			if(mon>=d&&cost[np][mon-d]>c) {
				cost[np][mon-d]=c;
				q.push(make_pair(cost[np][mon-d],P(np,mon-d)));
			}
		}
	}
	ll ret=INF*INF;
	REP(i,l+1) ret=min(ret,cost[n-1][i]);
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
		cin>>n>>m>>l;
		if(n==0) break;
		cout<<solve()<<endl;
	}
}




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

const int INF = 1000000000;

int N;
long h_list[100010];

long dp[100010];

int calc_min_cost(long *h_list, int *cost_list, int target_i, int K) {
    int min_cost = INF;
    int tmp;

    for (int j=1; j < K+1; ++j){
        tmp = abs(h_list[target_i] - h_list[target_i - j]) + cost_list[target_i-j];
        //cout << "cost_list[target_i-j]: " << cost_list[target_i-j] << endl;
        if (tmp < min_cost){
            min_cost = tmp;
        }
    }
    //cout << "min_cost" << min_cost << endl;
    return min_cost;
}

int main(){
    int N, K; cin >> N >> K;
    for (int i = 0; i<N; ++i) cin >> h_list[i];

    //for (int i = 0; i<N; ++i) cout << h_list[i] << ",";
    //cout << endl;

    
    int cost_list[N];
    int max_i;

    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    dp[0] = 0;
    cost_list[0] = 0;

    for (int i=1; i < N; i++){
        if (K < i){
            max_i = K;
        } else {
            max_i = i;
        }
        cost_list[i] = calc_min_cost(h_list, cost_list, i, max_i);
        //cout << "cost, " << cost_list[i] << endl;
    }
    cout << cost_list[N-1] << endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    if (n >= 1000)
        cout << "ABD" << endl;
    else
        cout << "ABC" << endl;
}

Measured memory_bytes: 256
// Postal Code

#include <iostream>

using namespace std;

int main(){
	int A, B;
	string S;
	cin >> A >> B >> S;

	for (int i = 0; i < A; ++i)
		if (S[i] < '0' || S[i] > '9'){
			cout << "No" << endl;
			return 0;
		}

	if (S[A] != '-'){
		cout << "No" << endl;
		return 0;
	}

	for (int i = A+1; i < A+B; ++i)
		if (S[i] < '0' || S[i] > '9'){
			cout << "No" << endl;
			return 0;
		}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
typedef long long ll;

struct Node{
  int key;
  Node *parent, *left, *right;
};

Node *root, *NIL;

Node * treeMinimum(Node *x){
  while(x->left != NIL) x = x->left;
  return x;
}

Node * find(Node *u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x){
  if(x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z){
  Node *y;
  Node *x;

  if(z->left == NIL || z->right == NIL) y = z;
  else{
    y = treeSuccessor(z);
    z->key = y->key;
  }

  if(y->left != NIL) x = y->left;
  else x = y->right;
  if(x != NIL) x->parent = y->parent;

  if(y->parent == NIL) root = x;
  else{
    if(y->parent->left == y) y->parent->left = x;
    else y->parent->right = x;
  }

  free(y);
}

void insert(int k){
  Node *y = NIL;
  Node *x = root;

  Node *z;
  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(k < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;
  if(y == NIL) root = z;
  else{
    if(k < y->key) y->left = z;
    else y->right = z;
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}

void preorder(Node *u){
  if(u == NIL) return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}

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

  rep(i, n){
    string com; cin >> com;
    if(com == "insert"){
      int x; cin >> x;
      insert(x);
    }
    else if(com == "find"){
      int x; cin >> x;
      Node *tmp = find(root, x);
      cout << (tmp != NIL ? "yes" : "no") << endl;
    }
    else if(com == "delete"){
      int x; cin >> x;
      treeDelete(find(root, x));
    }
    else if(com == "print"){
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }

  return 0;
}




Measured memory_bytes: 21796
#include<iostream>
#include<cmath>

int main()
{
    int a,b,c,d;
    
    std::cin >> a >> b >> c >> d;
    
    if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d))
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
    
    return 0;
}


Measured memory_bytes: 888
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    int h, w;
    scan(h, w);

    auto map = new char[][](h, w);
    iota(h).each!(i => map[i] = readln.chomp.to!(char[]));

    if (map[0][0] != '#') {
        writeln("Impossible");
        return;
    }

    int pi, pj;

    while (!(pi == h-1 && pj == w-1)) {
        int ni = pi + 1, nj = pj;
        if (ni < h && map[ni][nj] == '#') {
            map[pi][pj] = '.';
            pi = ni, pj = nj;
            continue;
        }
        ni = pi, nj = pj + 1;
        if (nj < w && map[ni][nj] == '#') {
            map[pi][pj] = '.';
            pi = ni, pj = nj;
            continue;
        }
        writeln("Impossible");
        return;
    }

    if (map[h-1][w-1] != '#') {
        writeln("Impossible");
        return;
    }

    map[h-1][w-1] = '.';

    debug {
        writefln("%(%-(%s %)\n%)", map);
    }

    foreach (i ; 0 .. h) {
        foreach (j ; 0 .. w) {
            if (map[i][j] == '#') {
                writeln("Impossible");
                return;
            }
        }
    }

    writeln("Possible");
    return;
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

i64 N;

bool isok(i64 h, i64 n, i64 w)
{
	if (w <= 0) return false;
	return 4 * h * n * w == N * (h * n + n * w + w * h);
}

int main()
{
	scanf("%lld", &N);

	for (int h = 1; h <= 3500; ++h) {
		for (int n = 1; n <= 3500; ++n) {
			double pohe = (4.0 / N - 1.0 / h - 1.0 / n);
			if (pohe > 0) {
				int w = 1 / pohe;
				if (isok(h, n, w)) {
					printf("%lld %lld %lld\n", h, n, w);
					return 0;
				}
				w += 1;
				if (isok(h, n, w)) {
					printf("%lld %lld %lld\n", h, n, w);
					return 0;
				}
				w -= 2;
				if (isok(h, n, w)) {
					printf("%lld %lld %lld\n", h, n, w);
					return 0;
				}
			}
		}
	}
	return 0;
}


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

using P = pair<int, int>;

struct edge {
    int to, weight;
};

using edges = vector<edge>;
using graph = vector<edges>;

constexpr int INF = 1e9;

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> T(N);
    for(int i=0; i<N; ++i) {
        cin >> T[i];
    }
    graph g(N);
    for(int i=0; i<M; ++i) {
        int a, b, d;
        cin >> a >> b >> d;
        a--; b--;
        g[a].push_back((edge){b, d});
        g[b].push_back((edge){a, d});
    }
    
    using state = tuple<int, int, int, int>;
    vector<vector<vector<int>>> d(N, vector<vector<int>>(3, vector<int>(X+1, INF)));
    d[0][0][X] = 0;
    priority_queue<state, vector<state>, greater<state>> que;
    que.push(make_tuple(0, 0, 0, X));
    while(!que.empty()) {
        int cd, v, t, x;
        tie(cd, v, t, x) = que.top();
        que.pop();
        if(d[v][t][x] < cd) {
            continue;
        }
        for(auto& e : g[v]) {
            int nx = (T[e.to] == 1 ? max(0, x - e.weight) : X);
            if(T[e.to] == 1 && d[e.to][t][nx] > d[v][t][x] + e.weight) {
                d[e.to][t][nx] = d[v][t][x] + e.weight;
                que.push(make_tuple(d[e.to][t][nx], e.to, t, nx));
            } else if(T[e.to] != 1 && (T[e.to] != t && x <= e.weight || T[e.to] == t)) {
                if(d[e.to][T[e.to]][nx] > d[v][t][x] + e.weight) {
                    d[e.to][T[e.to]][nx] = d[v][t][x] + e.weight;
                    que.push(make_tuple(d[e.to][T[e.to]][nx], e.to, T[e.to], nx));
                }
            }
        }
    }
    int res = INF;
    for(int i=0; i<3; ++i) {
        for(int j=0; j<X+1; ++j) {
            res = min(res, d[N-1][i][j]);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 28640
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  bool p[50001];
  memset(p, 1, sizeof(p));
  p[0] = p[1] = 0;
  for(int i = 0 ; i < 50001 ; i++){
    if(p[i]){
      for(int j = 2 * i ; j < 50001 ; j += i){
	p[j] = 0;
      }
    }
  }

  int n, sum;
  while(cin >> n, n){
    int cnt = 0;
    for(int i = 0 ; i <= n / 2 ; i++){
	if(p[i] == 1 && p[n - i] == 1) cnt++; 
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define N (140000)
#define LL long long
using namespace std;

struct Node
{
	LL a,b;
	bool operator < (const Node A) const
	{
		if (a!=A.a) return a<A.a;
		return b<A.b;
	}
}s;
struct Edge{int to,next,len;}edge[N<<1];
LL n,a[N],v[N],size[N],dis[N],l,r,ans,mid;
LL a1,b1,a2,b2,L,R,MID,ANS;
LL head[N],num_edge;
vector<Node>A[N],T;

void add(LL u,LL v,LL l)
{
	edge[++num_edge].to=v;
	edge[num_edge].next=head[u];
	edge[num_edge].len=l;
	head[u]=num_edge;
}

void Update(LL x,LL s0,LL s1)
{
	if (size[s0]>size[s1]) swap(s0,s1);
	LL len0=A[s0].size(), len1=A[s1].size();
	
	T.clear();
	for (int i=0; i<len0; ++i)
	{
		a1=A[s0][i].a; b1=A[s0][i].b;
		L=0; R=len1-1; ANS=-1;
		while (L<=R)
		{
			MID=(L+R)>>1;
			a2=A[s1][MID].a; b2=A[s1][MID].b;
			if (b1+a2+dis[s0]+dis[s1]<=mid) ANS=MID,L=MID+1;
			else R=MID-1;
			
		}
		if (ANS==-1) continue;
		a2=A[s1][ANS].a; b2=A[s1][ANS].b;
		s.a=a1+dis[s0]; s.b=b2+dis[s1]; T.push_back(s);
		s.a=b2+dis[s1]; s.b=a1+dis[s0]; T.push_back(s);
	}
	
	sort(T.begin(),T.end());
	LL maxn=1ll*N*N, len=T.size();
	for (int i=0; i<len; ++i)
		if (T[i].b<maxn)
			A[x].push_back(T[i]),maxn=T[i].b;
}

void Dfs(int x,int fa)
{
	size[x]=1;
	LL s0=0, s1=0;
	for (int i=head[x]; i; i=edge[i].next)
	{
		if (edge[i].to==fa) continue;
		if (!s0) s0=edge[i].to;
		else s1=edge[i].to;
		dis[edge[i].to]=edge[i].len;
		Dfs(edge[i].to,x);
		size[x]+=size[edge[i].to];
	}
	if (!s0) s.a=0, s.b=0,A[x].push_back(s);
	else Update(x,s0,s1);
}

bool check(LL x)
{
	for (int i=1; i<=n; ++i) A[i].clear();
	Dfs(1,0); return A[1].size()>0;
}

int main()
{
	scanf("%lld",&n);
	for (int i=1; i<=n-1; ++i)
	{
		scanf("%lld%lld",&a[i],&v[i]);
		add(i+1,a[i],v[i]); add(a[i],i+1,v[i]);
	}
	
	l=0, r=1ll*N*N, ans=-1;
	while (l<=r)
	{
		mid=(l+r)>>1;
		if (check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 36596
/*
    Written by Kabir Kanha Arora
    @kabirkanha
 */

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = scanner.nextInt();
            b[i] = scanner.nextInt();
        }
        int cnt = 0;
        boolean flag = false;
        for (int i = 0; i < n; ++i) {
            if (a[i] != b[i])
                cnt = 0;
            else {
                cnt++;
                if (cnt == 3) {
                    flag = true;
                    break;
                }
            }
        }
        if (flag)
            System.out.println("Yes");
        else
            System.out.println("No");
    }

}


Measured memory_bytes: 35984
Scanf.scanf "%d %d" (fun n m ->
    let h = Array.init n (fun _ -> Scanf.scanf " %d" (fun h -> h)) in
    let nei = Array.make n [] in
    for i = 1 to m do
        Scanf.scanf " %d %d" (fun a b ->
            let a = a - 1 in let b = b - 1 in
            nei.(a) <- b :: nei.(a);
            nei.(b) <- a :: nei.(b);
        )
    done;
    let rec loop i acc =
        if i = n then acc else
            let f = List.fold_left (fun acc v -> if h.(v) >= h.(i) then false else acc) true nei.(i) in
            loop (i + 1) (if f then acc + 1 else acc)
    in
    loop 0 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 12700
#include <iostream>
#include <list>
using namespace std;

#define sz(s) (int)(s.size())

int main () {
	clog << "Ready\n";
	int n;
	cin >> n;
	
	string s;
	cin >> s;
	
	list <char> lst;
	
	int h = 0;
	
	for (int i = 0; i < sz(s); ++ i) {
		if (lst.back() == s[i])
			continue;
		lst.emplace_back(s[i]);
	}
	cout << lst.size();
	return 0;
}

Measured memory_bytes: 3456
import sys
input=sys.stdin.readline

class CountTree():
  def __init__(self,n):
    self.n=n
    self.parents=[-1]*n
  
  def find(self,x):
    if self.parents[x]<0:
      return x
    else:
      self.parents[x]=self.find(self.parents[x])
      return self.parents[x]
    
  def union(self,x,y):
    x=self.find(x)
    y=self.find(y)
    if x==y:
      return
    if self.parents[x]>self.parents[y]:
      x,y=y,x
    self.parents[x]+=self.parents[y]
    self.parents[y]=x
    
  def roots(self):
    return [i for i,x in enumerate(self.parents) if x<0]
  def group_count(self):
    return len(self.roots())
  
def solve():
  n,m=(int(i) for i in input().split())
  ct=CountTree(n)
  for i in range(m):
    x,y,z=[int(i) for i in input().split()]
    ct.union(x-1,y-1)
  print(ct.group_count())
solve()
    

Measured memory_bytes: 65116
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<vector>
using namespace std;

const long mod = 1000000007;
const long indlim = 5368709119;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
long mybase(long N, long B) { if (N == 0) return 0; string S = ""; while (N != 0) { string M = to_string(N % B); N -= N % B; N /= B; S = M + S; }return stol(S); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	string res;
	long N; cin >> N;
	long A[100009]; for (int i = 0; i < N; i++) cin >> A[i];
	long odd = 0, even2 = 0, even4 = 0;

	for (int i = 0; i < N; i++) {
		if (A[i] % 4 == 0) even4++;
		if (A[i] % 4 == 1) odd++;
		if (A[i] % 4 == 2) even2++;
		if (A[i] % 4 == 3) odd++;
	}

	res = (odd + min(even2, (long)1) <= even4 + 1) ? "Yes" : "No";

	cout << res << endl;
}

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

int main(void){
	int N,K;
	vector<int> v(26);
	cin>>N>>K;
	for(int i=0; i<N; ++i){
		string tmp;
		cin>>tmp;
		v[tmp[0]-'A']++;
	}
	//multiset<int> s(v.begin(),v.end());
	int result=0;
	sort(v.begin(),v.end());
	while(true){
		if(v.size()<K){
			break;
		}
		//multiset<int>::iterator it=s.end();
		for(int i=0; i<K; ++i){
			v[v.size()-i-1]--;
		}
		result++;
		sort(v.begin(),v.end());
		if(v[0]<0){
			result--;
			break;
		}
	}
	cout<<result<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan =  new Scanner(System.in);
		
		int n = scan.nextInt();
		if(n >= 600) {
			if(n >= 800) {
				if(n >= 1000) {
					if(n >= 1200) {
						if(n >= 1400) {
							if(n >= 1600) {
								if(n >= 1800) {
									System.out.println("1");
								}else {
									System.out.println("2");
								}
							}else {
								System.out.println("3");
							}
						}else {
							System.out.println("4");
						}
					}else {
						System.out.println("5");
					}
				}else {
					System.out.println("6");
				}
			}else {
				System.out.println("7");
			}
		}else {
			System.out.println("8");
		}

	}

}


Measured memory_bytes: 35820
n = int(input())
A = list(map(int,input().split()))
print(' '.join(map(str, A)))
'''
for i in range(n):
    print(A[i], end=' ')
print('')
'''
for i in range(1, n):
    v = A[i]
    j = i - 1
    while j >=0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    '''
    for i in range(n):
        print(A[i], end=' ')
    print('')
    '''
    print(' '.join(map(str, A)))



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

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

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

using namespace std;

int main() {
  string s;
  cin >> s;
  vector<char> v;
  rep(i, s.length()) {
    char c = s[i];
    if (c == '0') v.push_back('0');
    if (c == '1') v.push_back('1');
    if (c == 'B' && v.size() > 0) v.pop_back();
  }

  rep(i, v.size()) {
    cout << v[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#coding: utf-8
# n,k = int(input())
# list = list(map(int,input().split()))
# strings = list(map(str, [input() for i in range(amount)]))

n,k,m = map(int,input().split())
# n,k,m = int(input())
a = n + k + m

if a >= 22:
    l = 'bust'
else:
    l = 'win'

print(l)


Measured memory_bytes: 2940
import math

c = list(map(float, input().split()))
a = c[0]
b = c[1]
x = c[2]
if x <= a * a * b / 2.0:
  print(90.0 - math.atan((x / a * 2.0 / b) / b) * 180.0 / math.pi)
else:
  print(math.atan(((a * a * b - x) / a * 2.0 / a) / a) * 180.0 / math.pi)

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

using namespace std;

int main()
{
	for(int n;cin>>n;){
		vector<string> a(n);
		for(int i=0;i<n;i++) cin>>a[i];
		vector<int> b;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++){
				if(i==j) continue;
				b.push_back(atoi((a[i]+a[j]).c_str()));
				if(b.size()>3){
					sort(begin(b),end(b));
					b.pop_back();
				}
			}
		cout<<b.back()<<endl;
	}
	
	return 0;
}

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

int main() {
  int n, t, a;
  int h[1000];

  cin >> n >> t >> a;
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }


  int mini_idx = std::numeric_limits<int>::max();
  double mini_diff = std::numeric_limits<double>::max();
  for (int i = 0; i < n; ++i) {
    if (mini_diff > abs(a - (t - h[i] * 0.006))) {
      mini_diff = abs(a - (t - h[i] * 0.006));
      mini_idx = i + 1;
    }
  }

  cout << mini_idx << endl;
}


Measured memory_bytes: 1016
use std::io;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();

    stdin.read_line(&mut buf).unwrap();

    let ab: Vec<usize> = buf.split_whitespace().map(|n| n.parse().unwrap()).collect();

    let n = ab[0] + ab[1];

    if n >= 10 {
        println!("error");
    } else {
        println!("{}", n);
    }
}

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

using namespace std;

using int64 = long long;

namespace FastFourierTransform
{
  using C = complex< double >;

  void DiscreteFourierTransform(vector< C > &F, bool rev)
  {
    const int N = (int) F.size();
    const double PI = (rev ? -1 : 1) * acos(-1);
    for(int i = 0, j = 1; j + 1 < N; j++) {
      for(int k = N >> 1; k > (i ^= k); k >>= 1);
      if(i > j) swap(F[i], F[j]);
    }

    C w, s, t;
    for(int i = 1; i < N; i <<= 1) {
      for(int k = 0; k < i; k++) {
        w = std::polar(1.0, 2 * PI / (i * 2) * k);
        for(int j = 0; j < N; j += i * 2) {
          s = F[j + k];
          t = C(F[j + k + i].real() * w.real() - F[j + k + i].imag() * w.imag(), F[j + k + i].real() * w.imag() + F[j + k + i].imag() * w.real());
          F[j + k] = s + t, F[j + k + i] = s - t;
        }
      }
    }
    if(rev) for(int i = 0; i < N; i++) F[i] /= N;
  }

  vector< int64 > Multiply(const vector< int > &A, const vector< int > &B)
  {
    int sz = 1;
    while(sz <= A.size() + B.size()) sz <<= 1;
    vector< C > F(sz), G(sz);
    for(int i = 0; i < A.size(); i++) F[i] = A[i];
    for(int i = 0; i < B.size(); i++) G[i] = B[i];
    DiscreteFourierTransform(F, false);
    DiscreteFourierTransform(G, false);
    for(int i = 0; i < sz; i++) F[i] *= G[i];
    DiscreteFourierTransform(F, true);
    vector< int64 > X(A.size() + B.size() - 1);
    for(int i = 0; i < A.size() + B.size() - 1; i++) X[i] = F[i].real() + 0.5;
    return (X);
  }
};

int main()
{
  int N, M, Q, A[40001], B[40001], C[100000];
  vector< int > F(200001), G(200001);

  scanf("%d %d %d", &N, &M, &Q);
  for(int i = 0; i < N; i++) scanf("%d", &A[i + 1]), A[i + 1] += A[i];
  for(int i = 0; i < M; i++) scanf("%d", &B[i + 1]), B[i + 1] += B[i];
  for(int i = 0; i < Q; i++) scanf("%d", &C[i]);

  for(int i = 1; i <= N; i++) {
    for(int j = 0; j < i; j++) {
      ++F[A[i] - A[j]];
    }
  }
  for(int i = 1; i <= M; i++) {
    for(int j = 0; j < i; j++) {
      ++G[B[i] - B[j]];
    }
  }
  reverse(begin(G), end(G));
  auto X = FastFourierTransform::Multiply(F, G);
  for(int i = 0; i < Q; i++) {
    if(C[i] == 0) printf("%lld\n", X[200000]);
    else printf("%lld\n", X[200000 - C[i]] + X[200000 + C[i]]);
  }
}

Measured memory_bytes: 25088
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define pbb pop_back
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
const int m=1e9+7;
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    ll  p=max(a,b);
    ll q=min(a,b);
    if(p-q>=2){
        cout<<p+p-1<<endl;
    }else
    cout<<p+q<<endl;
}
  
   

Measured memory_bytes: 256
;;; body

(defun calc-digit (int)
  (if (zerop int)
      0
      (1+ (calc-digit (floor int 10)))))

(defun int->lst (int)
  (if (zerop int)
      nil
      (cons (rem int 10) (int->lst (floor int 10)))))

(defun solve (n k ng-list)
  (loop with cand = n do
       (when (every (lambda (int)
                      (not (find int ng-list)))
                    (int->lst cand))
         (return cand))
       (incf cand)))



(defun main ()
  (let ((n (read))
        (k (read)))
    (let ((ng-list (loop repeat k collect (read))))
      (princ (solve n k ng-list))
      (fresh-line))))

#-swank (main)


Measured memory_bytes: 30676
#include<stdio.h>

int main()
{
	int n, ans=1, i;
	while(scanf("%d", &n)!=EOF)
	{
		for(i=1;i<=n;i++)
		{
			ans += i;
		}
		printf("%d\n", ans);
		ans= 1;
	}
	return 0;
}

Measured memory_bytes: 596