akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    V<ll> a(n);
    read(a);
    sort(all(a));
    reverse(all(a));
    multiset<ll, greater<ll>> st;
    ll res = a[0];
    st.insert(a[1]);
    st.insert(a[1]);
    for (int i = 2; i < n; i++) {
        ll s = *st.begin();
        res += s;
        st.erase(st.begin());
        st.insert(a[i]);
        st.insert(a[i]);
    }
    cout << res << newl;
}

Measured memory_bytes: 14284
#include<bits/stdc++.h>
using namespace std;
main(){
string s,t;
cin>>s>>t;

int dp[s.size()+1][t.size()+1];
for(int i=0;i<=s.size();i++)dp[i][0]=0;
for(int i=0;i<=t.size();i++)dp[0][i]=0;
memset(dp,0,sizeof(dp));

for(int i=1;i<=s.size();i++)for(int j=1;j<=t.size();j++){
if(s[i-1]==t[j-1]){dp[i][j]=dp[(i-1)][j-1]+1; }
else dp[i][j]=max(dp[(i-1)][j],dp[i][j-1]);
}
//for(int i=0;i<=s.size();i++){
//cout<<endl;
//for(int j=0;j<=t.size();j++)cout<<dp[i][j]<<" ";
//
//}




//cout<<dp[s.size()][t.size()]<<endl;
vector<char > vt;
int i=s.size();
int j=t.size();
while(i>=1&&j>=1)
{//cout<<i<<j<<endl;
//cout<<s[i-1]<<" "<<t[j-1]<<endl;

if(s[i-1]==t[j-1]){
	
	
	vt.push_back(s[i-1]);i--;j--;}
else{ if(dp[i][j]==dp[i-1][j]){i--;}
	else{j--;}

}




}

reverse(vt.begin(),vt.end());
for(char c: vt)cout<<c;
cout<<endl;}


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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) if((x)>(y))(x)=(y)
#define chmax(x,y) if((x)<(y))(x)=(y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n;
vi r, m;
bool p[60060];

// エラトステネスの篩 O(NloglogN)
void sieve() {
	rep(i,55556) p[i] = 1;
	p[0] = p[1] = false;
	for (int i = 2; i*i <= 55555; ++i)
		if (p[i]) for (int j = 2*i; j <= 55555; j += i) p[j] = false;
	rep(i,55556) if (p[i]) r.pb(i);
}

signed main() {
	cin >> n;
	sieve();
	each(i,r) if (i%5==1) m.pb(i);
	rep(i,n) cout << m[i] << bln(i,n);
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();

        TreeSet<String> ids = new TreeSet<String>();

        for(int i = 0; i < n; i++){
            ids.add(sc.next());
        }

        int m = sc.nextInt();
        boolean nowopen = false;

        for(int i = 0; i < m; i++){
            String nowcome = sc.next();
            if(ids.contains(nowcome)){
                if(nowopen){
                    nowopen = !nowopen;
                    System.out.print("Closed by ");
                    System.out.println(nowcome);
                }else{
                    nowopen = !nowopen;
                    System.out.print("Opened by ");
                    System.out.println(nowcome);
                }
            }else{
                System.out.print("Unknown ");
                System.out.println(nowcome);
            }
        }
	}
}

Measured memory_bytes: 20780
a,v=list(map(int,input().split()))
b,w=list(map(int,input().split()))
t=int(input())
if a<b:
    if a+v*t>=b+w*t:
        print('YES')
    else:
        print('NO')
elif a>b:
    if b-w*t>=a-v*t:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 9052
#include<bits/stdc++.h>
using namespace std;
int n;
int a[30][30];
long long dp[30][2100000];
vector<int> v[30];
int count1(int x) {
	int rv = 0;
	while(x) {
		rv++;
		x &= x-1;
	}
	return rv;
}
int main() {
	cin >> n;
	for(int i=1; i<=n; i++) {
		for(int j=0; j<n; j++) {
			cin >> a[i][j];
		}
	}
	for(int i=0; i<(1<<n); i++) {
		v[count1(i)].push_back(i);
	}
	dp[0][0] = 1;
	for(int i=1; i<=n; i++) {
		for(int j=0; j<n; j++) {
			if(a[i][j]==0) continue;
			for(int k=0; k<v[i].size(); k++) {
				int mask = v[i][k];
				if((mask>>j)%2!=1) continue;
				dp[i][mask] += dp[i-1][mask-(1<<j)];
				dp[i][mask] %= 1000000007;
			}
		}
	}
	cout << dp[n][(1<<n)-1] << endl;
}

Measured memory_bytes: 320956
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	hh := make([]int, n)
	for i := 0; i < n; i++ {
		hh[i] = getNextInt(scanner)
	}
	ee := make([][]edge, n)
	for i := 0; i < m; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner) - 1
		appendEdge(a, b, i, ee)
		appendEdge(b, a, i, ee)
	}
	ans := 0
	for i := 0; i < n; i++ {
		if exists(i, hh, ee) {
			continue
		}
		ans++
	}
	fmt.Fprintln(writer, ans)
}

func exists(i int, hh []int, ee [][]edge) bool {
	for _, e := range ee[i] {
		if hh[i] <= hh[e.to] {
			return true
		}
	}
	return false
}
func appendEdge(from, to, id int, ee [][]edge) {
	ee[from] = append(ee[from], edge{
		to: to,
		id: id,
	})
}

type edge struct {
	to, id int
}


Measured memory_bytes: 17928
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
int main(){
  while(1){
    int n,m;
    cin>>n>>m;
    if(n==0&&m==0) break;
    int a[100],b[100],suma=0,sumb=0;
    lp(i,n){
      cin>>a[i];
      suma+=a[i];
    }
    lp(i,m){
      cin>>b[i];
      sumb+=b[i];
    }
    int ans1=-1,ans2=-1;
    int sum=1000000;
    lp(i,n){
      lp(j,m){
	if(suma+b[j]-a[i]==sumb+a[i]-b[j]){
	  if(sum>a[i]+b[j]){
	    sum=a[i]+b[j];
	    ans1=a[i];
	    ans2=b[j];
	  }
	}
      }
    }
    if(ans1==-1&&ans2==-1)
      cout<<-1<<endl;
    else cout<<ans1<<" "<<ans2<<endl;
  }
  return 0;
}



Measured memory_bytes: 3100
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
  int n;
  double x[4];
  double y[4];
  const double eps = 1.0e-12;

  scanf("%d", &n);
  while (n--) {
    for (int i=0; i<4; i++) {
      scanf("%lf %lf", &x[i], &y[i]);
    }
    if (abs((y[1]-y[0])*(x[3]-x[2]) - (x[1]-x[0])*(y[3]-y[2])) < eps) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }

  return 0;
}

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

int main() {
  string s1, s2;
  cin >> s1 >> s2;
  
  string s;
  s = s1 + s2;
  
  int num;
  num = stoi(s);
  
  int flag = 0;
  for (int i = 1; i <= 350; i++) {
    if (i * i == num){
      cout << "Yes" << endl;
      flag = 1;
      break;
    }
  }
  if (flag == 0)
    cout << "No" << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  if (n >= m) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> X(m), diff(m - 1);
  for (int i = 0; i < m; i++) {
    cin >> X[i];
  }
  sort(X.begin(), X.end());

  for (int i = 0; i < m - 1; i++) diff[i] = X[i + 1] - X[i];

  sort(diff.begin(), diff.end(), greater<int>());
  int ans = X[m - 1] - X[0];

  for (int i = 0; i < n - 1; i++) ans -= diff[i];

  cout << ans << endl;

  return 0;
}

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

int main(){
    int a, b;
    char op;

    while(1){
        cin >> a >> op >> b;
        if(op == '?'){
            break;
        }else if(op == '+'){
            
            cout << (a + b) << endl;
        }else if(op == '-'){
            cout << (a - b) << endl;
        }else if(op == '/'){
            cout << (a / b) << endl;
        }else if(op == '*'){
            cout << (a * b) << endl;
        }
    }
}



Measured memory_bytes: 3112
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();

		// 計算
		long result = 0;
		int[] list = new int[n+1];
		Arrays.fill(list, 1);
		for(int i = 2; i <= n; i++){
    	    for(int j = i; j <= n; j += i){
    	        list[j]++; 
			}
		}
		
		for(int i = 1; i <= n; i++){
    	    result += (long)i*list[i];
		}
		
		// 出力
		System.out.println(result);
	}

	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 65292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll inf=1000000007;
const ll maxinput=25;
const ll mod=998244353;
#define mp make_pair
const int maxinput2=(1<<21)+5;
ll n,mat[21][21];
vector <int> adj[maxinput];
int dp[maxinput2];
int ways(int mask)
{
    int pos=__builtin_popcount(mask);
    if(pos==n)
        return(1);

    if(dp[mask]!=-1)
        return(dp[mask]);
    int temp=0;
    int j;
    for(int j=0;j<adj[pos].size();j++)
    {
        if(((1<<adj[pos][j])&mask)==0)
            temp+=(ways(mask|(1<<adj[pos][j])))%inf,temp%=inf;
    }
    return(dp[mask]=temp%inf);
}
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>mat[i][j];
            if(mat[i][j]==1)
                adj[i].push_back(j);
        }
    }

    cout<<(ways(0)+inf)%inf; //current position,mask
}

Measured memory_bytes: 8448
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<cmath>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    int ans = max(A + B,max(A - B,A*B));
    cout << ans << endl;
}


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

#pragma region _define

#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl;
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define endl "\n"
#define y() cout<<"Yes"<<endl
#define Y() cout<<"YES"<<endl
#define n() cout<<"No"<<endl
#define N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vs = vector<st>;
using vb = vector<bool>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
bool graph[node][node];
bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b)*b);
}

/************************************************************************/
int n, m;
LL ans = 0;

void dfs(int v) {
	bool all = true;
	f(i, 0, n) {
		if (visited[i] == false) {
			all = false;
		}
	}
	if (all)ans++;
	
	f(i, 0, n) {
		if (graph[v][i] == false)continue;
		if (visited[i] == true)continue;
		visited[i] = true;
		dfs(i);
		visited[i] = false;
	}
	return;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);

	cin >> n >> m;
	vi a(m), b(m);
	link(a, b, m);
	visited[0] = true;
	dfs(0);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+5;
int n,k,now,ans;
int a[N],sum[N],sum2[N];
signed main(){
	scanf("%lld%lld",&n,&k);
	for (register int i=1; i<=n; ++i) 
	{
		scanf("%lld",&a[i]);
		sum[i]=sum[i-1]+a[i]; 
		if (a[i]>0) 
		{
			now+=a[i];
			sum2[i]=sum2[i-1]+a[i];
		}
		else sum2[i]=sum2[i-1];
	}
	for (register int i=k; i<=n; ++i) 
	if (sum[i]-sum[i-k]>0) ans=max(ans,now-(sum2[i]-sum2[i-k])+(sum[i]-sum[i-k]));
	else ans=max(ans,now-(sum2[i]-sum2[i-k]));
	printf("%lld\n",ans);
return 0;	
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>

void exchange(long long &a, long long &b){
	if(a%2!=0) a--;
	a = a/2;
	b += a;
}

int main(){
	long long a, b;
	int k;
	std::cin >> a >> b >> k;
	for(int i=0;i<k;i++){
		if(i%2==0){
			exchange(a,b);
		}else{
			exchange(b,a);
		}
	}
	std::cout << a <<" "<< b <<std::endl;
	return 0;
}


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

int main()
{
  int x, y, s;
  cin >> x >> y;
  while( x !=0 or y != 0 ) {
    if( x > y ) {
      s = x; x = y; y = s;
    }
    else{
      x = x, y = y;
    }
    cout << x << " " << y << endl;

    cin >> x >> y;
  }
}

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

int main() {
    int h, w;
    cin >> h >> w;
    while (!(h==0&&w==0)) {
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                if (i==0||i==h-1||j==0||j==w-1) {
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
    return 0;
}


Measured memory_bytes: 3080
#include <stdio.h>

int main()
{
	int i, N, M, a[100001], b[100001];
	scanf("%d %d", &N, &M);
	for (i = 1; i <= M; i++) scanf("%d %d", &(a[i]), &(b[i]));
	
	int parity[100001] = {};
	for (i = 1; i <= M; i++) {
		parity[a[i]] ^= 1;
		parity[b[i]] ^= 1;
	}
	for (i = 1; i <= N; i++) if (parity[i] == 1) break;
	if (i <= N) printf("NO\n");
	else printf("YES\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1280
import io
import sys

MOD = 10 ** 9 + 7


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
136
'''


def MAIN():
  # T_IN()
  A()


def A():
  n = IN_I()

  t = 0
  if n > 9:
    t += 9

  if n > 999:
    t += 900

  if n > 99999:
    t += 90000

  if n <= 9:
    t += n
  elif 99 < n <= 999:
    t += n - 99
  elif 9999 < n <= 99999:
    t += n - 9999

  print(t)
  return None


def B():
  return None


def C():
  return None


MAIN()


Measured memory_bytes: 3064
n = int(input())
m = n
keta = 0
for i in range(1, 12):
    m -= 26 ** i
    if m <= 0:
        keta = i
        break

alpha = "abcdefghijklmnopqrstuvwxyz"

ans = str()
for j in range(keta):
    n -= 1
    ans += alpha[n % 26]
    n //= 26

print(ans[::-1])


Measured memory_bytes: 61768
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin>>n>>m;
    vector<set<int> > edges(n+1,set<int>());
    bool is_target[n+1]={};
    rep(i,m){
        int s,t;cin>>s>>t;
        edges.at(s).insert(t);
        is_target[t]=true; 
    }
    repr(i,1,n+1){
        if(!is_target[i]){edges.at(0).insert(i);}
    }
    int memo[n+1];
    rep(i,n+1){memo[i]=-1;}
    function<int(int)> solve = [&](int source){
        if(memo[source]!=-1){return memo[source];}
        int res=0;
        if(edges[source].size()==0){return memo[source]=0;}
        for(auto target:edges[source]){
            res = max(res, solve(target));
        }
        return memo[source] = res + 1;
    };
    cout << solve(0)-1 << endl;
    return 0;
}


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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define dbg(x) std::cerr<<#x<<" = " << (x) << std::endl
#define pnl(x) std::cout << x << "\n"

typedef	std::vector<int>	vi;
typedef std::pair<int,int>	ii;
typedef std::vector<std::string>	vs;
typedef std::vector<ii>	vii;
typedef std::vector<long long>	vl;
typedef	long long ll;


const int	NB_D = 4;
const int	DY[] = {-1, 1, 0, 0};
const int	DX[] = {0, 0, -1, 1};

int		main(void)
{
	std::ios_base::sync_with_stdio(false);
	int		A, B;
	std::string s;
	std::cin >> A >> B >> s;
	for (int i(0); i < A; ++i)
		if (s[i] < '0' or s[i] > '9')
		{
			pnl("No");
			return 0;
		}
	if (s[A] != '-')
	{
		pnl("No");
		return 0;
	}
	for (int i(A + 1); i < A + B; ++i)
		if (s[i] < '0' or s[i] > '9')
		{
				pnl("No");
				return 0;
		}
	pnl("Yes");
}



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

int main(){
    int N;  
    cin >> N;
    int tmp, m1,m2;
    vector<pair<int,int>> pairs(N),original(N);
    //vector<int> X, original;
    for(int i=0;i<N;i++){
      cin >> tmp;
      pairs[i] = make_pair(tmp,i);
      original[i] = make_pair(tmp,i);
      //original.push_back(tmp);
      //X.push_back(tmp);
    }

    sort(pairs.begin(), pairs.end());
    // for(int i=0;i<N;i++){
    //   cout << original[i].first << original[i].second << endl;
    // }

    m1 = pairs[N/2 -1].first;
    m2 = pairs[N/2].first;
    // cout << "m1" << m1 << "m2" << m2 << endl;
    if(m1==m2){
      for(int i=0;i<N;i++){
        cout << m1 << endl;
      }
    }else{
      for(int i=0;i<N;i++){
        // cout << "oi" << original[i].second << endl;
        if(original[i].first > m1 ){
          cout << m1 << endl;
        }else{
          cout << m2 << endl;
        }
      }
    }

}

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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    int n;
    cin >> n;
    vi a(n + 1), b(n);
    for (int i = 0; i <= n; ++i) {
        cin >> a[i];
    }

    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
        if (a[i] < b[i]) {
            int take = min(a[i + 1], b[i] - a[i]);
            a[i + 1] -= take;
            a[i] += take;
        }

        ans += min(a[i], b[i]);
    }

    cout << ans << '\n';
    
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.Remoting.Contexts;
using System.Security.Cryptography.X509Certificates;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int N;
        private int[] A;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            A = new int[N + 2];
            for (int i = 1; i <= N; i++)
            {
                A[i] = sc.NextInt();
            }
        }

        public void Solve()
        {
            Scan();
            long sum = 0;
            for (int i = 1; i < N + 2; i++)
            {
                sum += Math.Abs(A[i] - A[i - 1]);
            }
            var sb = new StringBuilder();
            for (int i = 1; i <= N; i++)
            {
                var p = Math.Abs(A[i + 1] - A[i - 1]);
                var m = Math.Abs(A[i] - A[i - 1]) + Math.Abs(A[i + 1] - A[i]);
                var line = sum + p - m;

                sb.AppendLine(line.ToString());
            }
            Console.Write(sb.ToString());
        }


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

Measured memory_bytes: 28764
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll fact[200005];

ll extgcd(ll a,ll b,ll& x,ll& y){
	ll d=a;
	if(b!=0LL){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;
		y=0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

ll mod_fact(ll n,ll p,ll& e){
	e=0;
	if(n==0)return 1;
	ll res=mod_fact(n/p,p,e);
	e+=n/p;
	if(n/p%2!=0){
		return res*(p-fact[n%p])%p;
	}
	return res*fact[n%p]%p;
}

ll mod_comb(ll n,ll k,ll p){
	if(n<0 || k<0 || n<k)return 0;
	ll e1,e2,e3;
	ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
	if(e1>e2+e3)return 0;
	return a1*mod_inverse(a2*a3%p,p)%p;
}

ll n;
ll a,b,c;

int main(void){
	fact[0]=1;
	for(ll i=1;i<=200000;i++){
		fact[i]=fact[i-1]*i%MOD;
	}
	scanf("%lld%lld%lld%lld",&n,&a,&b,&c);
	ll cnt=100LL*mod_inverse(100-c,MOD)%MOD;
	ll ans=0;
	ll a_ab=a*mod_inverse(a+b,MOD)%MOD;
	ll b_ab=b*mod_inverse(a+b,MOD)%MOD;
	ll a_abn=1;
	ll b_abn=1;
	for(int i=0;i<n;i++){
		a_abn=a_abn*a_ab%MOD;
		b_abn=b_abn*b_ab%MOD;
	}
	ll cur=1;
	for(ll i=0;i<n;i++){
		ll val=a_abn*cnt%MOD;
		val=val*cur%MOD;
		val=val*(n+i)%MOD;
		val=val*mod_comb(n+i-1,i,MOD)%MOD;
		ans+=val;
		ans%=MOD;
		cur=cur*b_ab%MOD;
	}
	cur=1;
	for(ll i=0;i<n;i++){
		ll val=b_abn*cnt%MOD;
		val=val*cur%MOD;
		val=val*(n+i)%MOD;
		val=val*mod_comb(n+i-1,i,MOD)%MOD;
		ans+=val;
		ans%=MOD;
		cur=cur*a_ab%MOD;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#include<atcoder/dsu>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
typedef vector<int > vi;
typedef vector<pair<int, int > > vp;
int main(){
	//m containers ai matchboxes bi matches
	//burglar bag n matchboes
	int n;
	cin>>n;
	dsu d(n);
	int m;
	cin>>m;
	int q,u,v,ur;
	while(m--){
		cin>>q>>u>>v;
		if(q==1){
			cout<<d.same(u,v)<<'\n';
		}
		else{
			ur = d.merge(u,v);
		}
	}

}

Measured memory_bytes: 4020
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x) - 1 * 100);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>

using namespace std;
int n;
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
int main(void) {
	ll ans = 1L;
	cin >> n;
	ll tm;
	rep(i, n) {
		cin >> tm;
		ans = lcm(ans, tm);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
d = {}
for i in range(N):
    S = input()
    if S in d.keys():
        d[S] = d[S] + 1
    else:
        d[S] = 1
max_val = max(d.values())
max_k_ls = [kv[0] for kv in d.items() if kv[1]==max_val]
max_k_ls = sorted(max_k_ls)

print(*max_k_ls, sep="\n")

Measured memory_bytes: 34012
#!/usr/bin/env python3

def main():
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(2)]

    S = []
    for i in range(0, N):
        S.append(sum(A[0][0:i + 1]) + sum(A[1][i:]))
    print(max(S))


main()

Measured memory_bytes: 3060
s = input()
q = int(input())
for i in range(q):
    a = list(input().split())
    if a[0] == 'print':
        print(s[int(a[1]):int(a[2])+1])
    elif a[0] == 'reverse':
        t = s[int(a[1]):int(a[2])+1]
        s = s[:int(a[1])] + t[::-1] + s[int(a[2])+1:]
    elif a[0] == 'replace':
        s = s[:int(a[1])] + a[3] + s[int(a[2])+1:]


Measured memory_bytes: 5616
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
ll MOD = (ll)1e9 + 7;
signed main(){
    map<char,int>up;
    map<char,int>lst;
    int n; cin >>n;
    string s,t; cin >> s >> t;
    rep(i,s.size() -1 ){
        auto u = s[i];
        auto l = t[i];
        if(i == 0){
            lst[u] = 1;
        } else {
            lst[u] = (lst[u] + lst[l]) % MOD;
        }
    }
    cout << (lst[t.back()]  + up[s.back()]) % MOD << endl;
}





Measured memory_bytes: 3360
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define all(v) v.begin() , v.end()
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
#define input(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
const ll MAX_N=100010;
ll a,b,c,d,e,f,x,y,z,k,m,n,l,h,w,t,p,q,ans=0;
vl v,v1(300000),v2(300000);
string s1,s2;
ll solve(){
    rep(i,n){
        if(i==0){
            v1[i]=-1;
        }
        else{
            v1[i]=max(v1[i-1],v[i-1]);
        }
    }

    rep(i,n){
        if(i==0){
            v2[n-1-i]=-1;
        }
        else{
            v2[n-1-i]=max(v2[n-i],v[n-i]);
        }
    }

    rep(i,n){
        cout<<max(v1[i],v2[i])<<endl;
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    input(v,n);
    solve();

}

Measured memory_bytes: 9304
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f
typedef long long ll;

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r = 0, g = 0, b = 0;
    for(char ch : s) {
        if(ch == 'R') ++r;
        else if(ch == 'G') ++g;
        else ++b;
    }
    long long ans = 1LL * r * g * b;
    for(int i = 0; i < n - 1; ++i) {
        for(int j = i + 1; 2 * j - i < n; ++j) {
            if(s[i] != s[j] && s[i] != s[2 * j - i] && s[j] != s[2 * j - i]) {
                --ans;
            }
        }
    }
    cout << ans << "\n";

    return 0;
}



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

int isPrime(int x){
    if(x<2) return 0;
    else if(x==2) return 1;
    if(x%2==0) return 0;
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0) return 0;
    }
    return 1;
}

int main(){
    int n,x,cnt=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        if(isPrime(x)) cnt++;
    }

    cout<<cnt<<endl;
}


Measured memory_bytes: 3100
// ALDS82.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
//#include "pch.h"
#include <iostream>
#include <string>
#include <stack>
#include <cstdlib>
#include <cstdio>
using namespace std;
stack <int> st;
int solve(string);
int main() {
	string str;
	while (cin >> str) {
		if (str == "+" || str == "-" || str == "*" || str == "/")
			st.push(solve(str));
		else st.push(atoi(str.c_str()));
		if (getchar() == '\n') {
			cout << st.top() << endl;
			return 0;
		}
	}
}
int solve(string str) {
	int b = st.top(); st.pop();
	int a = st.top(); st.pop();
	if (str == "+")return a + b;
	else if (str == "-")return a - b;
	else if (str == "*")return a * b;
	else if (str == "/")return a / b;
}




Measured memory_bytes: 3164
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
template <class Key, class Compare = less<Key>>
using Tree = __gnu_pbds::tree<Key, __gnu_pbds::null_type, Compare, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;



typedef pair<ll, ll> pl;
const ll mod = 1e9 + 7;

int V;
vector<int> G[100000];

pl dfs(int u, int p) {
  ll w = 1, b = 1;
  for (int v : G[u]) {
    if (v != p) {
      pl res = dfs(v, u);
      w *= (res.first + res.second) % mod;
      w %= mod;
      b *= res.first;
      b %= mod;
    }
  }
//  cout << "u=" << u << " w=" << w << " b=" << b << '\n';
  return pl(w, b);
}

void Main() {
  cin >> V;
  for (int i = 0; i < V-1; ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  pl res = dfs(0, -1);
  ll ans = (res.first + res.second) % mod;
  cout << ans << '\n';
}

int main() {
  ios::sync_with_stdio(false);
//  cin.tie(nullptr);
  #ifdef _DEBUG
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  #endif
  Main();
  return 0;
}


Measured memory_bytes: 12672
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
const int N = 1e6 + 10, OO = 0x3f3f3f3f, mod = 1e9 + 7;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
//int dx[] = {1, 0, -1, 0};
//int dy[] = {0, 1, 0, -1}; //4 Direction
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

//-- "كلٌّ من يسعى لابد يصل .. كلٌّ من يسعى مضمون له الوصول" --//

int x , dp[6][N];

int a[] = {100,101,102,103,104,105};

bool solve(int idx , int remW){
	if(remW < 0)
		return 0;
	if(idx == 6){
		if(remW == 0)
			return 1;
		return 0;
	}
	int &ret = dp[idx][remW];
	if(~ret) return ret;
	ret = solve(idx , remW-a[idx]) | solve(idx+1 , remW-a[idx]) | solve(idx+1 , remW);
	return ret;
}


int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	
	scanf("%d" , &x);
	clr(dp , -1);
	if(solve(0 , x))
		puts("1");
	else 
		puts("0");
		
	//for(int idx = 0 ; idx < 6 ; ++i)
		//dp[idx][0] = 1;
	//for(int idx = 0 ; idx < 6 ; ++i){
		//for(int rem = 0 ; rem <= x ; ++rem){
			//dp[idx][rem] = dp[idx+1][rem] | dp[idx][x-rem] | dp[idx+1][x-rem];
		//}
	//}
	//if(dp[6][x])
		//puts("1");
	//else 
		//puts("0");
	
    return 0;
}




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

void printv(vector<ll> v) {
  for (ll i : v)
    cout << i << endl;
}

int main() {
	int k;
	string s;
	cin>>k>>s;
	string ans;
	int s_size =s.size();
	if(s_size>k)ans=s.substr(0,k)+"...";
	else ans=s;
	cout<<ans<<endl;
}


Measured memory_bytes: 3632
program t
  implicit none
  integer :: M,D,i,j,ct

  read(*,*) M,D

  ct=0
  do i=1,D
     if((mod(i,10).ne.1).and.(i/10.ne.1)) then
        j=mod(i,10)*(i/10)
        if((j.gt.M)) then
        else
           if(j.gt.0) then
!              write(*,*) i,j                                                   
              ct=ct+1
           endif
        endif
     else

     endif

  enddo
  write(*,'(i0)') ct


end program t


Measured memory_bytes: 768
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let n = scan "%d" id

let factors n =
  let rec aux n i =
    if n = i then 1
    else if n mod i = 0 then succ @@ aux n (succ i)
    else aux n (succ i)
  in aux n 1

let () =
  ListL.map (1++n) ~f:(fun i ->
      if i mod 2 = 1 && factors i = 8 then 1 else 0)
  |> List.sum
  |> Printf.printf "%d\n"


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define mp make_pair
#define pb push_back
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)  ((a)*((b)/gcd(a,b)))
#define pi 3.14159265358979323846
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;

//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif
    
    int n,i,c=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    {
    	cin>>a[i];
    	if(a[i]%2==0)
    	c++;
	}
	int k=0;
	for(i=0;i<n;i++)
	{
		if((a[i]%2==0)&&((a[i]%3==0)||a[i]%5==0))
		k++;
	}
	//cout<<c<<" "<<k<<endl;
    if(c==k)
    cout<<"APPROVED"<<endl;
    else
    cout<<"DENIED"<<endl;
	return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main(void){
		int i,j,N,temp;
		int count=0;
		scanf("%d",&N);
		int a[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]){
					count++;
					temp=a[j];
					a[j]=a[j-1];
					a[j-1]=temp;
				}
			}
		}
		for(i=0;i<N-1;i++){
			printf("%d ",a[i]);
		}
		printf("%d\n",a[N-1]);		
		printf("%d\n",count);
return 0;
}

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

int main() {
    int N, K, S;
    cin >> N >> K >> S;
    vector<int> A(N, S + 1);
    for(int i = 0; i < K; i++) {
        A.at(i) = S;
    }
    for(int i = K; i < N; i++) {
        if(S == 1000000000) {
            A.at(i) = 1000000000 - 1;
        }
    }

    for(int i = 0; i < N - 1; i++) {
        cout << A.at(i) << " ";
    }

    cout << A.at(N - 1) << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
/*
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
*/

int main() {
	int N; cin >> N;
	vector<long long> a(N); rep(i, N) cin >> a.at(i);
	// long long x = a[0], y = a[N - 1];
	vector<long long> b(N - 1); rep2(i, 1, N - 1) b[i] = b[i - 1] + a[i];
	dbv(b);
	long long ans = 0; for(long long ai : a) ans += abs(ai); dbl(ans);
	rep(i, N - 1) {
		long long x = a[0] + b[i], y = (b[N - 2] - b[i]) + a[N - 1];
		db(x); db(y); dbl(x - y);
		ans = min(ans, abs(x - y));
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int num = 0;
		switch(x) {
		case 1:
			num +=300000;
			break;
		case 2:
			num +=200000;
			break;
		case 3:
			num +=100000;
			break;
		
		}
		switch(y) {
		case 1:
			num +=300000;
			break;
		case 2:
			num +=200000;
			break;
		case 3:
			num +=100000;
			break;
		
		}
		if(num ==600000) {
			num += 400000;
		}
		System.out.println(num);

				

	}

}

Measured memory_bytes: 25300
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define debug(x) cout << #x << ":" << x << endl
const intl INF = 1e9;
const intl MOD = 1e9+7;
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    intl a;
    cin >> a;
    intl b;
    cin >> b;
    intl c;
    cin >> c;
    fp(((c - a - b) * (c - a - b) > 4 * a * b) && (c - a - b) > 0);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int A, B;
    std::cin >> A >> B;
    if (A >= 13)cout << B << endl;
    if (A >= 6 && A <= 12)cout << B / 2 << endl;
    if (A <= 5)cout << 0 << endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS() std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
int main()
{
	IOS();
	int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int m1,d1,m2,d2;
	cin>>m1>>d1>>m2>>d2;
	 if(d1!=a[m1]) cout<<0<<endl;
	 else cout<<1<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
H = [int(i) for i in input().split()]

count = 0
for _ in range(101):
    flag = True
    for i in range(n):
        if H[i] > 0:
            H[i] -= 1
            if flag:
                count += 1
                flag = False
        else:
            flag = True

print(count)

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

int main() {

    int n;
    cin >> n;

    while(n != 0) {

        int x = n % 10;
        if(x == 7)
            break;

        n /= 10;

    }

    if(n != 0) 
        cout << "Yes";
    else
        cout << "No";

    cout << endl;

}

Measured memory_bytes: 3644
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

int n,m,x,a[15][15];
int rec(int i,int cost,vector<int>curr){
    bool ok=1;
    rep(j,1,m) if(curr[j]<x){
        ok=0;
        break;
    }
    if(ok) return cost;
    if(i>n) return 1e9;
    int ans=rec(i+1,cost,curr);
    rep(j,1,m) curr[j]+=a[i][j];
    return min(ans,rec(i+1,cost+a[i][0],curr));
}
signed main(){
    FastIO;
    cin>>n>>m>>x;
    rep(i,1,n){
        cin>>a[i][0];
        rep(j,1,m) cin>>a[i][j];
    }
    vector<int>curr(m+1,0);
    int ans=rec(1,0,curr);
    cout<<(ans>=1e9?-1:ans);
    return 0;
}


Measured memory_bytes: 3648