akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:TYPE();}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:TYPE();}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=2005;

int n,a[MAXN*2],col[MAXN*2],pos[2][MAXN],pre[MAXN*2][2][MAXN],f[MAXN][MAXN];

int main()
{
	char str[2];
	readint(n);
	for(int i=1;i<=2*n;++i)
		scanf("%s",str),col[i]=(str[0]=='B'),readint(a[i]),pos[col[i]][a[i]]=i;
	for(int i=1;i<=2*n;++i)
	{
		for(int j=1;j<=i;++j)++pre[i][col[j]][a[j]];
		for(int k=0;k<=1;++k)for(int j=1;j<=n;++j)pre[i][k][j]+=pre[i][k][j-1];
	}
	for(int i=1;i<=n;++i)
		f[i][0]=f[i-1][0]+pos[0][i]-pre[pos[0][i]][0][i],
		f[0][i]=f[0][i-1]+pos[1][i]-pre[pos[1][i]][1][i];
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			f[i][j]=min(f[i-1][j]+pos[0][i]-pre[pos[0][i]][0][i]-pre[pos[0][i]][1][j],
				f[i][j-1]+pos[1][j]-pre[pos[1][j]][0][i]-pre[pos[1][j]][1][j]);
	printf("%d\n",f[n][n]);
	return 0;
}

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

int main ()
{
	lint n;
	//string tmp_s;
	vector<string> s;

	cin >> n;

	rep(i,n)
	{
		string sc;
		cin >> sc;
		s.push_back(sc);
	}
	// rep(i,n)
	// {
	// 	for (int j = i + 1; j < n; j++)
	// 	{
	// 		if (s[i] == s[j])
	// 			s.erase(s.begin() + j);
	// 	}
	// }
	sort(s.begin(), s.end());
	s.erase( unique(s.begin(), s.end()), s.end() );
	cout << s.size() << endl;
	return 0;
}

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

 int calc(int a,int b){
    if(b%a > 0) return b/a+1;
    else return b/a;
}

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    if(calc(b,c) <= calc(d,a)) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3628
from collections import deque

q=deque()
for i in range(int(input())):
	req=list(map(int,input().split()))
	if req[0]==0:
		if req[1]==0:
			q.appendleft(req[2])
		else:
			q.append(req[2])
	elif req[0]==1:
		print(q[req[1]],end='\n')
	else:
		if req[1]==0:
			q.popleft()
		else:
			q.pop()


Measured memory_bytes: 21980
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);


            var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int D = p[0];
            int N = p[1];

            long k = (long)Math.Pow(100, D);
            long ans = 0;
            for(var i = 1; i <= N; i++)
            {
                ans += k;
                if (ans % (100 * k) == 0)
                {
                    ans += k;
                }
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();
            
        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}



Measured memory_bytes: 13268
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	const long M = 1000000007;
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	int N;
	long A, D;
	long[] j, k, l, m;
	bool[] z;
	List<E>[] g;
	public K()
	{
		var I = G; N = I[0]; var Q = I[1];
		I = G; int s = I[0] - 1, t = I[1] - 1;
		g = new List<E>[N];
		for (var i = 0; i < N; i++) g[i] = new List<E>();
		for (var i = 0; i < Q; i++)
		{
			I = G; int a = I[0] - 1, b = I[1] - 1, c = I[2];
			g[a].Add(new E(b, c));
			g[b].Add(new E(a, c));
		}
		C(s, ref j, ref l);
		C(t, ref k, ref m);
		A = S(l[t]);
		D = j[t];
		z = new bool[N];
		B(t);
		WriteLine((A %= M) < 0 ? A + M : A);
	}
	long S(long x) => x * x % M;
	void B(int u)
	{
		if (z[u]) return;
		z[u] = true;
		if (2 * j[u] == D) A -= S(l[u] * m[u] % M);
		foreach (var e in g[u]) if (j[e.V] + e.D == j[u])
			{
				if (2 * j[u] > D && 2 * j[e.V] < D) A -= S(m[u] * l[e.V] % M);
				B(e.V);
			}
	}
	void C(int u, ref long[] d, ref long[] c)
	{
		d = new long[N]; c = new long[N];
		for (var v = 0; v < N; v++) d[v] = (long)4e18;
		var q = new Q();
		d[u] = 0; c[u] = 1;
		q.E(new E(u, 0));
		while (q.C > 0)
		{
			var p = q.D();
			var v = p.V;
			if (d[v] < p.D) continue;
			foreach (var e in g[v])
			{
				var t = d[v] + e.D;
				if (d[e.V] > t) { q.E(new E(e.V, d[e.V] = t)); c[e.V] = c[v]; }
				else if (d[e.V] == t) c[e.V] = (c[e.V] + c[v]) % M;
			}
		}
	}
}
struct E
{
	public readonly int V;
	public readonly long D;
	public E(int v, long d) { V = v; D = d; }
	public long C(E e) => D - e.D;
}
class Q
{
	List<E> a = new List<E>();
	public int C;
	public void E(E x)
	{
		var i = C++;
		a.Add(x);
		while (i > 0)
		{
			var p = (i - 1) / 2;
			if (a[p].C(x) <= 0) break;
			a[i] = a[p];
			i = p;
		}
		a[i] = x;
	}
	public E D()
	{
		var v = a[0];
		var x = a[--C];
		a.RemoveAt(C);
		if (C == 0) return v;
		var i = 0;
		while (i * 2 + 1 < C)
		{
			var l = 2 * i + 1;
			var r = 2 * i + 2;
			if (r < C && a[r].C(a[l]) < 0) l = r;
			if (a[l].C(x) >= 0) break;
			a[i] = a[l];
			i = l;
		}
		a[i] = x;
		return v;
	}
}


Measured memory_bytes: 55812
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

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

const int OO = (int) 2e9;
const double eps = 1e-9;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	int x, y, res;
	cin >> x >> y;
	if (x < 0) {
		if (abs(y) <= abs(x)) {
			res = abs(x) - abs(y) + bool(y > 0);
		} else {
			res = abs(y) - abs(x) + 1 + bool(y < 0);
		}
	} else {
		if (x <= abs(y)) {
			res = abs(y) - x + bool(y < 0);
		} else {
			res = x - abs(y) + 1 + bool(y > 0);
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = inp()
pp = list(map(float, input().split()))
dp = [[0]*(N+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1,N+1):
    p = pp[i-1]
    for n in range(N+1):
        if n == 0:
            dp[i][n] = dp[i-1][n]*(1-p)
        else:
            dp[i][n] = dp[i-1][n-1]*p + dp[i-1][n]*(1-p)

print(sum(dp[-1][N//2+1:]))


Measured memory_bytes: 259972
#include <iostream>
using namespace std;
int main(void){
    string a;
    cin>>a;
    if (a[0]=='a' || a[0]=='i' || a[0]=='u' || a[0]=='e' || a[0]=='o'){
        cout<<"vowel"<<endl;
    }
    else {
        cout<<"consonant"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    int a, b, c;
    cin >> a >> b >> c;
    
    // 最小値を求める
    if(a > b) swap(a,b);
    if(b > c) swap(b,c);
    if(a > b) swap(a,b);
    
    if(c == (a+b)) cout << "Yes" << endl;
    else cout << "No" << endl;

}

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

using namespace std;
//
#define krep(i,k,n)      for(int i=k;i<n;++i)
#define rep(i,n)         for(int i=0;i<n;++i)
#define toupp(s)         transform(s.begin(),s.end(),s.begin(),::toupper) // string
#define tolow(s)         transform(s.begin(),s.end(),s.begin(),::tolower) // string
#define pb(v)            push_back(v)
#define all(v)           v.begin(),v.end()
#define mp               make_pair
#define __sort(v)        sort(v.begin(),v.end()) // vector
#define __stable_sort(v) stable_sort(v.begin(),v.end()) // vector
#define __exists(c,v)    (find(all(c), (v)) != (c).end()) // vector
#define __unique(v)      __sort(v);v.erase(unique(v.begin(),v.end()),v.end()) // vector
#define __swap(a, b, tmp)  tmp=a;a=b;b=tmp;
#define __memset(a)      memset(a,0,sizeof(a));
//
#define dumpVar(v)       cerr<<setw(30)<<#v" = ["<<v<<"]"<<endl
#define dumpArr(v, n)    for(int i=0;i<n;++i){cerr<<v[i]<<", ";} cerr<<endl
#define dumpPair(p)      cerr<<"<"<<p.first<<", "<<p.second<<">"<<endl
//
typedef long long              ll;
typedef vector<string>         vs;
typedef vector<double>         vd;
typedef vector<int>            vi;
typedef pair<int, int>         pii;
typedef pair<double, double>   pdd;
//
int main ()
{
        ios::sync_with_stdio ( false );
        //
        /* code start */

        int N,K;
  int ans = 0;
  cin >> N >> K;
  rep(i,N){
    int tmp;
    cin >> tmp;
    if(tmp >= K){
      ans++;
    }

  }
  cout << ans << endl;

        /* code end   */
        //
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
	ll n;
	cin >> n;
	for (int a = 1; a <= 3500; a++)
	{
		for (int b = 1; b <= 3500; b++)
		{
			ll up = n*a*b;
			ll down = 4*a*b-n*a-n*b;
			if (down <= 0) continue;
			if (up % down == 0) {
				ll c = up / down;
				cout << a << ' ' << b << ' '<< c << endl;
				return 0;
			}
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 3632
use std::io;

fn main() {
    let _n = read_one::<usize>();
    let a = read::<usize>();
    let mut cnt = 0;
    for i in a.into_iter() {
        let mut i_mut = i;
        loop {
           if i_mut % 2 == 0 {
            cnt += 1;
            i_mut = i_mut / 2;
           } else {
               break;
           }
        }
    }

    println!("{}", cnt);
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
int main() {
	int a, b, k;
	std::cin >> a >> b >> k;
	int Q = std::min((b - a + 1) * 2, 2 * k);
	std::vector<int> s(Q);
	for (int i = 0;i < k;++i) {
		if (a + i <= b) {
			s[i] = a + i;
		}
	}
	for (int i = 0;i < k;++i) {
		if (b - i >= a) {
			s[i + std::min(k, b - a + 1)] = b - i;
		}
	}
	std::sort(s.begin(), s.end());
	s.erase(std::unique(s.begin(), s.end()), s.end());
	for (int i = 0;i < s.size();++i) {
		std::cout << s[i] << std::endl;
	}

	return 0;

}

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

typedef long double ld;

const int Inf = 1000000000;
const ld bInf = 1e300l;
const int Maxn = 100005;

int n;
int X[Maxn], Y[Maxn];
int dX[Maxn], dY[Maxn];
ld res = bInf;

void Update(ld tim)
{
    ld mnx = bInf, mxx = -bInf;
    ld mny = bInf, mxy = -bInf;
    for (int i = 0; i < n; i++) {
        ld myX = X[i] + tim * dX[i];
        ld myY = Y[i] + tim * dY[i];
        mnx = min(mnx, myX);
        mxx = max(mxx, myX);
        mny = min(mny, myY);
        mxy = max(mxy, myY);
    }
    res = min(res, (mxx - mnx) * (mxy - mny));
}

void Check(int lef, int rig, int sp)
{
    if (lef == Inf || lef == -Inf || rig == Inf || rig == -Inf) return;
    if (lef <= rig) Update(ld(rig - lef) / ld(sp));
}

void Solve(int X[], int dX[])
{
    int lefmn = Inf, lefmx = -Inf;
    int rigmn = Inf, rigmx = -Inf;
    int othmn = Inf, othmx = -Inf;
    for (int i = 0; i < n; i++)
        if (dX[i] == -1) {
            rigmn = min(rigmn, X[i]);
            rigmx = max(rigmx, X[i]);
        } else if (dX[i] == 1) {
            lefmn = min(lefmn, X[i]);
            lefmx = max(lefmx, X[i]);
        } else {
            othmn = min(othmn, X[i]);
            othmx = max(othmx, X[i]);
        }
    Check(lefmn, rigmn, 2);
    Check(lefmn, rigmx, 2);
    Check(lefmx, rigmn, 2);
    Check(lefmx, rigmx, 2);
    Check(lefmn, othmn, 1);
    Check(lefmn, othmx, 1);
    Check(lefmx, othmn, 1);
    Check(lefmx, othmx, 1);
    Check(othmn, rigmn, 1);
    Check(othmx, rigmn, 1);
    Check(othmn, rigmx, 1);
    Check(othmx, rigmx, 1);
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        char ch;
        scanf("%d %d %c", &X[i], &Y[i], &ch);
        if (ch == 'R') dX[i] = 1;
        else if (ch == 'L') dX[i] = -1;
        else if (ch == 'U') dY[i] = 1;
        else if (ch == 'D') dY[i] = -1;
    }
    Update(0);
    Solve(X, dX);
    Solve(Y, dY);
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
monster = list(map(int, input().split(' ')))
hero = tuple(map(int, input().split(' ')))

total = 0
for i in range(N):
    n = min(monster[i], hero[i])
    n_1 = min(monster[i+1], hero[i] - n)
    monster[i+1] -= n_1
    total += n + n_1
print(total)

Measured memory_bytes: 19244
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        var n = long.Parse(Console.ReadLine());
        var dic = new Dictionary<long, long>() { };
        for (int i = 0; i < n; i++)
        {
            var tmp = long.Parse(Console.ReadLine());
            if (!dic.ContainsKey(tmp))
            {
                dic.Add(tmp, 1);
            }
            else
            {
                dic[tmp]++;
            }
        }

        long ans = 0;
        foreach (var item in dic)
        {
            if (item.Value % 2 != 0)
            {
                ans++;
            }
        }
        Console.WriteLine(ans);
    }
}


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

#define rep(i, n) for (int i=0; i< (n); ++i)
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;

int main() {
    int n;

    cin >> n;

    if (n % 2 == 0) {
        cout << n/2 << endl;
    } else {
        cout << (n+1)/2 << endl;
    }
}


Measured memory_bytes: 256
#114_D
N=int(input())
prime=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]

def Count(x):
    res=0
    tmp=N
    while tmp//x:
        tmp=tmp//x
        res+=tmp
    return res

cnt=[Count(p) for p in prime]

def Sum(n):
    return sum([x>=n for x in cnt])

Ans=0
Ans=Sum(74)+Sum(24)*(Sum(2)-1)+Sum(14)*(Sum(4)-1)+Sum(4)*(Sum(4)-1)*(Sum(2)-2)//2
print(Ans)

Measured memory_bytes: 3064
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
const bool DEBUG = 1;
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>
#include <stdio.h>
#include <sys/time.h>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef pair<int, PP> IPP;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

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

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define LREP(i,n) LFOR(i,0,n)
#define LRFOR(i,a,b) for(ll i=(b)-1;i>=(a);--i)
#define LRREP(i,b,a) LRFOR(i,0,n)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define REACH(i,c) RREP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define BR cout << "\n"

#define dump(x) if(DEBUG)cerr<<"[" << __LINE__ << "] "<<#x<<"="<<(x)<<"\n"
#define dump2(x,y) if(DEBUG)cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
			<<" , "<<#y<<"="<<(y)<<"\n"
#define dump3(x,y,z) if(DEBUG)cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
			<<" , "<<#y<<"="<<(y)<<"\n"\
			<<" , "<<#z<<"="<<(z)<<"\n"

#define SAY(x) if(DEBUG) cerr << "[" << __LINE__ << "] " << (x) << "\n"

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

ll ans;
bool ok[100000];

int main() {
	omajinai;
	int n,m;
	cin >> n >> m;
	REP(i, m){
		int a,b;
		cin >> a >> b;
		a--;b--;
		ok[a] = !ok[a];
		ok[b] = !ok[b];
	}

	bool flag =1;
	REP(i, n) flag &= !ok[i];

	if(flag){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  reverse(ALL(a));
  for(int i = 1; i < n; ++i) {
    if(a[i-1] >= a[i]) continue;
    --a[i];
    if(a[i-1] < a[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;
    
    set<int> st;
    for(int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        st.insert(tmp);
    }

    cout << st.size() << endl;

    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

bool p[101000];

void prime() {
  fill(p, p+101000, true);
  p[0] = false;
  p[1] = false;
  for(int i = 2; i < 101000; i++) {
    if(p[i]) {
      for(int j = 2; i*j < 101000; j++) {
	p[i*j] = false;
      }
    }
  }
}

int main() {
  int n;
  prime();  

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

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
#define     __        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define     pi        acos(-1)
#define     ll        long long int
#define     fopen     freopen("in.txt","r",stdin)
#define     fwrite    freopen("o.txt","w",stdout)
#define     f0(n)     for(int i=0;i<n;i++)
#define     mem(a)    memset(a,0,sizeof(a))
#define     mems(a)   memset(a,-1,sizeof(a))

int main()
{
    __
    int n,ans=0;
    cin>>n;
    int a[n];
    f0(n) cin>>a[i];
    f0(n){
    if(a[i]==a[i+1]) a[i+1]=0;
    }
    f0(n){
    if(a[i]==0) ans++;
    }
    cout<<ans;
    return 0;
}


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

using namespace std;

int solve(vector<vector<int>> area) {
	// 隣接しているマス(8近傍)を左上から時計回り
	const vector<int> nh = {-1, -1, -1, 0, 1, 1, 1, 0};
	const vector<int> nw = {-1, 0, 1, 1, 1, 0, -1, -1};

	const int h_size = area.size();
	const int w_size = area[0].size();

	int ret = 0;
	vector<vector<int>> visited(h_size, vector<int>(w_size, 0));

	for (int h = 0; h < h_size; ++h) {
		for (int w = 0; w < w_size; ++w) {
			if (area[h][w] == 0) continue;		// 海
			if (visited[h][w] == 1) continue;	// すでに見た陸

			++ret;		// まだ見ていない陸をカウントする
			visited[h][w] = 1;
			queue<pair<int,int>> que;		// pair<int, int> で ２つの int 型を一つの型にまとめられる (pair<int, double> とかもできる)
			que.push(make_pair(h, w));		// push() で que に要素を追加する

			// 幅優先探索はここを指します。 queue を while で回すのが一般的です
			while(que.size()) {
				pair<int, int> now = que.front();	// front() で que に先に入れた要素を取得する
				que.pop();							// pop() で front() で取れる要素を削除する

				for (int i = 0; i < 8; ++i) {
					// 今見ている場所の周囲の座標を計算する
					int next_h = now.first + nh[i];		// .first で pair の1つ目の要素を得る
					int next_w = now.second + nw[i];	// .second で pair の2つ目のの要素を得る

					if (next_h < 0 || next_w < 0 ||
						next_h >= h_size || next_w >= w_size) continue;		// エリアは (0 <= h < h_size), (0 <= w < w_size) の範囲
					if (area[next_h][ next_w] == 0) continue;
					if (visited[next_h][next_w] == 1) continue;

					visited[next_h][next_w] = 1;
					que.push(make_pair(next_h, next_w));
				}
			}
		}
	}

	return ret;
}

int main() {
	int w, h;
	vector<vector<vector<int>>> area;

	// 終了条件は w == 0 && h == 0
	while (cin >> w >> h, !(w == 0 && h == 0)) {
		area.push_back(vector<vector<int>>(h, vector<int>(w)));		// [h][w] になる二次元配列
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				cin >> area.back()[i][j];		// back() は vector の一番後ろの要素を得られます。
			}
		}
	}

	for (auto check_area : area) {
		cout << solve(check_area) << endl;
	}

	return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ii, ii> iii;
int MOD = 10;
const ld E = 1e-9;
#define null NULL
#define ms(x) memset(x, 0, sizeof(x))
#ifndef LOCAL
#define endl "\n"
#endif
#ifndef LONG_LONG_MAX
#define LONG_LONG_MAX LLONG_MAX
#endif
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define _read(x) freopen(x, "r", stdin)
#define _write(x) freopen(x, "w", stdout)
#define files(x) _read(x ".in"); _write(x ".out")
#define filesdatsol(x) _read(x ".DAT"); _write(x ".SOL")
#define output _write("output.txt")
#define input _read("input.txt")
#define prev time_prev
#ifndef M_PI
#define M_PI acos(-1)
#endif
#define remove tipa_remove
#define next tipa_next
#define left tipa_left
#define right tipa_right
#define mod % MOD
#define y1 hello_world
unsigned char ccc;
bool _minus = false;
template<typename T>
inline T sqr(T t) {
	return (t * t);
}
inline void read(ll &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n')
			break;
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
}
inline bool read(int &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n') {
			if (ccc == '\n')
				return true;
			break;
		}
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
	return false;
}
char wwww[19];
int kkkk;
inline void write(ll y) {
	long long x = y;
	kkkk = 0;
	if (x < 0) {
		putchar('-');
		x *= -1;
	}
	if (!x)
		++kkkk, wwww[kkkk] = '0';
	else
		while (x) {
			++kkkk;
			wwww[kkkk] = char(x % 10 + '0');
			x /= 10;
		}
	for (int i = kkkk; i >= 1; --i)
		putchar(wwww[i]);
}
#ifdef LOCAL
#define DEBUG
#endif
#ifdef DEBUG
#define dbg if(1)
#else
#define dbg if(0)
#endif

int main() {
	sync;
	srand(time(NULL));
	cout.precision(10);
	cout << fixed;
#ifdef LOCAL
	input;
#else

#endif

	string t = "AKIHABARA";

	int pos = 0;

	string s;
	cin >> s;

	for(char c : s) {
		if(pos < (int) t.size() && t[pos] == c) {
			pos++;
			continue;
		}
		if(t[pos] == 'A') {
			pos++;
		}
		if(pos < (int) t.size() && t[pos] == c) {
			pos++;
			continue;
		}
		cout << "NO" << endl;
		return 0;
	}
	if(pos < (int) t.size() && t[pos] == 'A'){
		pos++;
	}
	if(pos < (int) t.size()){
		cout << "NO" << endl;
		return 0;
	}

	cout << "YES" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5,mod=1e9+7;
typedef long long ll;
ll inv(ll x){return x==1?x:(mod-mod/x)*inv(mod%x)%mod;}
ll f[N],invf[N],s[N];
ll C(int n,int m)
{
    return f[n]*invf[n-m]%mod*invf[m]%mod;
}
int main()
{
    f[0]=invf[0]=f[1]=invf[1]=1;
    for(int i=2;i<N;i++) f[i]=f[i-1]*i%mod,invf[i]=(mod-mod/i)*invf[mod%i]%mod;
    for(int i=2;i<N;i++) invf[i]=invf[i-1]*invf[i]%mod;
    int n;scanf("%d",&n);
    ll ans=0;
    for(int k=(n+1)/2;k<n;k++)
        s[k]=C(k-1,n-k-1)*f[k]%mod*f[n-1-k]%mod;
    for(int k=(n+1)/2;k<n;k++)
        ans=(ans+(s[k]-s[k-1])*k)%mod;
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 21632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  rep(i, N) cin >> L[i];
  int ans = 1;
  int cur = 0;
  for (int i = 0; i < N; i++) {
    cur += L[i];
    if (cur <= X) {
      ans++;
    } else break;
  }
  cout << ans << '\n';
  return 0;
}

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

#define MAXN (100010)

typedef long long ll;

int n, k, x[MAXN];

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", x + i);
    }
    int ans = INT_MAX;
    for (int j = 1; j <= n - k + 1; ++j) {
        int r = abs(x[j] - x[j + k - 1]) + std::min(abs(x[j]), abs(x[j + k - 1]));
        ans = std::min(ans, r);
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
   int a,b,c,d;
   int e,f,g,h;
   cin>>a>>b>>c>>d;
   cin>>e>>f>>g>>h;
   int x=a+b+c+d;
   int y=e+f+g+h;
   if(x>y){
       cout<<x<<endl;
   }
   else{
       cout<<y<<endl;
   }

}


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

int A, B;

int main() {
    cin >> A >> B;
    if (A >= 13) cout << B << endl;
    else if (6 <= A && A <= 12) cout << B / 2 << endl;
    else cout << 0 << endl;
    
    return 0;
}

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

int N;
map<int, int> mp;

int main(void){
    // Your code here!
    cin >> N;
    int a;
    for(int i = 0; i < N; i++){
        cin >> a;
        auto itr = mp.find(a); 
        if( itr != mp.end() ) {
            mp[a] += 1;
        } else {
            mp[a] = 1;
        }
    }
    
    int ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        if(itr->second < itr->first) {
            ans += itr->second;
        } else{
            ans += (itr->second - itr->first);
        }
    }
    
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 10010

ll N;
ll A[MAX_N] = {};

signed main()
{
    cin >> N;
    ll ans = 0;
    REP(i, N) {
        cin >> A[i];
        while(A[i] % 2 == 0) {
            A[i] /= 2;
            ans++;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define vi vector<int>
#define pi pair<int, int>
#define pb push_back
#define ppb pop_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()


using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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

	char a, b;
	cin >> a >> b;
	int n = a- '0';
	int m = b - '0';
	if(n <= m){
        for(int i = 0;i<m;i++) cout << a;
	}
	else for(int i = 0;i<n;i++) cout << b;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

#define FOR(var,start,end) for(int var=start; var<end; var++)
#define REP(var,cnt) FOR(var,0,cnt)

int A[200100];
vector<int> nonzeros;

int main(void) {
	
	int N;
	cin >> N;
	REP(i, N) {
		cin >> A[i];
		
		if ( A[i] != 0 ) {
			nonzeros.push_back(i);
		}
	}
	
	long long cnt = 0;
	REP(i, N) {
		int su = A[i];
		int xo = A[i];
		
		cnt++;
		
		int pcnt = 0;
		for(int j=i+1; j<N; j++) {
			
			if ( pcnt > 23 ) { break; }
			
			auto nex = std::lower_bound(nonzeros.begin(), nonzeros.end(), j);
			if ( nex == nonzeros.end() ) {
				cnt += (N-j);
				break;
			}
//			cout << "j: " << j << " next: " << *nex << endl;
			cnt += (*nex-j);
			j = *nex;
			
			su = su + A[j];
			xo = xo ^ A[j];
			pcnt++;
			
//			cout << i << " to " << i+pj << " su " << su << " xo " << xo << endl;
			
			if ( su != xo ) {
				break;
			}
			cnt++;
		}
	}
	
	cout << cnt << endl;
}


Measured memory_bytes: 1912
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N_MAX 100

struct card {
	char suite;
	int number;
	int order;
};

int check = 1;

int
card_key(void *arg)
{
	return ((struct card *)arg)->number;
}

void
print_card(struct card *a, int n)
{
	int i;

	for (i = 0; i < n; i++)
		printf("%s%c%d", i ? " " : "", a[i].suite, a[i].number);
	printf("\n");
}

int
bubble_sort(struct card *a, int n, int (*key)(void *))
{
	int i, flag = 1;
	struct card v;

	while (flag) {
		flag = 0;
		for (i = n - 1; i > 0;i--) {
			if (key(&a[i]) < key(&a[i - 1])) {
				v = a[i];
				a[i] = a[i - 1];
				a[i - 1] = v;
				flag = 1;
			}
		}
	}
}

void
selection_sort(struct card *a, int n, int (*key)(void *))
{
	int i, j, minj;
	struct card v;

	for (i = 0; i < n; i++) {
		if (i &&
		    (key(&a[i]) == key(&a[i - 1])) &&
		    (a[i].order < a[i-1].order))
			check = 0;
		minj = i;
		for (j = i + 1; j < n; j++)
			if (key(&a[j]) < key(&a[minj]))
				minj = j;
		if (i != minj) {
			v = a[i];
			a[i] = a[minj];
			a[minj] = v;
		}
	}
}

int
main(void)
{
	int p0, n = 0;
	struct card a[N_MAX];
	struct card b[N_MAX];
	char name[8];

	scanf("%d", &p0);

	if (p0 < 1 || N_MAX < p0)
		return 1;

	for (n = 0; n < p0; n++) {
		scanf("%s", name);
		a[n].suite = name[0];
		sscanf(name+1, "%d", &a[n].number);
		a[n].order = n;
	}
	memcpy(b, a, sizeof(a));

	bubble_sort(a, n, card_key);
	print_card(a, n);
	printf("%s\n", "Stable");

	selection_sort(b, n, card_key);
	print_card(b, n);
	printf("%s\n", check ? "Stable" : "Not stable");

	return 0;
}



Measured memory_bytes: 2092
#include <iostream>
#include <cstdlib>

using namespace std;

int main(void){
    int a=0;
    int b=0;
    int c=0;
    int d=0;

    cin >> a >> b >> c >> d;

    if(abs(c-a)<=d)cout << "Yes" << endl;
    else if(abs(a-b)<=d&&abs(b-c)<=d)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

using namespace std;

int n;
string s;

int main()
{
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int nr = 0;
    cin >> n >> s;
    for (int i = 2; i < s.length(); ++i) {
        if (s[i - 2] == 'A' && s[i - 1] == 'B' && s[i] == 'C')
            ++nr;
    }
    return cout << nr, 0;
}


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

using namespace std;

using ll = long long;

template <class T>
using grid = vector<vector<T>>;

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

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  REP(i, 5) {
    int input(x);
    if (x == 0) {
      print(i + 1);
      break;
    }
  }
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n, m;

  cin >> n >> m;

  int ans = n;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    ans -= a;
  }
  if (ans < 0) ans = -1;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3592
while ((n,x = gets.split(" ").map(&:to_i)).select{|i| i == 0}.length != 2) do
  r = []
  n.downto(1) do |n1|
    (n1-1).downto(1) do |n2|
      (n2-1).downto(1) do |n3|
        r<<[n1,n2,n3] if ((n1 + n2 + n3) == x)
      end
    end
  end
  puts r.length
end

Measured memory_bytes: 8760
s = input()
ue = int(s[:2])
sita = int(s[2:4])
if ue < 1 or ue > 12:
    if 1 <= sita <= 12:
        print('YYMM')
    if sita < 1 or sita > 12:
        print('NA')
elif sita < 1 or sita > 12:
    print('MMYY')
else:
    print('AMBIGUOUS')

Measured memory_bytes: 3060
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    string s;
    int l = 0;
    cin >> s;
    for(int i = 1; i < s.size() / 2; ++i){
        bool flag = true;
        rep(j, i){
            if(s[j] != s[j + i]){
                flag = false;
                break;
            }
        }
        if(flag){
            l = i;
        }
    }
    cout << l * 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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 n, m;
vector<int> a(200020);
vector<int> table(200020, INF);
vector<int> dp(200020);

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	cin >> n >> m;
	rep(i, n) cin >> a[i];
	rep(i, m) {
		int l, r;
		cin >> l >> r;
		l--; r--;
		chmin(table[r], l);
	}
	rep(i, n) chmin(table[i], i);
	for(int i = n-2; i >= 0; i--) {
		chmin(table[i], table[i+1]);
	}
	// rep(i, n) cout << table[i] << " ";
	// cout << endl;
	rep(i, n) {
		chmax(dp[i+1], dp[i]);
		chmax(dp[i+1], dp[table[i]] + a[i]);
	}
	cout << dp[n] << endl;
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  for (int i = S.length() - 3; i >= 0; i -= 2) {
    bool flag = true;
    for (int j = 0; j <= i / 2; j++) {
      if (S.at(j) != S.at(j + i / 2 + 1)) flag = false;
    }

    if (flag) {
      cout << i + 1 << endl;
      break;
    }
  }
  return 0;
}

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

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

    int N = s.size();
    int cnt;

    vector<int> ans(N);

    cnt = 0;
    for (int i = 0; i < N; i++)
    {
        if (s[i] == 'L')
        {
            ans[i - 1] += (cnt + 1) / 2;
            ans[i] += cnt / 2;

            cnt = 0;
        }

        else
        {
            cnt++;
        }
    }

    cnt = 0;
    for (int i = N - 1; i >= 0; i--)
    {
        if (s[i] == 'R')
        {
            ans[i + 1] += (cnt + 1) / 2;
            ans[i] += cnt / 2;

            cnt = 0;
        }

        else
        {
            cnt++;
        }
    }

    for (int i = 0; i < N; i++)
    {
        cout << ans[i] << (i != N - 1 ? " " : "\n");
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {

 int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A+B==C+D){
    cout<<"Balanced"<<endl;
  }
  else if(A+B>C+D){
    cout<<"Left"<<endl;
  }
  else if (A+B<C+D){
   cout<<"Right"<<endl;
  }
}  

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

constexpr int MAXN = 200005;
int n, m;
vector<int> starts[MAXN], finishes[MAXN];
bool is_active[MAXN];

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

    scanf(" %d %d", &n, &m);
    int a, b;
    for (int i = 0; i < m; ++i) {
        scanf(" %d %d", &a, &b);
        starts[a].push_back(i);
        finishes[b].push_back(i);
    }

    vector<int> active;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        for (int v : finishes[i]) {
            if (is_active[v]) {
                ++ans;
                for (int x : active) {
                    is_active[x] = false;
                }
                active.clear();
                break;
            }
        }

        for (int v : starts[i]) {
            active.push_back(v);
            is_active[v] = true;
        }
    }

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


Measured memory_bytes: 15484
#include <stdio.h>
#define MAX_H 300

int main(void) {
  int i, n;
  int A[MAX_H];
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
  }

  for (i = 1; i <= n; i++) {
    printf("node %d: key = %d, ", i, A[i]);
    if (i != 1) {
      printf("parent key = %d, ", A[i/2]);
    }
    if (2*i <= n) {
      printf("left key = %d, ", A[2*i]);
    }
    if (2*i + 1 <= n) {
      printf("right key = %d, ", A[2*i + 1]);
    }
    putchar('\n');
  }

  return 0;
}

Measured memory_bytes: 600
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int a, b;
  cin >> a >> b;
  a--;b--;
  cout << (b/a) + (b%a!=0) << endl;
}


Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

g = [[] for _ in range(N+1)]

for a, b in ab:
    g[a].append(b)
    g[b].append(a)

temp = deque([[1, 0]])
visited = [-1] * (N+1)
visited[0] = 0
visited[1] = 0

while temp:
    q = temp.popleft()
    for i in g[q[0]]:
        if visited[i] == -1:
            temp.append([i, q[1]+1])
            visited[i] = q[0]
if -1 in visited: print('No')
else:
    print('Yes')
    for i in visited[2:]:
        print(i)


Measured memory_bytes: 63336
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<string>
#include<string.h>
using namespace std;

class dice{
public:
	int a[7];
	int b;
	void moveN(){
		b = a[1];
		a[1] = a[2];
		a[2] = a[6];
		a[6] = a[5];
		a[5] = b;
	}
	void moveE(){
		b = a[3];
		a[3] = a[1];
		a[1] = a[4];
		a[4] = a[6];
		a[6] = b;
	}
	void moveW(){
		b = a[1];
		a[1] = a[3];
		a[3] = a[6];
		a[6] = a[4];
		a[4] = b;
	}
	void moveS(){
		b = a[2];
		a[2] = a[1];
		a[1] = a[5];
		a[5] = a[6];
		a[6] = b;
	}
	void spinR(){
		b = a[2];
		a[2] = a[4];
		a[4] = a[5];
		a[5] = a[3];
		a[3] = b;
	}
	void spinL(){
		b = a[2];
		a[2] = a[3];
		a[3] = a[5];
		a[5] = a[4];
		a[4] = b;
	}
};
int main(){
	dice A, B;
	int dif = 0;
	for (int i = 1; i < 7; i++){
		cin >> A.a[i];
	}
	for (int i = 1; i < 7; i++){
		cin >> B.a[i];
	}
	for (int i = 1; i <= 6; i++){
		int judge = 0;
		if (A.a[1] == B.a[i]){
			if (A.a[6] == B.a[7 - i]){
				if (i == 2){
					B.moveN();
				}
				if (i == 3){
					B.moveW();
				}
				if (i == 4){
					B.moveE();
				}
				if (i == 5){
					B.moveS();
				}
				if (i == 6){
					B.moveN();
					B.moveN();
				}
				for (int j = 1; j <= 4; j++){
					for (int k = 2; A.a[k] == B.a[k] && k <= 5; k++){
						judge++;
					}
					if (judge == 4){
						cout << "Yes" << endl;
						break;
					}
					else{
						judge = 0;
						B.spinL();
					}
				}
			}
		}
		if (judge < 4){
			dif++;
			if (dif == 6){
				cout << "No" << endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3112
//                             ¯\_(ツ)_/¯   
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mma,ava,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),(a).end()
#define ll long long
 
 
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
 
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	int D;
	scanf("%d",&D);
	std::vector<int> c(26);
	for(int i=0;i<26;i++)scanf("%d",&c[i]);
	std::vector<vector<int>> s(D,vector<int>(26));
	for(int i = 0;i<D;i++){
		for(int j=0;j<26;j++){
			scanf("%d",&s[i][j]);
		}
	}
	int curr = 0;
	std::vector<int> a(26);

	for(int i=0;i<26;i++)a[i]=i+1;
	random_shuffle(all(a));
	for(int i=1;i<=365;i++){
		printf("%d\n",a[curr++]);
		curr%=26;
	}
	
}

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

int main(){
    long long ans = 0,k;
    cin >> k;
    for(int a = 1 ; a <= k ; a += 1){
        for(int b = 1 ; b <= k ; b += 1){
            for(int c = 1 ; c <= k ; c += 1){
                ans += __gcd(a,__gcd(b,c));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636