akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
bool isnp[10000010];
long long n,siz,ans=0;
int main(){
	cin>>n;
	siz=sqrt(n);
	for(long long i=2;i<=siz;++i)
		if(!isnp[i])
		{
			for(long long j=i*i;j<=siz;j+=i) isnp[j]=1;
			long long cnt=0;
			while(n%i==0) n/=i,++cnt;
			long long add,sum;
			for(add=0,sum=0;sum<=cnt;)sum+=++add;
			ans+=add-1;
		}
	if(n>1)++ans;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4656
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

inline int f(int n, int i, int L, const vector<int>& sum_rev){
    return (sum_rev[i - n] - sum_rev[i]) + L * (n - 1);
}

int dp[50010];
int sum_dp[50010];

int main(){
    int W, N;
    while(cin >> W >> N && N){
        vector<int> x(N);
        REP(i, N) cin >> x[i];

        vector<int> sum_rev(N + 1);
        sum_rev[N] = 0;
        for(int i = N - 1; i >= 0; i--){
            sum_rev[i] = sum_rev[i + 1] + x[i];
        }

        int lb_L = 0, ub_L = W; // ub
        while(ub_L - lb_L > 1){
            int L = (lb_L + ub_L) / 2;
            dp[0] = 1;
            dp[1] = 0;
            sum_dp[1] = 1;
            sum_dp[2] = 1;

            for(int i = 2; i < N; i++){
                dp[i] = 0;
                sum_dp[i] = sum_dp[i - 1] + dp[i - 1];
 
                int lb = 1, ub = min(i, (W + L)/(L + 1) + 2); // ub  true ??
                while(ub - lb > 1){
                    int n = (ub + lb) / 2;
                    if(f(n, i, L, sum_rev) >= W){
                        ub = n;
                    }else{
                        lb = n;
                    }
                }
                int begin_n = ub;

                //printf("dp[%d] : begin %d \n", i, begin_n);
                if(f(begin_n, i, L, sum_rev) < W){
                    continue;
                }

                lb = begin_n, ub = i + 1; // lb
                while(ub - lb > 1){
                    int n = (ub + lb) / 2;
                    if(f(n, i, 1, sum_rev) <= W){
                        lb = n;
                    }else{
                        ub = n;
                    }
                }
                int end_n = lb; 

                //printf("dp[%d] : end %d \n", i, end_n);
                if(f(end_n, i, 1, sum_rev) > W) {
                    continue;
                }

                int begin = i - end_n;
                int end = i - begin_n;
                // [begin, end]
                if(sum_dp[end + 1] - sum_dp[begin] > 0){
                    dp[i] = 1;
                }
                //printf("dp[%d] : [dp[%d], dp[%d]] (%d) -> %d\n", i, begin, end, sum_dp[end + 1] - sum_dp[begin], dp[i]);
            }

            bool ok = false;
            for(int n = 1; n <= N && (n - 1) + sum_rev[N - n] <= W; n++) {
                //printf("n - 1 + sum_rev[%d] = %d\n", i, n - 1 + sum_rev[i]);
                if(dp[N - n]){
                    ok = true;
                    break;
                }
            }
            //printf("L %d  is %d\n", L, ok);

            if(ok){
                ub_L = L;
            }else{
                lb_L = L;
            }
        }

        cout << ub_L << endl;
    }
    return 0;
}

Measured memory_bytes: 1836
#include<bits/stdc++.h>
using namespace std;
string s;
int l;
char n;
int main() {
	   cin>>s;
    l=s.size();
    for(int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int gcd(long long int &a, long long int &b){
  if (a == 0 || b == 0){
    return max(a, b);
  } else {
    long long int c = min(a, b);
    long long int d = max(a, b) % min(a, b);
    return gcd(c, d);
  }
}
int main()
{
  long long int A, B, C, D;
  cin >> A >> B >> C >> D;
  long long int ansA, ansB, a, lcm;
  a = C/gcd(C, D);
  lcm = a * D;
  ansA = (A-1)/C + (A-1)/D - (A-1)/lcm;
  ansB = B/C + B/D - B/lcm;
  cout << B - A + 1 - (ansB - ansA) << endl;
  return 0;
}

Measured memory_bytes: 256
l, r = gets.split.map(&:to_i)

def fin(mm)
  p mm
  exit
end

m = 2019
if l == r
  m = (l*r).modulo 2019
else
  (l..r-1).each{|i|
    (i+1..r).each{|j|
      t = (i*j).modulo 2019
      m = t if m > t
      fin(m) if m.zero?
    }
  }
end

p m

Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n,t,a;
    cin >> n >> t >> a;
    int h[1100];
    int ans;
    double v = INF;
    rep(i,n)cin >> h[i];
    rep(i,n){
        if(v>(double)abs(a-(t-h[i]*0.006))){
            v=(double)abs(a-(t-h[i]*0.006));
            //cout << (double)abs(a-(t-h[i]*0.006)) << endl;
            ans=i+1;
        }
    }
    
    cout << ans;
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 0; i < n; i++) {
        ans += (i + 1) * (n - i);
    }
    for(ll i = 0; i < n - 1; i++) {
        ll u, v;
        cin >> u >> v;
        if(u > v) swap(u, v);
        ans -= u * (n - v + 1);
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3660
import java.io.*;
class Main{
	public static void main(String args[])throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str = br.readLine();
		String array[] = str.split(" ");
		
		int W = Integer.parseInt(array[0]);
		int H = Integer.parseInt(array[1]);
		int x = Integer.parseInt(array[2]);
		int y = Integer.parseInt(array[3]);
		int r = Integer.parseInt(array[4]);
		
		if(x >= 0 && y >=0){
		if(W >= x + r && H >= y + r){
			System.out.println("Yes");
			}else {
				System.out.println("No");
			}
				}else if(x <= 0 && y <=0) {
					System.out.println("No");
					
					}else if(x >= 0 && y <=0) {
					System.out.println("No");
                       }else if(x <= 0 && y >=0){
					System.out.println("No");
					
					}
					}
					}

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

int main()
{
    //input
    long long x, k, d;
    cin >> x >> k >> d;
    x = abs(x);

    //the shortest distance from the origin
    long long shor = min(k, x / d);
    k -= shor;
    x -= shor * d;

    if (k % 2 == 0)
    {
        cout << x << endl;
    }
    else
    {
        cout << d - x << endl;
    }

    return 0;
}

// TLE
/***
#include <bits/stdc++.h>
using namespace std;

int main()
{
    //input
    long long x, k, d;
    cin >> x >> k >> d;

    //get close to the origin
    for (long long i = 0; i < k; i++)
    {
        long long p = abs(x + d);
        long long m = abs(x - d);
        if (p < m)
            x += d;
        else
            x -= d;
    }

    //output the absolute value of x
    cout << abs(x) << endl;
    return 0;
}
***/

Measured memory_bytes: 3604
//Code by: Nikhil Shukla, MMMUT GKP
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define V vector
#define pb push_back
#define all x x.begin(),x.end()
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc ll t; cin>>t; while(t--)
#define tc1 ll tt=1; while(tt--)
#define fir first
#define sec second
#define mod 998244353
#define out1(x) cout<<x<<"\n";
#define out2(x,y) cout<<x<<" "<<y<<"\n";
#define debug() cout<<"I am in\n";
#define Vll vector<long long>
#define FOR(i,x,n) for(ll i=x;i<n;i++)
#define RFOR(i,x,n) for(ll i=x;i>=n;i--)
////////////////////////////////////////////////////////////////////////////////////////
/*vector<ll>graph[100001];
vector<ll>temp;
vector<bool>visited(100001,false);
//long long count=0;
void dfs(long long node)
{
       // count++;
        temp.pb(node);
        visited[node]=1;
        for(ll i=0;i<graph[node].size();i++)
        {
            if(!visited[graph[node][i]])
            dfs(graph[node][i]);
        }
}*/
int main()
{
    fast()
    tc1
    {
        ll n,k,i,f;
        cin>>n;
        ll a[n],b[n],c[n];
        FOR(i,0,n)
        cin>>a[i]>>b[i]>>c[i];
        ll dp[n][3];
        dp[0][0]=a[0];
        dp[0][1]=b[0];
        dp[0][2]=c[0];
        FOR(i,1,n)
        {
            dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
            dp[i][1]=b[i]+max(dp[i-1][2],dp[i-1][0]);
            dp[i][2]=c[i]+max(dp[i-1][1],dp[i-1][0]);
        }
        cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<"\n";
    }
    return 0;
}


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

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

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

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

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

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

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

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

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

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

int main() {
	int n, k;
	cin >> n >> k;
	VI a(n);
	REP(i, n) { cin >> a[i]; }
	REP(i, n - k) {
		if(a[i] < a[i + k]) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}


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

int main(){
    int h,w;

    while(true){
        cin >> h >> w;
        if(h==0 && w==0) break;
        else{
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                    if((i+j)%2 == 0){
                       cout << '#';
                    }
                    else{
                       cout << '.';
                    }
                }
                cout << endl;
            }
            cout << endl;
        }
    }
}


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

int main(){
	int a,b;
	for(int i=1;i>=1;i++){
		cin>> b >> a ;
		if((a==0)&&(b==0)){
		    break;
		}
		for(int i=0;i<b;i++){
			for(int j=0;j<a;j++){
				cout << "#";
			}
			cout << endl;
		}	
		cout <<endl;
	}
	return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,W;
    cin>>n>>W;
    long long w[n],v[n];
    for(int i=0;i<n;i++)cin>>w[i]>>v[i];
    long long dp[n+1][n+1][n*3+1];//i個見てj個選んでkの重さのときの最大価値
    for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)for(int k=0;k<=n*3;k++)dp[i][j][k]=-1000000000;
    dp[0][0][0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=n*3;k++){
                dp[i+1][j][k]=max(dp[i+1][j][k],dp[i][j][k]);
                if(j<n && k+w[i]-w[0]<=n*3)dp[i+1][j+1][k+w[i]-w[0]]=max(dp[i+1][j+1][k+w[i]-w[0]],dp[i][j][k]+v[i]);
            }
        }
    }
    long long m=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n*3;j++){
            if(W-w[0]*i>=j)m=max(m,dp[n][i][j]);
        }
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 24192
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N, X;
int m[MAX_N];

int main(void)
{
  cin >> N >> X;
  REP(i, N) cin >> m[i];

  int ans = N;
  REP(i, N) X -= m[i];
  int mi = INT_MAX;
  REP(i, N) mi = min(mi, m[i]);
  ans += X / mi;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import Numeric

showF :: RealFloat a => a -> String
showF = flip (showFFloat Nothing) ""

main :: IO ()
main = do
  [x1, y1, x2, y2] <- fmap (map read . words) getLine
  putStrLn . showF $ dist2d (x1, y1) (x2, y2)
    where dist2d (x1, y1) (x2, y2) =
            sqrt $ ((x1-x2)^2) + ((y1-y2)^2)

Measured memory_bytes: 3864
import java.util.*;

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

		int N = stdIn.nextInt();
		String[] tramps = new String[N];
		int[] trampsNumber = new int[N];

		for (int i = 0; i < N; i++) {
			tramps[i] = stdIn.next();
			trampsNumber[i] = tramps[i].charAt(1);
		}

		String[] sectionSort = new String[N];
		String[] bubbleSort = new String[N];

		int[] sectionSortNumber = new int[N];
		int[] bubbleSortNumber = new int[N];

		for (int i = 0; i < N; i++) {
			sectionSort[i] = tramps[i];
			bubbleSort[i] = tramps[i];
			sectionSortNumber[i] = trampsNumber[i];
			bubbleSortNumber[i] = trampsNumber[i];
		}


		/*?????????????????¬???*/
		for (int i = 0; i < N; i++) {
			int min = sectionSortNumber[i];
			int minIndex = i;

			/*??´?????????????????????????????§????°????????????????*/
			for (int j = i + 1; j < N; j++) {
				if (min > sectionSortNumber[j]) {
					min = sectionSortNumber[j];
					minIndex = j;
				}
			}

			/*??\???????????????????????????????????????*/
			if (minIndex != i) {
				/*??´????????????????????????????????¨????°?????????´????????\????????????*/
				int tmpNumber = sectionSortNumber[i];
				String tmp = sectionSort[i];

				sectionSortNumber[i] = sectionSortNumber[minIndex];
				sectionSort[i] = sectionSort[minIndex];

				sectionSortNumber[minIndex] = tmpNumber;
				sectionSort[minIndex] = tmp;
			}
		}

		/*????????????????????¬???*/
		for (int i = 0; i < N; i++) {
			for (int j = N - 1; j > i; j--) {
				if (bubbleSortNumber[j] < bubbleSortNumber[j - 1]) {
					String tmp = bubbleSort[j - 1];
					int tmpNumber = bubbleSortNumber[j - 1];

					bubbleSort[j - 1] = bubbleSort[j];
					bubbleSortNumber[j - 1] = bubbleSortNumber[j];

					bubbleSort[j] = tmp;
					bubbleSortNumber[j] = tmpNumber;
				}
			}
		}
		/*????????????*/
		for (int i = 0; i < N - 1; i++) {
			System.out.print(bubbleSort[i] + " ");
		}
		System.out.println(bubbleSort[N - 1]);
		System.out.println("Stable");

		for (int i = 0; i < N - 1; i++) {
			System.out.print(sectionSort[i] + " ");
		}
		System.out.println(sectionSort[N - 1]);

		int stableFlag = 1;
		for (int i = 0; i < N; i++) {
			if (!sectionSort[i].equals(bubbleSort[i])) {
				stableFlag = 0;
				break;
			}

		}

		if (stableFlag == 1) {
			System.out.println("Stable");
		}else{
			System.out.println("Not stable");
		}

	}
}

Measured memory_bytes: 26140
#include <bits/stdc++.h>
using namespace std;
using lint  = long long;
const lint MOD = 1e9+7;

lint modpow(lint m, lint n){
  if(n == 0) return 1;
  else if(n % 2 == 0) return modpow(m * m % MOD, n/2);
  else{
    return modpow(m, n - 1) * m % MOD;
  }
}

signed main(){
  lint N; cin >> N;
  vector<lint> a(N);
  for(lint i = 0; i < N; i++) cin >> a[i];
  sort(a.begin(), a.end());
  lint ans;
  bool ok = true;
  vector<lint> p(N);
  if(N % 2 == 0){
    for(lint i = 0; i < N; i++){
      if(i % 2 == 0) p[i] = i + 1;
      else p[i] = i;
    }
    ans = modpow(2, N/2);
  }
  else{
    for(lint i = 0; i < N; i++){
      if(i % 2 == 0) p[i] = i;
      else p[i] = i + 1;
    } 
    ans = modpow(2, (N - 1)/2);
  }
  for(lint i = 0; i < N; i++){
    if(a[i] != p[i]) ok = false;
  }
  if(ok) cout << ans << endl;
  else cout << 0 << endl;
}

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

using namespace std;

int main(void) {
    string s;

    cin >> s;

    string rev = s;
    reverse(rev.begin(), rev.end());

    int n = s.size();

    string tmp = s.substr(0, (n / 2));
    string revTmp = tmp;
    reverse(revTmp.begin(), revTmp.end());

    string tmp2 = s.substr(((n + 3)/2) - 1, n - ((n + 3)/2) + 1);
    string revTmp2 = tmp2;
    reverse(revTmp2.begin(), revTmp2.end());

    if (s == rev && tmp == revTmp && tmp2 == revTmp2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	t = div(n*(n+1),2)
	if n%2 == 1
		println(div((n-1)*(n-1),2))
		s = t-n
		for i in 1:n
			for j in i+1:n
				if t-i-j != s
					println(i, " ", j)
				end
			end
		end
	else
		println(div((n-1)*(n-1)-1,2))
		s = t-n-1
		for i in 1:n
			for j in i+1:n
				if t-i-j != s
					println(i, " ", j)
				end
			end
		end
	end
end
main()

Measured memory_bytes: 110212
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
typedef long long ll;
string s;
  int main()
{
    int k;
    cin>>k;
    int target=7%k;
    int cnt=1;
    while(cnt<=k)
    {
        if(target==0)
        {
            cout<<cnt<<endl;
            return 0;
        }
        target=(target*10+7)%k;
        cnt++;
    }
    cout<<-1<<endl;
}



Measured memory_bytes: 3604
import sys
n = int(input())
i = -1
tmp = n
all9 = True
while True:
    if tmp % 10 != 9 and tmp // 10 != 0:
        all9 = False
    i += 1
    tmp //= 10
    if tmp == 0:
        break
if i == 0:
    print(n)
    sys.exit()
ans = n //(10 ** i)- 1
for j in range(i):
    ans += 9
if all9:
    ans += 1
print(ans)


Measured memory_bytes: 38256
#include<iostream>
using namespace std;
int main()
{
	int m, n, i, j, k, sum ;
	while (cin>>n>>m)
	{
		sum = 0;
		if (m == 0 && n == 0)break;
		for (i = 1; i <= n; i++)
			for (j = i + 1; j <= n; j++)
				for (k = j + 1; k <= n; k++)
					if (i + k + j == m)
						sum++;	
		cout << sum << endl;		
	}
	
	return 0;
}


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

int main(){
int a,ans;
ans=0;
cin>>a;
for(int i=0;i<=50000;i++){
  int tmp=i*1.08;
  if(tmp==a){
    ans=i;
    break;
  }
}
if(ans!=0){
  cout<<ans<<endl;
}else{
  cout<<":("<<endl;
}
}




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

int main(){
  ll n;
  cin >> n;
  vector<ll> k(20);
  k[0] = 1;
  int keta;
  for(int i=1; i<12; ++i){
    k[i] = k[i-1] * 26 +1;
    if(k[i] > n){
      keta = i;
      break;
    }
  }
  string ans(keta, 'a');
  n -= k[keta-1];
  keta = ans.size()-1;
  while(n > 0){
    ans[keta] += n%26;
    //cout << keta << ':' << ans[keta] << endl;
    n /= 26;
    keta--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <numeric>
#include <cmath>
#include <queue>

using namespace std;
using ll = long long;

int main()
{
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    vector<ll> A(X);
    vector<ll> B(Y);
    vector<ll> C(Z);

    for (auto&& Ai : A) {
        cin >> Ai;
    }

    for (auto&& Bi : B) {
        cin >> Bi;
    }

    for (auto&& Ci : C) {
        cin >> Ci;
    }

    sort(begin(A), end(A), greater<ll>());
    sort(begin(B), end(B), greater<ll>());
    sort(begin(C), end(C), greater<ll>());

    vector<ll> ABC;
    for (int a = 0; a < X; ++a) {
        for (int b = 0; b < Y; ++b) {
            if ((a+1)*(b+1) > K) {
                break;
            }

            for (int c = 0; c < Z; ++c) {
                if ((a+1)*(b+1)*(c+1) > K) {
                    break;
                }

                ABC.emplace_back(A[a] + B[b] + C[c]);
            }
        }
    }

    sort(begin(ABC), end(ABC), greater<ll>());

    for (int i = 0; i < K; ++i) {
        cout << ABC[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 1404
def from_10_to_n(x, n):
  tmp = x
  out = ''
  while tmp > 0:
    out = str(x % n) + out
    tmp = tmp // n
  return out
 
N, K = map(int, input().split())
N = from_10_to_n(N, K)
print(len(N))

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

using namespace std;

#define PB push_back
#define MP make_pair
#define FOR( i , n ) for( int i = 0; i < (n); i++ )
#define FORR( i , n ) for( int i = ( n - 1 ); i >= 0 ; i-- )
#define DB( x ) cout << #x << " = " << x << endl;
#define OUT( a , n ) for( int J = 0; J < (n); J++ )cout<< (a)[J] << " \n"[J == (n) - 1 ]
#define WAIT cout << flush , system("PAUSE");
#define CONTAINS(a, x) ((a).find(x) != (a).end())
#define endl '\n'

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

#define y1 _skjbgerge

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

	cin >> s;
	int lo = 0, hi = s.size() - 1;

	bool flag = true;
	while(lo < hi){
		flag &= (s[lo] == s[hi]);
		lo++;
		hi--;
	}
	cout << (flag ? "Yes" : "No") << endl;


	return 0;
}


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

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

const int N = 710;
const int M = N << 1;

int mat[N][N];
std::bitset <N> dp[2];
int fa[M], sz[2][M];
bool vis[N];

int find(int u){
    return fa[u] == u ? u : (fa[u] = find(fa[u]));
}

void unite(int u, int v){
    u = find(u), v = find(v);
    if (u == v) return;
    fa[u] = v;
}

inline int sqr(int n){return n * (n - 1) / 2;}

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0, u, v; i < m; ++ i){
        scanf("%d%d", &u, &v);
        mat[u][v] = mat[v][u] = 1;
    }
    for (int i = 1; i < M; ++ i){
        fa[i] = i;
    }
    for (int i = 1; i <= n; ++ i){
        for (int j = i + 1; j <= n; ++ j){
            if (!mat[i][j]){
                if (find(i) == find(j)){
                    puts("-1");
                    return 0;
                }
                unite(i, j + n);
                unite(i + n, j);
            }
        }
    }
    for (int i = 1; i <= n; ++ i){
        ++ sz[0][find(i)];
    }
    for (int i = n + 1; i <= n << 1; ++ i){
        ++ sz[1][find(i)];
    }
    int now = 0;
    dp[now].set(0);
    for (int i = 1; i <= n << 1; ++ i){
        if (find(i) != i || vis[i]) continue;
        vis[i] = vis[find(i + n)] = true;
        dp[now ^ 1] = dp[now] << sz[0][i] | dp[now] << sz[1][i];
        now ^= 1;
    }
    int min = INT_MAX;
    for (int i = 1; i <= n; ++ i){
        if (!dp[now].test(i)) continue;
        min = std::min(min, sqr(i) + sqr(n - i));
    }
    printf("%d\n", min);
    return 0;
}

Measured memory_bytes: 2176
fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

fn reads<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().split(' ').map(|x| x.parse().unwrap()).collect()
}

fn main() {
    let hw = reads();
    //let n = readln();
    get_line();
    let xs = reads();

    let mut idx = 0;
    let mut a: u64 = xs[idx];
    idx += 1;

    let mut rs = vec![vec![0; hw[1]]; hw[0]];

    for i in 0..hw[0] {
        for j in 0..hw[1] {
            let j = if i % 2 == 0 {j} else {hw[1] - j - 1};

            if a == 0 {
                a = xs[idx];
                idx += 1;
            }

            rs[i][j] = idx;
            a -= 1;
        }
    }

    for i in 0..hw[0] {
        for j in 0..(hw[1] - 1) {
            print!("{} ", rs[i][j]);
        }
        println!("{}", rs[i][hw[1] - 1]);
    }
}


Measured memory_bytes: 4352
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n;
ll k;
vector<ll>v1,v2;
bool judge(ll m)
{
    m++;
    ll ans=0;
    ll s1=v1.size(),s2=v2.size();
    if(m==0)
    {
        for(int i=0;i<s2;i++)
            if(v2[i]==0) ans+=s1;
        ans+=(ll)s1*(s1-1)/2;
        ans+=(ll)s2*(s2-1)/2;
        ans=(ll)n*(n-1)/2-ans;
        return ans>=k;
    }
    if(m>0)
    {
        for(int i=0;i<s1-1;i++)
        {
            ll x=m/v1[i];
            if(m%v1[i]) x++;
            int k=lower_bound(v1.begin()+i+1,v1.end(),x)-v1.begin();
            ans+=s1-k;
        }
        for(int i=0;i<s2-1;i++)
        {
            if(v2[i]==0) continue;
            ll x=m/v2[i];
            if(m%v2[i]) x++;
            int k=lower_bound(v2.begin()+i+1,v2.end(),x)-v2.begin();
            ans+=s2-k;
        }
        ans=(ll)n*(n-1)/2-ans;
        return ans>=k;
    }
    if(m<0)
    {
        m*=-1;
        ans+=(ll)s1*(s1-1)/2;
        ans+=(ll)s2*(s2-1)/2;
        for(int i=0;i<s1;i++)
        {
            ll x=m/v1[i];
            int k=upper_bound(v2.begin(),v2.end(),x)-v2.begin()-1;
            ans+=k+1;
        }
        ans=(ll)n*(n-1)/2-ans;
        return ans>=k;
    }
}
int main()
{
    scanf("%d%lld",&n,&k);
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);
        if(x<0) v1.push_back(-x);
        else v2.push_back(x);
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    ll l=-1e18,r=1e18,ans;
    while(l<=r)
    {
        ll m=l+r>>1;
        if(judge(m)) ans=m,r=m-1;
        else l=m+1;
    }
    printf("%lld\n",ans);
}



Measured memory_bytes: 2548
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

INF=Float::INFINITY
def min(a,b)
    return a>b ? b : a
end
H,W=get_i
c=array(10)
10.times do|i|
    c[i]=get_i
end
a=array(H)
H.times do|i|
    a[i]=get_i
end
10.times do|k|
  10.times do|i|
      10.times do|j|
        c[i][j]=min(c[i][j],c[i][k]+c[k][j])
      end
  end
end
ans=0
a.each do|arr|
    arr.each do|a_|
      ans+=c[a_][1] if a_!=-1  
    end
end
puts ans

Measured memory_bytes: 2556
#include <iostream>
#include <set>
#include <string>

int main()
{
    using namespace std;
    
    string s; cin >> s;
    
    set<char> se;
    
    for (auto c : s)
    {
        se.emplace(c);
    }
    
    if (se.size() == 26)
        cout << "None" << endl;
    else
        for (char a = 'a'; a <= 'z'; ++a)
            if (se.count(a) == 0)
            {
                cout << a << endl;
                break;
            }
    
    return 0;   
}

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

int main()
{
    int N;
    cin >> N;
    queue<int> a;
    int an;
    for (int i = 0; i < N; i++)
    {
        cin >> an;
        a.push(an);
    }

    int j = 0, count = 0;

    for (int i = 0; i < N-1; i++)
    {
        if (a.front() != j+1)
        {   
            a.pop();
            count++;
        }

        else
        {
            j++;
            a.pop();
        }        
        
    }


    if (a.front() != j+1 && j == 1)
    {
        cout << count+1;
    }

    else if (a.front() != j+1)
    {
        cout << -1;
    }

    else
    {
        cout << count;
    }
    
    
    
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
lists = ['{0:03d}'.format(i) for i in range(1000)]
import re
def check(target, a):
    ans = re.search(a, target)
    if ans == None:
        return None
    else:
        return target[ans.start()+1:]

def print_ans(N, S):
    """Test Case
    >>> print_ans(4, "0224")
    3
    >>> print_ans(6, "123123")
    17
    >>> print_ans(19, "3141592653589793238")
    329
    """
    # s = set()
    # for i in range(N):
    #     for k in range(i+1,N):
    #         for l in range(k+1, N):
    #             s.add(S[i] + S[k] + S[l])
    # print(len(s))
    ans = 0
    for a in lists:
        tmp = S
        for i in range(3):
            tmp = check(tmp, a[i])
            if tmp == None:
                break
        if tmp != None:
            ans += 1
    print(ans)


    # print(check('123','4'))


    
if __name__ == '__main__':
    N = int(input().rstrip())
    S = input().rstrip()
    print_ans(N, S)


Measured memory_bytes: 45532
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int i,j,k,l,n,a[202];
   cin>>n;l=0;
    for(i=0;i<n;i++){cin>>a[i];
      if(a[i]%2==1){l=1;}
        }
    if(l==1){cout<<"0\n";}
     else{
        j=0;

       while(l==0){
            for(i=0;i<n;i++){
            a[i]/=2;
                if(a[i]%2==1){l=1;break;}
      } 
            j++;
        }
        cout<<j<<endl;


     }


}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var p = sc.ArrayInt(N);
        var sorted = p.OrderBy(val => val).ToArray();
        var a = 0;
        for (int i = 0; i < N; i++) {
            if (p[i] != sorted[i]) {
                a++;
            }
        }
        if (a == 2 || a == 0) {
            WriteLine("YES");
        } else {
            WriteLine("NO");
        }
    }
    
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13268
# -*- coding: utf-8 -*-
import sys
from collections import deque

N=input()

nl=[ [] for i in range(N+1) ] 

for _ in range(N-1):
	a,b=map(int, sys.stdin.readline().split())
	nl[a].append(b)
	nl[b].append(a)


C=map(int, sys.stdin.readline().split())
C.sort(reverse=True)
C=deque(C)


start=None
max_nl_cnt=0
for i in range(1,N+1):
	nl_cnt=len( nl[i] )
	if max_nl_cnt < nl_cnt:
		start=i
		max_nl_cnt=nl_cnt

Visit=[ None for i in range(N+1) ] 

q=deque()
q.append(start)
val=C.popleft()
Visit[start]=val

ans=0
while q:
	x=q.popleft()
	for to in nl[x]:
		if Visit[to] is None:
			val=C.popleft()
			Visit[to]=val
			ans+=val
			q.append(to)

print ans
for x in Visit[1:]:
	print x,


Measured memory_bytes: 34460
#include<stdio.h>
int main(){
  int n,m,mi,lc,d[1010],t[1010],i;
  while(scanf("%d %d",&n,&m),n){
    for(i=0;i<n;i++)scanf("%d",&d[i]);
    for(i=mi=0;i<n;i++)t[i]=m%d[i];
    for(i=lc=1;i<n;i++){
      if(t[i]==t[mi]){
	if(d[i]==d[mi])lc++;
	if(d[i]< d[mi]){
	  mi=i;
	  lc=1;
	}
      }
      if(t[i]>t[mi]){
	mi=i;
	lc=1;
      }
    }
    printf("%d\n",lc-1?n:mi+1);
  }
  return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

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

long long mod_div(long long a,long long b){
	if(a % b == 0)return a/b;
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}


ll dp[4][111111];

int main(){
	
	string str;cin >> str;
	
	ll tmp = 1;
	ll cou = 0;
	REP(i,str.size()){
		if(str[i] == '?')cou++;
	}
	REP(i,cou){
		tmp *= 3;
		tmp %= MOD;
	}
	
	dp[0][0] = tmp;
	REP(i,str.size()){
		REP(j,4){
			if(dp[j][i]){
				if(j < 3){
					if(str[i] == 'A'+j){
						dp[j+1][i+1] += dp[j][i];
						dp[j+1][i+1] %= MOD;
					}
					else if(str[i] == '?'){
						dp[j+1][i+1] += mod_div(dp[j][i],3);
						dp[j+1][i+1] %= MOD;
					}
				}
				dp[j][i+1] += dp[j][i];
				dp[j][i+1] %= MOD;
			}
		}
	}
		
	cout << dp[3][str.size()] << endl;
	
	return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N; cin >> N;
	int ans = mod;
	int num, sum;
	for (int i = 0; i <= N; i++) {
		sum = 0;
		num = i;
		while (num > 0) {
			sum += num % 6;
			num /= 6;
		}
		num = N - i;
		while (num > 0) {
			sum += num % 9;
			num /= 9;
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;

public class Program
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        for (int cake = 0; cake <= n / 4; cake++)
        {
            for (int donut = 0; donut <= n / 7; donut++)
            {
                if (n == cake * 4 + donut * 7)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
        }

        Console.WriteLine("No");
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

int f(int x) {
  switch (x) {
    case (1):
    case (3):
    case (5):
    case (7):
    case (8):
    case (10):
    case (12):
      return 1;
    case (4):
    case (6):
    case (9):
    case (11):
      return 2;
    case (2):
      return 3;
  }
}
void solve(void) {
  int x, y;
  cin >> x >> y;
  Yes_No(f(x) == f(y));
}
int main(void) { solve(); }

Measured memory_bytes: 3480
#include <stdio.h>
#include <string.h>

#define M 1046527/* your task*/
#define L 14
#define X 7

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value */
int getKey(char str[]){
  int sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
  return key % M/* your task */;
}

int h2(int key){
  return 1 + key % (M-1)/* your task */;
}

int find(char str[]){
  int i = 0;
  int h = 0;
  int got = 0, got1 = 0, got2 = 0;

  got = getKey(str);
  got1 = h1(got);
  got2 = h2(got);
  while(1){
    h = (got1 + i * got2) % M;
    if(strcmp(str, H[h]) == 0){    
      return 1;
    }
    else if(strlen(H[h]) == 0)return 0;
    i++;
  }
}

void insert(char str[]){
  int i = 0;
  int h = 0;
  int got = 0, got1 = 0, got2 = 0;

  got = getKey(str);
  got1 = h1(got);
  got2 = h2(got);
  while(1){
    h = (got1 + i * got2) % M;
    if(strcmp(H[h],str) == 0)break;
    else if(H[h][0] == '\0'){
      strcpy(H[h],str);
      break;
    }
    i++;
  }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str) == 1){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 16052
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i, j, k;
	int a[11];
	for (i = 0; i < n; i++)
		a[i] = 0;
	int b[11];
	for (;;)
	{
		for (i = 0; i < n; i++)
			printf("%c", 'a' + a[i]);
		printf("\n");
		a[n - 1]++;
		k = 1;
		while(k>0)
		{
			k = 0;
			for (i = n - 1; i > 0; i--)
			{
				if (a[i] >= n)
				{
					a[i] = 0;
					a[i - 1]++;
				}
			}
			for (i = 0; i < n; i++)
				b[i] = 0;
			b[0]++;
			for (i = 1; i < n; i++)
			{
				if (a[i] > 0)
				{
					if (b[a[i] - 1] == 0)
					{
						a[i - 1]++;
						for (j = i; j < n; j++)
							a[j] = 0;
						k = 1;
						break;
					}
					else
						b[a[i]] = 1;
				}
			}
			if (a[0] > 0)
				break;
		}
		if (a[0] > 0)
			break;
	}
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
#define puts(x) cout << x << "\n"
#define endwith return
constexpr int mod = 1000000007;
using namespace std;
int input() { int t; cin >> t; return t; }
int n, a[234567], k;
signed main() {
	cin >> n;
	for0(i, n) { cin >> a[i]; k ^= a[i]; }
	for0(i, n) { if (i)cout << ' '; cout << (a[i] ^ k); }cout << endl;
}

Measured memory_bytes: 5152
#include<stdio.h>
#define ll long long
int main(void){
    ll n,i,d;
    ll count=0;
    scanf("%lld",&n);
    if(n%2==1)
    printf("0\n");
    else{
        d=2;
        for(i=1;(d*5)<=n;i++){
            d*=5;
            count+=n/d;
        }
        printf("%lld\n",count);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
int main() {
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for ( int i = 0; i < m; ++i ) {
        int x;
        cin >> x;
        sum += x;
    }
    if (n - sum >= 0) {
        cout << n - sum << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
program alchemist
  implicit none
  integer :: n, v(50) = 0, i
  real(8) :: ave = 0.d0
  character(64) :: s
  read(*,*) n
  read(*,*) v(1:n)
  call quick_sort(v(1:n))
  ave = real(v(1),8)
  do i = 2, n
    ave = 0.5d0*(ave+real(v(i),8))
  end do
  write(s,'(f32.16)') ave
  write(*,'(a)') trim(adjustl(s))
contains
  recursive subroutine quick_sort(a)
    integer, intent(inout) :: a(:)
    integer :: p, c
    integer :: n, l, r, m
    n = size(a)
    l = 1
    r = n
    m = (l+r)/2
    p = a(l)+a(m)+a(r)-max(a(l),a(m),a(r))-min(a(l),a(m),a(r))
    do
      do while (a(l) < p)
        l = l+1
      end do
      do while (a(r) > p)
        r = r-1
      end do
      if (l >= r) exit
      c = a(l)
      a(l) = a(r)
      a(r) = c
      l = l+1
      r = r-1
    end do
    if (l > 2) call quick_sort(a(1:l-1))
    if (n > r+1) call quick_sort(a(r+1:n))
  end
end program alchemist

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	char c;
	scanf("%c",&c);
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
		printf("vowel\n");
	}
	else{
		printf("consonant\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int a[10000];
int c[10];
int n,k;
int top;
bool used[10];
void DFS(int x,int dept){
	if(dept==k){
		bool t=true;
		for(int i=0;i<top;i++){
			if(a[i]==x)t=false;
		}
		if(t){
			a[top]=x;
			top++;
		}
		return;
	}
	for(int i=0;i<n;i++){
		if(!used[i]){
			used[i]=true;
			if(c[i]>=10)DFS(x*100+c[i],dept+1);
			else DFS(x*10+c[i],dept+1);
			used[i]=false;
		}
	}
}
int main(){
	while(true){
	cin>>n>>k;
	if(n==0&&k==0)break;
	top=0;
	for(int i=0;i<n;i++){
		cin>>c[i];
		used[i]=false;
	}
	DFS(0,0);
	cout<<top<<endl;
	}
	return 0;
}

Measured memory_bytes: 1168
n, k = map(int, input().split())
a = list(map(int, input().split()))

city = 1
p = [0]*n
p[0] = 1
root = [1]

for cnt in range(k):
    city = a[city-1]
    root.append(city)
    if p[city-1] == 1:
        break
    else:
        p[city-1] = 1
    if cnt == k-1:
        print(city)
        exit()
        
loop = root[root.index(city):-1]

num = (k - root.index(city))%(len(loop))
print(loop[num])

Measured memory_bytes: 32372
#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>
#include <sstream>
#include <regex>

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
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * 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;
	int ave = 0;
	vector<int> a(n); 
	rep(i, n)
	{
		cin >> a[i];
		ave += a[i];
	}
	int mn = 1e4;
	int res = 0;
	rep(i, n)if (chmin(mn, abs(ave - a[i] * n)))res = i;
	cout << res << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define endl '\n'
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
using namespace std;
using namespace __gnu_pbds;

int32_t main() {
	int v[3];
	for(int &i : v)
		cin >> i;
	sort(v, v+3);

	if(v[0] == v[1] && v[1] != v[2] or v[1] == v[2] && v[2] != v[0]) 
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  int n;
  cin >> n;
  LL sum = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      sum += i;
    }
  }
  cout << sum << "\n";
  return 0;
}

Measured memory_bytes: 3652