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

const int N = 1e5 + 50;
char s[N];
int cnt[5];

int main() {
    scanf("%s",s);
    int n = strlen(s);

    if(n==3) {
        set<char> st;
        for(int i=0; i<n; i++) st.insert(s[i]);
        if(st.size()==2)
            puts("NO");
        else puts("YES");
        return 0;
    }
    for(int i=0; i<n; i++) {
        cnt[s[i]-'a']++;
    }
    sort(cnt,cnt+3);
    if(cnt[2]-cnt[0] > 1) {
        puts("NO");
    } else {
        puts("YES");
    }


}




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

using namespace std;

int main(void){
	int n;
	int m;
	int x;

	int t;
	vector<int> a;

	int l=0;
	int r=0;

	cin >> n >> m >> x;

	for(int i=0; i < n; i++)
		a.push_back(0);


	while(cin >> t){
		a[t] = 1;
	}


	for(int i=0; i <= x; i++){
		l += a[i];
	}

	for(int i=x; i < n; i++){
		r += a[i];
	}

	if(l <= r)
		cout << l;
	else
		cout << r;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	string N;
	cin >> N;
	int sum = 0;
	for (int i = 0; i < N.size(); i++) {
		sum += stoi(N.substr(i,1));
	}
	cout << (sum == 1 ? 10 : sum) << endl;
	return 0;
}


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

int main() {
    int64_t N, A, B;
    cin >> N >> A >> B;

    if ((B - A) % 2 == 0) {
        cout << (B - A) / 2 << endl;
        return 0;
    }

    int64_t ans1 = 0, ans2 = 0;
    {
        int64_t AA = A, BB = B;
        ans1 += AA;
        BB -= AA;
        AA = 1;
        ans1 += (BB - AA) / 2;
    }
    {
        int64_t AA = A, BB = B;
        ans2 += N - B + 1;
        AA += N - B + 1;
        BB = N;
        ans2 += (BB - AA) / 2;
    }

    cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]);
    a.sort();
    auto asum = a.sum();
    auto b = asum - a[n - 1];
    writeln(a[n - 1] < b ? "Yes" : "No");
}







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 <bits/stdc++.h>
using namespace std;

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()


#include <vector>

struct UnionFind {
  // parentの番号を格納する。親だった場合は-(その集合のサイズ)
  vector<int> Parent;

  //作成時は全て-1なので木が全て独立している状態
  UnionFind(int N) { Parent = vector<int>(N, -1); }

  // Aがどのグループに属しているか調べる
  int root(int A) {
    if (Parent[A] < 0)
      return A;
    else {
      return Parent[A] = root(Parent[A]);
    }
  }

  //自分のいるグループの頂点数を調べる
  int size(int A) { return -Parent[root(A)]; }

  // AとBをくっつける
  bool merge(int A, int B) {
    // AとBを繋げるのではなくroot(A)とroot(B)を繋げる
    A = root(A);
    B = root(B);
    if (A == B) {
      //すでに繋がれているので繋がない
      return false;
    }

    //大きい方（A）に小さい方（B）をくっつけたい
    if (size(A) < size(B)) swap(A, B);

    // Aのサイズを変更する
    Parent[A] += Parent[B];
    // Bの親をAに変更する
    Parent[B] = A;

    return true;
  }
};

int main() {
    int N,M,K;
    cin >> N >> M >> K;



    vector<int> com(N,0); // 1:friend -1:block 



    UnionFind U(N);

    
    REP(i,M){
        int a,b;
        cin >> a >> b;
        com[a-1]++,com[b-1]++;
        U.merge(a-1,b-1);
    }

    REP(i,K){
        int a,b;
        cin >> a >> b;
        if(U.root(a-1)==U.root(b-1))com[a-1]++,com[b-1]++;
    }

    // REP(i,N) cout << U.size(i) << endl;

    REP(i,N-1){
        cout << U.size(i)-com[i]-1 << " ";
    }

    cout << U.size(N-1)-com[N-1]-1 << endl;

    // 到達可能な場合・相互ブロックもしくは友達でなければおｋ
    // グラフの右上斜めを埋めれば答えが出せる。

}



Measured memory_bytes: 1664
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

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

int N,K;
const int L=1e5+10;
vector<int> p[L];
int ret=0;

int f(int r,int a)
{
	int d=0;
	for(auto s:p[r])
	{
		d=max(d,1+f(s,r));
	}
	if(a&&d==K-1)
	{
		//cerr << r << ", " << a << endl;
		ret++;
		return -1;
	}
	return d;
}
int main() {
	cin >> N >> K;
	int a0;
	cin >> a0;
	if(a0!=1){
		ret++;
	}

	for(int i=1;i<N;i++){
		int a;
		cin >> a;
		a--;
		p[a].push_back(i);
	}
	f(0,0);
	cout << ret << endl;


	return 0;
}



Measured memory_bytes: 10368
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<chrono>
#include<random>
#include<cstdio>
#include<set>
#include<map>
#include<numeric>
#define MAX_N 100
#define MAX_M 100
#define INF 10000000
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;


int main(){
    int N;
    string s;
    cin>>N>>s;
    REP(i,s.length()){
        if((s[i]+N)>90){
            int a=s[i]+N-26;
            cout<<(char)a;
        }else{
            cout<<(char)(s[i]+N);
        }
    }
}

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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main() {
  int h,w;
	cin >> h >> w;
  string s[h*w];

  rep(i,0,h) cin >> s[i];
	int dx[8] = { 0,1,1,1,0,-1,-1,-1 };
	int dy[8] = { 1,1,0,-1,-1,-1,0,1 };

	rep(i,0,h){
		rep(j,0,w){
			if(s[i][j] == '#') cout << "#";
			else{
				int cnt = 0;
				for(int k = 0; k < 8; k++){
					int cx = i + dx[k], cy = j + dy[k];
					if(cx < 0 || cx >= h || cy < 0 || cy >= w) continue;
					if(s[cx][cy] == '#') cnt++;
				}
				cout << cnt;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def main(n:int, t:int, lst:list):
  lst = list(x for x in lst if x[1] <= t)
  if len(lst):
    return min(x[0] for x in lst)
  else:
    return "TLE"
n, t = map(int, input().split()) #t以内でcost最小に
lst = [list(map(int, input().split())) for i in range(n)] #n個cost,timeのpair
print(main(n, t, lst))

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

#define rep(i,n) for(int i=0; i<n; i++)

int n, m;
int nx, ny;
int x[5001], y[5001];
int index_x[5001], index_y[5001];
int sum[5001][5001];

int main(){

  cin >> n >> m;
  rep(i,n) cin >> x[i] >> y[i];
  memset(sum, 0, sizeof(sum));

  rep(i,n) index_x[i] = x[i];
  rep(i,n) index_y[i] = y[i];

  sort(index_x, index_x+n);
  sort(index_y, index_y+n);
  nx = unique(index_x, index_x+n) - index_x;
  ny = unique(index_y, index_y+n) - index_y;

  rep(i,n){
    int px = (lower_bound(index_x, index_x+nx, x[i]) - index_x) + 1;
    int py = (lower_bound(index_y, index_y+ny, y[i]) - index_y) + 1;
    sum[px][py] += 1;
  }
  rep(i,nx) rep(j,ny)
    sum[i+1][j+1] += (sum[i+1][j] + sum[i][j+1] - sum[i][j]);

  rep(i,m){
    int lx, ly, rx, ry;
    cin >> lx >> ly >> rx >> ry;

    lx = lower_bound(index_x, index_x+nx, lx) - index_x;
    ly = lower_bound(index_y, index_y+ny, ly) - index_y;
    rx = lower_bound(index_x, index_x+nx, rx+1) - index_x;
    ry = lower_bound(index_y, index_y+ny, ry+1) - index_y;

    cout << (sum[rx][ry] - sum[lx][ry] - sum[rx][ly] + sum[lx][ly]) << endl;
  }

  return 0;
}

Measured memory_bytes: 98960
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

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

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

#define ma 12345678
int G[100][100][2] = {0};

signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(n, m);
    if(n == 0 && m == 0)break;

    rep(i, 100)rep(j, 100)rep(k, 2)G[i][j][k] = ma;
    rep(i, n){
      int a, b, c, t;
      scanf("%d%d%d%d", &a, &b, &c, &t);
      --a; --b;
      G[a][b][0] = c; G[b][a][0] = c;
      G[a][b][1] = t; G[b][a][1] = t;
    }

    int l;
    rep(l, 2)rep(k, m)rep(i, m)rep(j, m){
      G[i][j][l] = min(G[i][k][l] + G[k][j][l], G[i][j][l]);
    }
    
    int(k);
    for(;k--;){
      int3(p, q, r);
      --p; --q;
      printf("%d\n", G[p][q][r]);
    }


//*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3224
def main():
    n = int(input())
    t, a = map(int, input().split())
    h = list(map(int, input().split()))

    z = []
    for x in h:
        t_x = abs(a - (t - x * 0.006))
        z.append(t_x)

    ans = z.index(min(z)) + 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,l,r,mid;
string g(int i)
{
	string s;
	printf("%d\n",i);
	fflush(stdout);
	cin>>s;
	return s;
}
int main()
{
	cin>>n;
	l=0; r=n-1;
	string a=g(0);
	if(a=="Vacant") return 0;
	string b=g(n-1);
	if(b=="Vacant") return 0;
	while(l<=r)
	{
		mid=(l+r)/2;
		string m=g(mid);
		if(m=="Vacant") return 0;
		if(mid%2==0)
		 if(m==a) l=mid+1;
		 else r=mid-1;
		else if(m==b) l=mid+1;
		else r=mid-1;
	}
	return 0;
}

Measured memory_bytes: 852
#include <algorithm>
#include <cstdio>
const int MAXN = 15;
const int MAXQ = 55;
int a[MAXQ], b[MAXQ], c[MAXQ], d[MAXQ];
int A[MAXN];
int M, N, Q;
int ret;

void dfs(int pos, int u) {
  if (pos > N) {
    int sum = 0;
    for (int i = 0; i < Q; ++i) {
      if (A[b[i]] - A[a[i]] == c[i]) {
        sum += d[i];
      }
    }
    ret = std::max(sum, ret);
    return;
  }
  for (int v = u; v <= M; ++v) {
    A[pos] = v;
    dfs(pos+1, v);
  }
}
    

int main() {
  scanf(" %d%d%d", &N, &M, &Q);
  for (int i = 0; i < Q; ++i) {
    scanf(" %d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
  }
  ret = 0;
  dfs(1, 1);
  printf("%d\n", ret);
  return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

/* 基本要素 */
typedef complex<double> Point;
typedef pair<Point, Point> Line;
typedef vector<Point> VP;
const double EPS = 1e-7; // 許容誤差^2
const double INF = 1e9;
#define X real()
#define Y imag()
// #define LE(n,m) ((n) < (m) + EPS)
#define LE(n,m) ((n) - (m) < EPS)
// #define GE(n,m) ((n) + EPS > (m))
#define GE(n,m) (EPS > (m) - (n))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// 内積　dot(a,b) = |a||b|cosθ
double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

// 外積　cross(a,b) = |a||b|sinθ
double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

// 点の進行方向
int ccw(Point a, Point b, Point c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

// 2直線の交点
Point crosspointLL(Point a1, Point a2, Point b1, Point b2) {
  double d1 = cross(b2-b1, b1-a1);
  double d2 = cross(b2-b1, a2-a1);
  if (EQ(d1, 0) && EQ(d2, 0)) return a1;  // same line
  assert(!EQ(d2, 0)); // 交点がない
  return a1 + d1/d2 * (a2-a1);
}

// 多角形の符号付面積
double area(const VP& ps) {
  double a = 0;
  rep (i, ps.size()) a += cross(ps[i], ps[(i+1) % ps.size()]);
  return a / 2;
}

const double pi = acos(-1);
Point f(int x, int n){
    return Point(cos(2*pi*x/n), sin(2*pi*x/n));
}

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

    VP tri;
    tri.pb(f(0,n));
    tri.pb(crosspointLL(f(0,n), f(k,n), f(1,n), f(n-k+1,n)));
    tri.pb(f(1,n));

    double S = sin(2*pi/n)/2;
    double T = abs(area(tri));
    printf("%.10f\n", n*(S-T));
    return 0;
}



Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
#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 ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();

int main(){
string s; cin>>s;
int res=0;

vector<string> y={"SUN","MON","TUE","WED","THU","FRI","SAT"};

REP(i,7)if(s==y[i])res=7-i;
cout<<res<<endl;

}

Measured memory_bytes: 256
require 'set'

def get_path(g, u, t, reached = Set[u])
	return [t] if u == t

	g[u].each do |v|
		next if reached.include?(v)
		reached << v
		if path = get_path(g, v, t, reached)
			return [u] + path 
		end
	end
	return nil
end

loop do
	params = gets.split.map(&:to_i)
	h, w, c, m, nw, nc, nm = params
	break if h == -1

	node_num = params.inject(:+) * 2 - h + 2

	g = (0..node_num-1).map { Set.new }

	id = 0
	s = id
	heros = (1..h).map { id += 1 }
	warriors_in = (1..w).map { id += 1 }
	warriors_out = (1..w).map { id += 1 }
	dummy_warriors_in = (1..nw).map { id += 1 }
	dummy_warriors_out = (1..nw).map { id += 1 }
	clerics_in = (1..c).map { id += 1 }
	clerics_out = (1..c).map { id += 1 }
	dummy_clerics_in = (1..nc).map { id += 1 }
	dummy_clerics_out = (1..nc).map { id += 1 }
	mages_in = (1..m).map { id += 1 }
	mages_out = (1..m).map { id += 1 }
	dummy_mages_in = (1..nm).map { id += 1 }
	dummy_mages_out = (1..nm).map { id += 1 }
	t = (id += 1)

	heros.each do |j|
		g[s] << j
	end

	warriors_in.each do |j|
		_, *hs = gets.split.map(&:to_i)
		hs.each do |l|
			i = heros[l-1]
			g[i] << j
		end
	end

	warriors_in.zip(warriors_out).each do |i, j|
		g[i] << j
	end

	dummy_warriors_in.each do |j|
		heros.each do |i|
			g[i] << j
		end
	end

	dummy_warriors_out.each do |i|
		clerics_in.each do |j|
			g[i] << j
		end
	end

	dummy_warriors_in.zip(dummy_warriors_out).each do |i, j|
		g[i] << j
	end

	clerics_in.each do |j|
		_, *ws = gets.split.map(&:to_i)
		ws.each do |l|
			i = warriors_out[l-1]
			g[i] << j
		end
	end

	clerics_in.zip(clerics_out).each do |i, j|
		g[i] << j
	end

	dummy_clerics_in.each do |j|
		warriors_out.each do |i|
			g[i] << j
		end
	end

	dummy_clerics_out.each do |i|
		mages_in.each do |j|
			g[i] << j
		end
	end

	dummy_clerics_in.zip(dummy_clerics_out).each do |i, j|
		g[i] << j
	end

	mages_in.each do |j|
		_, *cs = gets.split.map(&:to_i)
		cs.each do |l|
			i = clerics_out[l-1]
			g[i] << j
		end
	end

	mages_out.each do |j|
		g[j] << t
	end

	mages_in.zip(mages_out).each do |i, j|
		g[i] << j
	end

	dummy_mages_in.each do |j|
		clerics_out.each do |i|
			g[i] << j
		end
	end
	
	dummy_mages_out.each do |j|
		g[j] << t
	end

	dummy_mages_in.zip(dummy_mages_out).each do |i, j|
		g[i] << j
	end


	flow = 0
	loop do
		break unless path = get_path(g, s, t)
		flow += 1
		path.reverse.each_cons(2) do |j, i|
			g[i].delete(j)
			g[j] << i
		end
	end
	p flow
end

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

const int NIL = -1;
const int MAX = 100000;

struct Node {
  int parent {NIL};
  int left_child {NIL};
  int right_sibling {NIL};
  int depth {NIL};
};

void setDepth(int node_id, int depth, Node tree[]) {
  tree[node_id].depth = depth;
  if (tree[node_id].right_sibling != NIL) {
    setDepth(tree[node_id].right_sibling, depth, tree);
  }

  if (tree[node_id].left_child != NIL) {
    setDepth(tree[node_id].left_child, depth + 1, tree);
  }
}

int findRoot(Node tree[], int n) {
  int root {0};
  for (int i = 0; i < n; i++) {
    root = i;
    if (tree[i].parent == NIL) return root;
  }
  return root;
}

vector<int> getChildren(int id, Node tree[]) {
  vector<int> children_list;
  int child_node = tree[id].left_child;
  while (child_node != NIL) {
    children_list.push_back(child_node);
    child_node = tree[child_node].right_sibling;
  }

  return children_list;
}

string getKind(int id, Node tree[]) {
  if (tree[id].parent == NIL) return "root";
  if (tree[id].left_child == NIL) return "leaf";
  return "internal node";
}

void print(Node tree[], int n) {
  for (int i = 0; i < n; i++) {
    cout << "node " << i << ": parent = " << tree[i].parent << ", depth = " << tree[i].depth << ", " << getKind(i, tree) << ", [";
    vector<int> children_list = getChildren(i, tree);
    for (int i = 0; i < children_list.size(); i++) {
      cout << children_list.at(i);
      if (i != children_list.size() - 1) cout << ", ";
    }
    cout << "]" << endl;
  }
}

int main() {
  int n, id, k, child, prev_child;
  Node tree[MAX];
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> id >> k;
    for (int j = 0; j < k; j++) {
      cin >> child;
      if (j == 0) {
        tree[id].left_child = child;
      } else {
        tree[prev_child].right_sibling = child;
      }
      prev_child = child;
      tree[child].parent = id;
    }
  }

  int root = findRoot(tree, n);
  setDepth(root, 0, tree);

  print(tree, n);
}



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

int main() {
  int N;
  string S;
  cin >> N >> S;
  priority_queue<int> q;
  for (int i = 1; i < N ; i++) {
    bitset<26> ba, bb, bc;
    for (int j = 0; j < i; j++) {
      int k = S.at(j) - 'a';
      ba.set(k, 1);
    }
    for (int j = i; j < N; j++) {
      int k = S.at(j) - 'a';
      bb.set(k, 1);
    }
    bc = (ba & bb);
    int x = bc.count();
    q.push(x);
  }
  cout << q.top() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
#define int long long
#define f(i,n) for(ll i=0;i<n;i++)
#define fo(i,a,b) for(ll i=a;i<=b;i++)
#define forr(i,a,b) for(ll i=a;i>=b;i--)
#define bp __builtin_popcount
#define all(x) (x).begin(),(x).end()
#define s(x) sort(all(x))
#define r(x) reverse(all(x))
#define vll vector<ll>
#define pll pair<ll,ll>
#define sz size()
#define ln length()
#define pi acos(-1)
#define U 1e9
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second 
#define vl vector<ll>
#define pll pair<ll,ll>
#define KHILADI ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))
//cout << fixed << showpoint;
//cout << setprecision(7);

ll max(ll a , ll b){ if(a>b) return a; else return b;}
ll min(ll a , ll b){ if(a<b) return a; else return b;}

ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}          
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

signed main()
{
    KHILADI;
    ll n;
    cin >> n;
    map<string,int> m;
    f(i,n)
    {
        string s;
        cin >> s;
        m[s]++;
    }
    ll cnt=0;
    for(auto i:m)
    {
        cnt=max(cnt,i.S);
    }
    vector<string> ans;
    for(auto i:m)
    {
        if(i.S==cnt)
            ans.pb(i.F);
    }
    s(ans);
    f(i,ans.sz)
        cout << ans[i] << endl;
    return 0;
}




Measured memory_bytes: 25584
#include<bits/stdc++.h>
using namespace std;
int n,mx;
string s[200010];
map<string,int> mp;
vector<string> v;
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>s[i];
		mp[s[i]]++;
	}
	for (int i=0;i<n;i++) mx=max(mp[s[i]],mx);
	for (int i=0;i<n;i++) if (mx==mp[s[i]]) v.push_back(s[i]);
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	for (int i=0;i<v.size();i++) cout<<v[i]<<endl;
	return 0;
}

Measured memory_bytes: 28404
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>

#define div 1000000000+7

typedef long long ll;

using namespace std;


int main(){
    int a, b;
    cin >> a >> b;
    if(a+b < 24){
        cout << a+b << endl;
    }else{
        cout << a+b-24 << endl;
    }
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

const long long INF=1LL<<61;

int main(){
	int n; scanf("%d",&n);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]);

	lint sum[2][200001]={};
	rep(dir,2){
		auto tmp=a;

		vector<int> right(n);
		rep(i,n) right[i]=i;

		for(int i=n-2;i>=0;i--){
			sum[dir][i]=sum[dir][i+1];
			int pos=i;
			while(pos<n-1 && a[pos]>a[pos+1]){
				int r=right[pos+1];
				while(a[pos]>a[pos+1]){
					sum[dir][i]+=2*(r-pos);
					a[pos+1]*=4;
					if(pos+1<r) a[r]*=4;
				}
				pos=r;
			}
			right[i]=pos;
		}

		a=tmp;
		reverse(a.begin(),a.end());
	}

	lint ans=INF;
	rep(i,n+1) ans=min(ans,sum[0][i]+sum[1][n-i]+i);
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 7296
#include<iostream>
#define int long long
using namespace std;
const int mod = 1e9+7;
int n , k , ans=0;
struct matrix
{
	int m[51][51];
	matrix(){
		for(int i=0 ; i<51 ; ++i)
			for(int j = 0 ; j<51 ; ++j)
				m[i][j] = 0;
	}
	matrix operator*(const matrix &x)const{
		matrix c;
		for(int i=1 ; i<=n ; ++i)
			for(int j=1 ; j<=n ; ++j)
				for(int k=1 ; k<=n ; ++k)
					c.m[i][j] = (c.m[i][j]%mod + ((x.m[i][k]%mod) * (m[k][j]%mod))%mod)%mod;
		return c;
	}
};
matrix G , C;

matrix fpow(matrix M , int p){
	matrix c;
	for(int i=1 ; i<=n ; ++i)
		for(int j=1 ; j<=n ; ++j)
			if(i==j) c.m[i][j] = 1;
	for( ; p ; p>>=1 , M = M*M) if(p & 1) c = c * M;
	return c;
}

main(){ios::sync_with_stdio(false),cin.tie(0);
	cin >> n >> k;
	for(int i=1 ; i<=n ; ++i)
		for(int j=1 ; j<=n ; ++j)
			cin >> G.m[i][j];
	C = fpow(G , k);
	for(int i=1 ; i<=n ; ++i)
		for(int j=1 ; j<=n ; ++j)
			if(C.m[i][j]) ans+=C.m[i][j] , ans%=mod;

	cout << ans <<'\n';
}

Measured memory_bytes: 384
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<long long>;
using pll = pair<long, long>;
template<class T> using pr = pair<T, T>;
template<class T> using vec = vector<T>;

#define debug(x) (std::cerr << (x) << "\n")
#define debug_tab(n, x) (std::cerr << strMulti("\t",n) << (x) << "\n")
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b)
constexpr int INF = 2000000100;
constexpr ll MOD = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T mod_pow(T x, T n, const T& p) { T ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; }

/*****/

void Main()
{
	ll N;
	cin >> N;
	vecll A(N);
	rep(i, N)	cin >> A[i];

	sort(all(A));

	bool isYes = true;
	rep(i, N - 1)
	{
		if (A[i] == A[i + 1])
		{
			isYes = false;
			break;
		}
	}

	cout << (isYes ? "YES" : "NO");
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


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

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(input())
    a = list(map(int, input().split()))
    assert len(a) == n
    div = 1
    flag = "free"
    for i in range(1, n):
        if flag == "free":
            if a[i] > a[i - 1]:
                flag = "inc"
            elif a[i] < a[i - 1]:
                flag = "dec"
        elif flag == "inc":
            if a[i] < a[i - 1]:
                div += 1
                flag = "free"
        else:
            if a[i] > a[i - 1]:
                div += 1
                flag = "free"
    print(div)

main()


Measured memory_bytes: 14612
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  string s;
  ll k;
  cin >> s >> k;
  int m = -1;
  while (m+1 < s.size() && s[m+1] == '1') m++;
  cout << (m < k - 1 ? s[m+1] - '0' : 1) << endl;
  return 0;
}

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

using namespace std;

int main(void) {
	int N; cin >> N;
	vector<int> A, B, C;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		A.push_back(a);
		A[i]--;
	}
	for (int i = 0; i < N; i++) {
		int b; cin >> b;
		B.push_back(b);
	}
	for (int i = 0; i < N-1; i++) {
		int c; cin >> c;
		C.push_back(c);
	}

	int res = 0;
	for (int i = 0; i < N; i++) {
		res += B[A[i]];
		if (i > 0 && A[i-1] + 1 == A[i]) {
			res += C[A[i-1]];
		}
	}
	cout << res << endl;

	return 0;
}

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

int main()
{
    string tmp;
    
    char query[N][3];
    ll Q;
    cin >> tmp;
    vector<char> S(tmp.length());

    cin >> Q;

    bool flag=true;
    
    for(ll i=0;i<Q;i++){
        cin >> query[i][0];
        if(query[i][0]=='2')cin >> query[i][1] >> query[i][2];
    }
    for(ll i=0;i<tmp.length();i++)S[i]=tmp[i];
    for(ll i=0;i<Q;i++){
        if(query[i][0]=='1'){
            flag=!flag;
        }else{
            if(query[i][1]=='1'){
                if(flag){
                    S.insert(S.begin(),query[i][2]);
                }else{
                    S.push_back(query[i][2]);
                }
            }else{
                if(!flag){
                    S.insert(S.begin(),query[i][2]);
                }else{
                    S.push_back(query[i][2]);
                }
            }
        }
    }
    if(!flag){
        reverse(begin(S),end(S));
    }
    for(ll i=0;i<S.size();i++)cout << S[i];
    cout << endl;
    
}

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

int main(){
    int n, k, maxn = 0;
    cin >> n >> k;
    vector<int> dice(n);
    rep(i, n){
        cin >> dice[i];
        maxn = max(maxn, dice[i]);
    }

    vector<int> sum;
    rep(i, maxn) sum.push_back(i+1);
    vector<int> cumsum(sum.size()+1, 0);
    for (int i = 0; i < maxn; i++) cumsum[i+1] = cumsum[i] + sum[i];

    vector<long double> E(n);
    rep(i, n){
        E[i] = (long double)cumsum[dice[i]]/dice[i];
    }
    vector<long double> cumsumE(E.size()+1, 0);
    for (int i = 0; i < n+1; i++) cumsumE[i+1] += cumsumE[i] + E[i];

    long double ans = 0;
    rep(i, n-k+1){
        ans = max(ans, cumsumE[i+k] - cumsumE[i]);
    }
    printf("%.10Lf\n", ans);
}   


Measured memory_bytes: 7296
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int X = Integer.parseInt(in.next());
		int Y = Integer.parseInt(in.next());
		int Z = Integer.parseInt(in.next());
		int ans = (X-Z) / (Y+Z);
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
def prime_factorization(n) -> list:
	if n==1:
		return [1]
	ret = []
	i = 2
	while i*i<=n:
		while n%i==0:
			n //= i
			ret.append(i)
		i += 1
	if n!=1:
		ret.append(n)
	return ret
n=int(input())
from functools import reduce
from operator import mul
pf=set(prime_factorization(n))
print(int(reduce(mul,[n]+[1-1/p for p in pf])))


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

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

    vector<pair<long,long>> a(n);
    for(long i=0; i<n; i++)
        cin >> a[i].first, a[i].second = -i;

    sort(a.begin(), a.end(), greater<>());

    map<long, long> res;

    long top, cur;
    tie(top, cur) = a[0];
    cur = -cur;
    for(long i=1; i<n; i++) {
        res[cur] += i*(top - a[i].first);
        top = a[i].first;
        cur = min(cur, -a[i].second);
    }
    res[cur] += n*top;

    for(long i=0; i<n; i++)
        cout << res[i] << endl;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
#include <string>
#include<iostream>

#define watch(x) cout << #x << " is " << (x) << "\n";
#define watch_vi(x) cout << #x << " is "; for(int i = 0; i < x.size(); i++) cout << x[i] << " "; cout << "\n";
typedef long long ll;
using namespace std;

int main()
{
   string s;
   cin >> s;
   for(int i = 0; i < s.size() - 1; i++)
   {
       if(s[i] == s[i+1])
       {
           cout << "Bad";
           return 0;
       }
   }
   cout << "Good";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) cerr << #x << ": " << (x) << '\n'
#define ff first
#define ss second
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)

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

   int n;
   cin >> n;
   vector <int> v(n), dp(n);
   for (auto &i : v)
      cin >> i;
   dp[1] = abs(v[1] - v[0]);
   for (int i = 2; i < n; i++) {
      dp[i] = min(dp[i - 1] + abs(v[i] - v[i - 1]), dp[i - 2] + abs(v[i] - v[i - 2]));
   }
   cout << dp[n - 1] << '\n';

   return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
typedef long double LD;

int main() {
	LD a, b, c, d, e, f, g, h;
	while (cin >> a >> b >> c >> d >> e >> f >> g >> h) {
		LD i = (h-f)*(d - b);
		LD j = (c - a)*(g-e);
		if (i+j==0)cout << "YES" << endl;
		else cout << "NO" << endl;
		
	}
	return 0;
}

Measured memory_bytes: 3160
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut sum = 0;
    for i in 0..n {
        sum ^= a[i];
    }
    let mut a: Vec<_> = a.into_iter().map(|x| x & !sum).collect();
    let mut r = 0;
    for c in (0..64).rev() {
        let mut r2 = n;
        for i in r..n {
            if (a[i] & 1 << c) != 0 {
                r2 = i;
                break;
            }
        }
        if r2 == n {
            continue;
        }
        a.swap(r, r2);
        for i in 0..n {
            if i == r { continue; }
            if (a[i] & 1 << c) != 0 {
                let val = a[r];
                a[i] ^= val;
            }
        }
        r += 1;
    }
    let mut ma = 0;
    for i in 0..r {
        if ma < ma ^ a[i] {
            ma ^= a[i];
        }
    }
    puts!("{}\n", 2 * ma + sum);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 10620
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

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

	ll N; cin >> N;
	ll ans = LLINF;
	for (ll i = 1; i*i <= N; i++) {
		if (N%i == 0)ans = min(ans, i - 1LL + (N / i) - 1LL);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in);) {
            int n = scanner.nextInt();
            int cnt = 0;
            String ans = "No";

            for(int i = 0; i < n; i++) {
                if(scanner.nextInt() == scanner.nextInt()) {
                    cnt++;
                    if(cnt >= 3) {
                        ans = "Yes";
                        System.out.println(ans);
                        return;
                    }
                } else {
                    cnt = 0;
                }
            }
            
            System.out.println(ans);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 35964
from collections import deque
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
a=deque(a)
x=[]
for i in range(m):x.append(list(map(int,input().split()))[::-1])
x.sort(reverse=1)
for i,j in x:
  for k in range(j):
    if i<=a[0]:print(sum(a));exit()
    a.popleft();a.append(i)
print(sum(a))

Measured memory_bytes: 24808
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string.h>

using namespace std;

int n, m;
char a[100100];

int main () {
    cin >> n;
    scanf("%s", &a);
    m = strlen(a);
    if ( n < 3200 ) {
        cout <<"red";
    }
    else {
        for ( int j = 0; j < m; j++) {
            cout << a[j];
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1, 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    string s;
    cin >> s;

    vector<int> ans(s.size(), 1);

    FOR(i, 1, s.size()) {
        if (s[i - 1] == 'R' && s[i] == 'R') {
            ans[i] += ans[i - 1];
            ans[i - 1] = 0;
        }
    }
    RFOR(i, s.size(), 1) {
        if (s[i - 1] == 'L' && s[i] == 'L') {
            ans[i - 1] += ans[i];
            ans[i] = 0;
        }
    }
    FOR(i, 1, s.size()) {
        if (s[i - 1] == 'R' && s[i] == 'L' && ans[i - 1] != ans[i]) {
            int r      = ans[i - 1] - 1;
            int l      = ans[i] - 1;
            ans[i - 1] = r / 2 + (l - l / 2) + 1;
            ans[i]     = (r - r / 2) + l / 2 + 1;
        }
    }

    print(ans);

    return 0;
}

Measured memory_bytes: 1104
//Auuthor:Avdhoot
//Editor:Geany
//Favourite:One Piece
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll int>
#define vs vector<string>
#define v vector<int>
#define mi map<int,int>
#define mc map<char,int>

//ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	string s;
	cin>>s;
	int n=s.length();
	if(s[n-1]!='s'){
		s.push_back('s');
		}
		else{
			s.push_back('e');
			s.push_back('s');
			}
			cout<<s <<"\n";
}


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


int main()
{
    int n;
    cin>>n;
    if(n==111)
    {
        cout<<999<<endl;
    }
    else if(n==119)
    {
        cout<<991<<endl;
    }
    else if(n==191)
    {
        cout<<919<<endl;
    }
    else if(n==911)
    {
        cout<<199<<endl;
    }
    else if(n==199)
    {
        cout<<911<<endl;
    }
    else if(n==119)
    {
        cout<<991<<endl;
    }
    else if(n==919)
    {
        cout<<191<<endl;
    }
    else if(n==991)
    {
        cout<<119<<endl;
    }
    else if(n==999)
    {
        cout<<111<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

struct edge{
    int from, to;
    ll cost;
};

edge es[5010];
int N, M, P;
ll d[2510];

bool shortest_path(int s){
    for(int i = 1; i <= N; i++) d[i] = inf;
    d[s] = 0;
    int cnt = 0;
    bool update = true;
    while(update && cnt <= N){
        update = false;
        cnt++;
        for(int i = 0; i < M; i++){
            edge e = es[i];
            if(d[e.from] != inf && d[e.from] + e.cost < d[e.to]){
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
    }

    int res = d[N];

    cnt = 0;
    update = true;
    while(update && cnt <= N){
        update = false;
        cnt++;
        for(int i = 0; i < M; i++){
            edge e = es[i];
            if(d[e.from] != inf && d[e.from] + e.cost < d[e.to]){
                d[e.to] = d[e.from] + e.cost;
                d[e.to] = -2e10;
                update = true;
            }
        }
    }
    return d[N] != res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M >> P;
    for(int i = 0; i < M; i++){
        int A, B, C;
        cin >> A >> B >> C;
        es[i] = {A, B, P - C};
    }
    cout << (shortest_path(1) ? -1 : max(-d[N], 0LL)) << endl;
    return 0;
}

Measured memory_bytes: 384
def resolve():
    n,m=map(int, input().split())
    l=list(map(int, input().split()))
    sou=sum(l)
    cnt=0
    l.sort(reverse=True)
    for i in range(n):
        if l[i]>=sou*1/(4*m):
            cnt+=1
    if cnt>=m:
        print('Yes')
    else:
        print('No')
resolve()

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<char> d(k);
    for(int i = 0;i < k;i ++){
        cin >> d[i];
    }
    while(1){
        string s = to_string(n);
        bool ok = true;
        for(int i = 0;i < k;i ++){
            if(find(s.begin(),s.end(),d[i])!=s.end()) {ok=false;break;}
        }
        if(ok) break;
        n ++;
    }
    cout << n << endl;
    return 0;
}

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

using namespace std;

long long memo[100010];

long long sum(int x) {
  if (memo[x] != -1) return memo[x];
  return memo[x] = x + sum(x - 1);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  for (int i = 0; i < 100010; i++) memo[i] = -1;
  memo[0] = 0;
  memo[1] = 1;
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1, 0);
  for (int i = 1; i <= n; i++) cin >> a[i];
  map<int, int> mp;
  for (int i = 1; i <= n; i++) {
    a[i] = (a[i] + a[i - 1]) % m;
  }
  for (int i = 1; i <= n; i++) {
    mp[a[i]]++;
  }
  long long ans = 0;
  for (auto kv: mp) {
    if (kv.first == 0) {
      ans += sum(kv.second);
    } else {
      ans += sum(kv.second - 1);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#define INF 1000000;

using namespace std;

int main() {
    int k, n;
    cin >> k >> n;
    int a[n+1];
    for (int i=0; i<n; i++){
        cin >> a[i];
    }
    a[n] = k+a[0];

    int max_d=0, d;
    for (int j=0; j<n; j++){
        d = a[j+1] - a[j];
        if (d > max_d){
            max_d = d;
        }

    }

    int min_d = k - max_d;
    cout << min_d << endl;


}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        for(int i=1;i<1251;i++)
        {
            int countA= (int) (i*0.08);
            int countB=(int)(i*0.1);
            if(countA==a&&countB==b)
            {
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);
    }
}


Measured memory_bytes: 22228
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cctype>
using namespace std;
int map[26];
int main(void) {
	string s;

	while (getline(cin, s) ) {
		for (int i = 0; i < s.length(); i++) {
			if (s[i] >= 'a' && s[i] <= 'z') {
				map[s[i] - 'a']++;
			}
			else if (s[i] >= 'A' && s[i] <= 'Z') {
				map[s[i] - 'A']++;
			}
		}
	}
	for (int i = 0; i < 26; i++) {
		cout << (char)('a' + i) << " : " << map[i]<<endl;
	}
}


Measured memory_bytes: 3172
#include <iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(W<x+r||0>x-r||H<y+r||0>y-r){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3088