akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <bitset>

using namespace std;
using ull = unsigned long long;
using ll = long long;

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

#define EPS (1e-7) 
#define ALL(x) begin(x), end(x)

bool starts_with(const string& s, char c) {
	return s[0] == c;
}
bool ends_with(const string& s, char c) {
	return s[s.length() - 1] == c;
}

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

	ull ans = 0;
	for (ull k = 1; k * k < N + 1; k++) {
		const ull m = (N - k) / k;
		const ull m_mod = (N - k) % k;
		if (m_mod == 0 && m > k) {
			ans += m;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define FOR(i, x, y) for(int i = x; i < y; i++)
#define endll cout << "\n"
#define For(n) for(int i = 0; i < n; i++)
const ll maxn = 1000 + 100;
const int inf = 1e9;

bool isprime(int x)
{
    if(x <= 1)
        return false;
    for(int i = 2; i * i < x; i++)
        if(x % i == 0)
            return false;
    return true;
}
ll a[maxn];
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    ll x;
    cin >> x;
    ll g = x;
    a[0] = x;
    ll res = x, y;
    for(int i = 1; i < n; i++)
    {
        cin >> y;
        a[i] = y;
        g = __gcd(g, y);
        res = res / __gcd(res, y) * y;
    }
    cout << res << endl;
    return 0;
}


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

const int INF = 1LL << 60;

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

  int V,E; cin >> V >> E;
  vector< vector<int> > G(V,vector<int> (V,INF));
  for(int i = 0; i < E; i++){
    int s,t,d; cin >> s >> t >> d;
    G[s][t] = d;
  }

  vector< vector<int> > dp(1 << V,vector<int> (V,-1));
  function< int(int,int) > rec =
  [&](int S,int v){ //{すでに訪れた頂点,現在位置}
    if(dp[S][v] >= 0) return dp[S][v];
    if(S == (1 << V)-1 && v == 0){
      //全ての頂点を訪れて戻ってきた
      return dp[S][v] = 0;
    }

    int res = INF;
    for(int u = 0; u < V; u++){
      if(!(1 & S >> u)){
        res = min(res,rec(S | 1 << u,u) + G[v][u]);
      }
    }
    return dp[S][v] = res;
  };

  int ans = rec(0,0);
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;

  return 0;
}



Measured memory_bytes: 7812
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int inputN =  sc .nextInt();
	int money = 0;

	while(true){
		money += 1000;
		if(inputN <= money) {
			break;
		}
	}
	System.out.println(money - inputN);
}
}

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

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ld long double

//int arr[100001];
int main()
{
	IOS;
	int n;
	cin >>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin >>arr[i];
	}
	int sum=0;
	sort(arr,arr+n);
	if(n%2==0)
		sum=arr[(n/2)]-arr[(n/2)-1];
	else
		sum=arr[n/2];
	cout <<sum<<"\n";
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int H, W;
  cin >> H >> W;
  vector<string> g(H);
  cin >> g;
  vector<vector<int>> dp(H, vector<int>(W, numeric_limits<int>::max()));
  if (g[0][0] == '#') dp[0][0] = 1;
  else dp[0][0] = 0;
  for (int i = 0; i < H; ++i)
    for (int j = 0; j < W; ++j) {
      if (i)
        dp[i][j] = min(dp[i][j], dp[i - 1][j] + (g[i - 1][j] == '.' && g[i][j] == '#'));
      if (j)
        dp[i][j] = min(dp[i][j], dp[i][j - 1] + (g[i][j - 1] == '.' && g[i][j] == '#'));
    }
  cout << dp.back().back();

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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

using namespace std;
int main(){
    int output = 0, n, m;
    cin >> n >> m;
    if(n % m == 0) output = 0;
    else output = 1;
    cout << output << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
li = dict()

for i in range(n):
    a,b = map(int, input().split())
    li.setdefault(a,0)
    li[a] += b

li = sorted(li.items())
ans = 0
for i in range(len(li)):
    ans += li[i][1]
    if ans >= k:
        print(li[i][0])
        exit()

Measured memory_bytes: 14564
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;


vector<long long> a;
vector<long long> f;
int n;
long long k;
bool ok(long long val)
{
	long long cur = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] * f[i] > val)
		{
			long long dif = a[i] * f[i] - val;
			dif = (dif + f[i] - 1) / f[i];
			cur += min(dif, a[i]);
		}
		if (cur > k)
			return false;
	}
	return cur <= k;
}


int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	cin >> n >> k;
	a.resize(n);
	f.resize(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> f[i];
	sort(all(a));
	reverse(all(a));
	sort(all(f));
	
	long long l = 0, r = 1e14;
	long long ans = LLONG_MAX;
	while (l <= r)
	{
		long long mid = l + (r - l) / 2;
		if (ok(mid))
		{
			ans = min(ans, mid);
			r = mid - 1;
		}
		else
			l = mid + 1;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> l(n);
	rep(i,n){
		cin >> l[i];
	}
	sort(l.begin(),l.end());
	reverse(l.begin(),l.end());
	int ans = 0;
	rep(i,k){
		ans += l[i];
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
#define frr(i, r, l) for(int i = r; i >= l; --i)
#define fr(i, l, r) for(int i = l; i < r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
typedef pair<ll, ll> iPair; 
priority_queue< ll, vector <ll> , greater<ll>>pq1,pq2;
#define maxN 1000000000000000000
ll power(ll a,ll b){ll res=1;while(b>0){res*=a;b--;}return res;}
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,m,cnt[200005]={0},sum=0;
    vector<ll>v;
    cin>>n>>x>>m;
    v.pb(x);
    cnt[x]++;
    sum+=x;
    ll t=x,st,j=2;
    while(1)
    {
        if(j>n)
        {
            cout<<sum<<endl;
            return 0;
        }
        ll calc=(t*t)%m;
        if(cnt[calc]==0)
        {
            v.pb(calc);
            sum+=calc;
            cnt[calc]++;
        }
        else
        {
            fr(i,0,v.size())
            {
                if(v[i]==calc)
                {
                    st=i;
                    break;
                }
            }
            break;
        }
        j++;
        t=calc;
    }
    ll st1=n-v.size();
    ll st2=v.size()-st;

    ll tot=0;
    fr(i,st,v.size())
    tot+=v[i];

    sum=sum+(st1/st2)*tot;
    ll st3=st1%st2;

    fr(i,st,st+st3)
    sum+=v[i];

    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 5380
n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i).sort_by{|a| -a}

q = a_arr.shift
count = 1
queue = []
result = 0
a_arr.each_with_index do |a, i|
  queue << a
  count += 1
  result += q
  if count == 2
    count = 0
    q = queue.shift
  end
end

puts result



Measured memory_bytes: 36020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define pii pair<int , int>
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
const int INF = 1000 * 1000 * 1000 + 7;
const ll LINF = INF * (ll)INF;
int main()
{
	string s;
	cin >> s;
	for(auto &x : s)
		x = 'x';
	cout << s << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100000
int A[N];
int fib(int);

int main(){
    int i,a,b;

    for(i = 0;i < 45;i++)
        A[i] = 0;
    scanf("%d",&a);
    b = fib(a);
    printf("%d",b);
    printf("\n");
    return 0;
}
int fib(int num){
    if(num == 0 || num == 1){
        return A[num] = 1;
    }
    if(A[num] != 0){
        return A[num];
    }
    return A[num] = fib(num-1) + fib(num-2);
}


Measured memory_bytes: 2052
while gets
  n = $_.to_i
  break if n == 0
  m = Array.new(n).map{ gets.split.map(&:to_i) }
  a = Array.new
  n.times { |i| a << m[i].min }
  mt = m.transpose
  b = Array.new
  n.times { |i| b << mt[i].max }
  puts (c = a.reverse & b).empty? ? 0 : c
end

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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int h1, m1, h2, m2, k;
	cin>>h1>>m1>>h2>>m2>>k;
	m1 += h1*60;
	m2 += h2*60;
	int ans = m2-m1-k;
	cout<<max(ans, 0)<<'\n';	
	return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

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

#define int ll
#define double ld

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

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

	rep(i, n) {
		cout << s[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=1001001001;

int main(){
  int n;
  cin >> n;
  vector<vector<int>> ans(n, vector<int>(3));
  for(int i=0; i<n; ++i){
    vector<int> abc(3);
    cin >> abc.at(0) >> abc.at(1) >> abc.at(2);
    if(i==0){
      for(int j=0; j<3; ++j){
        ans.at(0).at(j) = abc.at(j);
      }
      continue;
    }
    ans.at(i).at(0) = max(ans.at(i-1).at(1), ans.at(i-1).at(2))+ abc.at(0);
    ans.at(i).at(1) = max(ans.at(i-1).at(0), ans.at(i-1).at(2))+ abc.at(1);
    ans.at(i).at(2) = max(ans.at(i-1).at(0), ans.at(i-1).at(1))+ abc.at(2);
  }
  cout << max(ans.at(n-1).at(0), max(ans.at(n-1).at(1), ans.at(n-1).at(2))) << endl;
}

Measured memory_bytes: 5760
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace DailyCP
{
    class cc
    {
        public static void Main()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            double pi = 3.14159265358979;
            double op = 2*pi*n;
            Console.WriteLine(Math.Round(op, 2));           
        }
        
    }
}

Measured memory_bytes: 27628
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int main(){

	int N,M,D,count = 0,left,right,up,down;
	scanf("%d %d %d",&N,&M,&D);
	char table[N][M+1];

	for(int i = 0; i < N; i++){
		scanf("%s",table[i]);

		for(left = 0;left < M && table[i][left] == '#'; left++);

		if(left == M)continue;

		while(true){
			for(right = left;right < M && table[i][right] != '#';right++);
			if(right - left >= D){
				count += (right-left-D+1);
			}

			if(right == M)break;
			for(left = right+1;left < M && table[i][left] == '#';left++);
			if(left == M)break;
		}
	}


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

		for(up = 0;up < N && table[up][i] == '#'; up++);

		if(up == N)continue;

		while(true){
			for(down = up;down < N && table[down][i] != '#';down++);
			if(down - up >= D){
				count += (down-up-D+1);
			}

			if(down == N)break;
			for(up = down+1;up < N && table[up][i] == '#';up++);
			if(up == N)break;
		}
	}


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

	return 0;
}

Measured memory_bytes: 2764
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[200009],num[200009],sum[200009],summ;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++) {
		cin>>a[i];
		num[a[i]]++;
	}
	for(int i=1;i<=n;i++) {
		sum[i]=num[i]*(num[i]-1)/2;
		summ+=sum[i];
	}
	for(int i=0;i<n;i++) {
		cout<<summ+(num[a[i]]-1)*(num[a[i]]-2)/2-(num[a[i]])*(num[a[i]]-1)/2<<"\n";
	}
	return 0;
}

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

int main(){
	int N, K;
	cin >> N >> K;
	vector<int> P(N);
	for(auto &p : P) cin >> p;
	vector<double> exp_value(N);
	for(int i=0;i<N;i++) {
		exp_value[i] = (1.0 + (double)P[i]) / 2.0;
	}
	double ans = 0;
	for(int i=0;i<K;i++) {
		ans += exp_value[i];
	}
	double seq = ans;
	for(int i=1;i<N-K+1;i++) {
		seq = seq + exp_value[i+K-1] - exp_value[i-1];
		if(ans < seq) {
			ans = seq;
		}
	}
	cout << fixed << setprecision(7) << ans << endl;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int x=max(a,max(b,c));
  cout << 2+(3*x-a-b-c)/2-((3*x-a-b-c+1)%2)*2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>

using namespace std;

#define ll long long
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pii pair <int, int>
#define pll pair <long long, long long>
#define pb push_back

ll ar[55], n;

ll dp[55][2555][55];

ll solve(ll i, ll amount, ll taken)
{
 //   cout << "a " << i << " " << amount << " " << taken << endl;
    if (i > n)
    {
        if (amount == 0 && taken == 0)
            return 1;
        else return 0;
    }

    if (dp[i][amount][taken] != -1)
        return dp[i][amount][taken];

    ll ret1=0, ret2=0;

    if(amount - ar[i] >=0 && taken >= 0)
        ret1 = solve(i + 1, amount-ar[i], taken - 1);

    ret2 = solve(i+1, amount, taken);

 //   cout << "b " << i << " " << amount << " " << taken << " " << ret1 << " " << ret2 << endl;


    return dp[i][amount][taken] = ret1 + ret2;
}

int main ()
{
  //  freopen("inl.txt", "r", stdin);
   // freopen("outu.txt", "w", stdout);
  //  ios_base::sync_with_stdio(0); // no printf/scanf must be present
    ll cs, t, i, j, k, x, y, z, ans = 0, q, m, a;

    sl(n);
    sl(a);

    for (cs = 1; cs <= n; cs++)
    {
        sl(ar[cs]);
    }

    memset(dp, -1, sizeof(dp));

    for (i = 1; i <= n; i++)
    {
   //     memset(dp, -1, sizeof(dp));
     //   cout << i << " GAHABBABBABA"  << endl;
        ans += solve(1, i*a, i);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 60672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int N;
	cin >> N;

	string s,t;
	cin >> s;
	cin >> t;

	int cnt = 0;
	REP(i, N) {
		if (s[i] == t[0]) {
			int j = 0;
			while (j < N - i - 1) {
				if(s[i+j] == t[j]) j++;
				else break;
			}
			if (j == N - i - 1) {
				cout << N + i << endl;
				return 0;
			}
		}
	}

	cout << 2 * N << endl;


	return 0;

}

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

using namespace std;

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

int main(void) {
  int w, h, c;
  cin >> w >> h >> c;

  cout << w * h / (gcd(w, h) * gcd(w, h)) * c << endl;

  return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string S; cin >> S;
    string K = S.substr(0, n / 2);
    K += K;
    if(K == S) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3640
N = int(raw_input())
A = map(int, raw_input().split())
count = 0
flag = True
while flag:
    flag = False
    for j in range(N-1, 0, -1):
        if A[j] < A[j-1]:
            A_j = A[j]
            A[j] = A[j-1]
            A[j-1] = A_j
            flag = True
            count += 1
print " ".join(map(str, A))
print count

Measured memory_bytes: 6344
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  int ans = 0;
  int a;
  for (int i = 1; i <= N; i++) {
    cin >> a;
    if (i % 2 == 1 && a % 2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3564
import fractions
from functools import reduce
def main():
  _=input()
  a=tuple(map(int,input().split()))
  fgcd=fractions.gcd
  def lcm_base(x, y):
    return (x * y) // fgcd(x, y)
  def lcm(numbers):
    return reduce(lcm_base, numbers, 1)
  q=lcm(a)
  x=[q//i for i in a]
  print(sum(x)%(10**9+7))
  
if __name__ == '__main__':
    main()

Measured memory_bytes: 264644
from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
    a, b = map(int, input().split())

    counter_a = Counter(prime_factorize(a))
    counter_b = Counter(prime_factorize(b))

    c_a = list(counter_a.keys())
    c_b = list(counter_b.keys())

    count = len(set(c_a) & set(c_b))

    print(count+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38512
import numpy as np
import math

# K = int(input())
# A, B = map(int, input().split())
# A = list(map(int, input().split()))

N, x = map(int, input().split())
A = list(map(int, input().split()))

A.sort()

tot = 0
for i, a in enumerate(A):
    tot += a
    if tot > x:
        print(i)
        exit(0)
    elif tot == x:
        print(i+1)
        exit(0)

print(len(A)-1)


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 200010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

ll n;

int a[maxn],cnt;

int main(){
	cin>>n;
	while(n)a[++cnt]=n%10,n/=10;
	int ans=0;
	int t=0;
	RREP(i,cnt,1){
		if(a[i])ans=max(ans,t+a[i]-1+(i-1)*9);
		t+=a[i];
	}
	ans=max(ans,t);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, x, y;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> x >> y;
  vector<vector<int>> g(n, vector<int>());

  REP(i, n - 1) {
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
  }
  x--; y--;
  g[x].push_back(y);
  g[y].push_back(x);

  vector<int> ans(n + 1);

  REP(i, n) {
    vector<bool> used(n, false);
    used[i] = true;

    queue<P> que;
    que.push(P(i, 0));
    while(!que.empty()) {
      P p = que.front(); que.pop();
      REP(j, g[p.first].size()) {
        if(!used[g[p.first][j]]) {
          ans[p.second + 1]++;
          que.push(P(g[p.first][j], p.second + 1));
          used[g[p.first][j]] = true;
        }
      }
    }
  }

  FOR(i, 1, n) {
    cout << (ans[i] / 2) << endl;
  }
}


Measured memory_bytes: 384
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
type I = usize;

fn main() {
    input!{
      n: usize,
      k: usize,
      s: chars,
    }
    let mut sums = vec![];
    let mut cnt = 0;
    for i in 0..n {
        if i > 0 && s[i] != s[i-1] {
            sums.push(cnt);
            cnt = 0;
        }
        cnt += 1;
    }
    sums.push(cnt);
    if s[0] == '0' {
        sums.insert(0, 0);
    }
    if s[s.len()-1] == '0' {
        sums.push(0);
    }

    let n = sums.len();
    let mut num = 0;
    for i in 0..(2*k+1) {
        if i < n {
            num += sums[i];
        }
    }
    let mut ans = num;
    let mut l = 2;
    while l+2*k < n {
        num -= sums[l-1];
        num -= sums[l-2];
        num += sums[l+2*k];
        num += sums[l+2*k-1];
        ans = max(ans, num);
        l += 2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

int cost_to_a(const char& c) {
  return (int) ('z' - c + 1);
}

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

  string s; cin >> s;
  int k; cin >> k;

  for (int i = 0, n = s.size(); i < n; ++i) {
    if (k <= 0) break;
    if (s[i] == 'a') continue;
    if (k >= cost_to_a(s[i])) {
      k -= cost_to_a(s[i]);
      s[i] = 'a';
    }
  }

  k %= 26;
  s.back() += k;

  cout << s << '\n';

  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
void slove(){
  int H, W, N;
  cin >> H >> W >> N;
  int x;
  if ( H < W ){
    x = W;
  }else{
    x = H;
  }
  int k = N / x;
  int a = N % x;
  if ( a != 0 ){
    k = k + 1;
  }
  cout << k << endl;
}
int main(){
  slove();
  return 0;
}

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

using namespace std;

int main(){
  int not_one, idx, k;
  string s;
  cin >> s >> k;
  //  cout << s.length() << endl;
  for (int i=0;i<s.length();i++) {
    idx = i;
    not_one = int(s[i]) - 48;
    if (s[i] != '1') {
      //      cout << idx << "\t" << not_one << endl;
      break;
    }
  }
  if (k <= idx) {
    cout << 1 << endl;
  } else {
    cout << not_one << endl;
  }
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int64_t MOD=10000007;
static const double pi = 3.141592653589793;
int main() {
  double A,B,H,M,Arad,Brad;
  cin>>A>>B>>H>>M;
  Arad=(pi/6)*(H+M/60);
  Brad=(pi/30)*M;
  double RAD=min(abs(Arad-Brad),2*pi-abs(Arad-Brad));
  double ans=sqrt(A*A+B*B-2*A*B*cos(RAD));
  cout << fixed << setprecision(11);
  cout<<ans;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int A,B;cin>>A>>B;
    int ans=0;
    for(int i=0;i<2;i++){
        if(A>B){
            ans+=A--;
        }else{
            ans+=B--;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll n;
cin>>n;
ll sum=0;
for(int i=1;i<=n;i++){
    if(ketasuu(i)%2==1){
        sum++;
    }
}
cout<<sum<<endl;
}










Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a+b<c)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
let n = stdin.ReadLine() 

let all753 =
    let rec all753 i (strList:seq<string>) =
        if i > n.Length-1 then strList |> Seq.filter (fun x -> int x <= int n)  
        else 
            all753 (i+1) 
                (strList |> Seq.collect (fun x -> 
                    if x.Length <> i then 
                        seq{yield x} 
                    else
                    seq{yield x; yield ("7"+x); yield("5"+x); yield("3"+x)}))
    
    all753 1 ["7";"5";"3"]

let contain753 (str:string) = str.Contains "7" && str.Contains "5" && str.Contains "3"

all753 |> Seq.filter contain753 |> Seq.length |> stdout.WriteLine

Measured memory_bytes: 15700
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	h, w := nextInt(), nextInt()
	s := make([]string, h)
	for i := range s {
		s[i] = next()
	}

	checked := make([][]bool, h)
	for i := range checked {
		checked[i] = make([]bool, w)
	}
	di := []int{0, 1, 0, -1}
	dj := []int{1, 0, -1, 0}
	ans := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if checked[i][j] {
				continue
			}

			black, white := 0, 0
			// BFS
			que := make([][2]int, 0)
			que = append(que, [2]int{i, j})
			for len(que) > 0 {
				I, J := que[0][0], que[0][1]
				que = que[1:]
				if checked[I][J] {
					continue
				}
				checked[I][J] = true
				if s[I][J] == '#' {
					black++
				} else {
					white++
				}
				for k := 0; k < 4; k++ {
					nextI, nextJ := I+di[k], J+dj[k]
					if nextI < 0 || h <= nextI || nextJ < 0 || w <= nextJ {
						continue
					}
					if checked[nextI][nextJ] {
						continue
					}
					if s[I][J] != s[nextI][nextJ] {
						que = append(que, [2]int{nextI, nextJ})
					}
				}
			}

			ans += black * white
		}
	}

	puts(ans)
}


Measured memory_bytes: 6176
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	int w,h,x,y,r;
	scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
	if((x<r)||(y<r)||(x+r>w)||(y+r>h)){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 3148
import sys

N=int(input())
A=list(map(int,input().split()))

A.sort()
A.reverse()

if A[N-1]==0:
    print(0)
    sys.exit()
ans=1
for i in range(N):
    ans=ans*A[i]
    if ans>10**18:
        print(-1)
        sys.exit()
print(ans)

Measured memory_bytes: 21468
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int MOD = 1000000007;

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

    vector<int> cnt(128, 0);
    for(int i=0; i<n; ++i)
        ++ cnt[s[i]];

    long long ans = 1;
    for(char c='a'; c<='z'; ++c){
        ans *= cnt[c] + 1;
        ans %= MOD;
    }
    ans = (ans - 1 + MOD) % MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
//
// Created by yamunaku on 2020/08/09.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    ll b1 = 1007, b2 = 1009;
    ll p1 = MOD1, p2 = MOD1 + 2;
    vector<map<pair<ll, ll>, vi>> mp(1000001);
    vector<pair<ll, ll>> hn(n, {0, 0});
    rep(i, n){
        vector<int> num(26, 0);
        for(auto &c:s[i]){
            num[c - 'a']++;
        }
        if(mp[0].find({0, 0}) == mp[0].end()) mp[0][{0, 0}] = vi(26, 0);
        auto &v = mp[0][{0, 0}];
        rep(t, 26) if(num[t] > 0) v[t]++;
        int sz = s[i].size();
        ll h1 = 0, h2 = 0;
        per(j, sz){
            h1 = (h1 * b1 + (s[i][j] - 'a')) % p1;
            h2 = (h2 * b2 + (s[i][j] - 'a')) % p2;
            num[s[i][j] - 'a']--;
            if(mp[sz - j].find({h1, h2}) == mp[sz - j].end()) mp[sz - j][{h1, h2}] = vi(26, 0);
            auto &vv = mp[sz - j][{h1, h2}];
            rep(t, 26) if(num[t] > 0) vv[t]++;
            if(j == 1){
                hn[i] = {h1, h2};
            }
        }
    }
    ll ans = 0;
    rep(i, n){
        if(mp[s[i].size() - 1].find(hn[i]) == mp[s[i].size() - 1].end()) continue;
        ans += mp[s[i].size() - 1][hn[i]][s[i][0] - 'a'] - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 238644
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


n = int(input())
divisors = make_divisors(n)
ans = float('inf')
for d in divisors:
    ans = min(ans, d + n // d)
print(ans - 2)

Measured memory_bytes: 3268
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <assert.h>
#include <iostream>

using namespace std;

int min(int a, int b){
    return a < b ? a : b;
}

int max(int a, int b){
    return a > b ? a : b;
}

void solucion(){

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vector<int> empleados(N+1,0);
    for (int i=0; i<N-1; i++){
        int aux;
        cin >> aux;
        empleados[aux]++;
    }
    for (int i=1; i<=N; i++){
        cout << empleados[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 3676
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue> 
using namespace std;
int a,x[103],y,n[103];
int main() 
{
 cin>>a;
 for(int i=1;i<=a;i++)
 cin>>x[i];
 for (int i=1;i<=100;i++){
 for (int j=1;j<=a;j++){
 if (x[j]==i) n[i]++;
 }}
 for (int i=1;i<=100;i++)
 if (n[i]!=0) y++;
 cout<<y;
 system("pause");                                                             
 return 0 ;
}        

Measured memory_bytes: 504
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#define ll long long
using namespace std;
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a+b==c+d)printf("Balanced");
	if(a+b<c+d)printf("Right");
	if(a+b>c+d)printf("Left");
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

///////////////////////////////////////////////////////////////////////////
char  a[55][55],b[55][55];
int n,m;

bool func(int x,int y){
    rep(i,0,m){
        rep(j,0,m){
            if(a[x+i][y+j] != b[i][j]){
                ret 0;
            }
        }
    }
    ret 1;
}

int main(){
	
	cin >> n >> m;
	rep(i,0,n)rep(j,0,n)cin >> a[i][j];
	rep(i,0,m)rep(j,0,m)cin >> b[i][j];
	
	rep(i,0,n){
	    rep(j,0,n){
            if(func(i,j)){
                Yes;
                return 0;
            }
	    }
	} 
	
	No;
	return  0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll maxx(ll a,ll b) {
	return a>b?a:b;;
}
void print(int x) {
	if(x>9) print(x/10);
	putchar(x%10+48);
}
int yzh=1e9+7,s,f[25500000+5];
int quick_pow(int a, int b) {
	int ans=1;
	while(b) {
		if(b&1) ans=1ll*ans*a%yzh;
		a=1ll*a*a%yzh,b>>=1;
	}
	return ans;
}
int count1(int n) {
	int ans = 0, r = 0, cnt = 0;
	for (int i = 1; i < 10000000; i++) {
		cnt -= f[i-1];
		while (cnt+f[r+1] <= s && r < 25500000) cnt += f[++r];
		if (cnt == s) ++ans;
		if (r == 25500000) break;
	}
	return ans;
}
int count2(int n) {
	int lim = n/8, ans = lim;
	for (int t = 1; t <= lim; t++) if (n%t == 0) {
			int len = n/t;
			(ans += (1ll*quick_pow(10, len-1)*9%yzh-t)%yzh) %= yzh;
	}
	return ans;
}
int main() {
	for (int i = 1, r = 10, cnt = 1; i < 10000000; i++, i = r, r = r*10, cnt++) for (int j = i; j < r; j++) f[j] = cnt;
	for (int i = 10000000; i <= 25500000; i++) f[i] = 8;
	cin>>s;
	if (((count1(s)+count2(s))%yzh+yzh)%yzh < 0) cout<<"-";
	print(maxx(((count1(s)+count2(s))%yzh+yzh)%yzh,-((count1(s)+count2(s))%yzh+yzh)%yzh));
	return 0;
}

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

string buf;

int calc(int& n, unsigned level = 0) {
    if (n == 0) throw runtime_error("EOF");
    if (buf.empty()) cin >> buf;
    if (buf.find_first_not_of('.') != level) throw runtime_error("EOL");
    int result;
    switch (buf.back()) {
        case '+':
            buf.clear();
            result = 0;
            for (;;) {
                try { result += calc(--n, level + 1); }
                catch (...) { ++n; break; }
            }
            break;
        case '*':
            buf.clear();
            result = 1;
            for (;;) {
                try { result *= calc(--n, level + 1); }
                catch (...) { ++n; break; }
            }
            break;
        default:
            result = buf.back() - '0';
            buf.clear();
            break;
    }
    return result;
}

int main() {
    for (int n; cin >> n, n; cout << calc(n) << endl) buf.clear();
}

Measured memory_bytes: 3188
N,Y = map(int,input().split())
Y = Y // 1000
ans = False
for i in range(N+1):
    for j in range(N-i+1):
        if 10*i + 5*j + (N-i-j) == Y:
            ans = True
            x = i; y = j; z = N-i-j
            break

if ans == True:
    print(x,y,z)
else:
    print(-1,-1,-1)

Measured memory_bytes: 3064
N, Y = map(int, input().split())

x = -1
y = -1
z = -1

for a in range(N+1):
    for b in range(N-a+1):
        c = N - a -b
        if 10000 * a + 5000 * b + 1000 * c == Y:
            x, y, z = a, b, c
            print("{} {} {}".format(x, y, z))
            exit()
print("{} {} {}".format(x, y, z))

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main()
{
	int N, sum = 0, thumb = 0;
  	float avrg, min, diff;
  	vector<int> frame;
  	cin >> N;
  	for (int i = 0; i < N; i++){
    	int f; cin >> f;
      	sum += f;
      	frame.push_back(f);
    }
  	avrg = (float)sum / N;
  	min = fabs(frame[0] - avrg);
  	for (int i = 1; i < N; i++){
      	diff = fabs(frame[i] - avrg);
    	if (min > diff){
          	thumb = i;
        	min = diff;
        }
    }
  	cout << thumb;
}

Measured memory_bytes: 256