akhauriyash/Code-Regression huggingface dataset:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, W = mapint()
wv = [list(mapint()) for _ in range(N)]
w0 = wv[0][0]

dp = [[[0]*(3*N+1) for _ in range(N+1)] for _ in range(N+1)]

for i in range(1, N+1):
    w, v = wv[i-1]
    w -= w0
    for j in range(1, i+1):
        for k in range(3*N+1):
            dp[i][j][k] = dp[i-1][j][k]
            if w<=k:
                dp[i][j][k] = max(dp[i][j][k], dp[i-1][j-1][k-w]+v)

ans = 0
for i in range(N+1):
    if W<i*w0:
        break
    ans = max(ans, max(dp[N][i][:W-i*w0+1]))
print(ans)

Measured memory_bytes: 98832
import numpy as np
from numba import njit
@njit
def op(A, n):
    B = np.zeros_like(A)
    for i, a in enumerate(A[:n]):
        B[max(i - a, 0)] += 1
        B[min(n - 1, a + i) + 1] -= 1
    return np.cumsum(B)

def main():
    n, k = list(map(int, input().split()))
    A = np.array(list(map(int, input().split())) + [0, ], dtype = np.int)
    for _ in range(k):
        A_new = op(A, n)
        if all(A[:n] == A_new[:n]):
            break
        A = A_new
    print(' '.join(list(map(str, A[:n]))))

if __name__ == '__main__':
    main()


Measured memory_bytes: 132700
#include<bits/stdc++.h>
	using namespace std;
	#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	#include <ext/pb_ds/assoc_container.hpp> 
	#include <ext/pb_ds/tree_policy.hpp> 
	using namespace __gnu_pbds; 
	#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
	
	#define all(a)      (a).begin(),(a).end()
	#define sz(x)       (int)x.size()
	
	#define ff first
	#define ss second
	#define mp make_pair
		 
	#define pb push_back
	#define endl "\n"
		 
	#define int long long 
	#define double long double
		 
	#define bp __builtin_popcountll
	#define inf 1e16
	
	const int N=1e5+5;
	const int M=1e6+6;
	const int MOD=1e9+7;
	
	void solve()
	{	
		int n;
		cin>>n;
		int a[n];
		map<int,int> mm;
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
			mm[a[i]]++;
		}
		int ans=0;
		for(auto X:mm)
		{
			ans+=((X.ss)*(X.ss-1))/2;
		}
		for(int i=0;i<n;i++)
		{
			int tt=mm[a[i]];
			int res=ans-(tt*(tt-1))/2;
			tt--;
			res+=(tt*(tt-1))/2;
			cout<<res<<endl;
		}
	}

	signed main()  
	{
		FAST
		int t=1;
		//cin>>t;
		while(t--)
		{
			solve();
		}
	}
		


Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 300000;
int 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;
	}
}
int COMB(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;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
map<int, int>mp;
signed main() {
	int n, m;
	cin >> n >> m;
	int memo = m;
	COMinit();
	if (prime(m))cout << n << endl;
	else {
		for (int i = 2; i <= sqrt(m); i++) {
			if (prime(i)) {
				while (memo % i == 0) {
					memo /= i;
					mp[i]++;
				}
			}
		}
		if (memo != 1)mp[memo]++;
		int ans = 1;
		for (auto x : mp) {
			ans *= COMB(n + x.second - 1, n - 1);
			ans %= mod;
		}
		cout << ans << endl;
	}
	ggr
}

Measured memory_bytes: 7296
import java.util.*;
import java.util.stream.*;

public class Main {
    public static final long MOD = 1_000_000_007;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        long[][] dp = new long[s.length()+1][4];
        for(int i = s.length(); 0 <= i; i--) {
            for(int j = 3; 0 <= j; j--) {
                if(i == s.length()) {
                    dp[i][j] = j == 3 ? 1L : 0L;
                } else {
                    dp[i][j] = dp[i+1][j] * (s.charAt(i) == '?' ? 3L : 1L);
                    if(j < 3 && (s.charAt(i) == '?' || s.charAt(i) == "ABC".charAt(j))) {
                        dp[i][j] += dp[i+1][j+1];
                    }
                    dp[i][j] %= MOD;
                }
            }
        }
        System.out.println(dp[0][0]);
    }
}

Measured memory_bytes: 30272
def get_sum_line(count, val_list):
    len_list = len(val_list)
    sum_line = 0
    for i in range(len_list):
        sum_line += val_list[i] * (i - (len_list - 1 - i))
    return sum_line

n, m = list(map(int, input().split()))
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))

sum_x_line = get_sum_line(n, x_list)
sum_y_line = get_sum_line(m, y_list)

ans = int(sum_x_line * sum_y_line % (10**9 + 7))

print(ans)




Measured memory_bytes: 18624
import sys
input=sys.stdin.readline

def main():
    N,M=map(int, input().split())
    K=[]
    for i in range(M):
        K.append(list(map(int, input().split())))
    P = list(map(int, input().split()))

    ans = 0
    for i in range(2**N):
        s = "{:0" + str(N) +"b}"
        b = True
        for j in range(M):
            x = 0
            for k in K[j][1:]:
                x += int(2**(N-k))
            s = "{:b}".format(i&x)
            if s.count("1")%2 != P[j]:
                b = False
                break
        if b:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n = int(input())
strs = [int(x) for x in str(n)]
kijyun = [9]*(len(strs)-1)
if strs[1:] == kijyun:
    print((len(strs)-1)*9+strs[0])
else:
    print((len(strs)-1)*9+strs[0]-1)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC147D
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] A = new long[N];
            string[] Ainput = Console.ReadLine().Split(' ');
            for(int i = 0; i < N; i++)
            {
                A[i] = long.Parse(Ainput[i]);
            }
            long[] zero = new long[60];
            long[] one = new long[60];
            for(int i = 0; i < N; i++)
            {
                string s = Convert.ToString(A[i], 2);
                int l = s.Length;
                //Console.WriteLine(s);
                for(int j = 0; j < l; j++)
                {
                    if (s[l - j - 1].ToString() == "1")
                    {
                        one[j] += 1;
                    }
                    else
                    {
                        zero[j] += 1;
                    }
                }
                if (l < 60)
                {
                    for (int j = l; j < 60; j++)
                    {
                        zero[j] += 1;
                    }
                }
            }
            long m = 1;
            long ans = 0;
            for(int i = 0; i < 60; i++)
            {
                long a = zero[i] * one[i];
                a %= 1000000007;
                ans += a*m;
                ans %= 1000000007;
                m *= 2;
                m %= 1000000007;
            }
            //Console.WriteLine(string.Join("",zero));
            //Console.WriteLine(string.Join("", one));
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 103072
package main

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

func main() {
	A, B := ReadInt(), ReadInt()
	v := 1 ^ 2 ^ 3 ^ A ^ B
	fmt.Println(v)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1836
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

int n;
vector<int> adj[N];

vector<int> bfs(int src){
    vector<int> vis(n + 2, 0);
    vector<int> dis(n + 1, 0);
    vis[src] = 1;
    dis[src] = 0;
    queue<int> q;
    q.push(src);
    while(q.size()){
        int node = q.front();
        q.pop();
        for(auto i: adj[node]){
            if(!vis[i]){
                vis[i] = 1;
                dis[i] = dis[node] + 1;
                q.push(i);
            }
        }
    }
    return dis;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int pos_a, pos_b;
    cin >> n >> pos_a >> pos_b;
    if(pos_a == pos_b) return cout << 0, 0;
    for(int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    auto dis_a = bfs(pos_a);
    auto dis_b = bfs(pos_b);
    int ans = 0;
    for(int i = 1; i <= n; i++){
      if(dis_a[i] < dis_b[i]) ans = max(ans, dis_b[i] - 1);
    }
    cout << ans;

    return 0;
}


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

int main() {
    //
    long long n, k;
    map<long long, long long> m;

    cin >> n >> k;

    long long a, b;
    for (long long i = 0; i < n; i++) {
        cin >> a >> b;
        m[a] += b;
    }

    for (auto itr : m) {
        k -= itr.second;
        if (k <= 0) {
            cout << itr.first;
            return 0;
        }
    }
    //
}


Measured memory_bytes: 7404
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;

// 1 つの証言を表す構造体
using pint = pair<int,int>; // 「人」と「0 or 1」

// 入力
int N;
vector<vector<pint>> v;

// 整数 bit に対応する「決め打ち」が整合しているかを判定
bool judge(int bit) {
    
    // i 人目の証言を検証する
    for (int i = 0; i < N; ++i) {
        
        // i 人目が「不親切」だったら、証言はすべて無意味
        if ( !(bit & (1 << i)) ) continue;

        // それぞれ確認
        for (pint xy : v[i]) {
            int x = xy.first; // x が
            int y = xy.second; // y = 1: 正直、y = 0: 不親切

            // y = 1 なのに「不親切」だったらダメ
            if (y == 1 && !(bit & (1 << x))) return false;

            // y = 0 なのに「正直者」だったらダメ
            if (y == 0 && (bit & (1 << x))) return false;
        }
    }
    return true;
}


int main() {
    cin >> N;
    v.resize(N);
    for (int i = 0; i < N; ++i) {
        int A; cin >> A;
        v[i].resize(A);
        for (int j = 0; j < A; ++j) {
            cin >> v[i][j].first >> v[i][j].second;
            --v[i][j].first; // 0-indexed に
        }
    }

    int res = 0;
    for (int bit = 0; bit < (1 << N); ++bit) {
        
        // 矛盾 check
        if (judge(bit)) {
            
            bitset<15> s(bit);
            // bit に含まれる人数を数える
            int cnt = s.count();
           
            res = max(res, cnt);
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
using namespace std;
int main(){
  string s,t;
  cin >>s>>t;

  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());

  if(s<t) cout <<"Yes"<<endl;
  else cout <<"No"<<endl;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, D, A;
  IN(N, D, A);
  vpll XH(N);
  REP(i,N) IN(XH[i].first, XH[i].second);
  sort(ALL(XH));

  vll R(N, N);
  ll head = 0;
  REP(i, N){
    if(head>=N) break;
    while(XH[head].first-XH[i].first<=2*D){
      head++;
      if(head>=N) break;
    }
    R[i] = head;
  }

  vll A_sum(N+1, 0);

  ll first=0;
  ll ans = 0;
  while(first<N){
    ll H_tmp = XH[first].second+A_sum[first];
    ll ans_tmp = H_tmp/A;
    if(ans_tmp*A!=H_tmp) ans_tmp++;
    ans += ans_tmp;
    A_sum[first] -= A*ans_tmp;
    A_sum[R[first]] += A*ans_tmp;
    while(XH[first].second+A_sum[first]<=0){
      first++;
      A_sum[first] += A_sum[first-1];
      if(first>=N) break;
    }
  }

  OUT(ans);

  return 0;
}


Measured memory_bytes: 6528
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var b = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long res = 0;
        for (int i = 0; i < 29; i++)
        {
            long totalCount = 0;
            int lessInd1 = n;
            int moreInd1 = n;
            int moreInd2 = n;
            var mask = ((1 << i + 1) - 1);
            var orderedAUntil = a.Select(x => x & mask).ToList();
            orderedAUntil.Sort();
            var orderedBUntil = b.Select(x => x & mask).ToList();
            orderedBUntil.Sort();
            for (int j = 0; j < orderedBUntil.Count; j++)
            {
                var bElem = orderedBUntil[j];
                while (0 < lessInd1)
                {
                    if ((1 << (i + 1)) <= orderedAUntil[lessInd1 - 1] + bElem) lessInd1--;
                    else break;
                }
                while (0 < moreInd1)
                {
                    if ((1 << i) <= orderedAUntil[moreInd1 - 1] + bElem) moreInd1--;
                    else break;
                }
                while (0 < moreInd2)
                {
                    if ((1 << (i + 1)) + (1 << i) <= orderedAUntil[moreInd2 - 1] + bElem) moreInd2--;
                    else break;
                }
                totalCount += moreInd1 - lessInd1 + (moreInd2 + 1);
            }
            res |= ((totalCount & 1) << i);
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 53840
#include <bits/stdc++.h>
			using namespace std;
			#define ll long long
			#define INF 100000000LL
			#define mod 1000000007
			#define pll pair<long,long>
			#define se second
			#define fi first
			#define pb push_back
			#include <ext/pb_ds/assoc_container.hpp>
			#include <ext/pb_ds/tree_policy.hpp>
			using namespace __gnu_pbds;

			typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
			typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update>pllordered_set;
			
			ll cache[3000][3000];
			vector<ll> v1;
			vector<ll> v2;
			
			ll dp(ll i,ll j)
			{
				if(i<0 || j<0)
					return 0;
				if(cache[i][j]!=-1)	
					return cache[i][j];
				
				ll ans=dp(i-1,j)+dp(i,j-1);
				ans%=mod;
				ans=(ans-dp(i-1,j-1)+mod)%mod;
				if(v1[i]==v2[j])
				{
					ans+=1+dp(i-1,j-1);
					ans%=mod;
				}
				return cache[i][j]=ans;
			}
			
			int main()
			{
				ll n,m;
				cin>>n>>m;
				v1.resize(n);
				v2.resize(m);
				for(ll i=0;i<n;i++)
				{
					cin>>v1[i];
				}
				for(ll i=0;i<m;i++)
				{
					cin>>v2[i];
				}
				for(ll i=0;i<=n;i++)
				{
					for(ll j=0;j<=m;j++)
						cache[i][j]=-1;
				}
				cout<<dp(n-1,m-1)+1;
				
						
			}


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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

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

void solve(){
    ll n;
    string s;
    cin >> n >> s;
    ll ans = 0;
    rep(i, sz(s)){
    	if(i+2 < sz(s) && s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
    		ans++;
    		i += 2;
    	}
    }
    cout << ans << endl;
}

int main(){
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    return 0;
} 

Measured memory_bytes: 256
N = int(input())
ba = b = a = ans = 0
for i in range(N):
    s = input()
    ans += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        ba += 1
    elif s[0] == 'B':
        b += 1
    elif s[-1] == 'A':
        a += 1

if ba == 0:
    ans += min(a, b)
else:
    if a + b > 0:
        ans += ba + min(a, b)
    else:
        ans += ba - 1

print(ans)

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

int main() {
  int n; cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];

  int mini = p[0], ans = 0;
  rep(i,n) {
    if (p[i] <= mini) ans++;
    mini = min(mini, p[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3984
import java.io.IOException;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] card=new int[n];
		int sum=0;
		for(int i=0;i<n;i++) {
			card[i] = sc.nextInt();
		}
		for(int i=0;i<n;i+=2) {
			if(card[i]%2==1) {
				sum++;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 35632
#include<stdio.h>
int main(){
  int n[5];
  int i,j,t;
  scanf("%d %d %d %d %d",&n[0],&n[1],&n[2],&n[3],&n[4]);
  for(i=0;i<5;i++){
    for(j=1;j+i<5;j++){
      if(n[j]>n[j-1]){
	t=n[j];
	n[j]=n[j-1];
	n[j-1]=t;
      }
    }
  }
  printf("%d %d %d %d %d\n",n[0],n[1],n[2],n[3],n[4]);

  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define all(x) x.begin(),x.end()
#define len(x) (int)(x).size()
//#define endl "\n"
#define m_p make_pair
#define int long long


using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pari;

ld PI = 3.14159265358979323846;


struct Circle{
    int x,y,r;
};

typedef tree<int, null_type, less<int >,
    rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void volodya22(){
    #ifdef THERE
        freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    cout << fixed;
}


int n;
const int N = 1e6+7;
const int alphabet = 256;
const int INF = 1e18;
const ll MOD = 1e9+7;
const ld eps = 1e-19;
const int L = 30;

int m1 = 137*137*137*137*13;
int m2 = 1e9+9;
//int p = 347;


void input(){

}


void solve(){
    string s;
    cin >> s;
    int a = (s[0]-'0')*10+(s[1]-'0');
    int b = (s[2]-'0')*10+(s[3]-'0');
    if(a == 0 && b > 12) cout << "NA";
    else if(b > 12 && a > 12) cout << "NA";
    else if(b == 0 && a > 12) cout << "NA";
    else if(a == 0 && b == 0) cout << "NA";
    else if(a == 0 && b <= 12) cout << "YYMM";
    else if(a > 12 && b <= 12) cout << "YYMM";
    else if(b == 0 && a <= 12) cout << "MMYY";
    else if(b > 12 && a <= 12) cout << "MMYY";
    else cout << "AMBIGUOUS";
}

signed main(){
    volodya22();
    input();
    solve();
}


Measured memory_bytes: 256
import numpy as np
N,T= [int(i) for i in input().split()]
a=[]
for i in range(N):
	a.append( [int(x) for x in input().split()])
a = np.array(a)
a = a[np.where(a[:,1] <= T)]
print(min(a[:,0]) if len(a) > 0 else "TLE")


Measured memory_bytes: 12444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K,Q; cin >> N >> K >> Q;
    vector<ll> A(Q),P(N,K-Q);
    rep(i,Q){
        int a; cin >> a;
        ++P[--a];
    }
    rep(i,N){
        if (P[i]<=0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int[] data = new int[n];
    	for (int i = 0; i < n; i++) {
    		data[i] = sc.nextInt();
    	}

    	int count = 0;
    	for (int i = 0; i < n; i++) {
    		for (int j = n - 1; j > i; j--) {
    			if (data[j] < data[j - 1]) {
    				int temp = data[j];
    				data[j] = data[j - 1];
    				data[j - 1] = temp;
    				count++;
    			}
    		}
    	}

    	printData(data);
    	System.out.println(count);

        sc.close();
	}

	private static void printData(int[] data) {
		StringBuffer printData = new StringBuffer();
		for (int i = 0; i < data.length; i++) {
			printData.append(data[i]);
			printData.append(" ");
		}
		printData.delete(printData.length() - 1, printData.length());
		System.out.println(printData);
	}
}

Measured memory_bytes: 18128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>

using namespace std;
typedef long long ll;

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

    cout << fixed << setprecision(9) << pow((double)L/3, 3) << endl;
    return 0;
}

Measured memory_bytes: 384
// Charan Sriramula
 
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;
 
const ll lg=22;
const ll N=1e5+5;
const ll M=5e8;
const ll INF=1e18;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;
 
#define is(n) scanf("%d",&n)
#define io(n) printf("%d\n",n)
#define ls(n) scanf("%lld",&n)
#define lo(n) printf("%lld\n",n)
 
#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
 
inline ll mul(ll a, ll b, ll p){ return (a * 1ll * b) % p; }
inline ll sub(ll a, ll b, ll p){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll add(ll a, ll b, ll p){ ll c = a + b; if(c > p) c -= p; return c; }
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int main()
{
    ll n,d;
    cin>>n>>d;
    ll val=(n/((2*d)+1));
    if(n%((2*d)+1)){val++;}
    cout<<val<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
using namespace std;
 
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;
 
int main() {
    unsigned long long a; cin >> a;
    char c; int b, bd;
    cin >> b >> c >> bd;
    cout << a * b + a * bd / 100 << '\n';
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define gSEewtwetaewtetw 100000000000000000ll
#define fhddfhdftghjtdfjtrfj pair<long long,long long>
#define efqat5eu5uturrtuutrrtu first
#define rgazwseseryhtreyuutserrutustr second
#define int long long
using namespace std;
int n,ans=gSEewtwetaewtetw,a[200005],s[200005];
inline int sec(int l,int r)
{
	if(l>r) return 0;
	return s[r]-s[l-1];
}
fhddfhdftghjtdfjtrfj cal(int L,int R)
{
	int l=L,r=R;
	while(r-l>1)
	{
		int mid=(l+r)>>1;
		if(sec(L,mid)<=sec(mid+1,R)) l=mid;
		else r=mid;
	}
	fhddfhdftghjtdfjtrfj sedfopfjsofehiefhiefb(sec(L,l),sec(l+1,R));
	fhddfhdftghjtdfjtrfj pr(sec(L,r),sec(r+1,R));
	return abs(sedfopfjsofehiefhiefb.efqat5eu5uturrtuutrrtu-sedfopfjsofehiefhiefb.rgazwseseryhtreyuutserrutustr)<abs(pr.efqat5eu5uturrtuutrrtu-pr.rgazwseseryhtreyuutserrutustr) ? sedfopfjsofehiefhiefb : pr;
}
int max(int a,int b,int c,int d){return max(a,max(b,max(c,d)));}
int min(int a,int b,int c,int d){return min(a,min(b,min(c,d)));}
int solve(int mid)
{
	fhddfhdftghjtdfjtrfj l=cal(1,mid),r=cal(mid+1,n);
	return max(l.efqat5eu5uturrtuutrrtu,l.rgazwseseryhtreyuutserrutustr,r.efqat5eu5uturrtuutrrtu,r.rgazwseseryhtreyuutserrutustr)-min(l.efqat5eu5uturrtuutrrtu,l.rgazwseseryhtreyuutserrutustr,r.efqat5eu5uturrtuutrrtu,r.rgazwseseryhtreyuutserrutustr);
}
main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++) s[i]=s[i-1]+a[i];
	for(int i=2;i<=n-2;i++) ans=min(ans,solve(i));
	printf("%lld\n",ans);
}


Measured memory_bytes: 3328
#include<stdio.h>
#define N 100
void printStatus(int,int[]);
int main(void)
{
  int A[N];//array
  int i,j;//counter
  int tmp;//temporary variable to swap 2 elements
  int count=0;//count how many times sort is done
  int n;//the number of elements
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  for(i=0;i<n;i++)
    {
      for(j=n-1;j>i;j--)
	{
	  if(A[j]<A[j-1])
	    {
	      tmp=A[j];
	      A[j]=A[j-1];
	      A[j-1]=tmp;
	      count++;
	    }
	}
    }
  printStatus(n,A);
  printf("%d\n",count);
  return 0;
}
void printStatus(int n,int A[])
{
  int i;
  for(i=0;i<n;i++)
    {
      if(i>0) printf(" ");
      printf("%d",A[i]);
    }
  printf("\n");
}



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

typedef  long long ll;
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;}

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int n;
ll gcd(ll x,ll y){
    if(x%y==0){
        return y;
    }
    else{
        return gcd(y,x%y);
    }
}
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll cd=c*d;
    ll div=gcd(c,d);
    cd/=div;
    ll candivide=-(b/cd-a/cd+(!(a%cd)))+(b/c-a/c+(!(a%c)))+(b/d-a/d+(!(a%d)));
    ll ans=(b-a+1)-candivide;
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 636
from decimal import Decimal
import sys
n = list(map(int, input().split()))

if n[0] == 1 or n[1] == 1:
    print(1)
    sys.exit()

if n[0] % 2 == 0:
    print(Decimal(int((n[0]/2)*n[1])))
    sys.exit()
else:
    if n[1] % 2 == 0:
        print(Decimal(int(n[0]*(n[1]/2))))
        sys.exit()
    else:
        a = ((n[0]-1)*n[1])/2
        b = n[1] - int(n[1]/2)
        print(Decimal(int(a+b)))
        sys.exit()
    


Measured memory_bytes: 5076
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>s;
    rep(i,Size(s)){
        if(s[i]=='1')cnt++;
    }
    cnt=min(cnt,(ll)Size(s)-cnt);
    Cout(cnt*2);
    return 0;
}


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

char s[200005]; int len;

int cnt[26];

int main() {
	scanf("%s", s + 1); len = strlen(s + 1);
	
	for (int i = 1; i <= len; ++i) ++cnt[s[i] - 'a'];
	
	long long ans = 1ll * len * (len - 1) / 2;
	
	for (int i = 0; i < 26; ++i)
		ans -= 1ll * cnt[i] * (cnt[i] - 1) / 2;
	
	printf("%lld\n", ans + 1);
	
	return 0;
}

Measured memory_bytes: 384
if __name__ == '__main__':
    A, B, C, X, Y = list(map(int, input().split()))
    if A + B <= 2 * C:
        # print(1)
        print(A * X + B * Y)
    else:
        if X == Y:
            # print(2)
            print(C * 2 * X)
        elif X < Y:
            # print(3)
            print(min(X * C * 2 + B * (Y - X), C * 2 * Y))
        else:
            # print(4)
            print(min(Y * C * 2 + A * (X - Y), C * 2 * X))


Measured memory_bytes: 3060
#include <stdio.h>

int selectionSort(int A[],int N);


int main()
{
  int A[100];
  int N;
  int i;
  int count;

  scanf("%d",&N);
  for( i = 0; i < N; i++){
    scanf("%d",&A[i]);
  }
  
  count =  selectionSort(A,N);
  
  for( i = 0; i < N; i++){
    if( i > 0 )printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}


int selectionSort(int A[],int N)
{
  int i,j;
  int minj;
  int c;
  int count=0;
  for( i = 0; i < N; i++){
    minj = i;
    for( j = i; j < N; j++){
      if( A[j] < A[minj]){
	minj = j;
      }
    }
	c = A[i];
	A[i] = A[minj];
	A[minj] = c;
	if(i != minj) count++;
  }
  

      return count;
	
}
    
  



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

int gcd(int a, int b){
  if(b==0)return a;
  else return gcd(b, a%b);
}

int main(){
  int n, k;
  cin >> n >> k;
  vector<int>a(n);
  for(int i=0; i<n; i++)cin >> a[i];
  int g=a[0], m=a[0];
  for(int i=1; i<n; i++){
    g = gcd(g, a[i]);
    m = max(m, a[i]);
  }
  if(m-k>=0 && (m-k)%g==0)cout << "POSSIBLE";
  else cout << "IMPOSSIBLE";
  return 0;
}
  

Measured memory_bytes: 640
using System;

namespace AOJ
{
	class Program
	{
		public static void Main(string[] args)
		{
			var s = Console.ReadLine();
			if(s == "1 1 0" || s == "0 0 1")
			{
				Console.WriteLine("Open");
			}
			else
			{
				Console.WriteLine("Close");
			}
		}
	}
}

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

int main(){
    ll x;
    cin >> x;
    ll q = x / 11;
    ll r = x % 11;
    if(r != 0){
        if(r < 7){
            cout << q * 2 + 1 << endl;
        } else {
            cout << q * 2 + 2 << endl;
        }
    } else {
        cout << q * 2 << endl;
    }
    return 0;
}

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

using namespace std;

#define ll long long

const int N = 2e5+15;

int ar[N];
int main(){

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

    int n;cin>>n;
    int maxi = 0;
    for(int i=0;i<n;++i){
        scanf("%d",&ar[i]);
        maxi = max(maxi,ar[i]);
    }
    int cand = maxi;
    int m = (maxi+1)/2;
    for(int i=0;i<n;++i){
        if( abs(cand-m)>= abs(ar[i]-m))
            cand = ar[i];
    }
    printf("%d %d\n",maxi,cand);
    return 0;
}

Measured memory_bytes: 640
from collections import deque

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

ans = [0] * (n - 1) 
seen = deque([1])
not_seen = [True] * n
not_seen[0] = False
cnt = n - 1

while cnt > 0:
    pre = seen.popleft()
    for now in path[pre]:
        if not_seen[now - 1]:
            seen.append(now)
            ans[now - 2] = pre
            not_seen[now - 1] = False
            cnt -= 1

print("Yes")
for i in ans:
    print(i)



Measured memory_bytes: 94656
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
void pk()
{
    ll x;
    cin>>x;
    if(x==0)
       cout<<1<<"\n";
    else cout<<0<<"\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //a #ifndef ONLINE_JUDGE 
    // freopen("/home/priyanshu/Hackercup/input.txt", "r", stdin); 
    // freopen("/home/priyanshu/Hackercup/output.txt", "w", stdout); 
    // #endif 
    ll t=1;
    //cin>>t;
    while(t--)
    {
        pk();
    }
} 


Measured memory_bytes: 3636
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto K = RD;
	auto D = RDR.ARR;

	string str;
	foreach (e; D)
	{
		str ~= e.to!string;
	}
	long ans;
	foreach (i; 0..100000)
	{
		auto x = (N + i).to!string;
		bool isNG;
		foreach (c; str)
		{
			auto pos = countUntil(x, c);
			if (pos != -1)
			{
				isNG = true;
				break;
			}
		}
		if (!isNG)
		{
			ans = N + i;
			break;
		}
	}
	
	writeln(ans);
	stdout.flush();
	//readln();
}

Measured memory_bytes: 1276
package main

import (
	"fmt"
	"strings"
)

func main() {
	var A, B, C string
	fmt.Scan(&A)
	fmt.Scan(&B)
	fmt.Scan(&C)
	fmt.Print(strings.ToUpper(string(A[0])))
	fmt.Print(strings.ToUpper(string(B[0])))
	fmt.Print(strings.ToUpper(string(C[0])))
	fmt.Println("")
}


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

int64_t lcm(int64_t a,int64_t b){
  int64_t x = a* b;
 if(a<b) swap(a,b);
  int64_t r = a % b;
  while(r != 0){
   a = b;
    b = r;
    r = a % b;
  }
  return x/b;
        }

int main() {
  int64_t a,b;
  cin >>a>>b;
  cout << lcm(a,b) <<endl;
}

Measured memory_bytes: 256
N = int(input())
a_arr = list(map(int,input().split()))

def div2(num):
    count = 0
    while num % 2 == 0:
        num /= 2
        count += 1
    return count

a_arr2 = [div2(i) for i in a_arr]
print(sum(a_arr2))

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9;
const int mod = 1e9+7;
const int maxn = 2e3+3;

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,L;
    while (cin >> n >> L) {
        VI A(n); int sum = 0;
        FOR(i,0,n) {
            A[i] = L+(i+1)-1;
            sum += A[i];
        }
        int diff = inf, ans;
        FOR(i,0,n) {
            const int x = sum - A[i];
            const int d = abs(sum-x);
            if (d < diff)
                ans = x, diff = d;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define INF -1000000000
int ar[5000];
int d[5001];

int max(int a,int b){
	if(a>=b)return a;
	else return b;
}

int main(){
	int n,i,j;
	while(1){
		scanf("%d",&n);
		if(n==0)return 0;
		for(i=0;i<n;i++){
			scanf("%d",&ar[i]);
		}
		d[0]=0;
		int ans=INF;
		for(i=1;i<n+1;i++)d[i]=d[i-1]+ar[i-1];
		for(i=0;i<n;i++)for(j=i+1;j<n+1;j++){
			ans=max(ans,d[j]-d[i]);
		}
		printf("%d\n",ans);
	}
}

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

int main() {
  int n, a, b;
  //string op;
  cin >> n >> a >> b;

  if (n*a > b) {
    cout << b << endl;
  }else{
    cout << n*a << endl;
  }
  
  
  // ここにプログラムを追記
}


Measured memory_bytes: 3572
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(void){

	string s;

	int n;
	cin >> n;
	for( int i = 0; i < n; i++ ) {
		cin >> s;
		string maxstr, minstr;
		char ch[8];
		for( int j = 0; j < 8; j++ )
			ch[j] = s[j];
		sort( ch, ch + 8 );
		for( int j = 0; j < 8; j++ ) {
			maxstr += ch[7-j];
			minstr += ch[j];
		}
		int max, min;
		max = atoi(maxstr.c_str());
		min = atoi(minstr.c_str());
		cout << max - min << endl;
	}

    return 0;
}

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

const int P = ll(1e9) + 7;
int pw(int x, int y) {
	int r = 1;
	for (; y; y >>= 1, x = 1ll * x * x % P)
		if (y & 1) r = 1ll * r * x % P;
	return r;
}

int n, a, b, ans, x, y;
int main() {
	cin >> n >> a >> b;
	ans = (pw(2, n) + P - 1) % P;
	x = y = 1;
	for (int i = 0; i < a; i++) {
		x = 1ll * x * (n - i) % P;
		y = y * (i + 1ll) % P;
	}
	ans = (ans + P - 1ll * x * pw(y, P - 2) % P) % P;

	x = y = 1;
	for (int i = 0; i < b; i++) {
		x = 1ll * x * (n - i) % P;
		y = y * (i + 1ll) % P;
	}
	ans = (ans + P - 1ll * x * pw(y, P - 2) % P) % P;

	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    Yes((c-1)/b <= (a-1)/d);

    return 0;
}


Measured memory_bytes: 3608
# -*- coding: utf-8 -*-
import numpy as np
n, m, x = map(int, input().split())

cost = np.empty(n, dtype=int)
skill_up = np.zeros((n, m), dtype=int)

for i in range(n):
    l = list(map(int, input().split()))
    cost[i] = l[0]
    skill_up[i,:] = l[1:]

flag = False
min_cost = np.sum(cost)
for i in range(1, 2 ** n):
    bidx = bin(i)[2:].rjust(n, '0')
    mask = list(map(lambda x: x == '1', list(bidx)))
    skill = np.sum(skill_up[mask], axis=0)
    if np.all(skill >= x):
        flag = True
        min_cost = min(min_cost, np.sum(cost[mask]))

if not flag:
    min_cost = -1

print(min_cost)


Measured memory_bytes: 27416
n= int(input())
a = [list(map(int, input().split())) for _ in range(n)]

p = [-1]*n
r = [-1]*n
l = [-1]*n

for i in range(n):
    ind = a[i][0]
    r[ind] = a[i][2]
    l[ind] = a[i][1]
    if r[ind]>=0:
        p[r[ind]] = ind
    if l[ind]>=0:
        p[l[ind]] = ind

root = -1
for i in range(n):
    if p[i]==-1:
        root = i
        break

def preorder(ind):
    print(' %i'%ind, end='')
    if l[ind]!=-1:
        preorder(l[ind])
    if r[ind]!=-1:
        preorder(r[ind])
        
def inorder(ind):
    if l[ind]!=-1:
        inorder(l[ind])
    print(' %i'%ind, end='')
    if r[ind]!=-1:
        inorder(r[ind])
        
def postorder(ind):
    if l[ind]!=-1:
        postorder(l[ind])
    if r[ind]!=-1:
        postorder(r[ind])
    print(' %i'%ind, end='')
    
print('Preorder')
preorder(root)
print()
print('Inorder')
inorder(root)
print()
print('Postorder')
postorder(root)
print()


Measured memory_bytes: 5616
#include <cstdio>

int main() {
	int a, b, c, d, e, tot = 0;
	scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
	if (c < a) c += 24;
	tot += (c - a) * 60 + (d - b);
	printf("%d", tot - e);
	return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void codeforces()
{
    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
}
string convert(int a) {
    string s;
    map<int, char> m;
    for(char c = 'a'; c<'z'; c++) m[c - 'a' + 1] = c;
    m[0] = 'z';
    while( a> 0){
        s+= m[a%26];
        if( a%26 == 0) a = a/26 - 1;
        else a = a/26;
    }
    reverse(s.begin(), s.end());
    return s;
}
int32_t main()
{
    
    // w(t)
    {
        int n; cin>>n;
       cout<<convert(n);
    }
    return 0;
}

Measured memory_bytes: 3540