akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
int mark=0;
void perm(long int a[],int k,int n){    //Time limit
    int i,c=0;
    long int temp;
    if(k==n-1){
        for(i=1;i<n;i++){
            if(a[i-1]*a[i]%4==0)
                c++;
        }
        if(c==n-1)
            mark=1;
    }else{
    for(i=k;i<n;i++){
      temp=a[k];a[k]=a[i];a[i]=temp;
      perm(a,k+1,n);
      temp=a[k];a[k]=a[i];a[i]=temp;
    }
    }
}

int main()
{
    long int n,n4=0,n2=0;
    scanf("%ld",&n);
    long int a[n];
    int i=0;
    for(i=0;i<n;i++){
        scanf("%ld",&a[i]);
    }
    /*perm(a,0,n);
    if(mark)
        printf("Yes");
    else
        printf("No");*/
    for(i=0;i<n;i++){
        if(a[i]%4==0)
            n4++;
        else if(a[i]%2==0)
            n2++;
    }
    if(2*n4+n2>=n||2*n4+1==n)
        printf("Yes");
    else
        printf("No");
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  string a, b;
  cin >> a >> b;

  string ans;
  if (a.size() > b.size()) {
    ans = "GREATER";
  } else if (a.size() < b.size()) {
    ans = "LESS";
  } else {
    ans = "EQUAL";
    for (unsigned int i = 0; i < a.size(); ++i) {
      if (a[i] > b[i]) {
        ans = "GREATER";
        break;
      } else if (a[i] < b[i]) {
        ans = "LESS";
        break;
      }
    }
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	string A[3];
	FOR(i, 0, 3) cin >> A[i];
	
	string ans;
	int dif = 'A' - 'a';
	FOR(i, 0, 3) {
		ans += (A[i][0] + dif);
	}

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


Measured memory_bytes: 256
#include<stdio.h>
 
int main (void){
 
int N;
int X;
int L[100];
int count = 0;
int current_d=0;
scanf("%d%d",&N,&X);
for(int i=0;i<N;i++){
    scanf("%d",&L[i]);
}
 
/* 
for(int i=0;i<N;i++){
    printf("%d",L[i]);
}
*/
 
//for(int i=0; i<(N+1);i++ ){
    
        int i = 0;
    while(current_d<=X){
    current_d = current_d + L[i];
    //printf("%d\n",current_d);
    i++; 
    count++;
    }
    
    printf("%d",count);
 
}
 

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

int main()
{
    string s;
    cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7')
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3592
#include <iostream>
#include <math.h>

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point{
public:
	double x, y;
	Point(double _x = 0, double _y = 0) :x(_x), y(_y){};

	Point operator+(const Point &p){ return Point(x + p.x, y + p.y); }
	Point operator-(const Point &p){ return Point(x - p.x, y - p.y); }
	Point operator*(const Point &p){ return Point(x * p.x, y * p.y); }
	Point operator*(double k){ return Point(x * k, y * k); }
	Point operator/(const Point &p){ return Point(x / p.x, y / p.y); }

	double norm() { return x*x + y*y; }
	double abs() { return sqrt(norm()); }

	bool operator<(const Point &p) const{
		return (x != p.x) ? x < (p.x) : (y < p.y);
	}

	bool operator==(const Point &p){
		return equals(x, p.x) && equals(y, p.y);
	}
};

typedef Point Vector;
struct Segment{
	Point p1, p2;
};

double dot(Vector a, Vector b){
	double res = a.x*b.x + a.y*b.y;
	return res;
}

double cross(Vector a, Vector b){
	double res = a.x*b.y - a.y*b.x;
	return res;
}

bool isOrthogonal(Vector a, Vector b){
	return equals(dot(a, b), 0.0);
}

bool isParallel(Vector a, Vector b){
	return equals(cross(a, b), 0.0);
}

Point project(Segment s, Point p){
	Vector base = s.p2 - s.p1;
	Vector v = p - s.p1;
	double l = dot(v, base) / base.norm();
	return s.p1 + base * l;
}

int main(){
	Segment s;
	cin >> s.p1.x >> s.p1.y >> s.p2.x >> s.p2.y;
	int n;
	cin >> n;
	cout.precision(20);
	for (int i = 0; i < n; ++i){
		Point pp;
		cin >> pp.x >> pp.y;
		Point res = project(s, pp);
		cout << res.x << " " << res.y << endl;
	}
	return 0;
}

Measured memory_bytes: 3284
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#ifdef TEST
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock
#endif
#define ins insert
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define ef emplace_front
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef double db;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int H, W, d, r, c, sr, sc, er, ec, dist[1005][1005], dr[] = {-1, 0, 0, 1}, dc[] = {0, -1, 1, 0};
char F[1005][1005];
deque<iii> D;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> H >> W >> sr >> sc >> er >> ec;
	for (int i = 1; i <= H; i++)
		for (int j = 1; j <= W; j++) cin >> F[i][j], dist[i][j] = 1e9;
	dist[sr][sc] = 0;
	D.eb(0, sr, sc);
	while (!D.empty()) {
		tie(d, r, c) = D.front();
		D.ppf();
		if (dist[r][c] < d) continue;
		if (r == er && c == ec) return cout << d << '\n', 0;
		for (int k = 0; k < 4; k++) {
			int nr = r + dr[k], nc = c + dc[k];
			if (1 <= nr && nr <= H && 1 <= nc && nc <= W && F[nr][nc] != '#' && dist[nr][nc] > d)
				dist[nr][nc] = d, D.ef(d, nr, nc);
		}
		for (int i = max(1ll, r - 2); i <= min(H, r + 2); i++)
			for (int j = max(1ll, c - 2); j <= min(W, c + 2); j++)
				if (F[i][j] != '#' && dist[i][j] > d) dist[i][j] = d + 1, D.eb(d + 1, i, j);
	}
	cout << "-1\n";
}


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

using namespace std;
const int N = 1e5 + 5;
int head[N], nxt[N * 2], to[N * 2], col[N * 2], dist[N * 2], ne = 0;
int par[N][20];
int lev[N];

struct node {
    pair<int, int> p;
    node *l, *r;

    node() : p({0, 0}), l(this), r(this) {}

    node(pair<int, int> p, node *l, node *r) : p(p), l(l), r(r) {}
};

node *empty = new node();
node *roots[N];

node *update(node *cur, int s, int e, int idx, int v) {
    if (idx < s || idx > e) return cur;
    if (s == e) {
        pair<int, int> p = cur->p;
        p.first++;
        p.second += v;
        return new node(p, empty, empty);
    }
    int mid = s + (e - s) / 2;
    node *lf = update(cur->l, s, mid, idx, v);
    node *rt = update(cur->r, mid + 1, e, idx, v);
    pair<int, int> p = cur->p;
    p.first++;
    p.second += v;
    return new node(p, lf, rt);
}

pair<int, int> query(node *cur, int s, int e, int idx) {
    if (cur == empty) return {0, 0};
    if (s == e) return cur->p;
    int mid = s + (e - s) / 2;
    if (idx <= mid) return query(cur->l, s, mid, idx);
    return query(cur->r, mid + 1, e, idx);
}


void addedge(int a, int b, int c, int d) {
    nxt[ne] = head[a];
    to[ne] = b;
    col[ne] = c;
    dist[ne] = d;
    head[a] = ne++;
}

void addbiedge(int a, int b, int c, int d) {
    addedge(a, b, c, d);
    addedge(b, a, c, d);
}

void dfs(int idx, int p, int l) {
    lev[idx] = l;
    par[idx][0] = p;
    roots[idx] = roots[p];
    for (int i = 1; i < 20; ++i) par[idx][i] = par[par[idx][i - 1]][i - 1];

    for (int i = head[idx]; ~i; i = nxt[i]) {
        int v = to[i];
        if (v == p) {
            roots[idx] = update(roots[idx], 1, 100000, col[i], dist[i]);
            break;
        }
    }
    for (int i = head[idx]; ~i; i = nxt[i]) {
        int v = to[i];
        if (v == p) {
            continue;
        }
        dfs(v, idx, l + 1);
    }
   // cout << idx << " " << roots[idx]->p.second << endl;
}

int lca(int a, int b) {
    if (lev[a] < lev[b]) swap(a, b);
    int d = lev[a] - lev[b];
    for (int i = 0; d; ++i, d /= 2) {
        if (d & 1) a = par[a][i];
    }
    if (a == b) return a;

    for (int i = 19; ~i; --i) {
        if (par[a][i] != par[b][i]) {
            a = par[a][i];
            b = par[b][i];
        }
    }
    return par[a][0];
}

int main() {
   // freopen("in.txt", "rt", stdin);
    memset(head, -1, sizeof head);
    roots[0] = empty;
    int n, q;
    scanf("%d %d", &n, &q);
    int a, b, c, d;
    for (int i = 1; i < n; ++i) {
        scanf("%d %d %d %d", &a, &b, &c, &d);
        addbiedge(a, b, c, d);
    }
    dfs(1, 0, 1);
    while (q--) {
        scanf("%d %d %d %d", &c, &d, &a, &b);
        int l = lca(a, b);
        int ans = roots[a]->p.second + roots[b]->p.second - 2 * roots[l]->p.second;
        pair<int, int> pa = query(roots[a], 1, 100000, c);
        pair<int, int> pb = query(roots[b], 1, 100000, c);
        pair<int, int> pl = query(roots[l], 1, 100000, c);
        ans -= (pa.second + pb.second - 2 * pl.second);
        ans += (pa.first + pb.first - 2 * pl.first) * d;
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 72704
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dp[1005][1005];
signed main() {
    int H,W;
    cin >> H >> W;
    vector<string>a(H);
    for(int i = 0; i < H; i++) {
        cin >> a[i];
    }
    dp[0][0] = 1;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(dp[i][j]) {
                if(i < H-1) {
                    if(a[i+1][j] == '.') {
                        dp[i+1][j] += dp[i][j];
                        dp[i+1][j]%=INF;
                    }
                }
                if(j < W-1) {
                    if(a[i][j+1] == '.') {
                        dp[i][j+1] += dp[i][j];
                        dp[i][j+1] %= INF;
                    }
                }
            }
        }
    }
    cout << dp[H-1][W-1]%INF << endl;
}


Measured memory_bytes: 13348
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 a, b, c;
  cin >> a >> b >> c;
  if (a + b + 2 * sqrtl(a * b) < c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset> 
using namespace std;
typedef long long ll;
struct node{
	ll k,v;
};
bool cmp(node a1,node a2)
{
	return a1.k<a2.k;
}
ll n;
int main(void)
{
	ll t;
	scanf("%lld",&t);
	while(t--)
	{
		scanf("%lld",&n);
		ll ans=0;
		vector<node> l,r;
		for(ll i=0;i<n;i++)
		{
			ll k,l1,r1;
			scanf("%lld%lld%lld",&k,&l1,&r1);
			if(l1==r1||k==n) ans+=l1;
			else if(l1>r1)
			{
				ans+=r1;
				l.push_back((node){k,l1-r1});
			}
			else
			{
				ans+=l1;
				r.push_back((node){n-k,r1-l1});
			}
		}
		sort(l.begin(),l.end(),cmp);
		sort(r.begin(),r.end(),cmp);
		priority_queue<ll , vector<ll>, greater<ll> > pq;
		for(ll i=0;i<l.size();i++)
		{
			if(l[i].k>pq.size())
			{
				pq.push(l[i].v);
			}
			else
			{
				if(pq.top()<l[i].v)
				{
					pq.pop();
					pq.push(l[i].v);
				}
			}
		}
		while(pq.size()) ans+=pq.top(),pq.pop();
		for(ll i=0;i<r.size();i++)
		{
			if(r[i].k>pq.size())
			{
				pq.push(r[i].v);
			}
			else
			{
				if(pq.top()<r[i].v)
				{
					pq.pop();
					pq.push(r[i].v);
				}
			}
		}
		while(pq.size()) ans+=pq.top(),pq.pop();
		printf("%lld\n",ans);
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    rep(i,N)cin>>A[i];

    vector<int> Color(9,0);

    rep(i,N){
        if(A[i]<400)Color[0]=1;
        else if(A[i]<800)Color[1]=1;
        else if(A[i]<1200)Color[2]=1;
        else if(A[i]<1600)Color[3]=1;
        else if(A[i]<2000)Color[4]=1;
        else if(A[i]<2400)Color[5]=1;
        else if(A[i]<2800)Color[6]=1;
        else if(A[i]<3200)Color[7]=1;
        else Color[8]++;
    }
    int MAX=0,MIN=0;

    rep(i,8)MIN+=Color[i];
    MAX=MIN+Color[8];
    if(MIN==0&&Color[8])MIN=1;

    cout<<MIN<<" "<<MAX<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
N = int(input())
S = input()

count = 0
for i in range(N):
    a = S[0:i]
    b = S[i:]
    cache = 0
    obj = []
    for j in range(len(a)):
        if a[j] not in obj:
            if a[j] in b:
                obj.append(a[j])
                cache += 1

    if cache > count:
        count = cache

print(count)

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

int main() {
  double w;
  while (cin >> w) {
    if (w <= 48.00) {
      cout << "light fly" << endl;
    } else if (w <= 51.00) {
      cout << "fly" << endl;
    } else if (w <= 54.00) {
      cout << "bantam" << endl;
    } else if (w <= 57.00) {
      cout << "feather" << endl;
    } else if (w <= 60.00) {
      cout << "light" << endl;
    } else if (w <= 64.00) {
      cout << "light welter" << endl;
    } else if (w <= 69.00) {
      cout << "welter" << endl;
    } else if (w <= 75.00) {
      cout << "light middle" << endl;
    } else if (w <= 81.00) {
      cout << "middle" << endl;
    } else if (w <= 91.00) {
      cout << "light heavy" << endl;
    } else {
      cout << "heavy" << endl;
    }
  }
}



Measured memory_bytes: 3224
n=gets.to_i
r=(1..n-1).map{gets.split.map(&:to_i)}
state=[0]*n
state[0]=1
state[-1]=2
root=(r+r.map{|a,b|[b,a]}).group_by{|a,b|a}.sort_by{|k,v|k}.map{|k,v|v.map{|a,b|b-1}}
fen=root[0].select{|i|state[i]==0}
snu=root[-1].select{|i|state[i]==0}
while fen[0]||snu[0]
  fen=fen.select{|i|state[i]==0}.flat_map{|i|state[i]=1;root[i]}.select{|i|state[i]==0}
  snu=snu.select{|i|state[i]==0}.flat_map{|i|state[i]=2;root[i]}.select{|i|state[i]==0}
end
puts state.count(1)>n/2?"Fennec":"Snuke"

Measured memory_bytes: 40464
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9


const int MAX_H = 51;
const int MAX_W = 51;
int d[MAX_W][MAX_H];    

char maze[MAX_W][MAX_H];

int H, W;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int num_of_w = 0;

bool isPossible(int x, int y) {
	if (x < 0 || W <= x || y < 0 || H <= y) return false;
	else {
		if (maze[x][y] == '.') return true;
		else return false;
	}
}

void input() {
	cin >> H >> W;
	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W; x++) {
			cin >> maze[x][y];
			if (maze[x][y] == '.') num_of_w++;
		}
	}
}


void bfs() {
	queue<P> q;

	// すべての点をINFで初期化
	for (int i = 0; i < W; i++) {
		for (int j = 0; j < H; j++) d[i][j] = INF;
	}

	// スタート地点をqueueに入れる
	q.push(P(0, 0));
	d[0][0] = 1;

	//キューが空になるまで続ける
	while (!q.empty()) {

		// キューの先頭を取り出す
		P p = q.front(); q.pop();
		// 取り出してきた状態がゴールなら終わり
		if (p.first == W-1 && p.second == H-1) break;

		// 移動4方向をループ
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];

			// 移動可能で未探索なら
			if (isPossible(nx,ny) && d[nx][ny] == INF) {
				// 移動可能ならキューに入れる
				q.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
}

int main() {
	input();
	bfs();

	if (d[W - 1][H - 1] != INF) cout << num_of_w - d[W - 1][H - 1] << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]", D: "List[int]"):

    conns = [[] for _ in range(N)]
    for i in range(M):
        conns[A[i] - 1].append(B[i] - 1)
        conns[B[i] - 1].append(A[i] - 1)

    par = list(range(N))
    counts = [0] * N
    ret = [0] * N

    def find_root(x):
        if par[x] != x:
            par[x] = find_root(par[x])
        return par[x]

    def is_same_group(a, b):
        a_root = find_root(a)
        b_root = find_root(b)
        return par[a_root] == b_root

    def union(a, b):
        a_root = find_root(a)
        b_root = find_root(b)
        par[a_root] = b_root
        return

    for i in range(M):
        a, b = A[i] - 1, B[i] - 1
        union(a, b)

    for i in range(N):
        root = find_root(i)
        counts[root] += 1

    for i in range(N):
        root = find_root(i)
        ret[i] = counts[root] - len(conns[i]) - 1

    for i in range(K):
        a, b = C[i] - 1, D[i] - 1
        if is_same_group(a, b):
            ret[a] -= 1
            ret[b] -= 1

    print(' '.join([str(r) for r in ret]))
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    C = [int()] * (K)  # type: "List[int]"
    D = [int()] * (K)  # type: "List[int]"
    for i in range(K):
        C[i] = int(next(tokens))
        D[i] = int(next(tokens))
    solve(N, M, K, A, B, C, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 83432
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<cassert>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<bitset>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const int INF = (1 << 30);
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

bool check(int n, vector<int> a, int x) {
    map<int, int> mp;
    mp[a[1]-1] = 0;

    // cerr << "x: " << x << endl;
    for(int i=1;i<=n;++i) {
        // cerr << i << endl;
        vector<int> to_erase;
        if(a[i-1] < a[i]) {
            map<int, int> mp2;
            for(auto itr=mp.begin();itr!=mp.end();++itr) {
                if(itr->first < a[i]) {
                    mp2[itr->first] = itr->second;
                } else {
                    break;
                }
            }
            swap(mp, mp2);
        } else if(a[i-1] == a[i]) {
            bool added = false;
            for(int j=a[i]-1;j>=0;--j) {
                if(mp.find(j) == mp.end()) {
                    if(x == 1) return false;
                    mp[j] = 1;
                    added = true;
                    break;
                } else if(mp[j] != x-1) {
                    ++mp[j];
                    added = true;
                    break;
                } else {
                    to_erase.push_back(j);
                }
            }
            if(!added) return false;
        } else {
            bool added = false;
            for(int j=a[i]-1;j>=0;--j) {
                if(mp.find(j) == mp.end()) {
                    if(x == 1) return false;
                    mp[j] = 1;
                    added = true;
                    break;
                } else if(mp[j] != x-1) {
                    ++mp[j];
                    added = true;
                    break;
                } else {
                    to_erase.push_back(j);
                }
            }
            if(!added) return false;

            for(auto itr=mp.begin();itr!=mp.end();++itr) {
                if(itr->first >= a[i]) {
                    to_erase.push_back(itr->first);
                }
            }
        }

        for(int e: to_erase) mp.erase(e);

        // for(auto itr=mp.begin();itr!=mp.end();++itr) {
        //     cerr << itr->first << " " << itr->second << endl;
        // }
    }

    return true;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1, 0);
    for(int i=1;i<=n;++i) cin >> a[i];
    
    int ng = 0, ok = 300000;
    while(ok-ng > 1) {
        // cerr << endl << ng << " " << ok << endl;
        int mid = (ok + ng) / 2;
        if(check(n, a, mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << endl;
}


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

int main() {
vector<int> x(5);
int im;
rep(i,5){
cin >> x.at(i);
}

rep(i,5){
if(x.at(i)==0){im=i+1;break;};
}
cout<<im<<endl;
}


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

int n;
ll a[111];

int main(){
	while(scanf("%d", &n)!=EOF){
		for(int i=0; i<n; i++){
			scanf("%lld", &a[i]);
		}
		ll min_=1000000000;
		for(int base=-100; base<=100; base++){
			ll sum=0;
			for(int i=0; i<n; i++){
				sum += (a[i]-base)*(a[i]-base);
			}
			min_ = min(sum, min_);
		}
		printf("%lld\n", min_);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max

int main ()  {

    string s;cin>>s;

    int ans=0;
    rep(i,s.size()) {
        int cnt=0,j=i;
        while(1) {
            if (s[j]=='A'||s[j]=='C'||s[j]=='G'||s[j]=='T') {
                cnt++;
                j++;
                if (j>s.size()-1) break;
            }
            else {
                break;
            }
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defmacro aif (expr then else)
  `(let ((it ,expr))
     (if it ,then ,else)))

(defmacro awhen (expr &rest then)
  `(aif ,expr (progn ,@then) nil))

(defun comulative (function list &key base)
  (if base
      (comulative function (cons base list))
      (do ((lst (cdr list) (cdr lst))
           (acc (list (car list))))
          ((null lst) (reverse acc))
        (push (funcall function (car acc) (car lst)) acc))))

(defun binary-search (function left right
                      &optional
                        (eps 1)
                        (average-function (lambda (x y) (ash (+ x y) -1))))
  (if (<= (abs (- left right)) eps)
      right
      (let ((mid (funcall average-function left right)))
        (if (funcall function mid)
            (binary-search function left mid eps average-function)
            (binary-search function mid right eps average-function)))))

(defun arithmetic-mean (&rest body)
  (/ (apply #'+ body) (length body)))

(defvar +MOD+ (+ (expt 10 9) 7))

(defun mapa-b (fn a b &optional (step 1))
  (do ((i a (+ i step))
       (result nil))
      ((> i b) (nreverse result))
    (push (funcall fn i) result)))

(defun map0-n (fn n)
  (mapa-b fn 0 n))

(defun map1-n (fn n)
  (mapa-b fn 1 n))

(defun read-string (&optional (stream *standard-input*))
  (labels ((is-empty (x)
             (or (char= x #\space) (char= x #\newline))))
    (loop for char = (read-char stream)
          with result
          when (is-empty char)
            do (return (concatenate 'string (nreverse result)))
          do (push char result))))

(defun main (a b)
  (reduce #'max
          (mapcar (lambda (x) (- (count x a :test #'equal)
                                 (count x b :test #'equal)))
                  a)
          :initial-value 0))

(princ (main (collect-times (read) (read-string)) (collect-times (read) (read-string))))


Measured memory_bytes: 13372
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

int n, q, a[100005];

void update(int x){
	if(x > 1) a[x-1] = 1;
	if(x < n) a[x+1] = 1;
}

int main(){
	scanf("%d %d",&n,&q);
	a[1] = 1; update(1);
	int cp = 1;
	while(q--){
		int aa, bb;
		scanf("%d %d",&aa,&bb);
		if(cp == aa) cp = bb;
		else if(cp == bb) cp = aa;
		swap(a[aa], a[bb]);
		update(cp);
	}
	cout << count(a + 1, a + n + 1, 1) << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define LL long long
#define MOD 1000000007
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

using namespace std;

int main()
{
    fastio;
    // ifstream f("f.txt");
    // ofstream g("out.txt");
    int n;
    cin >> n;
    LL a[n], ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    for (int i = 1; i < n; i++)
    {
        if (a[i - 1] > a[i])
        {
            ans += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }
    }
    cout << ans << "\n";
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;
const int INF = 1e9;
int a, b, c;

int main() {
  cin >> a >> b >> c;
  int ain = 0;
  ain = min(a, b + c);
  int ans = b + c - ain;
  cout << ans << endl;
  return 0;
}


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


int main() {
/*    int K;
    long long X;
    cin >> K >> X;


    int coins = 500;

    if(coins * K >= X) {
    	cout << "yes" << "\n";
    }
    else {
    	cout << "no" << "\n";
    }
*/

int N;
string S;

cin >> N;
cin >> S;
     int count = 0;
   for(int j = 0; j < N; j++) {
     string subs = S.substr(j, 3);
     if(subs == "ABC") {
       count = count + 1;
     }
   }
 cout << count << "\n";
    return 0;
}	


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

void dfs(vector<vector<int>>& m, int r, int c)
{
    int rows = m.size();
    int cols = m[0].size();

    m[r][c] = 0;
    int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
    int dy[] = {0, -1, -1, -1, 0, 1, 1, 1};
    for (int i = 0; i < 8; i++) {
        int nr = r + dy[i];
        int nc = c + dx[i];
        if (0 <= nr && nr < rows && 0 <= nc && nc < cols && m[nr][nc] == 1) {
            dfs(m, nr, nc);
        }
    }
}

int main()
{
    int cols, rows;
    while (true) {
        cin >> cols >> rows;
        if (cols == 0 && rows == 0) return 0;
        vector<vector<int>> m(rows, vector<int>(cols));
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                cin >> m[i][j];
            }
        }
        int ans = 0;
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                if (m[i][j] == 1) {
                    dfs(m, i, j);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3488
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var nm = ReadLongArray();
            var n = nm[0];
            var m = nm[1];
            Console.WriteLine($"{Math.Min((n * 2 + m) / 4, m / 2)}");
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


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

using namespace std;

int main () {
  vector<vector<int> > c(3);
  for (int i=0; i<3; i++) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    c[i].push_back(x);
    c[i].push_back(y);
    c[i].push_back(z);
  }

  if ((c[0][2]+c[1][1]+c[2][0] == c[0][1]+c[1][0]+c[2][2]) && (c[0][2]+c[1][1]+c[2][0] == c[0][0]+c[1][2]+c[2][1])) printf("Yes\n");
  else printf("No\n");

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    string a,b,c;
    
    cin>> b;
    c=b;
    cin>>a;
    int counter=0;
    b+="a";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="b";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="c";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="d";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="e";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="f";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="g";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="h";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="i";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="j";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="k";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="l";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="m";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="n";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="o";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="p";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="q";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="r";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="s";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="t";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="u";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="v";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="w";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="x";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="y";
    if(b==a){
        counter+=1;
    }
    b=c;
    b+="z";
    if(b==a){
        counter+=1;
    }
    
    if(counter==1){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, int> pli;

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

	string s;
	cin >> s;

	int n = s.size();

	rep(i, n - 1){
		if(s.substr(i, 2) == "AC"){
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	cout << "No" << endl;
}


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

struct Node{
    Node* left;
    Node* right;
    int val;
};

Node* newNode(int x){
    Node* cur = (Node*)malloc(sizeof(Node));
    cur->val = x;
    cur->left = NULL;
    cur->right = NULL;
    return cur;
}

void print(Node* x){
    cout << "(";
    if(x->left != NULL)     print(x->left);
    cout << ")[" << x->val << "](";
    if(x->right != NULL)    print(x->right);
    cout << ")";
}

Node* dfs(int &pos, const string &s){
    if(s[pos] != '('){
        return NULL;
    }
    pos++;  // (
    Node* root = newNode(-1);
    root->left = dfs(pos, s);
    pos++;  // )
    pos++;  // [
    int num = 0;
    while(isdigit(s[pos])){
        num = num*10 + s[pos++]-'0';
    }
    root->val = num;
    pos++;  // ]
    pos++;  // (
    root->right = dfs(pos, s);
    pos++;  // )
    return root;
}

Node* unite(Node* l, Node* r){
    if(l == NULL || r == NULL)  return NULL;
    Node* root = newNode(l->val + r->val);
    root->left = unite(l->left, r->left);
    root->right = unite(l->right, r->right);
    return root;
}

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

    int pos = 0;
    Node* roota = dfs(pos, a);
    pos = 0;
    Node* rootb = dfs(pos, b);

    Node* ret = unite(roota, rootb);

    print(ret);
    cout << endl;

    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n;
    cin >> n; n *= 2;

    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(all(l));

    int ans = 0;
    for (int i = 0; i < n; i += 2) {
        ans += l[i];
    }
    cout << ans << endl;
    return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

lli sum[12][1100];
lli dd[12][1100];

lli bitCount(lli num){
    lli cnt=0;
    while(num>0){
        if(num%2)cnt++;
        num/=2;
    }
    return cnt;
}

int main(){

    lli H,W,K;
    cin>>H>>W>>K;

    REP(i,0,H){
        REP(j,0,W){
            char tmp;
            cin>>tmp;
            lli num = tmp-'0';
            dd[i][j]=num;
        }
    }

    REP(i,0,H)REP(j,0,W)sum[i+1][j+1] = sum[i][j+1]+sum[i+1][j]-sum[i][j] + dd[i][j];

/*
    REP(i,0,H){
        REP(j,0,W){
            cout<<sum[i+1][j+1]<<" ";
        }
        cout<<endl;
    }
    */

    lli ans = INF;
    for(lli bit=0;bit<(1LL<<H+1);bit++){
        bit|=(1LL<<H);
        bit|=(1LL<<0);

        lli beforeW = 0;
        lli cnt=0;
        bool update=true;
        bool ng = false;
        REP(i,1,W+1){
            lli beforeH = 0;
            bool ok = true;
            REP(j,1,H+1){
                if(!(bit&(1LL<<j)))continue;
                LOG2(beforeH,beforeW);
                lli nowK = sum[j][i] - sum[beforeH][i] - sum[j][beforeW] + sum[beforeH][beforeW];
                LOG4(bit,j,i,nowK);
                if(nowK>K){
                    i--;
                    beforeW = i;
                    cnt++;
                    ok = false;
                    if(update==false){
                        ng=true;
                    }
                    break;
                }
                beforeH = j;
            }
            if(ok==false){
                update=false;
            }
            else{
                update=true;
            }
            if(ng){
                cnt=INF;
                break;
            }
        }
        cnt += bitCount(bit)-2;
        LOG(cnt);
        chmin(ans,cnt);
    }
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
// #define DEBUGGING

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(0);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

bool solve() {
    ll N, K;
    cin >> N >> K;
    V<ll> A(N);
    for(ll &e : A) cin >> e;
    sort(ALL(A));
    auto ite = unique(ALL(A));
    A.erase(ite, A.end());
    if(A.size() == 1) return A[0] == K;
    ll G = A[0];
    for(ll e : A) G = gcd(G, e);
    return *max_element(ALL(A)) >= K && K % G == 0;
}

int main() {
    cout << (solve() ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int begin = 0;
    int end = 0;
    int ans = 0;
    for (int i=0; i<s.size(); i++) {
        int len;
        if (s.at(i) == 'A') {
            begin = i;
            break;
        }
    }
    for (int i=0; i<s.size(); i++) {
        if (s.at(i) == 'Z') end = i;
    }
    ans = end - begin + 1;
    cout << ans << endl;
}


Measured memory_bytes: 640
# C - Step

N = int(input())
A = list(int(a) for a in input().split())

ans = 0
if N == 1:
    ans = 0
else:
    for i in range(1, N):
        d = A[i-1] - A[i]
        if d > 0:
            ans += d
            A[i] += d

print(ans)

Measured memory_bytes: 31960
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  string s;
  cin >> s;
  string t;
  cin >> t;
  if(s == t.substr(0, s.size())) cout << "Yes" << endl;
  else cout << "No" << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int n,m;
inline int read()
{
    int s=0,w=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')w=-1,ch=getchar();
    while(ch<='9'&&ch>='0')s=(s<<3)+(s<<1)+ch-'0',ch=getchar();
    return s*w;
}
char a[100010]={},ans[100010]={};
int top=0;
int main()
{
    n=read();
    // scanf("%s",a+1);
    for(int i=1;i<=n;++i)cin>>a[i];
    for(int i=1;i<=n;++i)
    {
        if(a[i]!=a[i-1])ans[++top]=a[i];
    }
    printf("%d\n",top);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

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

  const int M = 55555;
  const int L = 5 * M;
  vector<bool> is_prime(L, true);
  is_prime[0] = is_prime[1] = false;
  for (int i = 4; i < L; i += 2) is_prime[i] = false;
  for (int i = 3; i * i < L; i += 2) {
    if (!is_prime[i]) continue;
    for (int j = 2 * i; j < L; j += i) {
      is_prime[j] = false;
    }
  }
  vector<int> primes;
  REP(i, M + 1) {
    if (is_prime[i] && i % 5 == 1) {
      primes.push_back(i);
    }
  }

  int N;
  cin >> N;
  REP(i, N) {
    if (i > 0) {
      cout << ' ';
    }
    cout << primes[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#include<algorithm>
#include <string>
#include <stdexcept>
using namespace std; 
int main(){
  int a,b,c,d,e;
   char g; string h,i;
    cin >> a;
   if(a==25) cout <<"Christmas";
     else if(a==24) cout <<"Christmas Eve";
  else if(a==23) cout <<"Christmas Eve Eve";
  else if (a==22)cout <<"Christmas Eve Eve Eve";
}

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

for i in range(n):
    print("Case " + str(i + 1) + ":")
    num = int(input())
    for j in range(0,10):
        # 2乗
        num *= num
        sn = str(num)
        # 8桁にする
        if len(sn) < 8:
            d = 8 - len(sn)
            for k in range(d):
                sn = "0" + sn
        # 中央から値を取り出す
        num = int(sn[2:6])
        print(num)


Measured memory_bytes: 5592
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main() {
  long long N,P;
  cin >> N >> P;
  int A[N+10];
  bool ans=true;
  for(int i=0; i<N; i++){
    cin >> A[i];
    if(A[i]%2!=0) ans=false;
  }
  long long a=0;
  if(ans && P==1) a=0;
  else if(ans) a=pow(2,N);
  else a=pow(2,N-1);
  cout << a << endl;
}

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

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

    string s, t;
    cin >> s >> t;
    string tmp_t = t;

    rep(i, s.length()){
        if(s == tmp_t){
            puts("Yes");
            return 0;
        }
        tmp_t = tmp_t[tmp_t.length()-1] + tmp_t.substr(0, tmp_t.length()-1);
    }
    
    puts("No");
    return 0;
}

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

int main() {
  long long N, P;
  cin >> N >> P;

  long long P2 = P;
  map<long long, int> m;
  for (long long i = 2; i * i <= P; ++i)
    while (P2 % i == 0)
      ++m[i], P2 /= i;
  if (P2 != 1)
    ++m[P2];

  long long ans = 1;
  for (auto &&i : m)
    if (i.second >= N)
      for (int j = 0; j < i.second / N; ++j)
        ans *= i.first;

  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(void){
    int n,q,w;
    int i;
    int p[50];
    while(true){
        cin >> n >> q;
        if(n == 0) break;
        for(i = 0;i < 50;i++) p[i] = 0;
        i = 0;w = q;
        while(true){
            if(w){
                p[i]++;
                w--;
            }
            else{
                if(p[i] == q){
                    cout << i << endl;
                    break;
                }
                else{
                    w = p[i];
                    p[i] = 0;
                }
            }
            i = (i+1)%n;
        }
    }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    double w,h,x,y;
    cin>>w>>h>>x>>y;

    double ans=w*h/2;
    cout<<fixed<<setprecision(12)<<ans<<" ";
    if(w==2*x && h==2*y) cout<<1<<endl;
    else cout<<0<<endl;
}



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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

inline ll combi2(const ll n) {
    return n * (n - 1) / 2;
}



int main() {
    int n;
    cin >> n;
    vi h(n);
    REP(i, n) {
        cin >> h[i];
    }
    int cnd = 0, ans = 0, prevh = h[0];
    FOR(i, 1, n) {
        if(h[i] <= prevh) {
            cnd++;
            ans = max(ans, cnd);
        }
        else cnd = 0;
        prevh = h[i];
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 640
def main():
    n = int(input())
    h = tuple(map(int, input().split()))
    dp = [0] * n
    dp[1] = abs(h[0] - h[1])

    for i1 in range(2, n):
        dp[i1] = min(dp[i1-2]+abs(h[i1]-h[i1-2]),dp[i1-1]+abs(h[i1]-h[i1-1]))
    print(dp[n - 1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 14108
<?php

fscanf(STDIN, "%s", $a);
  
$weeks = array(
  'SUN',
  'MON',
  'TUE',
  'WED',
  'THU',
  'FRI',
  'SAT',
);

$num = array_search($a, $weeks);

echo 7 - $num;

Measured memory_bytes: 3828