akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intinf 1000000000
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
typedef long long ll;
using namespace std;

int n, cntev[123456], cntod[123456], v, mxod, mxev;
vector<int>mx;
bool f;
int main() {
	cin >> n;
	f = false;
	rep(111111)
		cntev[i] = cntod[i] = 0;
	rep(n) {
		cin >> v;
		if (f)
			cntev[v]++;
		else cntod[v]++;
		f = !f;
	}
	mxod = mxev = 0;
	rep(101010) {
		if (cntod[i] == cntev[i]) {
			mx.push_back(cntod[i]);
		}
		else {
			mxod = max(mxod, cntod[i]);
			mxev = max(mxev, cntev[i]);
		}
	}
	rep(mx.size()) {
		if (mxev < mxod)mxev = max(mxev, mx[i]);
		else mxod = max(mxod, mx[i]);
	}
	cout << n - mxod - mxev << endl;
	return 0;
}

Measured memory_bytes: 1788
import collections, itertools
N = int(input())
A = [int(_) for _ in input().split()]
C = sorted(collections.Counter(A).most_common(), key=lambda xs: -xs[1])
f = 0
if len(C) == 1:
    a, la = C[0]
    #a^a^a^
    if a == 0:
        f = 1
elif len(C) == 2:
    a, la = C[0]
    b, lb = C[1]
    #a^b^(a^b)^a^b^(a^b)^
    if la == lb * 2 and b == 0:
        f = 1
elif len(C) == 3:
    a, la = C[0]
    b, lb = C[1]
    c, lc = C[2]
    #x^y^(x^y)^x^y^(x^y)^
    if la == lb == lc and a ^ b == c:
        f = 1
if f:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 15520
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <math.h>
#include <string>
#include <math.h>

using namespace std;

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

const ll mod = 1000000007;
const ll INF = 1000000000000;
ll N, K, a[510], sum, ans;
vector<ll> divi;

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return pow_mod(x, y - 1) * x % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

int main()
{
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
		sum += a[i];
	}

	sum = abs(sum);

	for (int i = 1; i <= sqrt(sum); i++)
	{
		if (sum % i == 0)
		{
			divi.push_back(i);
			if (i != sqrt(sum))
			{
				divi.push_back(sum / i);
			}
		}
	}
	sort(divi.begin(), divi.end());

	for (int i = 0; i < divi.size(); i++)
	{
		ll b[510], par_sum = 0;
		for (int j = 0; j < N; j++)
		{
			b[j] = a[j] % divi[i];
			par_sum += b[j];
		}
		ll num = 0;
		sort(b, b + N);

		for (int j = 0; j < N - par_sum / divi[i]; j++)
		{
			num += b[j];
		}

		if (num <= K)
		{
			ans = divi[i];
		}
	}

	cout << ans << endl;

	int www;
	cin >> www;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int x,y,c=0,c1;
  cin>>x>>y;
 c=y-2*x;
  c=c/2;
  c1=x-c;
  if(c>=0&&c1>=0)
  {
   if(c+c1==x&&(4*c+2*c1==y))
      cout<<"Yes";
     else
      cout<<"No";
  }
  else
    cout<<"No";
      
    
  
   
   
return 0;


}


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

using namespace std;
typedef long long ll;

const int N=300000;
vector<int> tree(4*(N+5),0);

void update(int idx,int l,int r,int pos,int val)
{
    if(l==r) tree[idx]=val;
    else
    {
        int m=(l+r)/2;
        if(pos<=m) update(2*idx,l,m,pos,val);
        else update(2*idx+1,m+1,r,pos,val);
        tree[idx]=max(tree[2*idx],tree[2*idx+1]);
    }
}

int query(int idx,int l,int r,int ql,int qr)
{
    if(ql>qr) return 0;
    if(l==ql&&r==qr) return tree[idx];
    int m=(l+r)/2;
    return max(query(2*idx,l,m,ql,min(qr,m)),query(2*idx+1,m+1,r,max(ql,m+1),qr));
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    int res=0;
    for(int i=1;i<=n;i++)
    {
        int a;
        cin >> a;
        int now=query(1,1,N,clamp(a-k,1,N),clamp(a+k,1,N))+1;
        res=max(res,now);
        update(1,1,N,a,now);
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 7868
let
  K = parse(Int, readline())
  q = [1, 2, 3, 4, 5, 6, 7, 8, 9]
  for i = 1:K-1
    x = popfirst!(q)
    x%10 != 0 && push!(q, 10x + x%10 - 1)
    push!(q, 10x + x%10)
    x%10 != 9 && push!(q, 10x + x%10 + 1)
  end
  println(popfirst!(q))
end


Measured memory_bytes: 167112
n = int(input())
abc = [input() for i in range(3)]
d = [0]*n
for i in range(n):
    if abc[0][i]==abc[1][i]==abc[2][i]:
        d[i]=0
    elif abc[0][i]!=abc[1][i]!=abc[2][i]!=abc[0][i]:
        d[i]=2
    else:
        d[i]=1
print(sum(d))

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    long long cnt=0;
    while(a%2==0&&b%2==0&&c%2==0){
        if(a==b&&b==c){
            cout<<-1<<endl;
            return 0;
        }
        int ta=a,tb=b,tc=c;
        a=(tb+tc)/2;
        b=(tc+ta)/2;
        c=(ta+tb)/2;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

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

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	long long int n, a1, b;
	cin >> n >> a1 >> b;
	int flag = 0;
	if(n == a1){
		if(b == 1){
			for(int i = 0; i < n; i++){
				cout << i+1 << " ";
			}
			cout << '\n';
			return 0;
		}
		else{
			flag = 1;
		}
	}
	if(n == b){
		if(a1 == 1){
			for(int i = 0; i < n; i++){
				cout << n-i << " ";
			}
			cout << "\n";
			return 0;
		}
		else{
			flag = 1;
		}
	}
	if(a1 == 1 && b != n) flag = 1;
	if(a1 != n && b == 1) flag = 1;
	if(a1 > n || b > n){
		flag = 1;
	}
	if(flag == 1){
		cout << "-1\n";
		return 0;
	}
	int a[n];
	for(int i = 0; i < n; i++){
		a[i] = i;
	}
	for(int j = 0; j < b; j++){
		if(j > b-1-j){
			break;
		}
		swap(a[j], a[b-1-j]);
	}
	int x = 1;
	int rem = a1-1;
	int div = (n-b)/rem;
	int count = (n-b)%rem;
	if(div > b){
		cout << "-1\n";
		return 0;
	}
	// cout << "hi\n";
	// cout << div << " " << count << '\n';
	for(int i = b; i < n;){
		x++;
		int l = n - i;
		long long int size = div; 
		if(count > 0){
			size = min(size+count, b);
			count -= size - div;
		}
		for(int j = 0; j < size; j++){
			if(i+j > min(n,i+size)-1-j){
				break;
			}
			swap(a[i+j], a[min(n,i+size)-1-j]);
		}
		i += size;
	}
	// cout << x << '\n';
	if(x != a1){
		cout << "-1\n";
		return 0;
	}
	for(int i = 0; i < n; i++){
		cout << a[i]+1 << ' ';
	}
	cout << '\n';
	return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
   #include <vector>
    #include <algorithm>
    #include <queue>
    using namespace std;
    
    #define MAX_N 1001
    
   struct S {
       int y, x;
       S(int y, int x) : y(y), x(x) {}
   };
   
   const int dy[] = {0, 1, 0, -1},
             dx[] = {1, 0, -1, 0};
   
   int W, H, N;
   int X1[MAX_N], Y1[MAX_N], X2[MAX_N], Y2[MAX_N];
   
   int compress(int *x1, int *x2, int w) {
       vector<int> xs;
      for (int i = 0; i < N; i++) {
           if (x1[i] - 1 >= 0) xs.push_back(x1[i] - 1);
           xs.push_back(x1[i]);
           xs.push_back(x2[i] - 1);
           if (x2[i] < w) xs.push_back(x2[i]);
       }
       sort(xs.begin(), xs.end());
       xs.erase(unique(xs.begin(), xs.end()), xs.end());
       for (int i = 0; i < N; i++) {
           x1[i] = lower_bound(xs.begin(), xs.end(), x1[i]) - xs.begin();
           x2[i] = lower_bound(xs.begin(), xs.end(), x2[i]) - xs.begin();
       }
       return xs.size();
   }
   
   int main() {
       while (scanf("%d %d", &W, &H), W || H) {
           scanf("%d", &N);
           for (int i = 0; i < N; i++) {
               scanf("%d %d %d %d", &X1[i], &Y1[i], &X2[i], &Y2[i]);
           }
          int w = compress(X1, X2, W);
           int h = compress(Y1, Y2, H);
   
           bool F[h][w]; memset(F, 0, sizeof(F));
           for (int n = 0; n < N; n++) {
               for (int i = Y1[n]; i < Y2[n]; i++) {
                   for (int j = X1[n]; j < X2[n]; j++) {
                       F[i][j] = true;
                   }
               }
           }
   
           bool used[h][w]; memset(used, 0, sizeof(used));
          int cnt = 0;
           for (int y = 0; y < h; y++) {
               for (int x = 0; x < w; x++) {
                   if (!used[y][x] && !F[y][x]) {
                       cnt++;
                       used[y][x] = true;
                       queue<S> q; q.push(S(y, x));
                       while (!q.empty()) {
                           S s = q.front(); q.pop();
                           for (int i = 0; i < 4; i++) {
                               int ny = s.y + dy[i], nx = s.x + dx[i];
                               if (!(0 <= ny && ny < h && 0 <= nx && nx < w)) continue;
                               if (!used[ny][nx] && !F[ny][nx]) {
                                   used[ny][nx] = true;
                                   q.push(S(ny, nx));
                               }
                           }
                       }
                   }
               }
           }
   
           printf("%d\n", cnt);
       }
     return 0;
   }

Measured memory_bytes: 4612
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define PI 3.14159265359

int main(){
    string s, t;
    cin >> s;
    cin >> t;
    sort(all(s));
    sort(rall(t));
    if( s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 2000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
long long dp[2000] = {};
int main() {
#define int long long
	int n,m;
	cin >> n >> m;
	vector<tuple<int, int, int>> wow;
	REP(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		wow.push_back(make_tuple(a, b, -c));
	}
	for (int i = 2;i <= n;++i) {
		dp[i] = LONG_INF;
	}
	for (int i = 0;i < n*2;++i) {
		for (int q = 0;q < m;++q) {
			if (dp[get<0>(wow[q])] != LONG_INF&&dp[get<0>(wow[q])] + get<2>(wow[q]) < dp[get<1>(wow[q])]) {
				dp[get<1>(wow[q])] = dp[get<0>(wow[q])] + get<2>(wow[q]);
			}
		}
	}
	for (int i = 0;i < n;++i) {
		for (int q = 0;q < m;++q) {
			if (dp[get<0>(wow[q])] != LONG_INF&&dp[get<0>(wow[q])] + get<2>(wow[q]) < dp[get<1>(wow[q])]) {
				dp[get<1>(wow[q])] = dp[get<0>(wow[q])] + get<2>(wow[q]);
				if (get<1>(wow[q]) == n) {
					cout << "inf" << endl;
					return 0;
				}
			}
		}
	}
	cout << -dp[n] << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> c(n);
  rep(i, 0, n) {
    cin >> a[i];
    c[a[i]-1]++;
  }
  
  ll ans = 0;
  rep(i, 0, n)
    ans += c[i]*(c[i]-1)/2;    
  
  rep(i, 0, n) {
    ll y = a[i] -1;
    cout << ans - (c[y]-1)*c[y]/2 + (c[y]-1)*(c[y]-2)/2 << "\n";
  }

}


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

int main(){
  int count, N;
  long long D, D2;
  long long x, y;
  count = 0;
  cin >> N >> D;
  D2 = D*D;
for(int i = 0; i < N; i++) {
 cin >> x >> y;
  long long n;  n = (x*x) + (y*y);
  if(n <= D2)
    count++;
}
  cout << count <<endl;
}

Measured memory_bytes: 3612
#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() {
  string s;
  cin >> s;
  int front, back;
  front = stoi(s.substr(0, 2));
  back = stoi(s.substr(2, 2));
  
  if(front >= 1 && front <= 12) {
    if(back >= 1 && back <= 12) {
    	cout << "AMBIGUOUS" << endl;
      	return 0;
    }else {
    	cout << "MMYY" << endl;
      	return 0;
    }
  }else {
  	if(back >= 1 && back <= 12) {
    	cout << "YYMM" << endl;
      	return 0;
    }
  }
  cout << "NA" << endl;
  return 0;
}


Measured memory_bytes: 3632
N,M = map(int,input().split())
S = [list(map(int,input().split())) for _ in range(M)]
ans = [0 for _ in range(N)]
check = [0 for _ in range(N)]
e = 0
for i in range(M):
    s = S[i][0]
    c = S[i][1]
    if check[s-1] == 0:
        check[s-1] = 1
        ans[s-1] = c
    else:
        if ans[s-1] != c:
            e = 1
            break
if e == 1:
    print(-1)
else:
    if ans[0] == 0:
        if N == 1:
            print(0)
        else:
            if check[0] == 0:
                ans[0] = 1
                d = 0
                for i in range(N):
                    d += ans[i] * (10 ** (N-1-i))
                print(d)
            else:
                print(-1)

    else:
        d = 0
        for i in range(N):
            d += ans[i] * (10 ** (N-1-i))
        print(d)

Measured memory_bytes: 3064
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string[] kaisujikan = ReadLine().Split(' ');
        int kaisu = int.Parse(kaisujikan[0]);
        int jikan = int.Parse(kaisujikan[1]);
        string[] timeitemp= ReadLine().Split(' ');
        int[] timei = new int[kaisu];
        for(int i=0;i<kaisu;i++){
            timei[i] = int.Parse(timeitemp[i]);
        }
        long count = jikan;
        for(int i=1;i<kaisu;i++){
            if(timei[i] <= timei[i-1]+jikan){
                count += timei[i] - timei[i-1];
            }else{
                count += jikan;
            }
        }
        WriteLine(count);
    }
}

Measured memory_bytes: 28256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    ll N;
    cin>>N;
    v A(N);
    rep(i,0,N)cin>>A[i];
    ll ans = 0, a_min = A[0];
    rep(i,0,N){
        if(A[i] >= a_min){
            a_min = A[i];
        }
        else{
            ans += a_min-A[i];
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4836
import numpy as np
from numba import njit
N = np.array([int(_) for _ in input()])
dp = np.array([[0, 0] for _ in range(len(N))])


@njit
def solve(N, dp):
    dp[0, 0] = min(N[0], 11 - N[0])
    dp[0, 1] = min(N[0] + 1, 10 - N[0])
    for i in range(1, len(N)):
        dp[i, 0] = min(dp[i - 1, 0] + N[i], dp[i - 1, 1] + 10 - N[i])
        dp[i, 1] = min(dp[i - 1, 0] + N[i] + 1, dp[i - 1, 1] + 9 - N[i])
    print(dp[-1][0])


solve(N, dp)


Measured memory_bytes: 202376
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<tgmath.h>
using namespace std;

#define lld long long

int main(){
    lld X;
    cin >> X;
    lld ans = X / 500 * 1000;
    lld tmp = X % 500;
    ans += tmp / 5 * 5;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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




/******************************************************************************************/

ll sum[200005];


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

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

	for (int i = 1; i <= n; i++)
	{
		sum[i] = sum[i - 1] + a[i - 1];
	}
	
	ll ans = 1LL << 60;


	for (int i = 0; i <= n; i++)
	{

		int low = 0, high = i;
		while (high - low > 1) {
			int mid = (low + high) / 2;
			if (sum[mid] >= sum[i] - sum[mid]) high = mid;
			else low = mid;
		}
		ll P = sum[low];
		ll Q = sum[i] - sum[low];
		ll P2 = sum[high];
		ll Q2 = sum[i] - sum[high];
		ll left_min = min(P, Q);
		ll left_max = max(P, Q);
		if (abs(P2 - Q2) < abs(P - Q)) {
			left_min = min(P2, Q2), left_max = max(P2, Q2);
		}

		low = i, high = n;
		while (high - low > 1) {
			int mid = (low + high) / 2;
			if (sum[mid] - sum[i] >= sum[n] - sum[mid]) high = mid;
			else low = mid;
		}
		ll R = sum[low] - sum[i];
		ll S = sum[n] - sum[low];
		ll R2 = sum[high] - sum[i];
		ll S2 = sum[n] - sum[high];
		ll right_min = min(R, S);
		ll right_max = max(R, S);
		if (abs(R2 - S2) < abs(R - S)) {
			right_min = min(R2, S2), right_max = max(R2, S2);
		}

		ans = min(ans, max(left_max, right_max) - min(left_min, right_min));

	}

	cout << ans << endl;


	return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		double l = 0, r = A.Max() * 3;
		for(int _=200;_ >= 0; _--){
			double c = (l + r) * 0.5;
			int cnt = 0;
			for(int i=0;i<N;i++){
				double k = A[i] / c;
				cnt += (int) k;
				if(k - (int) k == 0) cnt--;
			}
			if(cnt <= K){
				r = c;
			} else {
				l = c;
			}
		}
		
		Console.WriteLine((int)Math.Ceiling((l + r) * 0.5));
		
		
		
		
	}
	int N,K;
	double[] A;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
		A = rda();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

typedef long long ll;
#define rep(i,n) for( ll (i)=0; (i)<(n); ++(i) )
#define rpi(i,n) for( int (i)=0; (i)<(n); ++(i) )
#define rpv(d) for(auto& v:d)
#if __cplusplus < 201703L
  std::ostream& co_(){ return std::cout << std::endl; }
  std::istream& cn_(){ return std::cin; }
  template<class Head, class... Args>
  std::ostream& co_( Head&& head, Args&&... args ){ std::cout << head; return co_(std::forward<Args>(args)...); }
  template<class Head, class... Args>
  std::istream& cn_( Head&& head, Args&&... args ){ std::cin >> head; return cn_(std::forward<Args>(args)...); }
#else
  template<class... Args>
  std::ostream& co_( Args... args ){ return std::cout << ... << args << std::endl; }
  template<class... Args>
  std::istream& cn_( Args... args ){ return std::cin >> ... >> args; }
#endif
#define co(...) co_(__VA_ARGS__);
#define cn(...) cn_(__VA_ARGS__);
#define all(x) (x).begin(), (x).end()
#define rgt(x,i) (x).begin(), (x).begin()+(i)

int main(){
  string s;cn(s)
  string h,b;
  bool sw = false;
  ll q;cn(q)
  rep(i,q){
    int t;cn(t)
    if (t==1){
      sw = !sw;
    }else{
      int f;char c;cn(f,c)
      if ((f==1&&sw)||(f==2&&(!sw))){
        h.push_back(c);
      }else{
        b.push_back(c);
      }
    }
  }
  if (!sw){
    for(auto v=b.rbegin(),e=b.rend();v!=e;++v){
      cout << *v;
    }
    co(s,h)
  }else{
    for(auto v=h.rbegin(),e=h.rend();v!=e;++v){
      cout << *v;
    }
    for(auto v=s.rbegin(),e=s.rend();v!=e;++v){ cout << *v; }
    co(b)
  }
}

Measured memory_bytes: 1088
// D - 11

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
const ll MOD = 1e9 + 7;

class Comb {
private:
	int MOD;
	long long* fac;
	long long* finv;
	long long* inv;
public:
	// 事前にテーブルを作成
	Comb(int MAX, int MOD) {
		this->MOD = MOD;

		fac = new long long[MAX + 1];
		finv = new long long[MAX + 1];
		inv = new long long[MAX + 1];

		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for (int i = 2; i <= MAX; i++) {
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}

	~Comb() {
		delete[] fac, finv, inv;
	}

	// 二項係数計算
	long long calc(int n, int k){
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}
};

int a[100000];

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

	map<int, int> cnt;
	int dup, dup1_idx, dup2_idx;
	for (int i=0; i<n+1; i++) {
		cin >> a[i];
		cnt[a[i]]++;
		if (cnt[a[i]] == 2) {
			dup2_idx = i;
			dup = a[i];
		}
	}

	for (int i=0; i<n+1; i++) {
		if (a[i] == dup) {
			dup1_idx = i;
			break;
		}
	}

	int inter_dup = dup2_idx - dup1_idx - 1; // 重複する要素の間の数
	//cout << "inter dup: " << inter_dup << endl; // **** debug ****

	Comb comb = Comb(n, MOD);

	// k = 1
	cout << n << endl;

	for (int k=2; k <= n+1; k++) {
		// ---- 重複要素を両方選ぶ ---- //
		ll c1 = comb.calc((n+1) - 2, k-2);

		// ---- 重複要素を片方選ぶ ----
		ll c2, c2_1, c2_2;
		// 重複要素の間を選ばない場合
		if ((n+1) - inter_dup - 2 >= k-1) {
			c2_1 = comb.calc((n+1) - inter_dup - 2, k-1);
		} else {
			c2_1 = 0;
		}

		// 重複要素の間を選ぶ場合
		c2_2 = (2 * (comb.calc((n+1) - 2, k-1) + MOD - c2_1) % MOD)  % MOD;

		c2 = (c2_1 + c2_2) % MOD;

		// ---- 重複要素を一つも選ばない ----
		ll c3 = comb.calc((n+1)-2, k);

		// ---- 上記の和が答え ----
		//cout << "k=" << k << " c1=" << c1 << " c2=" << c2 << " c3=" << c3 << endl; // **** debug ****
		//cout << "c2_1=" << c2_1 << " c2_2=" << c2_2 << endl; // **** debug ****
		cout << (((c1 + c2) % MOD) + c3) % MOD << endl;
	}

	return 0;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(); cout.tie();
    string s;
    cin>>s;
    if(s[0]=='R' && s[1]=='R'&&s[2]=='R')
    cout<<'3';
    else if( (s[0]=='R' && s[1]=='R') || (s[1]=='R'&&s[2]=='R')) cout<<2;
    else if(s[0]=='R' || s[1]=='R'||s[2]=='R')cout<<1;
    else cout<<0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define mod 1000000007
#define reg register
#define maxn 2000006
using namespace std;
int inv[maxn], fac[maxn], ifac[maxn], X1, X2, X3, X4, X5, X6,  Y1, Y2, Y3, Y4, Y5, Y6;
int f[maxn], g[maxn], ans;
int inc(int x, int y){
    return x + y >= mod ? x + y - mod : x + y;
}
int C(int x, int y){
    return 1ll * fac[x] * ifac[y] % mod * ifac[x - y] % mod;
}
int get_dis(int x1, int y1, int x2, int y2){
    int lenx = abs(x2 - x1), leny = abs(y2 - y1);
    return C(lenx + leny, lenx);
}
int get2(int x, int y, int l, int r, int d, int u){
    int res = 0;
    res = inc(get_dis(x, y, r + 1, u + 1), res);
    res = inc(mod - get_dis(x, y, l, u + 1), res);
    res = inc(mod - get_dis(x, y, r + 1, d), res);
    res = inc(get_dis(x, y, l, d), res);
    return res;
}
int get1(int x, int y, int l, int r, int d, int u){
    int res = 0;
    res = inc(res, get_dis(x, y, r, u));
    res = inc(res, mod - get_dis(x, y, l - 1, u));
    res = inc(res, mod - get_dis(x, y, r, d - 1));
    res = inc(res, get_dis(x, y, l - 1, d - 1));
    return res;
}
int main(){
    cin >> X1 >> X2 >> X3 >> X4 >> X5 >> X6;
    cin >> Y1 >> Y2 >> Y3 >> Y4 >> Y5 >> Y6;
    inv[0] = 1; ifac[0] = 1; fac[0] = 1;
    for(int i = 1; i < maxn; i++) {
        fac[i] = 1ll * fac[i - 1] * i % mod;
        inv[i] = (i == 1) ? 1 : 1ll * inv[mod % i] * (mod - mod / i) % mod;
        ifac[i] = 1ll * ifac[i - 1] * inv[i] % mod;
    }
    for(int i = Y3; i <= Y4; i++) {
        f[i] = get1(X4, i, X1, X2, Y1, Y2);
        f[i] = 1ll * f[i] * get2(X4 + 1, i, X5, X6, Y5, Y6) % mod;
        f[i] = 1ll * f[i] * (X4 + i + 1) % mod;
        ans = inc(ans, f[i]);
    }
    for(int i = X3; i <= X4; i++) {
        g[i] = get1(i, Y4, X1, X2, Y1, Y2);
        g[i] = 1ll * g[i] * get2(i, Y4 + 1, X5, X6, Y5, Y6) % mod;
        g[i] = 1ll * g[i] * (i + Y4 + 1) % mod;
        ans = inc(ans, g[i]);
    }
    //cout << ans << endl;
    for(int i = Y3; i <= Y4; i++) {
        f[i] = get1(X3 - 1, i, X1, X2, Y1, Y2);
        f[i] = 1ll * f[i] * get2(X3, i, X5, X6, Y5, Y6) % mod;
        f[i] = 1ll * f[i] * (mod - X3 - i) % mod;
        ans = inc(ans, f[i]);
    }
   // cout << 
    for(int i = X3; i <= X4; i++) {
        g[i] = get1(i, Y3 - 1, X1, X2, Y1, Y2);
        g[i] = 1ll * g[i] * get2(i, Y3, X5, X6, Y5, Y6) % mod;
        g[i] = 1ll * g[i] * (mod - Y3 - i) % mod;
        ans = inc(ans, g[i]);
    }
    cout << ans << endl;
}

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

int main (){
  int A,B,C,X;
  cin >> A >> B >> C >>X;
  //int n = x/50;
  
  int cnt =0;
  for(int i =0;i<=A;i++){
   for(int j=0;j<=B;j++){
     for(int k=0;k<=C;k++){
       if(500*i+100*j+50*k ==X)cnt++;
     }
   }
  }
  
  cout <<cnt<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define For(i,x,y) for(int i=x; i<y; ++i)
#define mem(x,y) memset(x,y,sizeof(x))
#define ALL(a) a.begin(),a.end()
#define PII pair<int,int>
#define INF 0x3f3f3f3f
#define DOF 0x7f7f7f7f
#define se second
#define fi first
#define endl '\n'
 
template <typename T>
inline void read(T &r){
    static char c; r=0; int f=1;
    for(c=getchar(); c<'0'||c>'9'; c=getchar()) if(c=='-')f=-1;
    for(; c>='0'&&c<='9'; r=(r<<1)+(r<<3)+(c^48),c=getchar());
    r*=f;
} // -_- 

const int N = 1e9 - 1;
int main(){
    int n, k, s;
    scanf("%d%d%d", &n, &k, &s);
    for(int i = 1; i <= n; ++i){
        if(i > 1) printf(" ");
        if(i <= k) printf("%d", s);
        else{
            if(s == N) printf("%d", N + 1);
            else printf("%d", N);
        }
    }
    // system("pause"); 0.0
    return 0;
}


Measured memory_bytes: 1280
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	LL n,k;
	cin>>n>>k;
	vector<int> a(2*n);
	vector<int> nxt(n);
	FOR(i,0,n){
		cin>>a[i];
		a[i+n]=a[i];
	}
	if(1){
		map<int,int> mp;
		FORD(i,2*n,n){
			mp[a[i]]=i;
		}
		FORD(i,n,0){
			nxt[i]=mp[a[i]];
			mp[a[i]]=i;
		}
	}
	FOR(i,0,n){
		cerr<<nxt[i]<<" ";
	}
	cerr<<endl;
	LL t_cnt=0,idx=0,bf=0;
	FOR(i,0,n*2+2){
		bf=idx;
		idx=nxt[idx]+1;
		if(idx==2*n){
			if(t_cnt+1==k){

			}else if(t_cnt+2==k){
				cout<<endl;
				return 0;
			}else{
				t_cnt++;
			}
		}
		if(idx>=n){
			if(t_cnt+1==k){
				vector<int> ans;
				FOR(ii,bf,n){
					if(nxt[ii]>=n){
						ans.PB(a[ii]);
					}else{
						ii=nxt[ii];
					}
				}
				for(const auto& x:ans){
					cout<<x<<" ";
				}
				cout<<endl;
				return 0;
			}else{
				t_cnt++;
				idx%=n;
			}

		}
		if(idx==0)break;
	}
	k%=t_cnt;
	cerr<<"t_cnt:"<<t_cnt<<endl;
	cerr<<"new k:"<<k<<endl;
	if(k==0){
		cout<<endl;
		return 0;
	}
	t_cnt=0,idx=0,bf=0;
	FOR(i,0,n*2+2){
		bf=idx;
		idx=nxt[idx]+1;
		if(idx>=n){
			if(t_cnt+1==k){
				vector<int> ans;
				FOR(ii,bf,n){
					if(nxt[ii]>=n){
						ans.PB(a[ii]);
					}else{
						ii=nxt[ii];
					}
				}
				for(const auto& x:ans){
					cout<<x<<" ";
				}
				cout<<endl;
				return 0;
			}else{
				t_cnt++;
				idx%=n;
			}

		}
		if(idx==0)break;
	}

	return 0;
}


Measured memory_bytes: 11904
#include<stdio.h>
#include<cmath>
using namespace std;
int main(){
    double a,b,C;
    scanf("%lf %lf %lf",&a,&b,&C);
    printf("%.8lf\n",a*b*sin(M_PI*C/180)/2);
    printf("%.8lf\n",a+b+sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(M_PI*C/180)));
    printf("%.8lf\n",b*sin(M_PI*C/180));
}


Measured memory_bytes: 2888
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

int main(void)
{
    int N;
    int i;
    vector<int> h(100100);
    vector<int> dp(100100, MOD);

    cin >> N;
    for (i = 1; i <= N; i++)
    {
        cin >> h[i];
    }

    dp[0] = dp[1] = 0;

    for (i = 2; i <= N; i++)
    {
        dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[max(i - 2, 1)]) + dp[max(i - 2, 1)]);
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 1024
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    a = LI()
    for c in a:
        if c % 2 == 1:
            continue
        if c % 3 != 0 and c % 5 != 0:
            return "DENIED"

    return "APPROVED"


print(main())





Measured memory_bytes: 5464
numz = input()
count = 0
numz_pair = numz.split(" ")
numz_pair = list(map(int, numz_pair))

for i in range(len(numz_pair)):
    if numz_pair[i] <= 9:
        count = count + 1
    else:
        print(-1)
        break

if count == len(numz_pair):
    print(numz_pair[0]*numz_pair[1])


Measured memory_bytes: 9176
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <chrono>
#include <assert.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

const int N = 10;
bool visited[N];
vector<ll> vals;
ll cost[N][N];
int n, j;

void dfs(int i, ll s) {
	visited[i] = true;
	int outs = 0;
	for (int t = 0; t < n; ++t) {
		if (! visited[t]) {
			++outs;
			dfs(t, s + cost[i][t]);
		}
	}
	if (outs == 0 && i > j) vals.push_back(s);
	visited[i] = false;
}

bool works() {
	for (j = 0; j+1 < n; ++j) dfs(j, 0);
	sort(vals.begin(), vals.end());

	bool ans = true;
	for (int i = 0; i+1 < vals.size(); ++i) {
		if (vals[i] == vals[i+1]) ans = false;
	}
	vals.clear();
	return ans;
}

// rand-function that works properly on windows, and is faster than rand
// https://codeforces.com/blog/entry/61587
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>
T rand(T a, T b) {
	return uniform_int_distribution<T>(a, b)(rng);
}

const ll MAX_V = 1e10;

ll log2(int v) {
	int res = 1;
	while(v > 1) {
		v /= 2;
		++res;
	}
	return res;
}

// Find 9 numbers s.t. their sum is distinct
int main() {
	vector<vector<int>> xr = {
	{1},
	{1,2},
	{1,2,4},
	{1,2,4,7},
	{1,2,4,7,12},
	{1,2,4,8,13,18},
	{1,2,4,8,14,19,24},
	{1,2,4,8,15,24,29,34},
	{1,7,10,13,21,26,41,43,45}
	};

	cin >> n;
	while(true) {
		ll b = 1;
		for (int i = 0; i+1 < n; ++i) {
			for (j = i+1; j < n; ++j) {
				cost[i][j] = b * xr[n-2-i][j-1-i];
				cost[j][i] = cost[i][j];
			}
			if (i+2 < n) b *= (xr[n-2-i][n-2-i] + xr[n-2-i][n-3-i]);
		}
		/*
		for (int i = 0; i < n; ++i) {
			for (j = i+1; j < n; ++j) {
				if (rand(0, 1)) cost[i][j] = rand(1ll, MAX_V);
				cost[j][i] = cost[i][j];
			}
		}
		*/
		if (works()) {
			for (int i = 0; i < n; ++i) {
				for (j = 0; j < n; ++j) {
					cout << cost[i][j] << ' ';
				}
				cout << '\n';
			}
			break;
		}
	}
}


Measured memory_bytes: 17896
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	double ans = 0;
	int N, K;
	cin >> N >> K;
	rep(i, 1, N+1)
	{
		double p = 1.0 / N;
		int t = i;
		while (t < K)
		{
			t *= 2;
			p /= 2.0;
		}
		ans += p;
	}

	printf("%.12lf\n", ans);

	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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 d = sc.nextInt();
        System.out.println(Math.max(a * b, c * d));
    }

}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second
 
int a[200009],b[200009],c[200009],n,m,C,ans;
vector<P>v[100009];
int dist[100009];
set<int>st;
 
void dij(){
  r(i,100009)dist[i]=1e16;
  priority_queue<P,vector<P>,greater<P> >q;
  r(i,n)if(st.count(i)){
    dist[i]=0;
    q.push(P(0,i));
  }
  while(!q.empty()){
    P p=q.top();q.pop();
    int cost=p.F;
    int now=p.S;
    r(i,v[now].size()){
      int ncos=cost+v[now][i].S;
      int nex=v[now][i].F;
      if(dist[nex]>ncos){
        dist[nex]=ncos;
        q.push(P(ncos,nex));
      }
    }
  }
}
 
signed main(){
  cin>>n>>m>>C;
  r(i,m){
    cin>>a[i]>>b[i]>>c[i]; a[i]--; b[i]--;
    v[a[i]].push_back(P(b[i],c[i]));
    v[b[i]].push_back(P(a[i],c[i]));
  }
  r(i,C){
    int x;
    cin>>x;
    st.insert(x-1);
  }
  dij();
  r(i,m) ans=max(ans,(dist[a[i]]+dist[b[i]]+c[i]+1)/2);
  r(i,n) ans=max(ans,dist[i]);
  cout<<ans<<endl;
}


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

using namespace std;

//#define FILE_IO

int N;
char s[500007], rs[500007];
int pi[500007];
int rpi[500007];

bool pfx(int pos)
{
    if(!pi[pos])    return true;
    return ( ( pos % (pos - pi[pos]) ) != 0 );
}

bool sfx(int pos)
{
    if(!rpi[pos])    return true;
    return ( ( pos % (pos - rpi[pos]) ) != 0 );
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    fgets(s + 1, 500005, stdin);
    N = strlen(s + 1) - 1;

    int p = 0;
    for(int i = 2; i <= N; i++)
    {
        while(p && s[i] != s[p + 1])
            p = pi[p];
        if(s[i] == s[p + 1])    p++;
        pi[i] = p;
    }

    int per = 0;
    if(pi[N] && N % (N - pi[N]) == 0)
        per = N - pi[N];

    if(!per)
    {
        printf("1\n1\n");
        return 0;
    }

    if(per == 1)
    {
        printf("%d\n1\n", N);
        return 0;
    }

    for(int i = 1; i <= N; i++)
        rs[i] = s[N - i + 1];
    p = 0;
    for(int i = 2; i <= N; i++)
    {
        while(p && rs[i] != rs[p + 1])
            p = rpi[p];
        if(rs[i] == rs[p + 1])    p++;
        rpi[i] = p;
    }

    printf("%d\n", 2);

    int ans = 0;
    for(int i = 1; i < N; i++)
        if( pfx(i) && sfx(N - i) )
            ans++;
    printf("%d\n", ans);

    return 0;
}


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

int main(){
long double ans=0;
int N; cin >> N; vector<int> A(N);
for(int i=0; i<N; i++){ cin >> A[i]; ans+=1.0/A[i]; }
ans=1.0/ans;
cout << fixed << setprecision(10) << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#define rep(i,N) for(int i=0; i<N;i++)
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i,N) cin >>P[i];
    int min=int(3*pow(10,6));
    int count =0;
    rep(i,N){
        if(P[i]<min){
            min=P[i];
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

int main()
{
    ll x;
    cin >> x;
    if (x >= 30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = (1 << 18) + 10;

int ans[N],A[N];
struct node {
	int v,id;
}Max[N],Sec[N];

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

int main() {

	int n = read(),cur = n;
	n = 1 << n;
	For(i,0,n - 1) A[i] = read();

	For(i,0,n - 1) {
		Max[i] = (node){A[i],i};
		For(j,0,cur - 1) if(i & (1 << j)){
			if(Max[i ^ (1 << j)].v > Max[i].v) {
				Sec[i] = Max[i];
				Max[i] = Max[i ^ (1 << j)];
			} else if(Max[i ^ (1 << j)].v == Max[i].v) {
				if(Max[i ^ (1 << j)].id == Max[i].id) continue;
				Sec[i] = Max[i ^ (1 << j)];
			} else if(Max[i ^ (1 << j)].v > Sec[i].v) Sec[i] = Max[i ^ (1 << j)];
			if(Sec[i ^ (1 << j)].v > Sec[i].v) Sec[i] = Sec[i ^ (1 << j)];
		}
	}

	For(i,0,n - 1) ans[i] = Max[i].v + Sec[i].v;
	For(i,1,n - 1) chkmax(ans[i],ans[i - 1]);

	For(i,1,n - 1) printf("%d\n",ans[i]);

	return 0;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
const int N=101;

int arr[11];
int solve()
{
    int p;
    cin>>p;
    arr[p]++;
    cin>>p;
    arr[p]++;
    cin>>p;
    arr[p]++;
    if(arr[5]==2 && arr[7]==1)
        return cout<<"YES", 0;
    return cout<<"NO", 0;
}

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

   // int t;
   // cin>>t;
   // while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>

int main()
{
    int N;
    scanf("%d", &N);
    int A[N], i;
    for(i=0; i<N; i++) {
        scanf("%d", &A[i]);
    }
    for(i=0; i<N; i++) {
        if(A[i] % 2 == 0 && (A[i] % 3 != 0 && A[i] % 5 != 0)) {
            printf("DENIED\n");
            return 0;
        }
        if(A[i] % 2 == 0 && (A[i] % 3 == 0 || A[i] % 5 == 0)) continue;
    }
    printf("APPROVED\n");
    return 0;
}


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

using namespace std;

int main(void){
    // Your code here
    int N; string S;
    int i;
    long long r=0,g=0,b=0;
    long long x=0,y=0,z=0;

    cin >> N >> S;

    for(i=0;i<N;i++){
        if(S.at(i)=='R')r++;
        if(S.at(i)=='G')g++;
        if(S.at(i)=='B')b++;   
    }

    long long all = r*g*b;

    for(x=0;x<N-2;x++){
        for(y=x+1;y<N-1;y++){
            z=y*2-x;
            if(z>N-1||S.at(x)==S.at(z)||S.at(y)==S.at(z)||S.at(x)==S.at(y))continue;
            all--;
        }
    }


    cout << all << endl;
}


Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
	class Program
	{
		public static void Main()
		{
			var intArray = IO.ReadLongArray();
			var allNum = intArray[1] - intArray[0] + 1;

			var nums = new[]
			{
				_GetPatternNum(intArray[0] , intArray[1] , intArray[2]),
				_GetPatternNum(intArray[0] , intArray[1] , intArray[3]),
				_GetPatternNum(intArray[0] , intArray[1] , Util.Lcm(intArray[2] , intArray[3]))
			};
			IO.Write(allNum - (nums[0] + nums[1] - nums[2]));
		}
		public static long _GetPatternNum(long iBeginNumber , long iEndNumber , long iScale)
		{
			var begin = iScale * (iBeginNumber / iScale);
			if(iBeginNumber % iScale != 0) { begin += iScale; }
			var end = iEndNumber - (iEndNumber % iScale);
			return ((end - begin) / iScale) + 1;
		}
	}

	public static class IO
	{
		public static string   Read()							   { return Console.ReadLine(); }
		public static string[] ReadArray(char iSplitter = ' ')	   { return Read().Split(iSplitter); }
		public static int	   ReadInt()						   { return int.Parse(Read()); }
		public static int[]	   ReadIntArray(char iSplitter = ' ')  { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); }
		public static long	   ReadLong()						   { return int.Parse(Read()); }
		public static long[]   ReadLongArray(char iSplitter = ' ') { return ReadArray().Select(iText => long.Parse(iText)).ToArray(); }
		public static char[]   ReadCharArray()					   { return Read().ToCharArray(); }

		public static void Write(string iValue)			  { Console.WriteLine(iValue); }
		public static void Write(int iValue)			  { Console.WriteLine(iValue); }
		public static void Write(IEnumerable<int> iValue) { Console.WriteLine(string.Join(" " , iValue)); }
		public static void Write(long iValue)			  { Console.WriteLine(iValue); }
		public static void Write(decimal iValue)		  { Console.WriteLine(iValue); }
		public static void Write(bool iValue)			  { Console.WriteLine(iValue ? "Yes" : "No"); }
	}

	public static class Util
	{
		public static long Gcd(long i0 , long i1) { return (i0 > i1) ? _Gcd(i0 , i1) : _Gcd(i0 , i1); }
		public static long Lcm(long i0 , long i1) { return (i0 * i1) / Gcd(i0 , i1); }
		public static long ModPow(long iBaseNumber , long iPow , long iModNumber)
		{
			var num = 1L;
			while(iPow != 0)
			{
				if((iPow & 0x1) != 0)
				{
					num = (num * iBaseNumber) % iModNumber;
				}
				iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber;
				iPow >>= 1;
			}
			return num;
		}

		private static long _Gcd(long i0 , long i1)	{ return (i1 == 0) ? i0 : _Gcd(i1 , i0 % i1); }
	}
}


Measured memory_bytes: 13396
fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)

fun cumGcd(x: List<Int>): List<Int> {
    var n = x.count()
    var res = x.toMutableList()

    res[0] = 0
    for (i in 0 until n - 1) {
        res[i + 1] = gcd(res[i], x[i])
    }
    return res
}

fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var xs = readLine()!!.split(" ").map(String::toInt)
    var left = cumGcd(xs)
    var right = cumGcd(xs.reversed())
    var ans = 0
    for (i in 0 until n) {
        val g = gcd(left[i], right[n - 1 - i])
        if (ans < g) {
            ans = g
        }
    }
    println(ans)
}

Measured memory_bytes: 74300
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

using ull_t = unsigned long long;
using ld_t = long double;

int main()
{
    ld_t L;
    cin >> L;

    L /= 3.0;
    cout << fixed << (L * L * L) << endl;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h> // only for GCC

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

//clear memory
// ------------------------------------------
#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
   map<int,int> m;
   int a,b,c,ans;
   while(cin >> a >> b >>c){
      ans=0;
      loop(i,1,11) if(i!=a&&i!=b&&i!=c)m[i]=1;
      loop(i,1,20-a-b+1) ans+=m[i];
      m.clear();
      if(ans>3) cout << "YES" << endl;
      else cout << "NO" << endl;
   }
}

Measured memory_bytes: 1184