akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
int N;
ll M;
const ll P = 1e9+7;
vector<bool> sieve;
vector<int> primes;
ll fact[200000];


void eratosthenes(int maximum){
	sieve = vector<bool>(maximum+1);
	sieve[0]=sieve[1]=false;
	for(int i=2; i<sieve.size(); i++) sieve[i]=true;
	for(int j=4; j<sieve.size(); j+=2) sieve[j]=false;
	for(int i=3; 2*i<sieve.size(); i++){
		if(!sieve[i]) continue;
		for(int j=2*i; j<sieve.size(); j+=i) sieve[j] = false;
	}
}

void get_primes(int maximum){
	if(sieve.size() < maximum) eratosthenes(maximum);
	for(int i=2; i<sieve.size(); i++){
		if(sieve[i]) primes.push_back(i);
	}
}

map<int, int> get_factors(int x){
	map<int, int> factors;
	for(int p: primes){
		if(p*p>x) break;
		while(x%p==0){
			factors[p]++;
			x /= p;
		}
	}
	if(x>1) factors[x]++;
	return factors;
}


// Extended Euclid's greatest common divisor algorithm
// Find (x, y, g)
// where $a*x + b*y = g$ and g is the greatest common divisor of (a, b)
ll ext_gcd(ll a, ll b, ll &x, ll &y){
	if(b == 0){
		x = 1;
		y = 0;
		return a;
	}
	ll nx, ny;
	ll g = ext_gcd(b, a%b, nx, ny);
	x = ny;
	y = nx - a/b *ny;
	return g;
}

// Modular inverse of x given modulo p, y
// x*y = 1 mod p
// <=> x*y + z*p = 1
ll inv_mod(ll x, ll p){
	ll y,z;
	ext_gcd(x, p, y, z);
	return y>=0 ? y : p+(y%p);
}


// Modular factorial of n, also counting p's appearance e
// n! = a * p^e
// return: a % p
// n! = n * (n-1) * ... * (k*p+1) *
//      (k*p) * (k*p-1) * ... ((k-1)*p+1) *
//      ...
//      p * (p-1) * ... * 2 * 1   (k = floor(n/p))
//    = (n%p) * ... * 1 *
//      (k*p) * (p-1) * ... * 1 *
//      p * (p-1) * ... * 1       (mod p, preserving p's multiples)
//    = (n%p)! * p^k * k! * (p-1)^k
//    = (n%p)! * p^k * k! * (p-1)^(k%2)
//
// From the facts:
//   (p-1)! = p-1 (mod p) (c.f. Willson's theorem)
//   (p-2)**2 = 1 (mod p)
ll fact_mod(ll n, ll p, ll &e){
	if(n == 0){
		e = 0;
		return 1;
	}

	ll na = fact_mod(n/p, p, e);

	e += n/p;
	ll a = na * fact[n%p] % p;

	if((n/p)%2) a = a * (p-1)%p;
	return a;
}


// Modular combination (n, m) given module p
// (n, m) = n!/(n-m)!m!
//        = (a_n * p^(e_n)) / ((a_{n-m} * p^(e_{n-m}) * (a_m * p^e_m))
//        = a_n / (a_{n-m} * a_m) * p^(e_n - e_{n-m} - e_m)
ll comb_mod(ll n, ll m, ll p){
	ll e1,e2,e3;
	ll a1 = fact_mod(n, p, e1);
	ll a2 = fact_mod(m, p, e2);
	ll a3 = fact_mod(n-m, p, e3);

	if(e1 > e2+e3) return 0;
	else return a1*inv_mod(a2*a3%p, p)%p;
}

int main(){
	get_primes(100000);
	fact[0] = fact[1] = 1;
	for(int i=2; i<200000; i++) fact[i] = fact[i-1]*i%P;

	cin >> N >> M;
	map<int, int> factor = get_factors(M);

	ll ans = 1;
	for(auto pair: factor){
		int prime = pair.first;
		int k = pair.second;
		ans *= comb_mod(N+k-1, k, P);
		ans %= P;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1920
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
d = sorted(map(int, raw_input().split()))
print d[N / 2] - d[N / 2 - 1]

Measured memory_bytes: 11572
import sys

def solve():
    N = int(input())
    if N % 2 == 1: print(0)
    else: 
        ans = 0
        for i in range(18):
            ans += N // pow(10, i+1)
            fd = 5 * pow(10, i+1)
            while fd <= N:
                ans  += (N // fd + 1) // 2
                fd *= 5
        print(ans)
    
    return 0

if __name__ == "__main__":
    solve()

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

int main() {
	int N;
	int d[100];
	int count = 0;
	int tmp[100] = { 0 };

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

	for (int i = 0; i < N; i++) {
		bool flag = true;
		for (int j = 0; j <= i; j++) {
			if (tmp[j] == d[i]) {
				flag = false;
			}
			if (j == i && flag) {
				tmp[i] = d[i];
				count++;
			}
		}
	}

	cout << count << endl;

	return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	int n;
	string s;
	cin >> n >> s;
	string ans;
	if(n%2==1) {cout << "No"<<endl;return 0;}
	else {
		rep(i,n/2) {
			if(s[i] != s[n/2+i]){ cout << "No" << endl;return 0;}
		}
		cout << "Yes" << endl;
	}

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        int k = sc.nextInt();
        for (int i = 0; i < k; i++) {
            if (i % 2 == 0) {
                if (a % 2 == 0) {
                    b += a / 2;
                    a = a / 2;
                } else {
                    a--;
                    b += a / 2;
                    a = a / 2;
                }
            } else {
                if (b % 2 == 0) {
                    a += b / 2;
                    b = b / 2;
                } else {
                    b--;
                    a += b / 2;
                    b = b / 2;
                }
            }
        }
        System.out.printf("%d %d%n", a, b);
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
int x[101];
int main()
{
int n,i;
cin>>n;
double cot=0;
for(i=0;i<n;i++)
   {
     cin>>x[i];
     cot+=x[i];
   }
   int pj=cot/n;
   if(cot/n-pj>=0.5)
    pj+=1;
int ans=0;
for(i=0;i<n;i++)
    ans+=pow((x[i]-pj),2);
    cout<<ans<<endl;
}


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

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

struct UnionFind{
    vector<int> v;
    int size;

    UnionFind(int n):size(n){
        v = vector<int>(size+1,-1);
    }

    int parent(int a){
        if(v[a] < 0)    return a;
        return v[a] = parent(v[a]);
    }

    void unite(int a,int b){
        if(same(a,b)){
            return;
        }
        int size_a = abs(v[parent(a)]);
        int size_b = abs(v[parent(b)]);

        if(size_a >= size_b){
            v[parent(a)] = -1*(size_a + size_b);
            v[parent(b)] = parent(a);
        }else{
            v[parent(b)] = -1*(size_a + size_b);
            v[parent(a)] = parent(b);
        }
    }

    bool same(int a,int b){
        return parent(a) == parent(b);
    }
};

struct mypair{
    int a;
    int b;

    mypair(){
        a = 0;
        b = 0;
    }

    mypair(int i, int j){
        a = i;
        b = j;
    }
    
    bool operator < (const mypair &right)const{
        return a < right.a;
    }
};

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

    int n,m;

    cin >> n >> m;

    vector<int> p(n+1);

    for(int i = 1; i < n+1; i++){
        cin >> p[i];
    }

    UnionFind uf = UnionFind(n);

    for(int i = 0; i < m; i++){
        int x,y;
        cin >> x >> y;
        uf.unite(x,y);
    }

    vector<mypair> vec(n+1);

    for(int i = 1; i < n+1; i++){
        vec[i] = mypair(uf.parent(i),i);
    }

    sort(vec.begin()+1,vec.end());

    int i = 1;
    int count = 0;
    while(i < n+1){
        int group = vec[i].a;
        vector<int> tmp;
        set<int> st;
        tmp.push_back(vec[i].b);
        st.insert(vec[i].b);
        i++;
        while(i < n+1 && vec[i].a == group){
            tmp.push_back(vec[i].b);
            st.insert(vec[i].b);
            i++;
        }
        for(int j = 0; j < tmp.size(); j++){
            if(st.find(p[tmp[j]]) == st.end()){

            }else{
                count++;
            }
        }
    }

    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 6904
s = input()
i, j = 0, 0
for t in range(len(s)):
    if s[t] == 'A':
        i = t
        break
for t in reversed(range(len(s))):
    if s[t] == 'Z':
        j = t
        break
print(len(s[i:j])+1)

Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    int n=0,i;
    cin>>a;
    cin>>b;
    for(i=0;i<a.size();i++)
    {
        if(a[i]!=b[i])
            n++;
    }
    cout<<n<<endl;
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    long long X;
    cin >> X;
    long long L = 100;
    long long cont = 0;

    while(true){
        cont++;
        L = L*1.01;
        //cout << L << endl;
        if(X <= L)break;
    
    }
    cout << cont << endl;
}


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

int N;
string s;
int a = 0;
int b = 0;
int c = 0;
int ans = 0;

int main() {
    cin >> N;
    for (int i=0; i<N; ++i) {
        cin >> s;
        int len = s.size();
        bool flag = false;
        for (int j=0; j<len; ++j) {
            if (flag && s[j]=='B') {
                ++ans;
                flag = false;
            } else if (s[j] == 'A') flag = true;
            else flag = false;
        }
        if (s[0] == 'B' && s[len-1]=='A') ++c;
        else if (s[0] == 'B') ++b;
        else if (s[len-1] == 'A') ++a;
    }
    if (c > 0) {
        ans += c - 1;
        c = 1;
        if (a > 0 || b > 0) ++ans;
    }

    cout << ans + min(a, b) << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

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

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

				`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	n := nextInt()
	m := nextInt()

	a := nextInts(n)
	sort.Ints(a)

	bc := make([]BC, m)

	for i := 0; i < m; i++ {
		bc[i].b = nextInt()
		bc[i].c = nextInt()
	}
	sort.Sort(PSort(bc))

	aindex := 0
	for i := m - 1; i >= 0; i-- {
		for j := 0; j < bc[i].b; j++ {
			if aindex >= n {
				i = -1
				break
			}
			if a[aindex] > bc[i].c {
				i = -1
				break
			}
			a[aindex] = bc[i].c
			aindex++
		}
	}
	ans := 0
	for i := 0; i < n; i++ {
		ans += a[i]
	}

	//	fmt.Fprintln(out, "[DEBUG]]", a)
	fmt.Fprintln(out, ans)
}

type BC struct {
	b int
	c int
}

type PSort []BC

func (a PSort) Len() int           { return len(a) }
func (a PSort) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a PSort) Less(i, j int) bool { return a[i].c < a[j].c }

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

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

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

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 6016
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a=Integer.parseInt(sc.next());
int b=Integer.parseInt(sc.next());
int numb=b-a;
int temp=0;
for(int i=1;i<=numb-1;i++){
    temp+=i;
}
System.out.println(temp-a);
}
}

Measured memory_bytes: 23764
num = int(input())
result = 0
for fizzbuzz in range(1, num+1):
    if fizzbuzz % 3 == 0 and fizzbuzz % 5 == 0:
        continue
    elif fizzbuzz % 3 == 0:
        continue
    elif fizzbuzz % 5 == 0:
        continue
    
    result += fizzbuzz

print(result)

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

int main() {
  long long N, M;
  cin >> N >> M;

  vector<long long> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);

  set<long long> Set;
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    if (H.at(A) < H.at(B))
      Set.insert(A);
    else if (H.at(A) > H.at(B))
      Set.insert(B);
    else {
      Set.insert(A);
      Set.insert(B);
    }
  }

  cout << N - Set.size() << endl;
}


Measured memory_bytes: 6616
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var a = int.Parse(_[0]);
            var b = int.Parse(_[1]);

            if(b % a == 0){
                Console.WriteLine(a + b);
            }else{
                Console.WriteLine(b - a);
            }
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	
	int n,k,x,y; cin>>n>>k>>x>>y; ll sum = 0;
	for(int i = 0; i < n; i++){
		if(i < k) sum += x;
		else sum += y;
	}
	cout<<sum<<"\n";
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define For(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
typedef vector<long long> vlint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<vector<long long>> vlint2;



int main() {
    int r; cin >> r;
    cout << r * r << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 6000;
ll dp[MAX_N],dp2[MAX_N*MAX_N];
// dp[i]は、i個のどんぐりを最大何個まで変換できるかを記録する
void chmax(ll &a, ll b){ if( a < b ){ swap(a,b);} return;}
int main(){
  ll N; cin >> N;
  vector<ll> a(3),b(3);
  for(ll i = 0; i < 3; i++){ cin >> a[i];}
  for(ll j = 0; j < 3; j++){ cin >> b[j];}
  
  for(ll i = 0; i <= N; i++){ 
    // AからBの遷移にかけて、どんぐりi個を最大何個まで変換できるかを考える
    chmax(dp[i],i); //何も変換しないとき
    for(ll j = 0; j < 3; j++){
      if( i-a[j] >= 0 ){ 
      chmax(dp[i], dp[i-a[j]]+b[j]);
      }
    }// fo-j
  }//for-i
  
  ll M = dp[N];
  
  for(ll i = 0; i <= M; i++){
    chmax(dp2[i],i);
    for(ll j = 0; j < 3; j++){
      if( i-b[j] >= 0 ){
        
        chmax( dp2[i], dp2[i-b[j]]+a[j] );
      }
    }
  }
  
  cout << dp2[M] << endl;
  
  return 0;
}


Measured memory_bytes: 196864
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n);
    vector<pair<ll,ll>> vec(n);
    vector<ll> x1(n),x2(n),x3(n),x4(n);
    rep(i,n){
        in(vec[i].first,vec[i].second);
        x1[i]=vec[i].first+vec[i].second;
        x2[i]=vec[i].first-vec[i].second;
        x3[i]=-vec[i].first+vec[i].second;
        x4[i]=-vec[i].first-vec[i].second;
    }
    sort(rall(x1));
    sort(rall(x2));
    sort(rall(x3));
    sort(rall(x4));
    out(max(x1[0]+x4[0],x2[0]+x3[0]));
}

Measured memory_bytes: 12736
import numpy as np
A,B,H,M = map(int,input().split())

s = np.zeros([2])
l = np.zeros([2])

s_deg = np.pi/2 - 2*np.pi/(12*60)*(60*H+M)
l_deg = np.pi/2 - 2*np.pi/60*M

s[0]=A*np.cos(s_deg)
s[1]=A*np.sin(s_deg)
l[0]=B*np.cos(l_deg)
l[1]=B*np.sin(l_deg)

print(np.sqrt((s[0]-l[0])**2+(s[1]-l[1])**2))

Measured memory_bytes: 27120
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
 
 
int main(){
    string s; cin >> s;
    ll n = s.size();
    //string tmp = "";
    //tmp.push_back(s[0]);
    char tmp = 'A';
    ll cnt = 0;
    rep(i,n){
        if(tmp == s[i]){
            i++;
            if(i < n) cnt++;
            tmp = 'A';
        }else{
            cnt++;
            tmp = s[i];
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(e,s) (s.find(e)!=s.end())
using ll=long long int; using dd=double;
using pii=pair<int,int>; using pll=pair<ll,ll>;
// #define int ll
typedef vector<int> vi;
ll INFLL=(ll)2e18, MOD=1e9+7;
const int INF=0x6f6f6f6f;
///////////*//////// DEBUG /////////////////////////////////////////
#ifdef DEBUG
#define D(x) cerr<<#x<<" is: "<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are: "<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are: "<<x<<' '<<y<<' '<<z<<'\n';
auto tStart = chrono::system_clock::now(); //freopen("op.txt","w",stdout);
#else 
#define D(x) ;
#define DD(x,y) ;
#define DDD(x,y,z) ;
#endif
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<ll>> adj; vi vis;
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m){ll res=1;while(n){if(n&1)res=(res*x)%m;n>>=1;x=((x%m)*(x%m))%m;}return res;}
inline bool ispow2(ll x){ return x && (!(x&(x-1)));}
inline ll gcd(ll x, ll y){ pll p{x,y}; while(p.ss) p={p.ss,p.ff%p.ss}; return p.ff;}

/////////////////// MAIN STARTS //////////////////////////////////
int main(void){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());

int n; cin>>n;
map<int,int> e,o;
vi v(n); for(int i=0;i<n;++i) {
  cin>>v[i];
  if(i%2==0) e[v[i]]++; 
  else o[v[i]]++;
}
vv<pii> a(all(e)), b(all(o));
auto comp= [](pii& a, pii& b){return b.ss<a.ss;};
a.eb(0,0); b.eb(0,0);
sort(all(a), comp); sort(all(b),comp);
for(auto& e: a) cerr<<e.ff<<' '<<e.ss<<'\n';
for(auto& e: b) cerr<<e.ff<<' '<<e.ss<<'\n';
if(a[0].ff!=b[0].ff){
  cout<<n-a[0].ss-b[0].ss<<'\n';
}
else if(a[0].ss==b[0].ss){
  cout<< n-a[0].ss-max(a[1].ss,b[1].ss) <<'\n'; 
}
else if(a[0].ss>b[0].ss){
  cout<<n-a[0].ss-b[1].ss<<'\n';
}
else{
  cout<<n-b[0].ss-a[1].ss<<'\n';
} 

#ifdef DEBUG
auto diff=chrono::system_clock::now()-tStart;
cerr<<"\nExecution time: "<<chrono::duration<dd,milli>(diff).count()<<" ms.\n";
#endif
return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
#define MAXN 200001
#define INF -200000000000000
ll a[MAXN];
ll dp[MAXN][3];
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < MAXN; i++) {
        for (int j = 0; j < 3; j++) {
            dp[i][j] = INF;
        }
    }
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    dp[1][0] = a[1];
    dp[1][1] = a[2];
    dp[1][2] = a[3];
    for (int i = 2; i <= n / 2; i++) {
        dp[i][0] = dp[i - 1][0] + a[i * 2 - 1];
        dp[i][1] = max(dp[i - 1][1], dp[i - 1][0]) + a[i * 2];
        if (n % 2) dp[i][2] = max(dp[i - 1][2], max(dp[i - 1][1], dp[i - 1][0])) + a[i * 2 + 1];
    }
    if (n % 2) cout << max(max(dp[n / 2][2], dp[n / 2][1]), dp[n / 2][0]) << endl;
    else cout << max(dp[n / 2][1], dp[n / 2][0]) << endl;
    return 0;
}

Measured memory_bytes: 9896
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INF = 1LL << 60;

 int main() {
   int N; cin >> N;
   vector<int> A(N);
   rep(i, 0, N) cin >> A.at(i);

   vector<int> left(N), right(N);

   left.at(0) = A.at(0);
   rep(i, 1, N) left.at(i) = __gcd(left.at(i - 1), A.at(i));

   right.at(N - 1) = A.at(N - 1);
   for (int i = N - 2; i >= 0; i--) right.at(i) = __gcd(right.at(i + 1), A.at(i));

   int ans = max(left.at(N - 2), right.at(1));
   rep(i, 1, N - 1) {
     ans = max(ans, __gcd(left.at(i - 1), right.at(i + 1)));
   }

   cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int ans[102][102];
int sum[102][102];

int main() {

    // 1. input.
    int r = 0, c = 0;
    scanf("%d %d", &r, &c);
    for(int i = 1; i <= r; i++){
        int rTotal = 0;
        for(int j = 1; j <= c; j++){
            int v = 0;
            scanf("%d", &v);
            ans[i][j] = v;
            sum[i][j] += sum[i - 1][j] + ans[i][j];
            rTotal += v;
        }
        ans[i][c + 1] = rTotal;
        sum[i][c + 1] += sum[i - 1][c + 1] + ans[i][c + 1];
    }
    for(int j = 1; j <= c + 1; j++) ans[r + 1][j] = ans[r][j] + sum[r - 1][j];
    
    // 2. output answer.
    for(int i = 1; i <= r + 1; i++){
        for(int j = 1; j <= c + 1; j++){
            printf("%d", ans[i][j]);
            if(j < c + 1) printf("%c", ' ');
        }
        printf("%c", '\n');
    }
    
    return 0;
    
}


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

using namespace std;

typedef long long ll;

ll A, B, C, D;

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

ll calc(ll x){
	ll ret = x;
	ret -= x / C;
	ret -= x / D;
	ret += x / lcm(C, D);

	return ret;
}

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


	cin >> A >> B >> C >> D;

	cout << calc(B) - calc(A - 1) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define INFTY 1000000000
int count=0;
void merge(int *, int, int, int);
void mergeSort(int *, int, int);
int main() {
  int i, n, left=0;
  scanf("%d", &n);
  int S[n];
  for(i = 0; i < n; i++) {
    scanf("%d", &S[i]);
  }
  mergeSort(S, left, n);
  for(i = 0; i < n; i++) {
    printf("%d", S[i]);
    if(i != n-1)printf(" ");
  }
  printf("\n%d\n", count);
  return 0;
}
  
void merge(int *A, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1], R[n2];
  for(i = 0; i < n1; i++) {
    L[i] = A[left+i];
  }
  for(i = 0; i < n2; i++) {
    R[i] = A[mid+i];
  }
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
  for(k = left; k < right; k++) {
    count++;
    if(L[i] <= R[j]) {
      A[k] = L[i];
	i = i + 1;
    }
    else {
      A[k] = R[j];
      j = j + 1;
    }
  }
}

void mergeSort(int *A, int left, int right) {
  int mid;
  if(left+1 < right) {
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

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

int main() {
    int N;
    cin >> N;
    
    set<string> S;
    rep (i, N) {
        string s;
        cin >> s;
        S.insert(s);
    }
    cout << S.size() << endl;
}

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

const ll mod = 1e9 + 7;
const ll nmax = 1e5 + 5;
vector<vector<ll>> g(nmax, vector<ll>());
ll k;

ll dfs(ll used = 0, ll now = 0, ll parent = -1) {
  ll ans = k - used;

  if (used < 2) {
    used++;
  } else {
    used = 2;
  }

  for (auto next : g[now]) {
    if (next == parent) continue;
    ans *= dfs(used, next, now);
    ans %= mod;
    used++;
  }

  return ans;
}

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

  ll a, b;
  for (ll i = 0; i < n - 1; i++) {
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  cout << dfs() << endl;
}


Measured memory_bytes: 11520
s = str(input())

if s[0]==s[3]==s[1]==s[2]:
  print('No')
elif (s[0]==s[1] and s[2]==s[3]) or (s[0]==s[2] and s[1]==s[3]) or (s[0]==s[3] and s[1]==s[2]):
  print('Yes')
else:
  print('No')

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) V vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define cont const auto
#define fi first
#define se second
#define Vec vector
#define P pair
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
typedef priority_queue<ll,vector<ll>,greater<>> PQ;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n,k;
  cin>>n>>k;
  V a(n);
  rep(i,n)cin>>a[i];
  
  int ans=-INF,mx=min(n,k);
  rep(i,mx+1){
    rep(j,mx-i+1){
      //debg(i);debg(j);
      if(i==0&&j==0)continue;
      int res=k-i-j;
      PQ tmp;
      rep(x,i)tmp.push(a[x]);
      rep(x,j)tmp.push(a[n-1-x]);
      while(res--){
        if(tmp.top()<0)tmp.pop();
        else break;
        if(tmp.empty())break;
      }
      int sum=0;
      //cout<<"que ";
      while(!tmp.empty()){
        //cout<<tmp.top()<<" ";
        sum+=tmp.top();
        tmp.pop();
      }
      chmax(ans,sum);
      //ENDL;debg(sum);debg(ans);
    }
  }
  out(ans);

  
  
  
  return 0;
}



Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {

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

  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(3));
  for (int i = 0; i<n; ++i) {
    for (int j = 0; j < 3; ++j) cin >> a[i][j];
  }
  vector<vector<int>> dp(n, vector<int>(3));
  for (int i = 0; i < 3; ++i) dp[0][i] = a[0][i];
  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j < 3; ++j) {
      dp[i + 1][j] = max(dp[i][(j + 1) % 3], dp[i][(j + 2) % 3]) + a[i + 1][j];
    }
  }
  int res = 0;
  for (int i = 0; i < 3; ++i) res = max(res, dp[n - 1][i]);
  cout << res << endl;

  return 0;
}

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

using namespace std;

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

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

    for (int p = 0; p < n - m + 1; ++p) {
        for (int q = 0; q < n - m + 1; ++q) {
            bool flag = true;
            for (int k = 0; k < m; ++k) {
                if (b[k] != a[p + k].substr(q, m)) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


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

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

    int a, b; cin >> a >> b;
    if (a > 0) {
        cout << "Positive" << endl;
    } else if (b > 0) {
        cout << "Zero" << endl;
    } else {
        if ((b-a+1)%2 == 0) {
            cout << "Positive" << endl;
        } else {
            cout << "Negative" << endl;
        }
    }

    return 0;
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	
	for(int i=0 ; i<n-2; i++)
	{
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
			ans++;
	}
	
	cout << ans;
}



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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()

const long long MOD = 1000000007;


int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll x[n];
    rep(i, n)
        cin >> x[i];

    ll cost = 0;
    rep(i, n-1){
        cost += min((x[i+1]-x[i])*a, b);
    }

    cout << cost << endl;

    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
vector<vector<int> > A;
typedef pair<short,short> P;

bool bfs(){
  sort(A.begin(),A.end());
  A.erase(unique(A.begin(),A.end()),A.end());
  int n = A.size();
  for(int i=0;i<n;i++)
    for(int j=0,used[10]={};j<A[i].size();j++)if(used[A[i][j]]++) return 1;
  
  queue<P> Q;
  bool D[1<<10][1<<10]={};
  D[0][0]=1;
  Q.push(P(0,0));

  while(!Q.empty()){
    P t = Q.front();Q.pop();
    int I = t.first,J = t.second;
    if(I&&J&&__builtin_popcount(I&J) == __builtin_popcount(J)) return 1;

    for(int i=0;i<n;i++){
      for(int k=0,ni=I;k<A[i].size();k++){
	int num = A[i][k],nj =(J|1<<num);
	if(k&&D[ni][nj]==0&&J!=nj)D[ni][nj]=1, Q.push(P(ni,nj));
	if(I&(1<<num))break;
	ni |= (1<<num);
      }
    }
  }
  return 0;
}

int main(){
  int n;
  while(cin>>n,n){
    string str;
    cin>>str;
    A.clear();
    for(int i=0;i<str.size();i++){
      A.push_back(vector<int>());
      while(str[i]!='u') A.back().push_back(str[i++]-'0');
    }
    cout<<(bfs()? "UN":"")<<"SAFE"<<endl;
  }
  return 0;
}

Measured memory_bytes: 4448
#include <stdio.h>
#include <string.h>
char str[205];

int main() {
#ifdef TEST
    freopen("input", "r", stdin);
#endif

    while(scanf("%s", str), 0 != strcmp("-", str)) {
        int n;
        int len = strlen(str);
        scanf("%d", &n);
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            int tmp;
            scanf("%d", &tmp);
            sum += tmp;
        }
        for (int j = 0; j < len; ++j) {
            printf("%c", str[(sum + j) % len]);
        }
        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 2056
def resolve():
    K, N = map(int, input().split())
    A = tuple(map(int, input().split()))
    diff_max = 0
    A_sum = 0

    for i in range(N):
        if i == N-1:
            diff = K-A[i]+A[0]
        else:
            diff = A[i+1] -A[i]

        diff_max = max(diff_max, diff)
        A_sum += diff

    print(A_sum - diff_max)
    
if __name__ == '__main__':
    resolve()

Measured memory_bytes: 26572
#include<iostream>
using namespace std;
const int MAX = 2001;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
	int N,K;
	cin>>N>>K;
	COMinit();
	for(int i=1;i<=K;i++)cout<<(COM(K-1,i-1)*COM(N-K+1,i))%MOD<<endl;
	return 0;
}

Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    loop {
        let h: u32 = sc.read();
        let w: u32 = sc.read();

        if h == 0 && w == 0 {
            break;
        }
        for _ in 0..h {
            for _ in 0..w {
                print!("#");
            }
            println!("");
        }
        println!();
    }
}


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

const int MOD = 1e9+7;
long long h, w, a, b, ans, fact[200005];

long long binexp(long long x, long long y) {
    long long res = 1;
    x %= MOD;
    while (y) {
        if (y&1) {
        	res = (res * x) % MOD;
        }
        y >>= 1;
        x = (x * x) % MOD;
    }
    return res;
}

long long f(long long x, long long y) {
	long long res = 0;
	res = (fact[x+y-2] * binexp(fact[x-1], MOD-2)) % MOD;
	res = (res * binexp(fact[y-1], MOD-2)) % MOD;
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
	cin >> h >> w >> a >> b;

	fact[0] = 1;
	for (int i = 1; i <= 200000; i++) {
		fact[i] = (fact[i-1] * i) % MOD;
	}

	ans = f(h, w);
	for (int i = 1; i <= a; i++) {
		long long x = f(h-i+1, b);
		long long y = f(i, w-b);
		ans = (ans - (x * y % MOD) + MOD) % MOD;
	}
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
using namespace std;
int main() {

	int e, y;
	cin >> e >> y;

	if (e == 0) {
		if (y < 1912)cout << "M" << y - 1867 << endl;
		else if (y < 1926)cout << "T" << y - 1911 << endl;
		else if (y < 1989)cout << "S" << y - 1925 << endl;
		else cout << "H" << y - 1988 << endl;
	}

	else if (e == 1)cout << 1867 + y << endl;
	else if (e == 2)cout << 1911 + y << endl;
	else if (e == 3)cout << 1925 + y << endl;
	else if (e == 4)cout << 1988 + y << endl;

}


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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

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

  string res = "No";
  FOR(i, 1, 10) FOR(j, 1, 10) {
    if (i * j == N) res = "Yes";
  }

  cout << res << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(ll X) {
	if (!X) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[20];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}
void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}
int A[100001];
int MA[100001], MI[100001];
int saidai, k = 1, k2 = 1;
ll kotae[100001];

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


	int N = getint();
	rep(i, N) {
		int a = getint();
		if (a > saidai) {
			MA[k] = a;
			MI[k++] = i;
			saidai = a;
		}
		else A[k2++] = a;
	}
	k2--;
	pakuri_sort(k2, A + 1);

	ll cnt = 0;
	for (int i = k - 1; i >= 1; i--) {
		ll tmp = (MA[i] - MA[i - 1]) * ++cnt;
		while (MA[i - 1] < A[k2]) {
			tmp += A[k2] - MA[i - 1];
			cnt++;
			k2--;
		}
		kotae[MI[i]] = tmp;
	}

	rep(i, N) putint(kotae[i]);

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

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

int main() {
    ll n;
    ll a[5];
    cin >> n;
    for (int i = 0; i < 5; i++) cin >> a[i];
    sort(a, a + 5);
    ll ans = n / a[0];
    if (n / a[0] > 0 && n % a[0] != 0) ans++;
    int c = 0;
    for (int i = 0; i < 5; i++) {
        if (n <= a[i]) c++;
    }
    cout << (c == 5 ? 5 : ans + 4) << endl;
    return 0;
}


Measured memory_bytes: 256
/**
   _           _
  / /         \ \
 / /  _   _  _ \ \
< < (_) (_) (_) > >
 \ \           / /
  \_\         /_/

Nerede Gitsen Çukur Orda
**/

#include<bits/stdc++.h>
#include<fstream>
///#include "windows.h"
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define Zohiri_dzd cout.tie(NULL);
#define Belafz cin.tie(NULL);
#define CODER ios_base::sync_with_stdio(0)  ;
#define p_b pop_back
#define p_f pop_front
#define quluq return 0;
using namespace std ;

    const ll N = 1e4 + 0.000001 ;

int main ()
{
    Zohiri_dzd
    Belafz
    CODER
    ///freopen("input.txt" , "r" , stdin );
    ///freopen("output.txt", "w" , stdout );
    ///Author of the greatest code :: Murtazoev Alijon
    ///4294967295
    /*ll cnt = 0 , f = 26 ;
    ll n ;
    cin >> n ;
    ll ans = 1 ;
    while (n > cnt + f)
    {
        cnt = f ;
        f *= 26 ;
        ans ++ ;
    }
    f += cnt ;
    string s ;
    for (ll i = 0 ; i < ans ; i ++ )
        s += 'z' ;
    f -= n ;
    while (f > 26)
    {
        if (s[1] > 'a')
        {
            s[1] -- ;
            continue;
        }
        else
        {
            for (ll i = 1 ; i < s.size() ; i ++ )
            {
                if (s[i] > 'a')
                {
                    s[i] -- ;
                    cnt = i ;
                    break ;
                }
            }
            for (ll i = 0 ; i <= cnt ; i ++ )
                s[i] = 'z' ;
        }
        f -= 26 ;
    }
    while (f -- )
    {
        if (s[0] > 'a')
        {
            s[0] -- ;
            continue ;
        }
        else
        {
            for (ll i = 1 ; i < s.size() ; i ++ )
            {
                if (s[i] > 'a')
                {
                    s[i] -- ;
                    cnt = i ;
                    break ;
                }
            }
            for (ll i = 0 ; i < cnt ; i ++ )
                s[i] = 'z' ;
        }
    }
    reverse(s.begin() , s.end()) ;
    cout << s << endl ;*/
    ll n ;
    deque < char > v ;
    cin >> n ;
    ll a ;
    string s ;
    for (ll i = 'a' ; i <= 'z' ; i ++ )
        v.pb ( i ) ;
    a = n ;
    while (a)
    {
        if ( a % 26 == 0 )
        {
            s += v[25] ;
            a /= 26 ;
            a -- ;
        }
        else
            s += v[ (a % 26) - 1] , a /= 26 ;
    }
    reverse(s.begin() , s.end());
    cout << s << endl ;
}
///Mavl studios
///Eco students


Measured memory_bytes: 3624
#include <bits/stdc++.h>
            #include <ext/pb_ds/assoc_container.hpp>
            #include <ext/pb_ds/tree_policy.hpp>
            using namespace std;
            using namespace __gnu_pbds;
            #define rep(i,a,b) for(ll i =a; i<b;++i)
            #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define endl "\n"
            #define pb push_back
            #define F first
            #define S second
            #define print(a)       for(auto x : a) cout << x << " "; cout << endl
            #define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
            #define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
            #define mk(x,y)  make_pair(x,y)
            typedef  long long  int ll;
            const ll N =  1e6+ 5 ;
            const ll mod = 998244353;
            ll   n  ,a[N] , b[N] , dp[N];
    ll pow_mod_m(ll a , ll n)
    {
        if(!n)
            return 1;
        ll pt =  pow_mod_m(a,n/2);
        pt *= pt , pt %= mod;
        if(n&1)
            pt *= a  ,pt %= mod;
        return pt;
    }

    int main()
    {
         IOS;
         int ts =1;
         while(ts--)
         {
             memset(dp, 1, sizeof(dp));
            cin >> n;
            rep(i,0,n) cin >> a[i];
            sort(a,  a+n);
            rep(i,0,n)
            {
                if(i and a[i] == a[i-1] ){ dp[a[i]] = 0;continue;}
                for(int j = 2; j*a[i] <= N; j++)
                {
                    dp[j*a[i]] = 0;
                }
            }
            ll ans  = 0;
            rep(i,0,n)
            {
                if(dp[a[i]]) ans++;
            }
            cout << ans << endl;
         }
    }


Measured memory_bytes: 13020
import numpy as np


def nCr(n, r, mod = 10**9+7):
    r = min(n-r, r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod


n, p = map(int, input().split())
A = np.array(list(map(int, input().split())), dtype=np.int)
A %= 2

odd = (A == 1).sum()
even = (A == 0).sum()

base = 2 ** even
if p == 0:
    odd_to_even = 0
    for select in range(0, odd+1, 2):
        pattern = nCr(odd, select)
        odd_to_even += pattern

    print(base * odd_to_even)

else:
    odd_to_odd = 0
    for select in range(1, odd+1, 2):
        pattern = nCr(odd, select)
        odd_to_odd += pattern

    print(base * odd_to_odd)


Measured memory_bytes: 13112
N = int(input())
H = list(map(int, input().split()))

for i in range(N):
    H[i] -= 1

for i in range(N-1):
    if H[i+1]-H[i] < 0:
        H[i+1] += 1

c = 0
for i in range(N-1):
    if H[i+1]-H[i] < 0:
        c += 1
        break

print("Yes" if c==0 else "No")

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

#define int long long 
#define dou  double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	int d,t,s;
	cin >> d >> t >> s;
	int x = s*t;
	if(d<=x)
		cout << "Yes\n";
	else
		cout << "No\n";
}

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
}

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

using namespace std;

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

	bool flag = true;

	for (int i = 0; i < input.size(); i++) {
		if (i % 2 == 0) {
			if (!(input[i] == 'R' || input[i] == 'U' || input[i] == 'D')) {
				flag = false;
				break;
			}
		} else {
			if (!(input[i] == 'L' || input[i] == 'U' || input[i] == 'D')) {
				flag = false;
				break;
			}
		}
	}
	
	if (flag == true) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}



	return 0;
}


Measured memory_bytes: 256