akhauriyash/Code-Regression huggingface dataset:
num = int(input())
str_line = input().split(" ")
num_line = [int(n) for n in str_line]

rank_line = [0 for i in range(num)]

for i in range(num):
    rank_line[num_line[i] - 1] = i+1

for i in range(num):
    print(rank_line[i],end="")
    if(i != num-1):
        print(" ",end="")


Measured memory_bytes: 24228
/* Coached by rainboy */
#include <stdio.h>

#define N 99999

int main() {
	static int aa[N];
	int n, i, x, m;

	scanf("%d", &n);
	x = 0;
	for (i = 0; i < n; i++) {
		scanf("%d", &aa[i]);
		x += aa[i];
	}
	for (i = 1; i < n; i += 2)
		x -= aa[i] * 2;
	printf("%d ", x);
	for (i = 0; i < n - 1; i++) {
		m = aa[i] * 2 - x;
		printf("%d ", m);
		x = m;
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int x[100] = { 0 }, y[100] = {0};
	long h[100] ;//存放方程
	int n;
	cin >> n;
	int i, j;//工具人
	for (i = 0;i < n;i++)//输入方程
		cin >> x[i] >> y[i] >> h[i];
	int p = 0;
	while (h[p] == 0)p++;
	int h_ans, h_t, k, judge;
	for(i=0;i<=100;i++)//使用（i,j）来测中心坐标
		for (j = 0;j <= 100;j++)
		{
			h_ans = h[p] + abs(i - x[p]) + abs(j - y[p]);
			judge = 1;
			for (k = 0;k < n;k++)
			{
				h_t = max(h_ans - abs(i - x[k]) - abs(j - y[k]), 0);
				if (h_t!=h[k])
				{
					judge = 0;
					break;
				}
			}
			if (judge)
			{
				cout << i << ' ' << j << ' ' << h_ans << endl;
				return 0;
			}
		}
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  int sum = 0;
  for(int i = 0;i<N;i++){
    cin >> A.at(i);
    sum += A.at(i);
  }
  int count = 0;
  for(int k =0;k<N;k++){
    if(4*A.at(k)*M >= sum){
      count++;
    }
  }
  if(count >= M){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

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

int main(void){
  ll N, K;
  cin >> N >> K;
  
  ll gcdnums[K+1];
  
  for(ll gcdnum = K; gcdnum>0; gcdnum--){
    ll types = K / gcdnum;
    ll numofarr = modpow(types,N,1000000007);
    if(numofarr<0){
      cout << gcdnum << ":" << numofarr << "\n";
    }
    for(ll i=2; gcdnum*i<=K; i++){
      numofarr -= gcdnums[gcdnum*i];
      if(numofarr < 0) numofarr += 1000000007;
    }
    gcdnums[gcdnum] = numofarr;
    numofarr %= 1000000007;
  }
  
  ll sumofgcdnums = 0;
  for(ll gcdnum=1; gcdnum<=K; gcdnum++){
    sumofgcdnums += gcdnums[gcdnum]*gcdnum;
    sumofgcdnums %= 1000000007;
  }
  cout << sumofgcdnums;
  
  return 0;
}


Measured memory_bytes: 4400
# coding: utf-8
from functools import reduce

n, a, b = map(int, input().split())

def nCr(n, r):
    r = min(n-r, r)
    if r == 0: return 1
    numer = reduce(lambda x, y: x * y % mod, range(n, n - r, -1))
    denom = reduce(lambda x, y: x * y % mod, range(1, r + 1))
    return numer * pow(denom, mod - 2, mod) % mod

mod = 10 ** 9 + 7

tnmo = pow(2, n, mod) - 1
an = nCr(n, a)
bn = nCr(n, b)
ans = (tnmo - an - bn) % mod

print(ans)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int res = 0;
  if (A>=K) res = K;
  else {
    res = A;
    if (K-A-B>0) res -= K-A-B;
  }
  cout << res << endl;
}

Measured memory_bytes: 3636
class UnionFind(T) {
	T[] arr;
	this(ulong n) {
		arr.length = n;
		arr[] = -1;
	}
	T root(T x) {
		return arr[x] < 0 ? x : root(arr[x]);
	}
	bool same(T x, T y) {
		return root(x) == root(y);
	}
	bool unite(T x, T y) {
		x = root(x);
		y = root(y);
		if(x == y) return false;
		if(arr[x] > arr[y]) swap(x, y);
		arr[x] += arr[y];
		arr[y] = x;
		return true;
	}
	T size(T a) {
		return -arr[root(a)];
	}
}

void main() {
	auto ip = readAs!(int[]), n = ip[0], q = ip[1];
	auto uf = new UnionFind!int(n);
	foreach(i; 0..q) {
		auto ip2 = readAs!(int[]), c = ip2[0], x = ip2[1], y = ip2[2];
		if(c == 0) uf.unite(x, y);
		else writeln(cast(int)uf.same(x, y));
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 3472
#include<bits/stdc++.h>
 
using namespace std;
 
void solve(int TestCase) {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    
    auto A = vector<int>(a);
    for(auto& x : A)
        cin >> x;
    auto B = vector<int>(b);
    for(auto& x : B)
        cin >> x;
    auto C = vector<int>(c);
    for(auto& x : C)
        cin >> x;
    
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    
    priority_queue<long long> q;
    long long s = 0;
    for(auto i = 0; i < x; ++i)
    {
        s += A.back();
        q.push(-A.back());
        A.pop_back();
    }
    for(auto i = 0; i < y; ++i)
    {
        s += B.back();
        q.push(-B.back());
        B.pop_back();
    }
    
    long long ret = s;
    for(auto i = 0; i < c; ++i)
    {
        s += C.back();
        q.push(-C.back());
        s += q.top();
        q.pop();
        ret = max(ret, s);
        C.pop_back();
    }

    cout << ret << endl;
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t = 1;
    //cin >> t;
    for(auto i = 1; i <= t; ++i) {
        //cout << "Case #"<< i << ": ";
        solve(i);
    }
}

Measured memory_bytes: 3572
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi p(n);
    rep(i,n){
        cin>>p[i];
    }
    vi a(n),b(n);
    rep(i,n){
        a[i]=n*(i+1);
        b[i]=n*(n-i);
        
    }
    rep(i,n)b[p[i]-1]+=i;
    rep(i,n){
        if(i)cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    rep(i,n){
        if(i)cout<<" ";
        cout<<b[i];
    }
    cout<<endl;
}

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

int main() {
  int n;
  std::cin >> n;
  if (64 <= n) {
    std::cout << 64 << std::endl;
  } else if (32 <= n) {
    std::cout << 32 << std::endl;
  } else if (16 <= n) {
    std::cout << 16 << std::endl;
  } else if (8 <= n) {
    std::cout << 8 << std::endl;
  } else if (4 <= n) {
    std::cout << 4 << std::endl;
  } else if (2 <= n) {
    std::cout << 2 << std::endl;
  } else {
    std::cout << 1 << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
from math import factorial

M, N = map(int, input().split())

def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

if M > 1 and N > 1:
    sum_n = combinations_count(M, 2) + combinations_count(N, 2)

elif M > 1:
    sum_n = combinations_count(M, 2)

elif N > 1:
    sum_n = combinations_count(N, 2)

else:
    sum_n = 0

print(sum_n)

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define INF 1000000000
#define forn(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define for1(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define BUG(x) cout<<x<<endl;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

int N, T, M, K;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	int a, b;
	cin >> a >> b;
	if(abs(a+b)%2 == 0){
		cout << abs(a+b)/2 << endl;
	} else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 256
a,b,c = list(map(int,input().split()))
k = int(input())

BIG = max(a,b,c)
if BIG == a:
  print(BIG*(2**k)+b+c)
elif BIG == b:
  print(BIG*(2**k)+a+c)
else:
  print(BIG*(2**k)+a+b)


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int S,h,m,s;
  scanf("%d",&S);
  h=S/3600;
    m=(S-h*3600)/60;
    s=S-h*3600-m*60;

  printf("%d:%d:%d\n",h,m,s);
  
  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int a[N],vis[N];
int main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	int  x=1,s=0;
	while(x!=2&&!vis[x]){
		vis[x]=1,x=a[x];
		s++; 
	}
	printf(x!=2?"-1":"%d\n",s); 
	return 0;
}

Measured memory_bytes: 4536
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))



n, m, k = map(int, input().split())
M = 998244353

N = 2*10**5 # 必要なテーブルサイズ

def cmb(n, r, M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] * g2[n-r]) % M

g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 

for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M
    
def sub(x):
    return m * pow(m-1, x-1, M)

s = 0
for i in range(k+1):
    if k>0:
        tmp = cmb(n-1, i, M) * sub(n-i)
    else:
        tmp = sub(n)
    s += tmp
    s %= M
#     print(i, tmp)
print(s)

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

int main(){
  int a, b, n, t;
  int k1, k2, k3, k4, k5;
  cin >> a >> b;
  n = b - a + 1;
  int ans = 0;
  int r = a;
  rep(i, n) {
    k5 = r % 10;
    t = r / 10;
    k4 = t % 10;
    t /= 10;
    k3 = t % 10;
    t /= 10;
    k2 = t % 10;
    t /= 10;
    k1 = t % 10;
    if (k1 == k5 && k2 == k4) ans++;
    r++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
import queue

n,m = list(map(int, input().split()))
puted = [0]*(n+1)

ab = [[] for i in range(n+1)]
for i in range(m):
	a,b = list(map(int, input().split()))
	ab[a].append(b)
	ab[b].append(a)

q = queue.Queue()
flg = [-1]*n
flg[0] = 0
q.put(1)

while not q.empty():
	item = q.get()
	for i in ab[item]:
		if puted[i]==0:
			flg[i-1]=item
			q.put(i)
			puted[i]=1

if -1 in flg:
	print("No")
	exit()

print("Yes")
for i in range(1,len(flg)):
	print(flg[i])


Measured memory_bytes: 98996
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int n;

  scanf("%d", &n);

  int c = 0;
  int carry = 0;
  for (int i = 1; i <= n; i++) {
    if (i >= pow(10, carry) && i < pow(10, (carry + 1))) {
      if (carry % 2 == 0) {
        c++;
      }
    } else {
      carry++;
      if (i == pow(10, carry) && carry % 2 == 0) {
        c++;
      }
    }
  }
  
  cout << c << endl;
}


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


int A[26];

int main(){
	long long n,sum;
	string s;
	cin >> s;
	
	n=s.size();
	sum=1ll*n*(n-1)/2;
	for(int i=0;i<n;i++){
		A[s[i]-'a']++;
	}
	
	for(int i=0;i<26;i++){
		sum-=1ll*A[i]*(A[i]-1)/2;
	}
	
	cout << sum+1 << endl;
	return 0;
}

Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
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 A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

ll dp[110][100010];

class EKnapsack2 {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    ll W;
	    in >> n >> W;
	    vector<ll> w(n), v(n);
	    for(int i=0; i<n; i++){
	        in >> w[i] >> v[i];
	    }

        Fill(dp, inf);
	    for(int i=0; i<=n; i++){
	        for(int j=0; j<=100000; j++){
	            dp[i][j] = inf;
	        }
	    }
	    dp[0][0] = 0;

	    for(int i=0; i<n; i++){
	        for(int j=0; j<=100000; j++){
	            if(j - v[i] >= 0) chmin(dp[i+1][j], dp[i][j - v[i]] + w[i]);
	            chmin(dp[i+1][j], dp[i][j]);
	        }
	    }

	    int res = 0;
	    for(int j=0; j<=100000; j++){
            if(dp[n][j] <= W) res = j;
	    }

	    out << res << endl;
	}
};


int main() {
	EKnapsack2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 86144
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
inline int read()
{
    int sum=0,p=1;char ch=getchar();
    while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
    if(ch=='-')p=-1,ch=getchar();
    while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
    return sum*p;
}

const int maxn=1e6+20;
const int mod=1e9+7;

inline int power(int a,int b)
{
    int ans=1;
    while(b)
    {
	if(b&1)ans=(ll)ans*a%mod;
	b>>=1;
	a=(ll)a*a%mod;
    }
    return ans;
}

int n,m,d;
int N1,N2;

inline void init()
{
    n=read();m=read();d=read();
    int jc=1;
    REP(i,1,n)jc=(ll)jc*i%mod,N1=(N1+jc)%mod;
    N2=jc;
}

int f[maxn];

inline void doing()
{
    f[0]=1;
    int s=1;
    REP(i,1,m)
    {
	if(i>d)s=(s-f[i-1-d]+mod)%mod;
	f[i]=(ll)s*N1%mod;
	s=(s+f[i])%mod;
    }
    f[m]=(ll)f[m]*power(N1,mod-2)%mod*N2%mod;
    printf("%d\n",f[m]);
}

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



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

int main(void)
{
	int n, x;
	int d = 0;
	int counter = 1;
	vector<int> l;
	cin >> n >> x;
	for (int i = 0; i < n; ++i)
	{
		int buf;
		cin >> buf;
		l.push_back(buf);
	}
	for (int i = 0; i < n; ++i)
	{
		d += l[i];
		if (d <= x)
		{
			counter++;
		}
		else
		{
			break;
		}
	}
	cout << counter << endl;

	return 0;
}


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

using namespace std;

int main() {
    int n,k;
    cin >> n >> k;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    sort(arr, arr+n);
    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum+=arr[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3592
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;

struct point {
    long long x;
    long long y;
    __int128 dx, dy;

    point() {

    }
    point(long long x, long long y, char d):x(x),y(y){
        dx = dy = 0;
        switch(d) {
            case 'R':
                dx = 1;
                break;
            case 'L':
                dx = -1;
                break;
            case 'U':
                dy = 1;
                break;
            case 'D':
                dy = -1;
                break;
        }
    }

    pair<long double, long double> move(long double time) const {
        return {x+dx*time, y+dy*time};
    }
};

long double check(const vector<point> &m, long double time) {
    long double minx, miny;
    long double maxx, maxy;
    auto q = m[0].move(time);
    maxx = minx = q.first;
    maxy = miny = q.second;
    for (int i = 1; i < m.size(); i++) {
        q = m[i].move(time);
        maxx = max(maxx, q.first);
        minx = min(minx, q.first);
        maxy = max(maxy, q.second);
        miny = min(miny, q.second);
    }
    return abs(maxx-minx) * abs(maxy-miny);
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n,k;
    cin >> n;
    vector<point> P(n);
    for (int i = 0; i < n; i++) {
        long long x,y;
        char d;
        cin >> x >> y >> d;
        P[i] = point(x,y,d);
    }

    long double l = 0.0;
    long double r = 1000000000000000001.0;
    long double m1v, m2v;
    while (r-l > 0.00000000001) {
        long double m1 = l + (r - l) / 3.0;
        long double m2 = r - (r - l) / 3.0;
        m1v = check(P, m1);
        m2v = check(P, m2);
        if (m1v > m2v) {
            l = m1;
        } else {
            r = m2;
        }
    }

    cout << fixed;
    cout << setprecision(12) << (m1v < m2v ? m1v : m2v);
    return 0;
}


Measured memory_bytes: 4992
def main():
    import copy
  
    n = int(input())

    chars_list = ['a']
    a = 'abcdefghij'

    while n - 1 > 0:
        new_list = []
        for char in chars_list:
            for alphabet in a:
                new_list.append(char + alphabet)
                if alphabet not in char:
                    break
        chars_list = copy.deepcopy(new_list)
        n -= 1

    print('\n'.join(chars_list))

if __name__ == '__main__':
    main()


Measured memory_bytes: 16980
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
	size_t n{0};
	cin >> n;
	double a{0};
	double sum{0.0};
	while (n != 0) {
		cin >> a;
		sum = sum + (1 / a);
		n--;
	}
	//cout << (1 / sum) << endl;
	printf("%lf\n", (1 / sum));
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, A[112345], C[112345], B[112345];

int main() {

	cin >> N;
	rep(i, N + 1) cin >> A[i];

	for (ll i = N; i >= 0; --i) {
		C[i] = (C[i + 1] + 1) / 2 + A[i];
	}
	if (N == 0 && A[0] != 1) {
		cout << -1 << endl;
		return 0;
	}
	rep(i, N) {
		if (i < 60 && C[i] >(1ll << i)) {
			cout << -1 << endl;
			return 0;
		}
	}

	ll ans = 0;

	B[0] = 1;
	rep(i, N) {
		B[i + 1] = min((B[i] - A[i]) * 2, 1123456789012345678ll);
	}
	for (ll i = N; i >= 0; --i) {
		C[i] = min(C[i + 1] + A[i], B[i]);
	}

	rep(i, N + 1) ans += C[i];

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5984
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int MOD = 998244353;
const int MAX = 100005;
/* struct for mod Calculation*/
struct mint {
        ll x;
        mint(ll x = 0):x((x % MOD + MOD) % MOD) {}
        mint operator-() const { return mint(-x); }
        mint& operator+=(const mint a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
        mint& operator-=(const mint a) { if ((x += MOD - a.x) >= MOD) x -= MOD; return *this; }
        mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this; }
        mint operator+(const mint a) const { mint res(*this); return res += a; }
        mint operator-(const mint a) const { mint res(*this); return res -= a; }
        mint operator*(const mint a) const { mint res(*this); return res *= a; }
        mint pow(ll t) const {
            if(!t) return 1;
            mint res = pow(t/2);
            res *= res;
            return (t&1)?res*x:res;
        }
        // for prime mod
        mint inv() const { return pow(MOD - 2); }
        mint& operator/=(const mint a) { return (*this) *= a.inv(); }
        mint operator/(const mint a) const { mint res(*this); return res /= a; }
        bool operator<(const mint& a)const{ return x < a.x;}
        bool operator==(const mint& a)const{ return x == a.x;}
};
mint ex(mint x, ll t) { return x.pow(t);}
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
/* global variables */
/* function */
/* main */
int main(){
    int n;
    cin >> n;
    vector<int> cnt(MAX), d(MAX);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
        cnt[d[i]]++;
    }
    if (cnt[0] > 1 || d[0] != 0) {
        cout << 0 << '\n';
        return 0;
    }

    mint ans = 1;
    for (int i = 1; i < MAX; i++) {
        mint x = cnt[i - 1];
        ll p = cnt[i];
        ans *= ex(x, p);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 4012
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
             if 500*i + 100*j + 50*k == x:
                    ans +=1
print(ans)

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

int main()
{
	while (true)
	{
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0)
		{
			break;
		}

		for (int i = 0; i < h; i++)
		{
			
			for (int j = 0; j < w; j++)
			{
				if (i == 0 || j == 0 || i == h -1 || j == w -1)
				{
					cout << "#";
				}
				else
				{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    
    int a = scan.nextInt();

    int b = scan.nextInt();

    int c = scan.nextInt();
    
    if(a+b>=c){
    	System.out.println("Yes");
    }else{

    	System.out.println("No");
    }

  }
}

Measured memory_bytes: 21716
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

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

	int A, B;
	cin >> A >> B;

	cout << (A - 1) * (B - 1) << "\n";

	return 0;
}

Measured memory_bytes: 256
package main

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

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

func nextInt16() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return int(i)
}

func main() {
	sc.Split(bufio.ScanWords)
	var n int = nextInt16()
	var A []int
	var i int = 0
	for ; i < n; i++ {
		A = append(A, nextInt16())
	}
	shellSort(A, n)
	_ = wtr.Flush()
}

func insertionSort(A []int, n int, g int, cnt int) int {
	for i := g; i < (n);i++ {
		v := A[int(i)]
		j := i - g
		for ;j >= 0 && A[int(j)] > v ;{
			A[int(j+g)] = A[int(j)]
			j = j - g
			cnt++
			// fmt.Println("かうんとふえたよ")
			// fmt.Println(j)
		}
		A[j+g] = v
	}
	return cnt
}

func shellSort(A []int, n int) {
	cnt := 0
	G := make([]int,0,0)
	G = append(G, 1)
	for i := 0; i < 99; i++ {
		nextNum := (G[i] * 3) + 1
		if nextNum > int(n) {
			// fmt.Println("ぶれいく")
			break
		}
		G = append(G, nextNum)
		// fmt.Println("ここだよ")
		// fmt.Println(i)
	}
	
	m := len(G)
	fmt.Fprintln(wtr, m)
	fprintArray(G)
	_ = wtr.Flush()

	for i := (m - 1); i >= 0; i-- {
		// fmt.Println("つぎだよ")
		cnt = insertionSort(A, n, G[i], cnt)
		// fmt.Println(i)
	
	}
	fmt.Fprintln(wtr, cnt)
	fprintArrayln(A)
}

func fprintArrayln(arr []int) {
	for i := 0; i < len(arr); i++ {
		fmt.Fprintf(wtr, "%d\n", arr[i])
	}
}
func fprintArray(arr []int) {
	// fmt.Println(len(arr))
	for i := 0; i < len(arr); i++ {
		if i == 0 {
			fmt.Fprintf(wtr, "%d", arr[len(arr)-i-1])
		} else {
			fmt.Fprintf(wtr, " %d", arr[len(arr)-i-1])
		}
	}
	fmt.Fprintln(wtr)
}



Measured memory_bytes: 31372
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll x;
    cin >> x;
    double ans;
    ans = ceil((-1 + sqrt(1 + 8 * x) ) / 2);
    cout << ans << endl;
}   


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int f(int n){
    return ((n+1)/2)%2^(n%2?0:n);
}

void run(){
    int a,b;
    cin>>a>>b;
    cout<<(f(b)^f(a-1))<<endl;
}

Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())

hour = 30 * (M / 60) + 360 * (H / 12)
minute = 360 * (M / 60)

if hour > minute:
    degree = hour - minute
else:
    degree = minute - hour

degree = 360 - degree if degree > 180 else degree
length = A**2 + B**2 - 2 * A * B * math.cos(math.radians(degree))
print(math.sqrt(length))


Measured memory_bytes: 9380
import java.util.*;
public class Main{
  
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int an = a/b;
      if(a%b != 0) an+=1;
      
      System.out.println(an);
	}
 
}

Measured memory_bytes: 23764
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		while( scan.hasNextDouble() ) {
			double y = Math.pow(( scan.nextDouble() / 9.8), 2) * 4.9;
			int i;
			for(i = 1; ; i++ ) {
				if( ( y - (5*i-5) ) < 0 ) {
					break;
				}
			}
			
			System.out.println(i);
		}
	}
}

Measured memory_bytes: 18672
h,w = map(int,input().split())

grid = []
for i in range(h):
    row = str(input())

    for j in range(w):
        if row[j] == "#":
            grid.append(row)
            break

cls = []
for i in range(w):
    count = 0

    for j in range(len(grid)):    

        if grid[j][i] == "." :
            count += 1

    if count >= len(grid) :
        cls.append(i)

for i in range(len(grid)):
    for j in range(w) :
        if j not in cls:
            print(grid[i][j],end="")
    print()
        

Measured memory_bytes: 4468
N=int(input())
H = list(map(int, input().split()))
k=1
if N==1:
  answer='Yes'
else:
  while k<=N-1:
    if H[N-k-1]-H[N-k]>=2:
      answer='No'
      break
    elif H[N-k-1]-H[N-k]==1:
      H[N-k-1]=H[N-k-1]-1
      k+=1
    else:
      k+=1
  if k==N:
    answer='Yes'
  else:
    pass
print(answer)

Measured memory_bytes: 14396
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
bool isprime(int n) {
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
signed main() {
    int X;cin >> X;
    int a = X/1000;
    int b = X/100%10;
    int c = X/10%10;
    int d = X%10;
    if(a+b+c+d==7)cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
    else if(a+b+c-d==7)cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
    else if(a+b-c+d==7)cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
    else if(a+b-c-d==7)cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl; 
    else if(a-b+c+d==7)cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
    else if(a-b+c-d==7)cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
    else if(a-b-c+d==7)cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
    else cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
    return 0;
}

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

int main()
{
	const int BUFF_SIZE = 100;
	char buff[BUFF_SIZE];
	
	while (NULL != fgets(buff, BUFF_SIZE, stdin))
	{
		int a, b;
		sscanf(buff, "%d %d", &a, &b);
		sprintf(buff, "%d", a + b);
		printf("%d\n", strlen(buff));
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
const int INF = 10000000;

int main(){
	int N,Ma,Mb;
	int a[41],b[41],c[41];
	int dp[41][411][411];
	
	for(int i=0;i<41;i++){
		for(int j=0;j<411;j++){
			for(int k=0;k<411;k++){
				dp[i][j][k] = INF;
			}
		}
	}
	dp[0][0][0] = 0;
	
	cin >> N >> Ma >> Mb;
	for(int i=0;i<N;i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	
	for(int i=0;i<N;i++){
		for(int ca=0;ca<=410;ca++){
			for(int cb=0;cb<=410;cb++){
				if(dp[i][ca][cb]==INF)continue;//まだ更新されていない
				dp[i+1][ca][cb] = min(dp[i+1][ca][cb],dp[i][ca][cb]);//i番目の薬品を買わない場合。
				//次の場所(i+1)に、次の場所で必要な金と今の場所で必要な金の最小値を入れる。
				
				dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);//i番目の薬品を買う場合
				//i番目を買うと、Maにa[i]追加　Mbにb[i]追加　　今の場所で必要な金と薬品iの値段(c[i]) との最小値
			}
		}
	}
	
	int answer = INF;
	for(int ca=1;ca<=410;ca++){//比が0対
		for(int cb=1;cb<=410;cb++){//0だとif文が通ってしまう。
			if(ca*Mb == cb*Ma){
				answer = min(answer,dp[N][ca][cb]);//dp後はdp[N](dp[i+1]の終着点)を参照すれば良い
			}
		}
	}
	
	if(answer == INF){//目的の比率にならなかった
		answer = -1;
	}
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 27900
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ttgl, null_type,less<ttgl>, rb_tree_tag,tree_order_statistics_node_update>*/
 
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 100001;
ll arr[mxN];
map<ll, int> mp;
int sz[mxN];
vector<ttgl> ans;
vector<int> adj[mxN];
int par[mxN];
int n;
int dist[mxN];
ll sd = 0;
bool istree() {
    memset(dist, -1, sizeof(dist));
    queue<int> Q;
    Q.push(mp[arr[0]]);
    dist[mp[arr[0]]] = 0;
    while(!Q.empty()) {
        int u = Q.front();
        Q.pop();
        for(int v: adj[u]) {
            if(dist[v]!=-1) {
              return false;
            }
            Q.push(v);
            dist[v] = dist[u]+1;
        }
    }   
    owo(i, 0, n) {
        if(dist[i]==-1) {
            return false;
        }
        sd+=dist[i];
    }
    if(sd!=arr[0])return false;
    return true;
}
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n;
    owo(i, 0, n) {
        cin>>arr[i];
        mp[arr[i]] = i;
    }
    sort(arr, arr+n);
    uwu(i, n, 1) {
        int u = mp[arr[i]];
        sz[u]++;
        ll k = arr[i] + 2LL*sz[u] - n;
        if(mp.count(k)) {
            int v = mp[k];
            par[u] = v;
            adj[v].senpai(u);
            ans.senpai({u, v});
            sz[v]+=sz[u];
        }else {
            cout<<"-1\n";
            exit(0);
        }
    }
    if(istree()) {
        for(auto p: ans) {
            cout<<(p.first+1)<<" "<<(p.second+1)<<"\n";
        }
    }else {
        cout<<"-1\n";
    }
    return 0;
}

Measured memory_bytes: 17724
def floor_sum(n, m, a, b):
    ans = 0
    while 1:
        ans += (n-1)*n//2*(a//m)+n*(b//m)
        a %= m
        b %= m
        y = (a*n+b)//m
        x = b-y*m
        if y == 0:
            return ans
        ans += (x//a+n)*y
        n,m,a,b = y,a,m,x%a
T = int(input())
for i in range(T):
    N,M,A,B = list(map(int,input().split()))
    print(floor_sum(N,M,A,B))


Measured memory_bytes: 70496
#include<iostream>
#include<vector>

using namespace std;

int dp[6][100010];
int dongxi[6] = {100, 101, 102, 103, 104, 105};

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

	for(int i = 0; i < 6; ++i){
		for(int j = 0; j < 100010; ++j){
			if(i == 0 && j!=0 && j % 100 == 0){ dp[i][j] = 1; }
			else { dp[i][j] = 0; }
		}
	}

	for(int i = 0; i < 6; ++i){
		for(int j = 0; j < 100010; ++j){
			if(j == dongxi[i]) { dp[i][j] = 1; }
			if(i-1 >= 0 && dp[i-1][j] == 1) dp[i][j] = 1;
			if(j-dongxi[i] >= 0 && dp[i][j-dongxi[i]] == 1) dp[i][j] = 1;
		}
	}

	if(dp[5][X] == 1){ cout << 1 << endl; }
	else { cout << 0 << endl; }

	return 0;
}


Measured memory_bytes: 2688
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;
const string last = "zyxwvutsrqponmlkjihgfedcba";

char not_yet_used_char(string s){
    bool used[26];
    FOR(i, 0, 26){
        used[i] = false;
    }
    
    for(char c : s){
        used[c - 'a'] = true;
    }
    FOR(i, 0, 26){
        if(!used[i]){
            return 'a' + i;
        }
    }
}

// ecdba => ed
string next_word(string s){
    int i = s.size() - 1;
    while(s[i-1] > s[i]){
        i--;
        if(i==0){
            return "-1";
        }
    }
    char c = s[i-1];
    // cより大きい文字一覧
    vector<char> bigger;
    FOR(j, i, s.size()){
        if(s[j] > c){
            bigger.push_back(s[j]);
        }
    }
    sort(ALL(bigger));
    char q = bigger[0];
    return s.substr(0, i-1) + q;
}

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

    // input
    string s;
    cin >> s;

    if(s.size()<26){
        // まだ使っていない文字で1番若い文字を後端につける
        char c = not_yet_used_char(s);
        p(s + c);
    }
    else{
        if(s == last){
            p(-1);
        }else{
            p(next_word(s));
        }
    }
    return 0;
}

Measured memory_bytes: 256
/* Bismillahir Rahmanir Rahim */
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<string>
#define   mod          1000000007
#define   lp(i,a,b)    for(ll i=a;i<=b;i++)
#define   ll           long long int
#define   ull          unsigned long long int
#define   tst          int t;cin>>t;while(t--)
#define   pb           push_back
#define   vi(v)        vector<int>v;
#define   vl(v)        vector<ll>v;
#define   vs           vector<string>v
#define   rslt(x)      cout<<x<<endl;
#define   mp(x,y)      make_pair(x,y)
#define   yes          rslt("YES");
#define   no           cout<<"NO"<<endl;
#define   srt(v)       sort(v.begin(),v.end())
#define   rvs(v)       reverse(v.begin(),v.end());
#define   AR           ios::sync_with_stdio(false);cin.tie(0);
#define   gcd(a,b)     __gcd(a,b)
#define   lcm(a,b)     (a/gcd(a,b))*b
#define   max          1000007
#define   str          int s[200000];
#define   coutv(v)     for(auto it:v)cout<<it<<' ';cout<<endl;
#define   cinv(v)      for(auto &it:v)cin>>it;
using namespace std;
int main()
{
    AR
    ll n;
    cin>>n;
    if(n==1)
        cout<<0<<endl;
    else cout<<1<<endl;







    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

int main(){
  string s;
  cin >> s;
  vector<int> a;
  for(int i = 0; i < 4; i++){
    int temp = s[i]-'0';
    a.push_back(temp);
  }
  for(int bit = 0; bit < (1<<3); bit++){
    string ans;
    ans += s[0];
    int temp = a[0];
    for(int i = 0; i < 3; i++){
      if(bit & (1<<i)){
        temp += a[i+1];
        ans += "+";
        ans += s[i+1];
      }else{
        temp -= a[i+1];
        ans += "-";
        ans += s[i+1];
      }
    }
    if(temp == 7){
      cout << ans + "=7" << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
typedef pair<int,int> P;
std::vector<P> ans;//答え
int nowx=0,nowy=0;//現在のxとyの場所
void move(int x,int y){
  nowx+=x;nowy+=y;
  ans.push_back(P(nowx,nowy));
}
//main
signed main(){
  int k,x,y;cin>>k>>x>>y;
  if(k%2==0&&((x+y)&1)){cout<<-1<<endl;return 0;}//いけない時
  if(abs(x)+abs(y)==k){cout<<1<<endl<<x<<" "<<y<<endl;return 0;}//一回で行ける場合
  int X=abs(x),Y=abs(y);//x,y>=0にしておく
  int cou=-1;//相殺分
  for(int j=k*2;cou<0;j+=k)if((j-(X+Y))%2==0)cou=(j-(X+Y))/2;//couが相殺分になった
  if(cou){
    int a=cou/k;
    while(a--)move(-k,0);//まず(-k,0)でxを反対方向に行かせる（相殺分を稼ぐ）（cou>=kの時のみ使える）
    cou%=k;
    if(nowx<0)move(k-cou,-cou);//上のwhileが行われた時:残りのcou分yを反対方向に行かせて、xは目的地を目指し始める　
    else{
      /*上のwhileが行われなかった時:
      xかyのどっちかをcou分反対方向に行かせなくてはならない
      この時、xとyの小さい方を反対方向に行かせるべき
      (反対方向に行かなかったやつは正方向にk-cou進むので、そこで目的地を通り越さないようにするため)
      この解法が正しいか自信がないのはここのパート
      */
      if(X>Y)move(k-cou,-cou);
      else move(-cou,k-cou);
    }
  }//これで相殺分逆向きに行ったのであとは目的地を目指すだけ
  while(nowx+k<=X)move(k,0);//(k,0)でxを目的地に行かせる
  while(nowy+k<=Y)move(0,k);//(0,k)でyを目的地に行かせる
  if(nowx!=X||nowy!=Y)ans.push_back(P(X,Y));//もしxとyがたどり着いてないなら最後の一回でたどり着けるようになってる
  cout<<ans.size()<<endl;
  for(auto p:ans){
    if(x<0)cout<<p.first*(-1);//xが負ならxの動き全てに-1倍をすればよい
    else cout<<p.first;
    cout<<" ";
    if(y<0)cout<<p.second*(-1);//yが負の時も同様
    else cout<<p.second;
    cout<<endl;
  }
}


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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if((a == b) && (b == c))
  {
    cout << "No" << endl;
  }
  else if((a == b) || (b == c) || (c == a))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}

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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define btpc       __builtin_popcountll
#define spc(x)     cout<<fixed<<setprecision(x)

const   long long  inf = 1e18;
const   long long  cs =  200005;
const   long long  mod = 1000000007;
const   double     PI =  2 * acos(0.0);
void solve()
{
    long long t,n,m,a,b,i,j,k,x,y,cnt=1;
    bool flag = false; string s;

    cin>>n;
    double aa,sum=0.0;
    for(i=0;i<n;i++)
    {
        cin>>a;
        aa=1.0/a;
        sum+=aa;
    }
    spc(6);
    cout<<1.0/sum<<endl;

}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // ll tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}

Measured memory_bytes: 3660
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 1000000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 60
#define ll long long
#define ull unsigned long long
#define RNG mt19937
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
int n;
int a[200005] = {},loc[200005];
int r[2][100005][20] = {};

int marg(int x,int y){
	if(x > n)return y;
	return (a[x] < a[y]?x:y);
}

int query(int l, int nd){
	int e = l&1;
	int res = MOD;
	int d = (nd - l)/2 + 1;
	l>>=1;
	cd(i,20,0){
		if((d>>i)&1){
			res = marg(res, r[e][l][i]);
			l = l + (1 << i);
		}
	}
	return res;
}

pair<pii,pii> solve(int l, int r){
	assert((r-l)&1);
	int f = query(l,r);
	int s = query(f+1,r);
	return {{a[f],a[s]},{l,r}};
}

int main(){
	fast_io();
	cin >> n;
	cu(i,0,n){
		cin >> a[i];
		loc[a[i]] = i;
		r[i&1][i>>1][0] = i;
	}
	cu(e,0,2){
		cu(p,1,20){
			cu(i,0,n>>1){
				if(i + (1 << p) > n/2)continue;
				r[e][i][p] = marg(r[e][i][p-1], r[e][i + (1 << (p-1))][p-1]);				
			}
		}
	}
	priority_queue<pair<pii,pii>, vector<pair<pii,pii>>, greater<pair<pii,pii>>> pq;
	pq.push(solve(0,n-1));
	while(pq.size()){
		pair<pii,pii> cur = pq.top();pq.pop();
		cout << cur.F.F << ' ' << cur.F.S << ' '; 	
		int l = cur.S.F;
		int nd = cur.S.S;
		int f = loc[cur.F.F];
		int s = loc[cur.F.S];
		if(l < f - 1)pq.push(solve(l,f-1));
		if(f + 1 < s - 1)pq.push(solve(f+1,s-1));
		if(s + 1 < nd)pq.push(solve(s+1,nd));
	}cout << '\n';
}


Measured memory_bytes: 19444
nq = list(map(int, input().split()))
queue = list()

for i in range(nq[0]):
    queue.append(input().split())

ti = 0
cur = 0
while int(queue[cur][1]) > 0:
    num = queue[cur]
    syori = int(num[1]) - nq[1]
    
    if syori > 0:
        num[1] = syori
        queue.append(num)
        ti += nq[1]
    else:
        ti += int(num[1])
        print('{} {}'.format(num[0], ti))
    cur += 1
    
    if len(queue) <= cur:
        break



Measured memory_bytes: 17892
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
ll a[N],b[N];
pair<ll,ll>c[N];
int main()
{
    ft
    ll i,j,n,m,l,r,s=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>b[i];
        a[b[i]]++;
    }
    for(i=1;i<=n;i++)
    {
        l=a[i];
        if(l<2)
        {
            l=0;
        }
        else
        {
            l=(l*(l-1))/2;
        }
        r=a[i]-1;
        if(r<2)
        {
            r=0;
        }
        else
        {
            r=(r*(r-1))/2;
        }
        s+=l;
        c[i]={l,r};
    }
    for(i=0;i<n;i++)
    {
        l=b[i];
        r=s;
        r-=c[l].F;
        r+=c[l].S;
        cout<<r<<"\n";
    }
    return 0;
}



Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,d,x,y;
    cin >> n >> d;
    long long ans = 0;
    for(int i = 0;i < n;i ++){
        cin >> x >> y;
        if(x * x + y * y <= d * d) ans ++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3636