akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

void insertionSort(int array[],int n,int g);
void shellSort(int array[], int n);
int cnt,N;

int main(void){
	scanf("%d",&N);
	int array[N];
	for(int i=0;i<N;i++){
		scanf("%d\n",&array[i]);
		}
	shellSort(array,N);
	printf("%d\n",cnt);
	for(int i=0;i<N;i++){
		printf("%d\n",array[i]);
		}
	return 0;	
}
	
	
	

void insertionSort(int array[],int N,int g){
	int v,j;
	for(int i=g;i<N;i++){
		v=array[i];
		j=i-g;
		while(j>=0&&array[j]>v){
		array[j+g]=array[j];
		j=j-g;
		cnt++;
		}
		array[j+g]=v;
	}
}

void shellSort(int array[], int N){
	int num=0;
	int array2[100];
	array2[0] = 1;
	for(num = 1; 3*array2[num-1]+1 <= N; ++num){
	array2[num] = 3*array2[num-1]+1;
	}
	printf("%d\n", num);
	cnt=0; 
	for(int i = num-1; i >= 0; --i) {
    printf("%d%c", array2[i], " \n"[i==0]);
    insertionSort(array, N, array2[i]);
  }
}
		


Measured memory_bytes: 5584
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

vector<bool> used(50, false);
vector<vector<int> > graph;
pair<int, int> p;
void check(int from){
  rep(i, graph[from].size()){
    int to = graph[from][i];
    if((p.first == from && p.second == to) || (p.first == to && p.second == from)) continue;
    if(!used[to]) {
      used[to] = true;
      check(to);
    }
  }
  return;
}

int main(){
  int n, m;
  cin >> n >> m;
  graph.resize(n);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    --a; --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  ll ans = 0;
  rep(i, n){
    if(graph[i].size() <= 0)  continue;

    rep(j, graph[i].size()){
      rep(j, n){
        used[j] = false;
      }
      p.first = i;
      p.second = graph[i][j];
      check(0);
      for(int j = 0; j < n; ++j){
        if(used[j] == false){
          ans++;
          break;
        }
      }
    }

  }
  cout << ans / 2 << endl;
}


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

int main(){
	int N;
	double answer = 0;
	cin >> N;
	if(N % 2 == 0) answer = 0.5;
	else{
		answer = 1- (double)(N/2)/(double)N;
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,h,x;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&h);
	if(h%2==0){
		x=(a+b)*h/2;
		printf("%d\n",x);
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int main(){
    int n;
    cin >> n;
    ll ans = 0;

    rep(i, n) ans += i;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())
def judge(x):
    ans=0
    while x!=0:
        ans+=x%10
        x=x//10
    if ans>=a and ans<=b:
        return True
    else:
        return False
sum=0
for i in range(1,n+1):
    if judge(i):
        sum+=i
print(sum)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
   cin.tie(0);
   ios::sync_with_stdio(false);
   cout<<fixed<<setprecision(20);

   int N;
   cin >> N;
   map<int,int> mp;
   int mn = inf;
   int mx = 0;
   rep(i,N){
      int a,b;
      cin >> a >> b;
      mp[a] = b;
      mn = min(mn,a);
      mx = max(mx,a);
   }
   // for(auto x:mp)cout << x.first << endl;
   cout << mx + mp[mx]<< endl;
}

Measured memory_bytes: 4992
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n,m,sum=0;
  cin >> n >> m;
  int a[n+1]={0};
  for(int i=1;i<=n;i++){
    cin >> a[i];
    sum+=a[i];
  }
  int cuttoff = (sum+4*m-1)/(4*m);
  for(int i=1;i<=n;i++){
    if(a[i]>=cuttoff)m--;
  }
  if(m<=0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }


return 0;
}
///....


Measured memory_bytes: 256
#include <iostream>
#define llint long long

using namespace std;

llint N;

llint count(llint n)
{
llint ret = 0;
for(;n;n/=10) ret += n%10;
return ret;
}

int main(void)
{
cin >> N;

llint mul = 1, ans = count(N);
for(int i = 0; i < 17; i++){
	ans = max(ans, count(N/mul*mul-1));
mul *= 10;
}

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

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

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


Measured memory_bytes: 256
from operator import itemgetter

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

R.sort(reverse=True, key=itemgetter(1))
B.sort()

ans = 0
for b in B:
    for r in R:
        if r[0] < b[0] and r[1] < b[1]:
            ans += 1
            R.remove(r)
            break
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
template<typename T>void read(T &x){
	x=0;int f(1);char c(getchar());
	for(;!isdigit(c);c=getchar())if(c=='-')f=-f;
	for(; isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c-'0');
	x*=f;
}
template<typename T>void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)write(x/10),x%=10;
	putchar(x+'0');
}
int q,ans=0,A[11],a[50],b[50],c[50],d[50];
void dfs(int n,int la){
	if(n==0){
		int test=0;
		for(int i=0;i<q;++i)
			if(A[b[i]]-A[a[i]]==c[i])
				test+=d[i];
		ans=max(ans,test);
		return;
	}
	for(int i=la;i>=1;--i)
		A[n]=i,dfs(n-1,A[n]);
}
int main(){
	int n,m;
	read(n),read(m),read(q);
	for(int i=0;i<q;++i)
		read(a[i]),read(b[i]),read(c[i]),read(d[i]);
	dfs(n,m);write(ans),putchar('\n');
	return 0;
}


Measured memory_bytes: 3624
#include <cstdio>

using namespace std;

int main() {
	while(true) {
		int a,b,c,d,e,f;
		if(scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f)<6)break;
		// adx + bdy = cd
		// adx + aey = af
		// (bd-ae)y = cd-af
		int y = (c*d-a*f)*2000/(b*d-a*e);
		// aex + bey = ce
		// bdx + bey = bf
		// (ae-bd)x = ce-bf
		int x = (c*e-b*f)*2000/(a*e-b*d);
		if(x >= 0) {
			x = (x+1)/2;
			printf("%d.%03d ",x/1000, x%1000);
		} else {
			x = (-x+1)/2;
			printf("-%d.%03d ",x/1000, x%1000);
		}
		if(y >= 0) {
			y = (y+1)/2;
			printf("%d.%03d\n",y/1000, y%1000);
		} else {
			y = (-y+1)/2;
			printf("-%d.%03d\n",y/1000, y%1000);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

int main(){
  string S;
  cin >> S;
  //入力終了

  //登場回数が多いものから順に並べれば良い
  
  //最初の2文字が決まると後は自動的に決まる
  //a b ときたら次はcしかダメ
  //a b aは回文だし，a b b も回文も含むため
  
  //各文字の登場回数を数える
  int appeared[3] = {0};
  rep(i, S.size() )
    appeared[S[i]-'a']++;

  //登場回数を大きいものから並べ替え  
  sort(appeared, appeared+3, greater<>());

  //appeared[i]が0になるまでループ
  bool flag = true;
  while(flag){
    rep(i, 3){
      if(appeared[i] > 0)
	appeared[i]--;
      else{
	flag = false;
	break;
      }
    } // rep
  } //while

  //各文字を使い切っていたらOK
  if(appeared[0] == appeared[1] && appeared[1] == appeared[2])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 3740
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		ArrayList<Integer> priceList = new ArrayList<>();
		int ans = 0;
		
		for(int i = 0; i < n; i++) {
			priceList.add(sc.nextInt());
		}
		Collections.sort(priceList);
		
		for(int i = 0; i < k; i++) {
			ans += priceList.get(i);
		}
		System.out.println(ans);
		sc.close();
	}

}

Measured memory_bytes: 39004
n = int(input())
s = input()

abc = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']

	
for i in range(0, len(s)):
	b = s[i]
	x = abc.index(b) + n
	while x > 25:
		x = x - 26	
	y = abc[x]
	s = list(s)
	s[i] = y
	s = ''.join(s)
print(s)
	

Measured memory_bytes: 3064
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	ll k; cin >> k;
	vector<int> a(n); rep(i, n)cin >> a[i];
	if (k <= n)
	{
		int pos = 0;
		while (k--)
		{
			pos = a[pos] - 1;
		}
		cout << pos + 1 << endl;
	}
	else
	{
		vector<int> b(n, -1);
		b[0] = 0;
		int pos = 0;
		int f, s;
		int cnt = 0;
		while (true)
		{
			pos = a[pos] - 1;
			++cnt;
			if (b[pos] != -1)
			{
				f = b[pos];
				s = cnt;
				break;
			}
			b[pos] = cnt;
		}
		k -= f;
		k %= (s - f);
		while (k--)
		{
			pos = a[pos] - 1;
		}
		cout << pos + 1 << endl;
	}
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

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

int main() {
  u32 X, K;
  cin >> K >> X;

  cout << ((500 * K >= X) ? "Yes" : "No") << endl;

  return 0;
}

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

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

    int p;
    int minnum=2e5+1;
    int ans=0;
    for(int i=0;i<N;i++){
        cin>>p;

        if(p<=minnum){
            ans++;
        }

        if(minnum>p){
            minnum=p;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);


signed main(){
  int a, b;cin >> a >> b;
  if(a < b)swap(a, b);
  if(a == b)cout << a+a << endl;
  else cout << a+a-1 << endl;
  return 0;
}






Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
int n, sqrtN;
long long ans, d;
char buf[8],out[20];
char k;
s;
size_t i;
int main() {
    s = read(0, buf, 8);
    for(;;) {
        k = buf[i++];
        if(k < '0') break;
        n = n * 10 + k - '0';
    }
    if(n == 1) {
        putchar(49);
    } else {
        const int sqrtN = sqrt(n);
        ans = -(long long)(sqrtN) * (sqrtN + 1) * (2 * sqrtN + 1) / 6;
        for(int i = 1; i <= sqrtN; ++i) {
            const int a = n / i;
            ans += ((long long)i * (i + a) * (a + 1 - i));
        }
        i = 20;
        do{
            out[--i]=ans%10+'0';
            ans/=10;
        }while(ans);
        write(1,out+i,20-i);
    }
}

Measured memory_bytes: 1876
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

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


//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	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;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

int main() {
ll n,m;
cin>>n>>m;

int d1[n+1];
int dn[n+1];

rep(i,n){
	d1[i]=0;
	dn[i]=0;
}



rep(i, m){
	int p,q;
	cin>>p>>q;
	if(p==1) d1[q]=1;
	if(q==1) d1[p]=1;
	if(p==n) dn[q]=1;
	if(q==n) dn[p]=1;
}

rep(i,n){
	if(d1[i] && dn[i]){
		cout<<"POSSIBLE"<<endl;
		return 0;
	}
}

cout<<"IMPOSSIBLE"<<endl;
return 0;

}



Measured memory_bytes: 1792
import math

while True:
    temp = []
    n = int(input())
    if n == 0:
        break
    point = list(map(int, input().split()))
    m = sum(point)/len(point)
    for i in point:
        temp.append((i - m)**2)
    print('{0:.8f}'.format(math.sqrt(sum(temp)/n)))

Measured memory_bytes: 7676
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))

def count_cumbit(x, i):
    if i == 0:
        d, m = divmod(x, 4)
        return int((m == 1) | (m == 2))
    else:
        d, m = divmod(x, 2**(i+1))
        return int((m >= 2**i) & (m%2==0))

A, B = inpl()
ans = 0
for i in range(41):
    ans += (2**i * (count_cumbit(A-1, i) ^ count_cumbit(B, i)))
print(ans)

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n; scanf("%d", &n);
    
    vector<int> a(n);
    
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    
    vector<int> dp; dp.push_back(a[0]);
    
    for(int i = 1; i < n; i++)
    {
        if(dp[dp.size() - 1] < a[i])
        {
            dp.push_back(a[i]);
        }
        else
        {
            int pos = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
            
            dp[pos] = a[i];
        }
    }
    
    printf("%d\n", (int)(dp.size()));
    
    return 0;
}

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

const int DIM = 2e5 + 5;

deque<pair<int, int>> que;
vector<int> edg[DIM], axe[DIM];

int lev[DIM], fth[DIM];
bool oki[DIM], mrk[DIM];

void dfs( int x, int f ) {
    lev[x] = lev[f] + 1; fth[x] = f;
    
    for( int y : edg[x] )
        if( y != f )
            dfs( y, x );
    
    return;
}

int main( void ) {
    
    int n, x, y;
    cin >> n >> x >> y;
    
    for( int i = 2; i <= n; i ++ ) {
        int x, y;
        cin >> x >> y;
        
        axe[x].push_back( y );
        axe[y].push_back( x );
    }
    
    for( int i = 2; i <= n; i ++ ) {
        int x, y;
        cin >> x >> y;
        
        edg[x].push_back( y );
        edg[y].push_back( x );
    }
    
    lev[0] = -1; dfs( y, 0 );
    for( int i = 1; i <= n; i ++ ) {
        for( int j : axe[i] ) {
            bool ok = true;
            int x = i, y = j;
            
            if( lev[x] > lev[y] )
                swap( x, y );
            
            if( fth[x] == fth[y] ) ok = false;
            if( fth[fth[y]] == x ) ok = false;
            if( fth[y] == x )      ok = false;
            
            if( ok == true )
                oki[x] = oki[y] = true;
        }
    }
    
    mrk[x] = true; int ans = 0;
    que.push_back( make_pair( x, 0 ) );
    for( ; que.empty() == false; que.pop_front() ) {
        pair<int, int> x = que.front();
        ans = max( ans, lev[x.first] * 2 );
        
        if( oki[x.first] == true )
            ans = 1e9;
        
        for( int y : axe[x.first] ) {
            if( mrk[y] == 1 || x.second + 1 >= lev[y] )
                continue;
            
            mrk[y] = true;
            que.push_back( make_pair( y, x.second + 1 ) );
        }
    }
    
    if( ans == 1e9 )
        ans = -1;
    cout << ans << endl;
    return 0;
}

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

using namespace std;


void solve() {
    int n; cin >> n;
    struct Node {
        string s;
        int p;
    };
    vector<Node> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].s;
        cin >> a[i].p;
    }
    vector<int> id(n);
    iota(id.begin(), id.end(), 0);
    sort(id.begin(), id.end(), [&](int x, int y){
            if (a[x].s < a[y].s) return true;
            if (a[x].s == a[y].s && a[x].p > a[y].p) return true;
            return false;
            });
    for (int i: id) {
        cout << i+1 << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    
    for(int i = 0; i < ty - sy; i++)
        cout << "U";
    for(int i = 0; i < tx - sx; i++)
        cout << "R";
    for(int i = 0; i < ty - sy; i++)
        cout << "D";
    for(int i = 0; i < tx - sx; i++)
        cout << "L";
    
    cout << "L";
    for(int i = 0; i < ty + 1 - sy; i++)
        cout << "U";
    for(int i = 0; i < tx - sx + 1; i++)
        cout << "R";
    cout << "D";
    
    cout << "R";
    for(int i = 0; i < ty - sy + 1; i++)
        cout << "D";
    for(int i = 0; i < tx + 1 - sx; i++)
        cout << "L";
    cout << "U";
    
    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
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*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll K;
    cin >> K;


    if(K<=9){
        cout << K << endl;
        return 0;
    }

    queue<pair<int,vector<int>>> que;

    for(ll i=1; i<=9; i++){
        pair<int,vector<int>> a;
        a.first = i;
        a.second.push_back(i);
        que.push(a);
    }

    ll count = 0;
    while(count < K){
        if(!que.empty()) {
            pair<int,vector<int>> p=que.front();
            que.pop();
            count++;
            if(count > K) return 0;
            // cout << "count:" << count << endl;
            // cout << "K:" << K << endl;
            // cout << p.first << endl;

            if(count == K){
                for(auto v: p.second){
                    cout << v;
                }
                cout << endl;
                return 0;
            }
            else{
                if(p.first == 0){
                    pair<int,vector<int>> next;
                    next.first = 0;
                    next.second = p.second;
                    next.second.push_back(0);
                    que.push(next);

                    next.first = 1;
                    next.second = p.second;
                    next.second.push_back(1);
                    que.push(next);
                }
                else if(p.first != 9){
                    pair<int,vector<int>> next;
                    next.first = p.first-1;
                    next.second = p.second;
                    next.second.push_back(p.first-1);
                    que.push(next);

                    next.first = p.first;
                    next.second = p.second;
                    next.second.push_back(p.first);
                    que.push(next);

                    next.first = p.first+1;
                    next.second = p.second;
                    next.second.push_back(p.first+1);
                    que.push(next);

                }
                else{
                    pair<int,vector<int>> next;
                    next.first = 8;
                    next.second = p.second;
                    next.second.push_back(8);
                    que.push(next);

                    next.first = 9;
                    next.second = p.second;
                    next.second.push_back(9);
                    que.push(next);
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 16916
#include <iostream>
#include <algorithm>
using namespace std;
typedef  long long LL;
int main(){
	LL n,d;
	cin >> n >> d;
	d *= d;
	int cnt = 0;
	LL x,y;
	while(n--){
		cin >> x >> y;
		if(x*x + y*y <= d) cnt++;
	}
	cout << cnt;
	return 0;
} 

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

using namespace std;

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

    for(int i=0;i<str.length()-1;i++){
        if(str[i]==str[i+1]) {
            cout << "Bad\n";
            return 0;
        }
    }
    cout << "Good\n";

    return 0;
}


Measured memory_bytes: 256
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = list(map(int, sys.stdin.readline().split()))
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]

graph = [[] for _ in range(N + 1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)


def spanning_tree(root, ret=None, seen=None):
    if ret is None:
        ret = [set() for _ in range(N + 1)]
    if seen is None:
        seen = [False] * (N + 1)
        seen[root] = True
    for v in graph[root]:
        if seen[v]:
            continue
        ret[root].add(v)
        seen[v] = True
        ret = spanning_tree(v, ret, seen)
    return ret


if M % 2 == 1:
    print(-1)
    exit()

# 全域木
root = 1
st = spanning_tree(root)

# 出次数
outdeg = [0] * (N + 1)
ans = []
# 使わなかった辺に向きをつける
for a, b in AB:
    if a not in st[b] and b not in st[a]:
        ans.append((a, b))
        outdeg[a] += 1


def dfs(par):
    # 全域木で par 以下の辺に向きをつける
    for v in st[par]:
        if st[v]:
            dfs(v)
        if outdeg[v] % 2 == 0:
            ans.append((par, v))
            outdeg[par] += 1
        else:
            ans.append((v, par))
            outdeg[v] += 1


dfs(root)
for r in ans:
    print(*r)


Measured memory_bytes: 169260
N, M = map(int, input().split())
key = []
for i in range(M):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    t = 0
    for j in c:
        t |= 1 << (j - 1)  # 1:1, 2:10, 3:100, 4:1000,…
    key.append([t, a])  # 開けられる宝箱を2進数で保持

INF = 10 ** 12
dp = [INF] * (1 << N)  # 1 << N : 2 ** N
dp[0] = 0  # 初期設定
for i in range(1 << N):
    for j in range(M):
        T = i | key[j][0]  # i:すでに開けられる宝箱の状態と鍵で開けられる宝箱の和集合
        cost = dp[i] + key[j][1]
        dp[T] = min(dp[T], cost)

ans = dp[-1]
if ans == INF:
    ans = -1
print(ans)

Measured memory_bytes: 45672
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// class
// ------------------------------------------------
class Combi
{
  public:
    Combi();
    long long Combination(long long n, long long k);
  private:
    vector<vector<long long>> memo;
    long long n_num;
    long long k_num;
    void Resize(long long n, long long k);
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {

  ll h,w,n;cin>>h>>w>>n;
  ll buf = max(h,w);

  ll ans = kiriage(n,buf);


  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}

int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi(){
  n_num = -1;
  k_num = -1;
};
ll Combi::Combination(ll n, ll k)
{
  Resize(n,k);

  ll ret;
  if(memo[n][k] != 0)
  {
    ret = memo[n][k];
  }
  else if(n == k || k == 0)
  {
    memo[n][k] = 1;
    ret = 1;
  }
  else
  {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

void Combi::Resize(ll n, ll k)
{
  if(n_num <= n || k_num <= k)
  {
    n_num = (n + 1) * 2;
    k_num = (k + 1) * 2;
    memo.resize(n_num);
    for(auto itr = memo.begin(); itr != memo.end(); ++itr)
    {
      itr->resize(k_num);
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>

#include <vector>
#include <stack> // s.top()
#include <queue> // s.front()
using namespace std;
typedef long long llong;

#define INFTY 10000000

typedef pair<llong, llong> P;

bool pairComp(const P& firstElof, const P& secondElof) {
	return firstElof.second > secondElof.second;
}

int main() {
	double t, x;

	cin >> t >> x;

	cout << t / x << endl;




	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];
    s = r.readLine();
    sl = s.split(" ");
    
    int v[] = new int[1234];

    int x = Integer.parseInt(sl[0]);
    
    v[1] = 1;
    for(int i = 2; i <= 1000; i++)
    {
      for(int j = i * i; j <= 1000; j *= i)
      {
        v[j] = 1;
      }
    }
    
    for(int i = x; ; i--)
    {
      if(v[i] == 1)
      {
        System.out.println(i);
        System.exit(0);
      }
    }

  }

}

Measured memory_bytes: 21204
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1000000007;

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

  bool cond = s[2] == s[3] && s[4] == s[5];
  string ans = cond ? "Yes" : "No";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
def factorial(a):
    r = 1
    for i in range(a):
        r *= i+1
    return r

def combinations(a, b):
    if a>=0 and b>=0 and a >= b:
        return pow(9, b) * factorial(a) // factorial(b) // factorial(a-b)
    else:
        return 0

def count(m, a, b):
    # return the count of numbers in range [0, m x 10^a] with b non zero digitals
    ## the count of numbers in range [0, m x 10^a) with b non zero digitals
    r = combinations(a-1, b) + (m-1) * combinations(a-1, b-1)
    if b == 1:
        ## m x 10^a
        r += 1
    return r

def COUNT(N,K):
    digit = list(map(int, str(N)))
    M = len(digit)
    C = count(digit[0], M, K)
    if len(digit) > 1:
        N_ = int("".join(map(str, digit[1:])))
    else:
        N_ = 0
    return C, N_
    

N = int(input())
K = int(input())

C = 0
while (N>0) and (K>0):
    c, N = COUNT(N, K)
    C+= c
    K-= 1

print(C)    

Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;

#define ld long double
#define int long long
#define pb push_back 
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef vector< pii > vp;
void swap(int &a,int &b)
{ auto tm=a; a=b; b=tm; }
 
  //Take care of duplicates

  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=(1LL<<50)-1;
  const int N=2e5+25;
  const int M=1e5+2e4+3e3+4e2+5e1;


 void bheja_fry()
 { 
   int n,a,b; cin>>n>>a>>b;
   int x=min(a,b),y=max(a,b);
   if((y-x)%2==0)
   { cout<<(y-x)/2;
     return;
   }

   int ans=min(y-1,n-x);
   a=1; b=y-x;
   ans=min(ans,x+(b-a)/2);
   b=n; a=x+n-y+1;
   ans=min(ans,n-y+1+(b-a)/2);

   cout<<ans;
 }

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

  
   int t=1;                         
//   cin>>t;

  rep(i,1,t+1)
  { // cout<<"Case #"<<i<<": ";
   bheja_fry();
   if(i<t)
   cout<<nl;
  }
  
 return 0; 
}

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

using namespace std;

int main( ) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n;
    string s;
    t = 1;
    while(t--) {
     cin >> n >> s;
     if(n < 3200)
      cout << "red" << endl;
     else
      cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> T keta(T num){ T k=0; while(num>0){ num/=10; k++; } return k; }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll a, b;
    cin >> a >> b;

    ll res = 0;
    if(a <= 0 && 0 <= b) res = 0;
    else if(b < 0 && (abs(a)-abs(b)+1)%2 == 1) res = -1;
    else res = 1;

    if(res == 0){
        cout << "Zero" << endl;
    }else if(res == -1){
        cout << "Negative" << endl;
    }else{
        cout << "Positive" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys

diff = sys.maxsize
ans = ""

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

for i in range(0, N):
    t = T - H[i] * .006
    d = abs(A - t)
    if diff > d:
        ans = i + 1
        diff = d

print(ans)


Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_set>

using namespace std;

typedef unsigned long long ull;

const static ull P = 107;

signed main(void)
{
	string s1, s2;
	cin >> s1 >> s2;

	int len1 = s1.length();
	int len2 = s2.length();

	ull p[30] = {1ULL}; for (int i = 1; i < 30; ++i)p[i] = p[i - 1] * P;

	for (int len = min(len1, len2); len >= 1; --len)
	{
		unordered_set<ull> us1;
		unordered_set<ull> us2;

		register ull tmp1 = 0ULL;
		for (int i = 0; i < len1; ++i)
		{
			tmp1 += p[s1[i] - 'a'];

			if (i >= len)
				tmp1 -= p[s1[i - len] - 'a'];
			if (i >= len - 1)
				us1.insert(tmp1);
		}

		register ull tmp2 = 0ULL;
		for (int i = 0; i < len2; ++i)
		{
			tmp2 += p[s2[i] - 'a'];

			if (i >= len)
				tmp2 -= p[s2[i - len] - 'a'];
			if (i >= len - 1)
				us2.insert(tmp2);
		}

		for (auto i : us1)
			if (us2.count(i))
				return cout << len << endl, 0;
	}

	return cout << 0 << endl, 0;
}

Measured memory_bytes: 3432
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main() {
  int N;
  cin >> N;
  vector<i64> b(N);
  vector<i64> used(N, false);
  rep(i,0,N - 1) cin >> b[i];
  vector<i64> ans;
  for(int c = 0;c < N;c++) {
    int cnt = 0;
    int MAX = -1;
    int MI = -1;
    for(int i = 0;i < N;i++) {
      if(used[i]) continue;
      cnt++;
      if(b[i] == cnt) MAX = cnt, MI = i;
    }
    if(MAX == -1) {
      cout << -1 << endl;
      return 0;
    }
    ans.push_back(MAX);
    used[MI] = true;
  }

  reverse(all(ans));
  for(auto x : ans) {
    cout << x << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <cassert>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <map>

using namespace std;

int main() {
	int n;
	cin >> n;
	int sum = 0;
	int last = 0;
	int current = 0;
	for (int i = 0; i < n-1; ++i) {
		cin >> current;
		if (i == 0) {
			sum += current;
		}
		else {
			sum += min(current, last);
		}
		last = current;
	}
	sum += last;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define ll long long
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
int read(char *s){
    R int len=0;R char ch;while(((ch=getc())>'9'||ch<'0'));
    for(s[++len]=ch;(ch=getc())>='0'&&ch<='9';s[++len]=ch);
    return s[len+1]='\0',len;
}
double readdb()
{
    R double x=0,y=0.1,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(x=ch-'0';(ch=getc())>='0'&&ch<='9';x=x*10+ch-'0');
    for(ch=='.'&&(ch=getc());ch>='0'&&ch<='9';x+=(ch-'0')*y,y*=0.1,ch=getc());
    return x*f;
}
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R int x){
    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
const int N=1e5+5;
struct node{
    int x,y;
    inline bool operator <(const node &b)const{return x<b.x;}
}a[N];
int n,m,k;ll res;
int main(){
    n=read(),m=read();
    fp(i,1,n)a[i].x=read(),a[i].y=read();
    sort(a+1,a+1+n);
    fp(i,1,n)k=min(m,a[i].y),m-=k,a[i].y-=k,res+=1ll*k*a[i].x;
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;


int main()
{
    int i,j,k,n,m;
    cin>>n; string s,t;
    unordered_map<string,int> h;
    bool f=true;
    for(i=0;i<n;i++)
    {
        cin>>s;
        if(i!=0)
        {
            if(h.find(s)!=h.end()) f=false;
            if(s[0]!=t[t.length()-1]) f=false;
        }
        h[s]=1;
        t=s;
    }
    cout<<(f ? "Yes" : "No");
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

N = int(readline().strip())
A = readline().split()

ans = 1
limit = 10**18
for i in range(N):
  if A[i] == '0':
    print(0)
    exit()
for i in range(N):
  ans *= int(A[i])
  if ans > limit:
    ans = -1
    break
print(ans)

Measured memory_bytes: 19492
#include <iostream>
#include <algorithm>

using namespace std;

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

	int l[N];
	for(int i = 0; i < N; i++){
		cin >> l[i];
	}

	int sum_length = 0;

	/*
	int swap;
	for(int i = 0; i < N; i++){
		for(int j = i + 1; j < N; j++){
			if(l[j] > l[i]){
				swap = l[j];
				l[j] = l[i];
				l[i] = swap;
			}
		}
		if(i < K){
			sum_length += l[i];
		}
	}
	*/

	sort(l, l+N, greater<int>());

	for(int i = 0; i < K; i++){
		sum_length += l[i];
	}

	cout << sum_length << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
    ll a=0,b=getchar(),c=1;
    while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
    while(isdigit(b))a=a*10+b-'0',b=getchar();
    return a*c;
}
void print(ll x){
    char y=x%10+'0';
    if(x>=10)print(x/10);
    putchar(y);
}
int n,x,y,a[200];
int main(){
	n=read();
	for(int i=0;i<n;i++){
		x=read(),y=0;
		while(x)a[y++]+=x&1,x>>=1;
	}
	for(int i=0;i<200;i++)
		if(a[i]%2!=0){
			puts("No");
			return 0;
		}
	puts("Yes");
	return 0;
}

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int ans = 0;
	ll X, m = 100;

	cin >> X;

	while (m < X) {
		ans++;
		m = m + m / 100;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {

    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    String revStr = "";
    while (input.ready()) {
      char[] str = input.readLine().toCharArray();
      for (char ch : str) {
        revStr = ch + revStr;
      }
      System.out.println(revStr);
    }
  }

}

Measured memory_bytes: 24336
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define CAT(a,b)a b
#define VASIZE(a,b,N,...)N
template<class T>auto size(T&&a)->decltype(a.size(), int()) { return a.size(); }
template<class T>typename make_signed<decltype(T() % 0)>::type size(T a) { return a; }
#define REP(t,a,N)for(decltype(size(N))t=size(a),_l##t=size(N);t<_l##t;t++)
#define RREP(t,a,N)for(decltype(size(N))t=size(N)-1,_l##t=size(a);t>=_l##t;t--)
#define rep(t,...)CAT(REP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define rrep(t,...)CAT(RREP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define all(a)begin(a),end(a)

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

void Calc() {
  int a, b, c;
  in, a, b, c;

  cout << ((a + b)*c / 2) << endl;


}


Measured memory_bytes: 256