akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 65;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
 int x,y;
 cin>>x>>y;
  for(int i=1;i<=20000;i++){
    int a = (int)(i * 0.08);
    int b = (int)(i * 0.1);
    if(a==x&&b==y){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())

class Drink:
	def __init__(self,price,qty):
		self.price=price
		self.qty=qty

drinks = []

for n in range(N):
	a,b=map(int,input().split())
	drinks.append(Drink(a,b))

count = 0
ans = 0

# greedy approach
priceSortedDrink=sorted(drinks, key=lambda d:d.price)

for d in priceSortedDrink:
	if M <= count + d.qty:
		ans = ans + d.price * (M-count)
		break
	else:
		ans += d.price * d.qty
		count += d.qty

print(ans)

Measured memory_bytes: 29080
N ,W = gets.split.map{|i| i.to_i}
w = Array.new(N)
v = Array.new(N)
for i in 0 .. N - 1
    w[i] , v[i] = gets.split.map{|i| i.to_i}
end

c = Hash.new
dp = Hash.new(10 ** 18)
dp[0] = 0
max = 0

for i in 0 .. N - 1

    dp.each do |key , value|

        if value + w[i] > W
            next
        end

        if dp[key + v[i]] > value + w[i]
            c[key + v[i]] = value + w[i]

            if key + v[i] > max
                max = key + v[i]
            end

        end

    end

    dp.merge!(c)
    c.clear

end

puts max

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

int main()
{
    int n;
    cin >> n;
    if ((n / 10) == 9 || n - (int)(n / 10) * 10==9)
    {
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
let n = Scanf.scanf " %d" @@ (+) 0
let ts = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let rec gcd a b = if b = 0 then a else gcd b (a mod b)
let rec lcm a b = a / gcd a b * b
let _ = Array.fold_left lcm 1 ts |> Printf.printf "%d\n"

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

string s;
int main() {
  cin >> s;
  i64 l = 0, r = s.size() - 1;
  for (; s[l] != 'A'; ++l);
  for (; s[r] != 'Z'; --r);
  cout << r - l + 1 << '\n';
  return 0;
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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;}


int main() {
  int n;cin >> n;
  ll ans=0;
  rep(i,n){
    int a;cin >> a;
    a--;ans+=a;
  }
  cout << ans;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
d = dict(Counter(list(map(int,input().split()))))
m = int(input())
t = list(map(int,input().split()))
check = True
for i in t:
  if i in d.keys():
    if d[i] > 0:
      d[i] -= 1
    else:
      check = False
      break
  else:
    check = False
    break
print("YES" if check else "NO")

Measured memory_bytes: 50496
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int N=1e5+5;
struct P {
    int val,id;
    bool operator <(const P &t)const {
        if(val!=t.val) return val>t.val;
        return id<t.id;
    }
}p[N*3];
int main() {
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    for(int i=0,d;i<a;i++) {
        scanf("%d",&d),p[i]={d,1};
    }
    for(int i=0,d;i<b;i++) {
        scanf("%d",&d),p[i+a]={d,2};
    }
    for(int i=0,d;i<c;i++) {
        scanf("%d",&d),p[i+a+b]={d,0};
    }
    a=a+b+c;
    sort(p,p+a);
    ll ans=0;
    int t=0;
    for(int i=0;i<a;i++) {
        if(p[i].id==1) {
            if(x) x--,ans+=p[i].val;
        }
        else if(p[i].id==2) {
            if(y) y--,ans+=p[i].val;
        }
        else {
            t++,ans+=p[i].val;
        }
        if(t==x+y) break;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long int LL;
const LL MOD(1000000000LL + 7LL);
const int Max_N(305);

void exgcd(const LL &a, const LL &b, LL &x, LL &y)
{
	if (b == 0LL)
		x = 1LL, y = 0LL;
	else
		exgcd(b, a % b, y, x), y -= x * (a / b);
}

inline LL inverse(const LL &a)
{
	LL invx, invy;
	exgcd(a, MOD, invx, invy);
	return (invx % MOD + MOD) % MOD;
}

inline LL Mult(const LL &a, const LL &b)
{
	return a * b % MOD;
}

int N, D[Max_N];
LL Fac[Max_N], Inv[Max_N];

void init()
{
	scanf("%d", &N);
	for (int i = 1;i <= N;++i)
		scanf("%d", D + i);
	Fac[0] = Inv[0] = 1LL;
	for (int i = 1;i <= N;++i)
	{
		Fac[i] = Mult(Fac[i - 1], i * 1LL);
		Inv[i] = inverse(Fac[i]);
	}
}

//假定我们已经得到一个环，大小为k（k >= 3），环上点要求度数为d1，d2，...，dk
//考虑一种新的prufer编码方式，不删除环上的点，只删除树上的点
//那么，树上的点出现次数必定为d-1，环上的点出现次数必定为d-2，并且序列的最后一个点是环上的点 
//编码总长度 = 西格玛(d - 1) - k = N - k 
//对答案的贡献为(k - 1)! / 2 * s! / xxx

inline void update(LL &a, const LL &b)
{
	(a += b) %= MOD;
}

LL Ans, F[Max_N][Max_N][2];
void dp()
{
	F[0][0][0] = 1LL;
	for (int i = 1;i <= N;++i)
		F[0][0][0] = Mult(F[0][0][0], Inv[D[i] - 1]);
	for (int i = 1;i <= N;++i)
	{
		for (int j = 0;j <= i - 1;++j)
			for (int c = 0;c <= 1;++c)
				F[i][j][c] = F[i - 1][j][c];
		if (D[i] >= 2)
			for (int j = 0;j <= i - 1;++j)
				for (int c = 0;c <= 1;++c)
					update(F[i][j + 1][c], Mult(F[i - 1][j][c], Mult(Fac[D[i] - 1], Inv[D[i] - 2])));
		if (D[i] >= 3)
			for (int j = 0;j <= i - 1;++j)
				update(F[i][j + 1][1], Mult(F[i - 1][j][0], Mult(Fac[D[i] - 1], Inv[D[i] - 3])));
	}
	for (int j = 3;j <= N - 1;++j)
		update(Ans, Mult(F[N][j][1], Mult(Mult(Fac[j - 1], inverse(2LL)), Fac[N - j - 1])));
	for (int i = 1;i <= N;++i)
		if (D[i] != 2)
			goto loop;
	update(Ans, Mult(Fac[N - 1], inverse(2LL)));
	loop :
	printf("%lld", Ans);
}

int main()
{
	init();
	dp();
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[1000];
    gets(a);
    int l=strlen(a);
    bool f=true;
    for(int i=0;i<l;i++)
    {
    	if(a[i]=='C')
		{
			for(int j=i;j<l;j++)
			{
				if(a[j]=='F')
				{
					f=false;
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	if(f)
	{
		cout<<"No";
	}
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x7fffffff
#define INFL 0x7fffffffffffffffLL

int main() {
	ll		b,c,i,j,k,n,m,x,y,ans = 0;
	string	str;

	cin >> n >> k;
	for(i=k;i<=n+1; i++) {
		x = (i-1)*i/2;
		y = (n + (n-i+1))*i/2;
		ans += y-x+1;
		ans = ans % 1000000007;
		//cout << i << ' ' << ans << endl;
	}
	//cout << endl;
	cout << ans << endl;

}


Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

int inputValue();
void inputArray(int *, int);
void inputVector(vector<int> *, int);
template <typename T> void output(T, int);
int gcd(int a, int b);

vector<bool> solve(string s) {
    vector<bool> ans(26);
    rep(i, s.length()) { ans[s[i] - 'a'] = ans[s[i] - 'a'] | true; }
    return ans;
}

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

    int ans = 0;
    repd(i, 1, n) {
        string a = s.substr(0, i), b = s.substr(i, n - i);
        vector<bool> result0 = solve(a), result1 = solve(b);
        int ans_temp = 0;
        rep(j, 26) {
            if (result0[j] && result1[j]) {
                ans_temp++;
            }
        }
        ans = max(ans, ans_temp);
    }

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

int inputValue() {
    int a;
    cin >> a;
    return a;
}

void inputArray(int *p, int a) {
    rep(i, a) { cin >> p[i]; }
}

void inputVector(vector<int> *p, int a) {
    rep(i, a) {
        int input;
        cin >> input;
        p->push_back(input);
    }
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

int gcd(int a, int b) {
    if (b > a) {
        int temp = a;
        a = b;
        b = temp;
    }
    if (b == 0) {
        return a;
    }
    return (b, b % a);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long

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

    int n,m,total=0;
    cin>>n>>m;
    int a[n+5];
    for(int i=0; i<n; i++){
        cin>>a[i];
        total += a[i];
    }
    double temp = 1.0/(4*m);
    int cnt = 0;
    for(int i=0; i<n; i++){
        if(a[i] >= total*temp){
            cnt++;
        }
    }
    if(cnt>=m)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー
#include <stack>
#include <bitset>

#define rep(i,m,n) for(int i=(m);i<(n);i++)
#define mer(i,m,n) for(int i=(m);i>(n);--i)

#define MOD 1000000007
//#define MOD 998244353
#define MAX 

using namespace std;

using ll = long long int;
using ld = long double;
using std::swap;

vector<int> v;
vector<int> w;
vector<long long int> vll;
vector<long long int> wll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<vector<int>> ww;
//vector<char> vc;
vector<string> vs;



int main() {
	int n;
	cin >> n;
	cout << n + n * n + n * n*n << '\n';

	return 0;
}

Measured memory_bytes: 3636
import sys
N = int(input())
s = 0
i = 1
x = 0
while s<=N:
  s += i
  if s==N:
    x = i
  i += 1
if x == 0:
  print('No')
  sys.exit()
print('Yes')
print(x+1)
anslis = []
i,j = 0,1
while len(anslis)<=x:
  anslis.append([x])
n = 1
while n <= N:
  anslis[i].append(n)
  anslis[j].append(n)
  if j < x:
    j += 1
  else:
    i += 1
    j = i+1
  n += 1
i = 0
for arrays in anslis:
  print(" ".join(map(str, arrays)))

Measured memory_bytes: 9076
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <math.h>
#include <string> 
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long n;
    cin >> n;
    if(n%10==3){
        cout << "bon" <<endl;
    }else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	ll n;
	cin>>n;
	vector<P> robot(n), robot_(n);
	rep(i,n){
		ll x,l;
		cin>>x>>l;
		robot[i].second = x-l;
		robot[i].first = x+l;

		// robot_[i].first = x-l+1;
		// robot_[i].second = x+l-1;
	}
	sort(all(robot));
	// sort(all(robot_));
	// reverse(all(robot_));

	ll pos = -INF*2LL;
	int ans = 0;
	rep(i,n){
		if(robot[i].second >= pos){
			ans++;
			pos = robot[i].first;
		}
	}


	// int ans_ = 0;
	// pos = INF*3LL;

	// rep(i,n){
	// 	if(robot_[i].second < pos){
	// 		ans_++;
	// 		pos = robot_[i].first;
	// 	}
	// }
	// ans = max(ans,ans_);
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <unistd.h>
#include <random>

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
    //    random_device rnd;
    //    mt19937 mt(rnd());
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    string S;
    cin >> N >> K >> S;
    S[K-1] += 0x20;
    cout << S << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <complex>
#include <cctype>
#include <exception>
#include <iostream>
using namespace std;

typedef string::iterator State;
typedef complex<int> C;

constexpr int LIMIT = 10000;

const C I = C(0, 1);

C expr(State&);
C term(State&);
C factor(State&);

string s;

int main() {
    while(cin >> s) {
        State st = s.begin();
        try {
            C ret = expr(st);
            if (real(ret) != 0 || imag(ret) == 0) {
                cout << real(ret);
            }
            if (real(ret) != 0 && imag(ret) > 0) {
                cout << "+";
            }
            if (imag(ret) != 0) {
                cout << imag(ret) << "i";
            }
            cout << endl;
        } catch (...) {
            cout << "overflow" << endl;
        }
    }
    return 0;
}

C expr(State& st) {
    C ret = term(st);

    while (st != s.end() && (*st == '+' || *st == '-')) {
        char oper = *st++;

        C t = term(st);

        if (abs(real(t)) > LIMIT || abs(imag(t)) > LIMIT) { throw "overflow"; }

        if (oper == '+') {
            ret += t;
        } else if (oper == '-') {
            ret -= t;
        }

        if (abs(real(ret)) > LIMIT || abs(imag(ret)) > LIMIT) { throw "overflow"; }
    }

    if (abs(real(ret)) > LIMIT || abs(imag(ret)) > LIMIT) { throw "overflow"; }

    if (st != s.end() && *st == ')') {
        ++st;
    }

    return ret;
}

C term(State& st) {
    C ret = factor(st);

    while (st != s.end() && *st == '*') {
        ++st; // *
        C f = factor(st);
        if (abs(real(f)) > LIMIT || abs(imag(f)) > LIMIT) {
            throw "overflow";
        }
        ret *= f;
        if (abs(real(ret)) > LIMIT || abs(imag(ret)) > LIMIT) {
            throw "overflow";
        }
    }

    if (abs(real(ret)) > LIMIT || abs(imag(ret)) > LIMIT) { throw "overflow"; }

    return ret;
}

C factor(State& st) {
    if (*st == '(') {
        return expr(++st);
    }

    if (*st == 'i') {
        ++st;
        return I;
    }

    int sign = 1;

    if (*st == '-') {
        sign = -1;
        ++st;
    }

    int r = 0;
    while (isdigit(*st)) {
        r = 10 * r + (*st++ - '0');
        if (r > 2 * LIMIT) {
            throw "overflow";
        }
    }

    return C(sign * r, 0);
}

/*
 * E := T | T + E
 * T := T | F * T
 * F = E | digit | i
 * digit = 0~9
 */

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define show(x) cout<<x<<'\n'
#define showh(x) cout<<x<<' '
#define go(i,a,n) for(ll i=a;i<n;i++)
#define gor(i,a,n) for(ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
bool prime[100001];
bool ispoweroftwo(ll x)
{
    return x && !(x & (x-1));
}
ll xorcal(ll n)
{
    if(n%4==0)
        return n;
    if(n%4==1)
        return 1;
    if(n%4==2)
        return n+1;
    if(n%4==3)
        return 0;
}
void sieve(ll n)
{
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }
        }
    }
    show(prime[89]);
}
bool isprime(ll n)
{
    if (n<=1) return false;
    if (n<=3) return true;

    if(n%2==0 or n%3==0) return false;

    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0 or n%(i+2)==0) return false;
    }
    return true;
}

ll modinverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m; a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}

ll gcd(ll a,ll b)
{
    if(a==0)
    {
        return b;
    }
    return(b%a,a);
}

ll power(ll A, ll B)
{
    if (A == 0)
        return 0;
    if (B == 0)
        return 1;

    ll y;
    if (B % 2 == 0) {
        y = power(A, B / 2);
        y = (y * y) % mod;
    }

    else {
        y = A % mod;
        y = (y * power(A, B - 1) % mod) % mod;
    }

    return (ll)((y + mod) % mod);
}
ll MinimumNumIncreasingSubsequences(ll arr[], ll n) 
{ 
    multiset<ll> last; 
  
    // last element in each  increasing subsequence  
    // found so far 
    for (ll i = 0; i < n; i++) { 
  
        // here our current element is arr[i] 
        multiset<ll>::iterator it = last.lower_bound(arr[i]); 
  
        // iterator to the first element larger  
        // than or equal to arr[i] 
        if (it == last.begin()) 
  
            // if all the elements in last larger 
            // than or to arr[i] then insert it into last 
            last.insert(arr[i]); 
  
        else { 
            it--; 
  
            // the largest element smaller than arr[i] is the number 
            // before *it which is it-- 
            last.erase(it); // erase the largest element smaller than arr[i] 
            last.insert(arr[i]); // and replace it with arr[i] 
        } 
    } 
    return last.size(); // our answer is the size of last 
} 
  

int main()
{
    ios_base::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    go(i,0,n)
    {
        cin>>a[i];
    }
    show(MinimumNumIncreasingSubsequences(a, n));
    return 0;
}


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

char s[101][101];

int dp[101][101];

int main()
{
	int H, W;
	scanf("%d%d", &H, &W);
	for(int i = 1; i <= H; i++)
		scanf("%s", s[i] + 1);
	dp[1][1] = (s[1][1] == '#');
	for(int i = 1; i <= H; i++)
	{
		for(int j = 1; j <= W; j++)
		{
			if(i == 1 && j == 1)
				continue;
			if(i == 1)
				dp[i][j] = dp[i][j-1] + (s[i][j-1] == '.' && s[i][j] == '#');
			else if(j == 1)
				dp[i][j] = dp[i-1][j] + (s[i-1][j] == '.' && s[i][j] == '#');
			else
				dp[i][j] = min(dp[i][j-1] + (s[i][j-1] == '.' && s[i][j] == '#'), dp[i-1][j] + (s[i-1][j] == '.' && s[i][j] == '#'));
		}
	}
	printf("%d\n", dp[H][W]);
	return 0;
}

Measured memory_bytes: 3860
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();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int min = a * x + b * y;
		if (x > y) {
			int total = c * 2 * y + (x - y) * a;
			if (total < min) { 
				min = total;
			}
			total = c * 2 * x;
			if (total < min) { 
				min = total;
			}
		} else {
			int total = c * 2 * x + (y - x) * b;
			if (total < min) { 
				min = total;
			}
			total = c * 2 * y;
			if (total < min) { 
				min = total;
			}
		}
		System.out.println(min);
	}
}


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

int main(){
    int N;
    long long Y;
    cin >> N;
    cin >> Y;
    bool found = false;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N - i; j++){    
                if(Y == 10000*i + 5000*j + 1000*(N - i - j)){
                    found = true;
                    cout << i << " " << j << " " << N - i - j <<endl;
                    break;
                }
        }
        if(found){
            break;
        }
    }
    if(found == false){
        cout << -1 << " " << -1 << " " << -1 <<endl;
    }
    return 0;
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s;cin>>s;
  int a=0,b=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='1')a++;
    else b++;
  }
  cout<<min(a,b)*2<<endl;


  return 0;
}


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

int main() {
  ll n; cin >> n;
  vector<ll> flog(n),dp(n-1);
  for(ll i=0;i<n;++i) cin >> flog[i];
  auto a = [](ll a, ll b){ return (a<b)? a:b; };

  dp[0] = 0;
  dp[1] = abs(flog[1] - flog[0]);
  for(ll i=2;i<n;++i) {
    dp[i] = a(dp[i - 1] + abs(flog[i - 1] - flog[i]),dp[i - 2] + abs(flog[i - 2] - flog[i]));
  }
  cout << dp[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll a[100005];
int main() {
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	ll count = 1;
	ll ans = 0;
	for (int i = 0; i < n-1; i++) {
		if (a[i] == a[i + 1]) {
			count++;
		}
		else {
			if (a[i] - count <= 0) {
				ans += min(abs(a[i] - count), count);
			}
			else {
				ans += count;
			}
			count = 1;
		}
	}
	if (a[n-1] - count <= 0) {
		ans += min(abs(a[n-1] - count), count);
	}
	else {
		ans += count;
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define itn int
#define rep(i, n) for (int i = 0; i < n; i++)
 
using namespace std;
typedef long long ll;
 
int main() {
    int N;
    cin >> N;
    int nowx=0;
    int nowy=0;
    int nowt=0;
    string ans="Yes";
    rep(i, N){
        int t;
        int x;
        int y;
        cin >> t >> x >> y;
        if(t-nowt<abs(x-nowx+y-nowy)){
            ans="No";
            break;
        }
        else if(t-nowt==abs(x-nowx+y-nowy)){
            nowt=t;
            nowx=x;
            nowy=y;
            continue;
        }
        else{
            if(abs(x - nowx + y - nowy - (t - nowt))%2==1){
                ans="No";
                break;
            }
            else{
                nowt = t;
                nowx = x;
                nowy = y;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    #define COUT(N) cout<<fixed<<setprecision(N)
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;

int main(){
    int a,b,c;
    cin >> a >> b >>c;
    if((a-b)*(c-b)*(a-c)!=0||(a-b==0 && a-c==0&& c-b==0))
    cout << "No";
    else cout << "Yes";

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i<=i##end;++i)
#define DREP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i>=i##end;--i)
template<typename T>bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
template<typename T>T read(){
	T x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define read() read<int>()
template<typename T>void write(T x,char c){
	static char t[25];
	static int tlen;
	t[tlen=1]=c;
	if(x<0)putchar('-'),x=-x;
	do t[++tlen]=(x%10)^48;
	while(x/=10);
	while(tlen)putchar(t[tlen--]);
}
#define pb push_back
typedef long long ll;
typedef double lf;
const int maxn=1005;
int n,m,A,B;
char s[maxn][maxn];
int main(){
	n=read(),m=read(),A=read(),B=read();
	REP(i,1,n)REP(j,1,m)s[i][j]='.';
	if(n&1){
		for(int i=1;(i+1<=m)&&(A);i+=2)
			s[1][i]='<',s[1][i+1]='>',--A;
	}
	if((m&1)&&(m!=1)&&(n!=1)){
		if(A)s[n][m-1]='<',s[n][m]='>',--A;
		if((A&1)&&(n>=2)){
			if((n&1)&&(m>=3))
				s[n-1][m-2]='<',s[n-1][m-1]='>',--A;
			if((!(n&1))&&(m>=2))
				s[n-1][m-1]='<',s[n-1][m]='>',--A;
		}
	}
	REP(j,1,m-1)
		REP(i,1,n)
			if((s[i][j]=='.')&&(s[i][j+1]=='.')&&(A))
				s[i][j]='<',s[i][j+1]='>',--A;
	REP(i,1,n-1)
		REP(j,1,m)
			if((s[i][j]=='.')&&(s[i+1][j]=='.')&&(B))
				s[i][j]='^',s[i+1][j]='v',--B;
	if((A)||(B))puts("NO");
	else{
		puts("YES");
		REP(i,1,n)puts(s[i]+1);
	}
	return 0;
}

Measured memory_bytes: 2176
import collections

if __name__ == '__main__':

    n = int(input())
    s = [input() for i in range(n)]
    c = collections.Counter(s).most_common()
    n = c[0][1]
    
    result = [i[0] for i in c if i[1] == n]
    
    for i in sorted(result):
        print(i)


Measured memory_bytes: 45040
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << (x) << std::endl
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF() { return std::numeric_limits<T>::max() / 16; }
std::mt19937 mt{std::random_device{}()};
template <typename T, typename A>
std::ostream& operator<<(std::ostream& os, const std::vector<T, A>& v)
{
    os << "[";
    for (const auto& p : v) { os << p << ","; }
    return (os << "]\n");
}
struct Graph
{
    Graph(const std::size_t v) : V{v}, edge(v), rev_edge(v) {}
    void addEdge(const std::size_t from, const std::size_t to) { edge[from].push_back(to), rev_edge[to].push_back(from); }
    const std::size_t V;
    std::vector<std::vector<std::size_t>> edge, rev_edge;
};

class SCC
{
public:
    SCC(const Graph& g) : size(g.V), comp(size, size)
    {
        for (std::size_t i = 0; i < size; i++) {
            for (const std::size_t to : g.edge[i]) { edge.push_back({i, to}); }
        }
        std::vector<std::size_t> st;
        std::vector<bool> used(size, false);
        auto dfs1 = [&](auto&& self, const std::size_t s) -> void {
            used[s] = true;
            for (const std::size_t to : g.edge[s]) {
                if (not used[to]) { self(self, to); }
            }
            st.push_back(s);
        };
        auto dfs2 = [&](auto&& self, const std::size_t s) -> void {
            comp[s] = comp_num;
            for (const std::size_t to : g.rev_edge[s]) {
                if (comp[to] != size) { continue; }
                self(self, to);
            }
        };
        for (std::size_t i = 0; i < size; i++) {
            if (used[i]) { continue; }
            dfs1(dfs1, i);
        }
        for (std::size_t i = 0; i < st.size(); i++) {
            const std::size_t s = st[st.size() - i - 1];
            if (comp[s] != size) { continue; }
            dfs2(dfs2, s), comp_num++;
        }
    }
    const std::vector<std::size_t>& getComp() const { return comp; }
    Graph toDAG() const
    {
        Graph dag(comp_num);
        for (const auto& e : edge) {
            const std::size_t u = comp[e.first], v = comp[e.second];
            if (u != v) { dag.addEdge(u, v); }
        }
        return dag;
    }

private:
    std::size_t size, comp_num = 0;
    std::vector<std::size_t> comp;
    std::vector<std::pair<std::size_t, std::size_t>> edge;
};
int main()
{
    int N, K, L;
    std::cin >> N >> K >> L;
    Graph g1(N), g2(N);
    for (int i = 0, p, q; i < K; i++) { std::cin >> p >> q, p--, q--, g1.addEdge(p, q), g1.addEdge(q, p); }
    for (int i = 0, p, q; i < L; i++) { std::cin >> p >> q, p--, q--, g2.addEdge(p, q), g2.addEdge(q, p); }
    const auto c1 = SCC(g1).getComp();
    const auto c2 = SCC(g2).getComp();
    using P = std::pair<int, int>;
    std::map<P, int> mp;
    for (int i = 0; i < N; i++) { mp[{c1[i], c2[i]}]++; }
    for (int i = 0; i < N; i++) { std::cout << mp[{c1[i], c2[i]}] << " "; }
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 46260
loop do
  m,f,r = gets.split.map(&:to_i)
  break if m == -1 && f == -1 && r == -1
  next puts "F" if m == -1 || f == -1 || m+f < 30
  next puts "D" if m+f < 50 && r < 50
  next puts "C" if m+f < 65
  next puts "B" if m+f < 80
  next puts "A"
end



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

int main(){
  int a,b;
  cin>>a>>b;
  if(b<10){
    if((int)(sqrt(10*a+b))*(int)(sqrt(10*a+b))==10*a+b){
      cout<<"Yes";
      return 0;
    }else{
      cout<<"No";
      return 0;
    }
  }
  if(b<100){
    if((int)(sqrt(100*a+b))*(int)(sqrt(100*a+b))==100*a+b){
      cout<<"Yes";
      return 0;
    }else{
      cout<<"No";
      return 0;
    }
  }
  if((int)(sqrt(1000*a+b))*(int)(sqrt(1000*a+b))==1000*a+b){
    cout<<"Yes";
    return 0;
  }else{
    cout<<"No";
    return 0;
  }
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  double oddCount = ceil(n / 2.0);
  double result = oddCount / n;

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;
int R,G,B,N;
int ans = 0;
signed main(void) {

    cin >> R >> G >> B >> N;

    int r = 0;

    while(R*r <= N){
        int g = 0;
        while(R*r + G*g <= N){
            int nokori = N - (R*r + G*g);
            if(nokori % B == 0){
                ans++;
            }
            g++;
        }
        r++;
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    if (N % 2 == 0) {
        cout << ((float)N / 2.0000000000) / (float)N;
    }
    else {
        cout << (((float)N + 1.0 )/ 2.0000000000) / (float)N;
    }
    return 0;
}


Measured memory_bytes: 256
s = gets.chomp.split('')
x, y = gets.split.map(&:to_i)

while s[0] == 'F'
    x -= 1
    s.shift
end

moves_x = []
moves_y = []
move_x = true
while s.length > 0 do
    if s[0] == 'T'
        move_x = !move_x
        s.shift
    else
        m = 0
        while s[0] == 'F' do
            s.shift
            m += 1
        end
        if move_x
            moves_x.push(m)
        else
            moves_y.push(m)
        end
    end
end

def check(moves, target)
    len = moves.length
    if len == 0
        return target == 0
    end
    total = moves.inject(:+)
    return false if (total + target) % 2 == 1
    return false if total < target.abs
    return true if total == target.abs
    target = (total - target.abs) / 2

    dp = Array.new(len){Array.new(target+1)}
    dp[0][0] = true
    dp[0][moves[0]] = true
    (1...len).each do |i|
        (0..target).each do |j|
            dp[i][j] = dp[i - 1][j]
            dp[i][j] ||= dp[i - 1][j - moves[i]] if j - moves[i] >= 0
        end
        return true if dp[i][target]
    end
    return dp[len - 1][target]
end

if check(moves_x, x) && check(moves_y, y)
    puts 'Yes'
else
    puts 'No'
end

Measured memory_bytes: 16508
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

signed main() {
  string s;
  cin >> s;
  string tmp = "CODEFESTIVAL2016";

  int cont = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != tmp[i]) cont++;
  }

  cout << cont << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    char_s = input()

    char_len = len(char_s)
    char_first = char_s[0:int((char_len-1)/2)]
    char_second = char_s[int((char_len+3)/2-1):char_len]

    flg_a = is_kaibun(char_s)
    flg_b = is_kaibun(char_first)
    flg_c = is_kaibun(char_second)

    if (flg_a==1) & (flg_b==1) & (flg_c==1):
        print('Yes')
    else:
        print('No')

def is_kaibun(str):

    strlen = len(str)
    for k in range(int(strlen/2)):
        if str[k] == str[strlen-k-1]:
            continue
        else:
            return 0

    return 1

if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include "iostream"
#include "string"

using namespace std;

int main() {
	string n;
	cin >> n;
	if (n[0] == n[1] && n[1] == n[2]) cout << "Yes" << endl;
	else if(n[1] == n[2] && n[2] == n[3]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline ll qp(int a,ll b,int mo){ll ans=1ll;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}


signed main() {


    int n, k;

    cin >> n >> k;

    ll sum = 0;
    vector<ll> v(k+1);
    for(int i = k; i > 0; i--) {
        v[i] = qp(k/i, n, SMOD);
        
        for(int j = i + i; j <= k; j += i) 
            v[i] = (SMOD + v[i] - v[j]) % SMOD;
        
        sum = (sum + (v[i] * i) % SMOD) % SMOD;
        
    }
    
    cout << sum << endl;
    
    return 0;
}



Measured memory_bytes: 4000
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	ll r = 0;
	ll g = 0;
	ll b = 0;
	REP(i, n) {
		switch(s[i]) {
			case 'R':
				r++;
				break;
			case 'G':
				g++;
				break;
			case 'B':
				b++;
				break;
		}
	}

	ll result = r * g * b;
	for(int i = 0; (i + 1) * 2 < n; i++) {
		for(int j = 0; j + (i + 1) * 2 < n; j++) {
			set<int> st;
			st.insert(s[j]);
			st.insert(s[j + (i + 1)]);
			st.insert(s[j + (i + 1) * 2]);
			result -= st.size() == 3 ? 1 : 0;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin>>h>>w;
    char a[10][10];
    FOR(i,1,h+1)FOR(j,1,w+1) cin>>a[i][j];
    int now=1;
    FOR(i,1,h+1)FOR(j,1,w+1){
      if(a[i][j]=='#'){
        if(j<now){
          cout<<"Impossible"<<endl;
          return 0;
        }else{
          now=j;
        }
      }
    }
    cout<<"Possible"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 100005;
int n, l, r, z[MX], ans;
string s;
int main(){
	cin >> n >> s;
	s += "#";
	rep(i,n){
		fill(z, z+n, 0);
		l = 0; r = 1;
		rep(j,n-i){
			if(z[j-l]+j < r) z[j] = z[j-l];
			else{
				for(l=j, r=max(r,j); s[r-l+i]==s[r+i]; r++);
				z[j] = r-l;
			}
			ans = max(ans, min(j,z[j]));
		}
	}
	printf("%d\n", ans);
}

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

int main()
{
    string ans = "consonant";
    char c;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'o' || c == 'e' ){
        ans = "vowel";
    }
    cout << ans << "\n";
    return 0;
}


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

int main() {
  int R;
  int G;
  // R,Gを宣言
  cin >> R >> G;
  // 入力結果をR,Gに代入
  cout << 2*G - R << endl;
  // 必要レートを出力
}

Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/



int main() {
int N;
cin>>N;
string s,t;
cin>>s>>t;
rep(i,N){
    if(s.substr(i,N-i)==t.substr(0,N-i)){
        cout<<i+N<<endl;
        return 0;
    }
}
cout<<2*N<<endl;

return 0;
}


Measured memory_bytes: 3600
mod=1000000007
n=int(input())
a=list(map(int,input().split()))
c=1
r=0
g=0
b=0
for x in a:
    tmp=0
    if x==b:
        tmp+=1
    if x==g:
        tmp+=1
    if x==r:
        tmp+=1
    if x==b:
        b+=1
    elif x==g:
        g+=1
    else :
        r+=1
    c*=tmp
    c%=mod
print(c)

Measured memory_bytes: 14056
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, k; 
  int X = 0;
  string C; 
  cin >> A >> B;
  k = 0;
  for (int j = A; j < B + 1; j++) {
    C = to_string(j);
    for (int i = 0; i < 2; i++) {
      if (C[i] == C[4 - i]) {
        X++;
      } 
      if (X == 2) {
        k++;
      }
    }
    X = 0;
  }
  cout << k << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,l,a[100000+2],d[100000+2];
const int INF=1000000000;

void solve(int x){
	if(d[x]==INF){
		int m=0;
		if(x!=0)if(a[x]<a[x-1]){solve(x-1); m=d[x-1];}
		if(x!=n-1)if(a[x]<a[x+1]){solve(x+1); if(m<d[x+1])m=d[x+1];}
		d[x]=l-a[x]+m;
	}
}

int main(){
	for(int i=0;i<100002;i++)d[i]=INF;
	scanf("%d%d",&n,&l);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	for(int i=0;i<n;i++){
		if(d[i]==INF)solve(i);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		if(ans<d[i])ans=d[i];
	}
	printf("%d\n",ans);
}

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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

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

    vector<vector<tuple<int, ll>>> g(N, vector<tuple<int,ll>>());

    rep(i,N-1){
        int a,b;
        ll c;
        cin >> a >> b;
        a--;
        b--;
        cin >> c;

        g[a].push_back(make_tuple(b, c));
        g[b].push_back(make_tuple(a, c));
    }

    int Q, K;
    cin >> Q >> K;
    K--;

    ll INF = 100100100100100100LL;

    vector<ll> cost(N,INF);
    cost[K] = 0;

    queue<int> q;
    q.push(K);

    while(!q.empty()){
        int cur = q.front();
        q.pop();

        for (auto t : g[cur]) {
            int n = get<0>(t);
            int c = get<1>(t);

            if(cost[n] != INF) continue;

            q.push(n);
            cost[n] = cost[cur] + c;
        }
    }


    rep(q,Q){
        int x,y;
        cin >> x >> y;
        x--;
        y--;

        cout << cost[x] + cost[y] << endl;
    }
}


Measured memory_bytes: 11588
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    vector<int> a(3, 0);
    for(int i=0;i<3;i++) cin >> a.at(i);
    sort(a.begin(), a.end());
    cout << (a.at(1) - a.at(0)) + (a.at(2) - a.at(1)) << endl;
    return 0;
}


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

int main() {

    int n;
    cin >> n;
    vector<vector<int>> graph(n);
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }        

    int black = 0;
    int white = 0;
    queue<int> que_snuke, que_fennec;
    vector<int> dis_snuke(n,-1), dis_fennec(n,-1);

    que_snuke.push(0);
    dis_snuke[0] = 0;
    while(!que_snuke.empty()){
        int v = que_snuke.front();
        que_snuke.pop();
        for(int c : graph[v]){
            if(dis_snuke[c] == -1){
                que_snuke.push(c);
                dis_snuke[c] = dis_snuke[v] + 1;
            }
        }
    }

    que_fennec.push(n-1);
    dis_fennec[n-1] = 0;
    while(!que_fennec.empty()){
        int v=que_fennec.front();
        que_fennec.pop();
        for(int c : graph[v]){
            if(dis_fennec[c] == -1){
                que_fennec.push(c);
                dis_fennec[c] = dis_fennec[v] + 1;
            }
        }
    }

    rep(i,n){
        if(dis_snuke[i] <= dis_fennec[i]){
            black++;
        }
        else{
            white++;
        }
    }
    if(black <= white){
        cout<<"Snuke"<<endl;
    }
    else{
        cout<<"Fennec"<<endl;
    }
    return 0;
}


Measured memory_bytes: 6528