akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#define calc(a,b)  a<b

typedef int item;


int num;

item *PushHeap(item value,item *heap){
    int now=num;
    heap[now]=value;
    num++;
    while(now>0){
        if(calc(heap[(now-1)/2],heap[now])){
            item tmp=heap[now];
            heap[now]=heap[(now-1)/2];
            heap[(now-1)/2]=tmp;
            now=(now-1)/2;
        }else{
            // for(int i=0;i<num;i++){
            //     printf("%d ",heap[i]);
            // }
            // printf("\n");
            return heap;
        }
    }
    // for(int i=0;i<num;i++){
    //     printf("%d ",heap[i]);
    // }
    // printf("\n");
    return heap;
}

item PopHeap(item *heap){
    if(num==0){
        printf("poperror num=0\n");
        exit(1);
    }
    item ans=heap[0];
    heap[0]=heap[num-1];
    num--;
    int now=0;
    while(now*2+2<num){
        if(calc(heap[now*2+1],heap[now*2+2])){
            if(calc(heap[now],heap[now*2+2])){
                item tmp=heap[now];
                heap[now]=heap[now*2+2];
                heap[now*2+2]=tmp;
                now=now*2+2;
            }else return ans;
        }else{
            if(calc(heap[now],heap[now*2+1])){
                item tmp=heap[now];
                heap[now]=heap[now*2+1];
                heap[now*2+1]=tmp;
                now=now*2+1;
            }else return ans;
        }
    }
    if(now*2+1<num){
        if(calc(heap[now],heap[now*2+1])){
            item tmp=heap[now];
            heap[now]=heap[now*2+1];
            heap[now*2+1]=tmp;
            now=now*2+1;
        }else return ans;
    }
    return ans;
}

item *CreateHeap(int max){
    num=0;
    item *heap=(item *)malloc(sizeof(item)*max);
    return heap;
}

int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int *heap=CreateHeap(n);
    for(int i=0;i<n;i++){
        int val;
        scanf("%d ",&val);
        heap=PushHeap(val,heap);
    }
    for(int i=0;i<m;i++){
        int tmp=PopHeap(heap);
        heap=PushHeap(tmp/2,heap);
    }
    
    long ans=0;
    for(int i=0;i<n;i++){
        ans=ans+(long)heap[i];
    }
    printf("%ld",ans);
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.util.HashSet;

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

	    int N = sc.nextInt();
        HashSet list = new HashSet();
      
      for(int i=0 ;i < N; i++){
        String prize = sc.next();
        list.add(prize);
      }
      
      System.out.println(list.size());
      
    }
}


Measured memory_bytes: 72260
from collections import defaultdict
def solve():
  ans = 0
  mod = 10**9+7
  s = defaultdict(lambda: -1)
  t = defaultdict(lambda: -1)
  N, M = map(int, input().split())
  S = list(map(int, input().split()))
  T = list(map(int, input().split()))
  dp = [[0]*(M+1) for _ in range(N+1)]
  for j in range(M+1):
    dp[0][j] = 1
  for i in range(1,N+1):
    dp[i][0] = 1
  for i in range(1,N+1):
    for j in range(1,M+1):
      if S[i-1]==T[j-1]:
        dp[i][j] += dp[i-1][j]+dp[i][j-1]
      else:
        dp[i][j] = dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]
      dp[i][j]%= mod
  ans = dp[-1][-1]%mod
  return ans
print(solve())

Measured memory_bytes: 96372
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
    int n,a[100];
    
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    
    for(int j=0;j<n;j++)
        printf(j+1==n ? "%d\n" : "%d ",a[j]);
    
    for(int i=1;i<n;i++){
        for(int j=i;j>0;j--)
            if(a[j-1]>a[j])
                swap(a[j-1],a[j]);
        
        for(int j=0;j<n;j++)
            printf(j+1==n ? "%d\n" : "%d ",a[j]);
    }
    return 0;
}

Measured memory_bytes: 1028
def solve():
    a,b,c,x,y = map(int, input().split())

    res = 10**10
    for q in range(2 * max(x, y) + 1):
        cost = q * c
        cost += max(x - int(q/2), 0) * a
        cost += max(y - int(q/2), 0) * b
        res = min(res, cost)
    print(res)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }

/*

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


        char q;cin>>q;
        if((int)(q - 'A')  >= 0 && (int)(q - 'A') <= 25){
            cout<<"A\n";
        }
        else{
            cout<<"a\n";
        }

   return 0;
}
*/


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;cin>>n>>k;
    std::vector<int> v(n);
    REP(i,n) cin>>v[i];

    sort(v.begin() , v.end());
    ll int sum = 0;
    for (int i = 0; i < k; ++i)
    {
        sum += v[i];
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3660
def fast_pow(x, n, MOD):
    res = 1
    while n:
        if n & 1:
            res = res * x % MOD
        x = x * x % MOD
        n >>= 1
    return res

def prepare(n, MOD):
 
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs

MOD = 998244353
fact, fact_inv = prepare(3*10**5, MOD)

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

dp = [0] * (n+1)
ans = 0
for i in range(k+1):
    color = fast_pow(m-1, n-1-i, MOD)
    order = fact[n-1] * fact_inv[i] % MOD * fact_inv[n-1-i] % MOD
    ans += m * color % MOD * order % MOD
    ans %= MOD    

print(ans)

Measured memory_bytes: 103544
<?php
  
  $tmp = explode(" ", trim(fgets(STDIN)));

  $n = $tmp[0];
  $a = $tmp[1];
  $b = $tmp[2];

  if($n*$a<$b){
    echo $n*$a;
  }else{
    echo $b;
  }
  echo "\n";

Measured memory_bytes: 4728
ord_a = ord('a')
L = 26

S = list(map(lambda c: ord(c)-ord_a,input()))


memo = []

f = [0]*L
cnt = 0


for i,s in zip(reversed(range(len(S))),reversed(S)):

  cnt += (f[s] == 0)
  f[s] += 1
  if cnt == L:
    memo.append((i,f))
    f = [0]*L
    cnt = 0


result = [f.index(0)]

for i,f in reversed(memo):
  c = result[-1]
  for j in range(i,len(S)):
    s = S[j]
    f[s] -= 1
    if s == c:
      break

  result.append(f.index(0))

print(''.join(map(lambda x: chr(x+ord_a), result)))

Measured memory_bytes: 7676
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int h,a;
  cin >> h >> a;
  cout << (h + a - 1) / a << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	cin>>s;
	cout<<(s[0]-'0')+(s[1]-'0')+(s[2]-'0')<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Text.Printf

main :: IO ()
main = do
  n <- readLn
  replicateM_ n $ do
    solve <$> f <*> f >>= (\p -> printf "%.7f %.7f\n" p (1.0 - p))
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> [Int] -> Double
solve xs ys = let gw = length $ filter (game xs) $ permutations ys
              in fromIntegral gw / tng
  where
    tng = fromIntegral . product $ [1 .. 9]

game :: [Int] -> [Int] -> Bool
game xs ys = (> 0) . sum $ zipWith f xs ys
  where
    f x y
      | x > y = x + y
      | otherwise = -(x + y)



Measured memory_bytes: 5764
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int a[110];

int main() {
    ios_base::sync_with_stdio(0);
    int n; cin >> n;
    for (int i=0;i<n;i++) cin >> a[i];

    int cost = 1e9;
    for (int p=-100;p<=100;p++) {
        int now = 0;
        for (int i=0;i<n;i++) now += (p-a[i])*(p-a[i]);
        cost = min(cost, now);
    }
    cout << cost << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
using namespace std;
signed main()
{
	fastio;
	int n;
	cin>>n;
	int ac=0,wa=0,tle=0,re=0;
	string a="AC";
	string w="WA";
	string t="TLE";
	string r="RE";
	
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		if(s==a)
		{
			ac++;
		}
		if(s==w)
		{
			wa++;
		}
		if(s==t)
		{
			tle++;
		}
		if(s==r)
		{
			re++;
		}
	}
	
	cout<<"AC x "<<ac<<endl;
		cout<<"WA x "<<wa<<endl;
			cout<<"TLE x "<<tle<<endl;
				cout<<"RE x "<<re;
	
return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <cstring>
const int N = 4e2 + 100;
int f[N];
int ff(int x) {
	return f[x] == x ? x : f[x] = ff(f[x]);
}
int n, h;
int in[N], ou[N], ok[N];

int main() {
	scanf("%d%d", &n, &h);
	for (int i = 1; i <= h + h; ++i)
		f[i] = i;
	for (int i = 1; i <= n; ++i) {
		int a, b, c, d, l, r;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		l = c == 0 ? h + a : c;
		r = d == 0 ? b : h + d;
		++ou[l], ++in[r];
		if (ff(l) != ff(r))
			f[ff(l)] = ff(r);
	}
	for (int i = 1; i <= h; ++i)
		if (ou[i] > in[i])
			return puts("NO"), 0;
	for (int i = h + 1; i <= h + h; ++i)
		if (in[i] > ou[i])
			return puts("NO"), 0;
	for (int i = 1; i <= h + h; ++i)
		if (in[i] != ou[i])
			ok[ff(i)] = true;
	for (int i = 1; i <= h + h; ++i)
		if (ff(i) == i && !ok[i] && in[i] + ou[i] != 0)
			return puts("NO"), 0;
	return puts("YES"), 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    int r = 0;
    for (int i = 0; i < n;i++){
        if(s[i]=='R')
            r++;
    }
    if(r>n/2)
        cout << "Yes" << endl;
        else
            cout << "No" << endl;
        return 0;
}

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

int main(){
    int n,r;
    cin >> n >> r;
    if(n >=10){
        cout << r << endl;
        return 0;
    }
    cout << r + 100 * (10-n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool is_prime(int x) {
    if(x <= 1) return false;
    for(int i = 2; i * i <= x; i++) if(x % i == 0) return false;
    return true;
}

int main() {

    int X;
    cin >> X;

    while(!is_prime(X)) X++;

    cout << X << endl;

    return 0;
}

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

#define str(a) to_string(a)
#define int long long
#define pb push_back
#define mp make_pair
#define SORT(c) sort(c.begin(),c.end())
#define max_heap priority_queue<int>
#define min_heap priority_queue< int,vector<int>, greater<int> >
#define mod 1000000007
#define setbits(x) __builtin_popcount(x)
#define ps(x,y) fixed<<setprecision(y)<<x
#define start(t) int x;cin>>x;while(x--)
#define inf LLONG_MAX
#define sync ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"




int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int x; cin >> x;
	int a = 100;
	int count = 0;
	while (a < x) {
		a += a / 100;
		count += 1;
	}
	cout << count << endl;

}









Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,T;
    cin >> n >>T;
    int def_c=1001;
    for(int i=0;i<n;i++){
        int c,t;
        cin >> c >> t;
        if(def_c > c&&t<=T){
            def_c=c;
        }
    }
    if(def_c==1001){
        cout <<"TLE"<<endl;
    }else{
        cout << def_c <<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int long long
 
using namespace std;
 
 
 
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    int N, Q;
    cin >> N >> Q;
 
    vector<pair<int,pair<int,int>>> v1, v2;
 
    v1.push_back({1,{0,N-2}});
    v2.push_back({1,{0,N-2}});
 
    int res = (N-2)*(N-2);
 
    for(int i = 0 ; i < Q ; i++)
    {
    	int qu, x;
    	cin >> qu >> x;
 
    	x = N-x+1;
 
    	if(qu == 1)
    	{
    		pair<int,pair<int,int>> pp = {x,{0,0}};
    		auto it = lower_bound(v1.begin(), v1.end(), pp);
 
    		if(it == v1.end())
    		{
    			v1.push_back({x, {v2.back().second.second, N - x - 1}});
 
    			res -= v2.back().second.second;
    		}
    		else
    		{
    			res -= (*it).second.first;
    		}
    	}
    	else
    	{
    		pair<int,pair<int,int>> pp = {x,{0,0}};
    		auto it = lower_bound(v2.begin(), v2.end(), pp);
 
    		if(it == v2.end())
    		{
    			v2.push_back({x, {v1.back().second.second, N - x - 1}});
 
    			res -= v1.back().second.second;
    		}
    		else
    		{
    			res -= (*it).second.first;
    		}
    	}
    }
 
    cout << res << '\n';
 
    return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void rec(vector<ll> &b)
{
  if(b.size() <= 1) return;
  bool ok = false;
  for(ll i = b.size()-1; i > 0; i--) {
    cerr << i << ":" << endl;
    if(b[i] == i) {
      ok = true;
            cerr << i << ":" ;rep(i, b.size()) cerr << b[i] << " "; cerr<< endl;
      b.erase(b.begin() + i);
      if(b.size() > 1) rec(b);
      cout << i << endl;
      break;
    }
  }
  if(!ok) {
    cout << -1 << endl;
    exit(0);
  }
}

void solve()
{
  ll N; cin >> N;
  vector<ll> b(N+1); rep1(i, N) cin >> b[i];
  rec(b);
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3700
A,B = (int(x) for x in input().split())
if A == 0:
    m = B % 4
    if m == 0:
        print(B)
    elif m == 1:
        print('1')
    elif m == 2:
        print(B^1)
    else:
        print('0')
else:
    ma = (A-1) % 4
    mb = B % 4
    if ma == 0:
        xora = A-1
    elif ma == 1:
        xora = 1
    elif ma == 2:
        xora = (A-1) ^ 1
    else:
        xora = 0
    if mb == 0:
        xorb = B
    elif mb == 1:
        xorb = 1
    elif mb == 2:
        xorb = B ^ 1
    else:
        xorb = 0
    print(xora^xorb)

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

					using namespace std;
					typedef long long ll;
					int main()
					{
                      ll n, k = 0, t = 10;
                      cin >> n;
                      if(n & 1)
                        return cout << 0, 0;	
                      while(n >= t)
                      {
                        k += n/t;
                        t *= 5;
                      }
                      cout << k;
                    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD (1e9 + 7)
#define fi(i,a,b) for(int i = a; i < b; i++)
#define fd(i,a,b) for(int i = a; i >= b; i--)
#define vfi(v,i) for(auto i = v.begin(); i != v.end(); i++)
#define vfd(v,i) for(auto i = v.rbegin(); i != v.rend(); i++)
#define vi vector<int>
#define vll vector<ll>
#define pb push_back 

using namespace std;
typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	ll a[n];
	fi(i,0,n){
		cin>>a[i];
	}	
	ll dp[n][n];

	fd(i,n-1,0){
		fi(j,i,n){
			if(i == j){
				dp[i][j] = a[i];
				continue;
			}

			dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]);
		}
	}

	cout<<dp[0][n-1]<<'\n';

	return 0;
}

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

template <int MOD_>
struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");

private:
	using ll = long long;

	int v;

	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}

public:

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }

	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}

	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}

	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}

	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<int(1e9) + 7>;

using ll = long long;

num powmod(num a, ll b) {
	num r = 1;
	while (b) {
		if (b & 1) {
			r *= a;
		}
		a *= a;
		b /= 2;
	}
	return r;
}

const int MAXV = 110;

pair<num, num> go(vector<int> H) {
	int Hmin = *min_element(H.begin(), H.end());
	int num0 = 0;
	for (int i = 0; i < int(H.size()); i++) {
		H[i] -= Hmin;
		if (H[i] == 0) num0++;
	}

	assert(num0 >= 1);
	num p0 = 1;
	num p1 = 1;
	int prv = 0;
	for (int i = 0; i <= int(H.size()); i++) {
		if (i == int(H.size()) || H[i] == 0) {
			if (prv < i) {
				auto p = go(vector<int>(H.begin() + prv, H.begin() + i));
				p0 *= (p.first + p.second);
				p1 *= p.second;
			}
			prv = i+1;
		}
	}
	num tot = powmod(2, num0) * p0 + (powmod(2, Hmin) - 2) * p1;
	num alt = powmod(2, Hmin) * p1;
	return {tot, alt};
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	auto ans = go(H);
	cout << ans.first << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  vector<int> v;
  rep(i,5){
    int a;
    cin >> a;
    v.push_back(a);
  }
  sort(ALLOF(v));

  int ret = 1000000;
  do {
    int now = 0;
    rep(i,v.size()){
      while(now%10 != 0) now++;
      now += v[i];
    }
    ret = min(ret, now);
  } while(next_permutation(ALLOF(v)));

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n, k := iScan(), iScan()
	a := iSScan(n)
	x, y := 0, 0
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if a[i] > a[j] && i < j {
				x++
			}
			if a[i] > a[j] {
				y++
			}
		}
	}
	fmt.Println((x*k + k*(k-1)/2%mod*y) % mod)
}


Measured memory_bytes: 1788
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

const ll M = 1e9+7;
const ll INF = 1e9+7;

ll n, ans;
ll a[220000];
bool p[1100000];

int main() {
  cin >> n;
  
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  sort(a, a+n);
  
  ll last = 0;
  for (ll i = 0; i < n; i++) {
    if (a[i] == last) continue;
    last = a[i];
    if (!p[a[i]]) {
      bool f = true;
      if (i != 0 and a[i] == a[i-1]) f = false;
      if (i != n and a[i] == a[i+1]) f = false;
      if (f) ans++;
    }
    for (ll j = a[i]; j <= 1000000; j += a[i]) {
      p[j] = true;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6148
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

int main(){
    ll n ;
    cin >> n ;
    vector<ll> a(n) , b(n) ;
    ll tota = 0 ;
    ll totb = 0 ; 
    rep(i, n) cin >> a[i] ;
    rep(i, n) cin >> b[i] ;
    rep(i, n) tota += a[i] ;
    rep(i, n) totb += b[i] ;
    if(tota < totb) {
        cout << -1 << endl ;
        return 0 ; 
    }
    priority_queue<ll, vector<ll>> que ;
    ll mns = 0 ;
    ll ans = 0 ; 
    rep(i, n){
        if(b[i] > a[i]){
            mns += b[i] - a[i] ;
        }
        else {
            que.push(a[i] - b[i]) ;
            ans++ ; 
        }
    }
    while(1){
        if(mns <= 0 ){
            break ; 
        }
        ll t = que.top() ;
        que.pop() ;
        mns -= t ; 
        ans-- ;
    }
    cout << n - ans << endl ; 
}


Measured memory_bytes: 5700
import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate
import sys
import bisect

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

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

S, W = mii()

if S <= W:
    print('unsafe')
else:
    print('safe')

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

using namespace std;

int R0, W0, C, R;

int main() {
	while (cin >> R0 >> W0 >> C >> R && R) {
		if (R0 >= C*W0) {
			cout << 0 << endl;
		} else {
			cout << ceil((C*W0-R0)/((double)R))<< endl;
		}
	}
}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define red(i,a,b) for(int i=(a);i>=(b);i--)
#define db double
#define ld long db
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=105;
const int INF=1e9;
int n,a[N],ans;
signed main(){
	//freopen("a","r",stdin);
	n=read();rep(i,1,n)a[i]=read();ans=INF;
	rep(i,-100,100){int re=0;rep(j,1,n)re+=(a[j]-i)*(a[j]-i);if(re<ans)ans=re;}
	return cout<<ans,signed();
}

Measured memory_bytes: 3616
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<utility>
using std::max;
using std::min;
using std::pair;
using std::make_pair;
typedef long long ll;
const int N=1e4+5;
int n;
ll x[N],y[N];
int res[3];
int dp[64][2][3];
inline void calc(ll c,ll x,ll y,ll r)
{
	ll n=x-c;
	register int i,j,k;
	r-=y;
	if(r<0)
		return res[0]=res[1]=res[2]=0,void();
	memset(dp,0,sizeof(dp));
	dp[63][1][0]=1;
	for(i=63;i>0;i--)
		if(!(n>>(i-1)&1))
		{
			for(j=0;j<3;j++)
			{
				if(dp[i][0][j])
					dp[i-1][0][(j*2)%3]^=1;
				if(dp[i][1][j])
				{
					if(r>>(i-1)&1)
						dp[i-1][0][(j*2)%3]^=1;
					else
						dp[i-1][1][(j*2)%3]^=1;
				}
			}
		}
		else
		{
			for(j=0;j<3;j++)
			{
				if(dp[i][0][j])
				{
					dp[i-1][0][(j*2)%3]^=1;
					dp[i-1][0][(j*2+1)%3]^=1;
				}
				if(dp[i][1][j])
				{
					if(r>>(i-1)&1)
						dp[i-1][0][(j*2)%3]^=1,dp[i-1][1][(j*2+1)%3]^=1;
					else
						dp[i-1][1][(j*2)%3]^=1;
				}
			}
		}
	y=(y%3+3)%3;
	res[y]=dp[0][0][0]^dp[0][1][0];
	res[(y+1)%3]=dp[0][0][1]^dp[0][1][1];
	res[(y+2)%3]=dp[0][0][2]^dp[0][1][2];
	return;
}
int lres[3],rres[3],mres[3];
inline ll epc(ll c)
{
	int k;
	ll l=-1000000000000000000ll,r=1000000000000000000ll,mid;
	register int i;
	rres[0]=rres[1]=rres[2]=0;
	for(i=1;i<=n;i++)
	{
		calc(c,x[i],y[i],r);
		rres[0]^=res[0];rres[1]^=res[1];rres[2]^=res[2];
	}
	lres[0]=lres[1]=lres[2]=0;
	for(i=0;i<3;i++)
		if(rres[i])
		{
			k=i;
			break;
		}
	while(l<r)
	{
		mid=(l+r)>>1;
		mres[0]=mres[1]=mres[2]=0;
		for(i=1;i<=n;i++)
		{
			calc(c,x[i],y[i],mid);
			mres[0]^=res[0];mres[1]^=res[1];mres[2]^=res[2];
		}
		if(mres[k]^lres[k])
			r=mid,memcpy(rres,mres,sizeof(int)*3);
		else
			l=mid+1,memcpy(lres,mres,sizeof(int)*3);
	}
	return l;
}
inline bool light(ll x,ll y)
{
	int res=0;
	ll xx,yy,n,m;
	register int i;
	for(i=1;i<=::n;i++)
	{
		xx=::x[i];yy=::y[i];
		n=xx-x;m=y-yy;
		if(m<0||m>n)
			continue;
		res^=((n|m)==n);
	}
	return res;
}
inline void solve(ll c,pair<ll,ll> &a)
{
	ll k=epc(c),lk=k,rk=k;
//	fprintf(stderr,"%lld\n",k);
	register ll i;
	for(i=1ll<<62;i;i>>=1)
		if(light(c,lk-i))
			lk-=i;
	for(i=1ll<<62;i;i>>=1)
		if(light(c,rk+i))
			rk+=i;
	a.first=c+(rk-lk);a.second=lk;
	return;
}
signed main()
{
	pair<ll,ll> a;
	register int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%lld%lld",&x[i],&y[i]);
	solve(-100000000000000000,a);
	printf("%lld %lld\n",a.first,a.second);
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main{
    
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int n=sc.nextInt();
        int max=-1000000,min=1000000;
        long sum=0;
        
        for(int i=0;i<n;i++){
        int a=sc.nextInt();
        if(a>max) max=a;
        if(a<min) min=a;
        sum+=a;
        }

        System.out.println(min+" "+max+" "+sum);
        
    }
    
}


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

bool name_point(tuple<int, string, int> l, tuple<int, string, int> r)
{
  if (get<1>(l) == get<1>(r))
  {
    return get<2>(l) > get<2>(r);
  }
  else
  {
    return get<1>(l) < get<1>(r);
  }
}

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

  vector<tuple<int, string, int>> SP(N);

  rep(i, N)
  {
    string s;
    int p;
    cin >> s >> p;
    SP.at(i) = make_tuple(i + 1, s, p);
  }

  sort(SP.begin(), SP.end(), name_point);

  rep(i, N)
  {
    cout << get<0>(SP.at(i)) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict

input = sys.stdin.readline


def main():
    N, W = [int(x) for x in input().split()]
    WV = [[int(x) for x in input().split()] for _ in range(N)]

    weight = set()
    weight.add(0)
    weight.add(WV[0][0])
    for i in range(1, N + 1):
        for j in range(3 * i):
            weight.add(WV[0][0] * i + j)

    weight = sorted(list(weight))

    dp = defaultdict(int)

    for i in range(N):
        for j in weight[::-1]:
            if j >= WV[i][0]:
                dp[j] = max(dp[j], dp[j - WV[i][0]] + WV[i][1])

    ans = 0
    for i in weight:
        if i > W:
            break
        ans = max(ans, dp[i])

    print(ans)


if __name__ == '__main__':
    main()


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

typedef long long               ll;
typedef long double             ld;


#define racecar          ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define si(a)            scanf("%d", &a)
#define si2(a,b)         scanf("%d %d", &a,&b)
#define sll(a)           scanf("%I64d",&a)
#define sll2(a,b)        scanf("%I64d %I64d",&a,&b)
#define pb               push_back
#define pi(a)            printf("%d",int(a))
#define pll(a)           printf("%I64d",ll(a))
#define all(x)           (x).begin(),(x).end()
#define rall(x)          (x).rbegin(),(x).rend()
#define ps               printf(" ")
#define nln              printf("\n")
#define ff               first
#define ss               second
#define vi               vector<int>
#define vll              vector<ll>
#define vstr             vector<string>
#define vc               vector<char>
#define pii              pair<int,int>
#define PLL              pair<ll,ll>
#define PI               acos(-1)
#define sq(x)            x*x
#define forr(i,a,b)      for(ll i=ll(a);i<ll(b);i++)
#define forn(i,a,b)      for(ll i=ll(a);i>ll(b);i--)
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(max3(a,b,c),d)
#define min3(a,b,c)      min(a,min(b,c))
#define mod              1000000007
#define inf              9223372036854775807

ll power(ll b,ll n)
{
    if(n==0) return 1;
    else if(n%2) return b*power(b,n/2)*power(b,n/2);
    else return power(b,n/2)*power(b,n/2);
} 

ld root(ll n,ll r)
{
    ld dif=0.0001;
    ld guess=n/2.0;
    while(abs(pow(guess,r)-n)>=dif)
    {
        ld temp=pow(guess,r)-n;
        ld tmp=r*pow(guess,r-1);
        guess-=temp/tmp;
    }
    return guess;
}

void fileio()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

      

int solve()
{
	string x;
	cin>>x;
	bool flag=false;
	for(int i=0;i<x.size()-1;i++)
	{
		if(x[i]==x[i+1])
		{
			flag=true;
			break;
		}
	}
	if(flag) printf("Bad");
	else printf("Good");
    
	return 0;
}

int main()
{   

//    racecar;
//    cout<<fixed<<setprecision(6);
//    fileio();
    solve();
}



///    Before submission=>
///    ***check for integer overflow,array bounds
///    ***check for n

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9 + 5
using namespace std;
const int maxn = 15;
const int maxm = 50;
int mp[maxn][maxn];
int a[maxm],b[maxm],c[maxm];
int n,m;

void init()
{
	for(int i = 0;i <= n;i++)
	for(int j = 0;j <= n;j++)
	if(i == j) mp[i][j] = 0;
	else       mp[i][j] = INF;
}

void floyd()
{
	for(int k = 0;k <= n;k++)
	for(int i = 0;i <= n;i++)
	for(int j = 0;j <= n;j++)
	mp[i][j] = min(mp[i][j],mp[i][k] + mp[k][j]);
}

int main()
{
	while(scanf("%d",&m) != EOF && m){
		n = 0;
		for(int i = 0;i < m;i++){
			scanf("%d %d %d",&a[i],&b[i],&c[i]);
			n = max(n,max(a[i],b[i]));
		}
		init();
		for(int i = 0;i < m;i++){
			mp[a[i]][b[i]] = min(mp[a[i]][b[i]],c[i]);
			mp[b[i]][a[i]] = min(mp[b[i]][a[i]],c[i]);
		}
		floyd();
		int minsum,nowsum,pos;
		minsum = nowsum = INF;
		for(int i = 0;i <= n;i++){
			nowsum = 0;
			for(int j = 0;j <= n;j++){
				nowsum += mp[i][j];
			}
			if(minsum > nowsum){
				minsum = nowsum;
				pos = i;
			}
		}
		printf("%d %d\n",pos,minsum);
	}
	return 0;
}

Measured memory_bytes: 3188
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    cout<<(n==1?0:1);

    return 0;
}


Measured memory_bytes: 3568
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Data{
    int A;
    string S;
    
    bool operator<( const Data& right ) const {
        return A == right.A ? S < right.S : A < right.A;
        //return A < right.A;
    }
};

int Func(){
    int x = 0;
    return x;
}

int main(){
    int N;
    int a[200010];
    
    // 入力
    cin >> N;
    for (int i=0;i<N;i++) cin >> a[i];
    
    int temp = 1;
    int count = 0;
    for (int i=0;i<N;i++) {
        if (a[i]==temp) {
            count += 1;
            temp += 1;
        }
    }
    
    if (temp==1) {
        cout << -1 << endl;
    }
    else {
        cout << N - count << endl;
    }
    
    return 0;
}


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

using namespace std;

const int N = 200000 + 7;

int gcd(int a, int b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int n;
  cin >> n;
  int a = 0;
  int b = 0;
  int ba = 0;
  int ans = 0;
  for(int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    for(int j = 0; j + 1 < s.length(); ++j) {
      if(s[j] == 'A' && s[j + 1] == 'B') ++ans;
    }
    if(s[0] == 'B' && s[s.length() - 1] == 'A') ++ba;
    else if(s[s.length() - 1] == 'A') ++a;
    else if(s[0] == 'B') ++b;
  }
  //ans += max(0, ba - 1);
  //cout << ans << endl;
  if(ba >= 1) {
    if(a > 0) {
      ++ans;
      --a;
    }
    ans += ba - 1;
    if(b > 0) {
      ++ans;
      --b;
    }
  }
  ans += min(a, b);
  cout << ans << "\n";
  return 0;
}


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

int d, s;

int main()
{
    cin >> d;

    for (int i = 0; i < d; i++) {
        cin >> s;

        cout << "Case " << i + 1 << ":" << endl;

        for (int j = 0; j < 10; j++) {
            s = s * s;

            s /= 100;
            s %= 10000;

            cout << s << endl;
        }
    }

    return 0;
}



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

struct parsed {string str, val; };

//calclate -X
string mi(string x)
{
    if(x == "0")
        return "2";
    else if(x == "2")
        return "0";
    else 
        return x;
}

//calclate X * Y
string mul(string left, string right)
{
    if(left == "0" || right == "0")
        return "0";
    else if(left == "1" || right == "1")
        return "1";
    else 
        return "2";
}

//calclate X + Y
string add(string left, string right)
{
    if(left == "0" && right == "0")
        return "0";
    else if(left == "2" || right == "2")
        return "2";
    else 
        return "1";
}

//parse expression
parsed formula(string str)
{
    string s = str.substr(0, 1);
    string t = str.substr(1);
    if(s == "0" || s == "1" || s == "2") {
        return (parsed){t, s};
    } else if(s == "-") {
        parsed p = formula(t);
        return (parsed){p.str, mi(p.val)};
    } else {
        parsed lhs = formula(t);
        string op  = lhs.str.substr(0, 1);
        parsed rhs = formula(lhs.str.substr(1));


        if(op == "*") {
            return (parsed){rhs.str.substr(1), mul(lhs.val, rhs.val)};
        } else {
            return (parsed){rhs.str.substr(1), add(lhs.val, rhs.val)};
        }
    }
}

int main()
{
    string str;
    while(cin >> str && str != ".") {
        int ans = 0;
        for(int i = 0; i < 3; i++) {
            for(int j = 0; j < 3; j++) {
                for(int k = 0; k < 3; k++) {
                    string ex = str;
                    char P = '0' + i;
                    char Q = '0' + j;
                    char R = '0' + k;
                    for(int l = 0; l < ex.size(); l++) {
                        if(ex[l] == 'P')
                            ex[l] = P;
                        else if(ex[l] == 'Q')
                            ex[l] = Q;
                        else if(ex[l] == 'R')
                            ex[l] = R;
                    }
                    //cout << ex << endl;
                    parsed ret = formula(ex);
                    if(ret.val == "2")
                        ans++;

                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 924
from array import array

n = eval(input())
arr = array('i')

while n > 0:
    arr.append(eval(input()))
    n -= 1

max_number = arr[1] - arr[0]
min_number = arr[0]
length = len(arr)
for i in range(1, length):
    max_number = max(arr[i] - min_number, max_number)
    min_number = min(arr[i], min_number)

print(max_number)



Measured memory_bytes: 6936
import collections

n = int(input())
s = str(input())
ans = 1

s_l = [s.count('R'), s.count('G'), s.count('B')]
for k in s_l:
    ans *= k


cnt = 0
for i in range(1, n-1):
    for j in range(1, min(i, n - i - 1) + 1):
        if s[i] != s[i - j] and s[i] != s[i + j] and s[i - j] != s[i + j]:
            cnt += 1

print(ans - cnt)

Measured memory_bytes: 9464
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        long n = sc.nextLong();
        String res = "";
        while(n > 0){
            char c = (char)((n % 26 == 0 ? 26 : n % 26) - 1 + 'a');
            res = c + res;
            if(n % 26 == 0)
                n = n / 26 - 1;
            else
                n/= 26;
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 39388
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

const int MOD = 1e9 + 7;

vector<bool> used;

pair<int, int> dfs(vector<vector<int>>& E, int node){

  used[node] = true;

  long long retW = 1;
  long long retB = 1;
  
  for(int nextNode: E[node]){
    if(!used[nextNode]){
      auto temp = dfs(E, nextNode);
      retW = (retW * ((temp.first + temp.second) % MOD)) % MOD;
      retB = (retB * temp.first) % MOD;
    }
  }
  
  return make_pair(retW, retB);
}

int main(){

  int N;
  cin >> N;

  vector<vector<int>> E(N);
  int a, b;
  for(int i = 0; i < N - 1; i++){
    cin >> a >> b;
    E[a - 1].push_back(b - 1);
    E[b - 1].push_back(a - 1);
  }

  used.assign(N, false);

  auto ans = dfs(E, 0);

  cout << (ans.first + ans.second) % MOD << endl;

  return 0;
}


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

using namespace std;

int main() {
    string s;
    int flag = 0;
    cin >> s;

    for (int i = 0; i < s.length(); i++) {
        if (i % 2 == 0) {
            if (s[i] == 'L') {
                flag = 1;
            }
        } else {
            if (s[i] == 'R') {
                flag = 1;
            }
        }
    }

    if (flag == 0) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
/*
* @Author: 王文宇
* @Date:   2017-11-18 21:59:24
* @Last Modified by:   王文宇
* @Last Modified time: 2017-11-18 22:03:14
*/
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	char a[5];
	cin>>a;
	int ok=0;
	if(a[0]==a[1]&&a[1]==a[2])ok=1;
	if(a[1]==a[2]&&a[2]==a[3])ok=1;
	if(ok)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    def inputs():
        li = []
        count = 0
        try:
            while count < 200:
                li.append(input())
                count += 1
        except EOFError:
            return li
        return li

    li = inputs()
    for x in li:
        a = x.split(" ")
        result = len(str(int(a[0]) + int(a[1])))
        print(result)
    return None

if __name__ == '__main__':
    main()

Measured memory_bytes: 7596
#include <bits/stdc++.h>
using namespace std;
///https://www.youtube.com/watch?v=-tJYN-eG1zk&list=RD-tJYN-eG1zk&start_radio=1
const int MOD = 1e9 + 7;
#define ll long long int
#define pii pair<int, int>
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define vi vector<int>
#define vpii vector<pii>
#define si set<int>
#define mpii map<int, int>
#define prq priority_queue<int>
#define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
const int MXX = 2e5 + 5;

int a[100];
int main()
{

    FAST_IO;
    string s, t;cin>>s>>t;int ans = 0;
    for(int i = 0; i<t.size(); i++)
    {
        if(s[i]==t[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
def main():
    s = input()
    N = len(s)
    ans = 0

    tmp = ""
    i = 0
    while i < N:
        if not tmp == s[i]:
            tmp = s[i]
            ans += 1
        else:
            tmp = ""
            i += 1
            if not i == N:
                 ans += 1
        i += 1
        # print(tmp, ans, i)

    print(ans)
    return


if __name__ == "__main__":
    main()

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main()
{
    int a,b,x;cin>>a>>b>>x;

    if(a<=x && a+b>=x){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
	return;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())

void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}

bool sortdes(const pair<int,int> &a, const pair<int,int> &b){return a.ss<b.ss;}
bool sortasc(const pair<int,int> &a, const pair<int,int> &b){return a.ss>b.ss;} 
int gcd(int x,int y){return __gcd(x,y);}

lld fact(lld n);
lld nCr(lld n,lld r){ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
lld fact(lld n){ 
    lld res = 1; 
    for(lld i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 

// const int maxi = 1e6+10;
// vector<int> v[maxi];
// long long a[maxi];

// void dfs(int x,int y){
//     a[x]+=a[y];
//     for(int i:v[x]){
//         if(i!=y){
//             dfs(i,x);
//         }
//     }
// }

void test_case(){
    int n;
    cin>>n;
    // vector<string> v;
    unordered_map<string,int> ump;
    lld cnt=0;
    for(int i=0;i<n;++i){
        string temp;
        cin>>temp;
        sort(temp.begin(),temp.end());
        if(ump[temp]){
            cnt+=ump[temp];
            ++ump[temp];
        }
        else{
            ump[temp]=1;
        }
    }
    test(cnt);
    // for(auto x:ump){
    //     cout<<x.ff<<" "<<x.ss<<endl;
    // }
    // long long sum=0;
    // for(auto x:ump){
    //     sum+=(long long)(x.ss)*(x.ss-1)/2;
    // }
    // test(sum);
    // int cnt=0;
    // for(int i=0;i<n;++i){
    //     for(int j=i+1;j<n;++j){
    //         if(v[i]==v[j]){
    //             ++cnt;
    //         }
    //     }
    // }
    // test(cnt);
}

int main(){
    fastio;
    file();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
		test_case();
    }
}

Measured memory_bytes: 10660
fn main() {
    let v = read_vec::<u32>();
    let n = v[0];
    let a = v[1];
    let b = v[2];
    println!("{}", std::cmp::min(n * a, b));
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352