akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::tuple;
using std::make_tuple;
using std::get;

using std::min;
using std::abs;
using std::max;
using std::swap;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // code here
    int n = input<int>();
    vector<string> s(n);
    input_seq(ALL(s));

    int ans = 0;
    vector<int> en_a, st_b;

    int i = -1;
    for (string& str: s) {
        ++i;
        
        if (str.back() == 'A')
            en_a.push_back(i);
        if (str[0] == 'B')
            st_b.push_back(i);

        for (int i = 1; i < SZ(str); ++i)
            if (str[i - 1] == 'A' and str[i] == 'B')
                ++ans;
    }

    if (en_a == st_b and not st_b.empty()) {
        ans += SZ(en_a) - 1;
    } else {
        ans += min(SZ(en_a), SZ(st_b));
    }
    
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 1024
// Problem Link: 
// Tutorial Link: 

#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<=b;++i)
#define repb(i,a,b) for(LL i=a;i>=b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL pr[10000006];
LL ans[10000006];

inline void sieve()
{
    pr[1]=1;
	ans[1] = 1;
    rep(i,2,10000003) if(pr[i]==0){
        for(LL j=2;i*j<=10000003;j++){
            pr[i*j]=1;
			LL tmp=i*j,cnt=0;
            while(tmp%i==0){
                cnt++;
                tmp/=i;
            }
            if(ans[i*j] == 0) ans[i*j] = 1;
			ans[i*j] *= (cnt+1);
        }
		ans[i] = 2;
    }
}

LL n;

int main()
{
	FIO;
	sieve();
	cin >> n;
	LL tot = 0;
	rep(i,1,n) tot += (i*ans[i]);
	cout << tot << "\n"; 
}

Measured memory_bytes: 159896
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = S()
    c = s.count("0")
    print(2*min(c,len(s)-c))
    return

#B
def B():
    n = I()
    h = LI()
    ans = 0
    m = min(h)
    while m:
        ans += m
        k = max(h)
        for i in range(n):
            if h[i] >= m:
                h[i] -= m
                if h[i]:k = min(k,h[i])
            else:break
        m = k
    print(ans)
    return

#C
def C():
    n,k = LI()
    x = LI()
    ans = float("inf")
    j = bisect.bisect_left(x,0)
    if n == 1:
        print(abs(x[0]))
        quit()
    if j < n:
        if x[j] == 0:
            k -= 1
            x.pop(j)
            n -= 1
    for i in range(n):
        if i < j:
            if abs(i-j) > k:continue
            elif abs(i-j) == k:ans = min(ans,abs(x[i]))
            elif k+i-1 < n:
                ans = min(ans,abs(x[i])+x[k+i-1]-x[i])
        else:
            if abs(i-j)+1 > k:continue
            elif abs(i-j)+1 == k:ans = min(ans,x[i])
            elif i-k+1 >= 0:
                ans = min(ans,abs(x[i])+x[i]-x[i-k+1])

    print(ans)
    return

#D
def D():
    n = I()
    a = LI()
    ans = 0
    p = [1<<i for i in range(100)]
    for i in range(n):
        l = 0
        r = 100
        while r-l > 1:
            m = (l+r)//2
            if a[i]%p[m] == 0:
                l = m
            else:
                r = m
        ans += l
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    D()


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

const int INF=1000000000;

int a[1002];
int b[1002];
int dp[10002]; //dp[i]:=HPをiにするために必要な魔力の最小値

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

int main(){
    int h,n; cin >> h >> n;
    for(int i=0;i<n;i++) cin >> a[i] >> b[i];
    fill(begin(dp),end(dp),INF);
    dp[h]=0;
    for(int i=h;i>0;i--){
        for(int j=0;j<n;j++){
            chmin(dp[max(i-a[j],0)],dp[i]+b[j]);
        }
    }
    //for(int i=0;i<=h;i++) cout << dp[i] << endl;
    cout << dp[0] << endl;
    return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

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

  long long now = abs(x);
  long long ans = 0;

  long long cnt = 0;
  cnt = now / d;
  if(k >= cnt){
    now = now - d * cnt;
    cnt = k - cnt;
    if(cnt%2 == 0){
      ans = now;
    }else{
      ans = d - now;
    }
  }else{
    ans = now - k * d;
  }
  ans = abs(ans);
  // if(now >= 0){
  //   cnt = now / d;
  //   if(k >= cnt){
  //     now = now - d * cnt;
  //     cnt = k - cnt;
  //     if((k-cnt)%2 == 0){
  //       ans = now;
  //     }else{
  //       ans = d - now;
  //     }
  //   }else{
  //     ans = now - k * d;
  //   }
  // }else if(now < 0){
  //   now = -1 * now;
  //   cnt = now / d;
  //   if(k >= cnt){
  //     now = now - d * cnt;
  //     cnt = k - cnt;
  //     if((k-cnt)%2 == 0){
  //       ans = now;
  //     }else{
  //       ans = d - now;
  //     }
  //   }else{
  //     ans = now - k * d;
  //   }
  // }
  // ans = abs(ans);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3540
N = int(input())
num = [False for i in range(N+1)]

A=[]
for i in range(N):
    Ai = int(input())
    A.append(Ai)
A.sort()
A.append(0)

ans = 0
prev = 0
num_sum=0
for Ai in A:
    if prev==Ai:
        num_sum+=1
    else:
        ans+=num_sum%2
        num_sum=1
    prev=Ai

print(ans)


Measured memory_bytes: 8276
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
using namespace std;

typedef long long ll;

int main()
{
    string s;
    cin >> s;
    int offset = 0, cnt = 0;
    while ((offset = s.find("0", offset)) != -1)
    {
        cnt++;
        offset++;
    }
    cout << 2*min((int)s.length()-cnt, cnt) << "\n";
    return 0;
}

Measured memory_bytes: 512
n, m, p = [int(i) for i in input().split()]
e = [[int(i) for i in input().split()] for _ in range(m)]

for i in e:
    i[0] -= 1
    i[1] -= 1
    i[2] -= p

d = [-10**18] * n
ok1 = [False] * n
ok2 = [False] * n
d[0] = 0
ok1[0] = True
ok2[-1] = True

for _ in range(n):
    for a, b, c in e:
        if ok1[a]:
            d[b] = max(d[b], d[a] + c)
            ok1[b] = True
        if ok2[b]:
            ok2[a] = True
aa = d[:]

for _ in range(1):
    for a, b, c in e:
        if ok1[a]:
            d[b] = max(d[b], d[a] + c)
            ok1[b] = True
        if ok2[b]:
            ok2[a] = True

bb = d[:]

ok = False
for i in range(n):
    if ok1[i] and ok2[i]:
        if aa[i] != bb[i]:
            ok = True
if ok:
    print("-1")
else:
    print(max(aa[-1], 0))


Measured memory_bytes: 80524
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

const val mod = (1e9 + 7).toInt()

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

   /* val H = sc.nextLong()
    val W = sc.nextLong()
    val t = sc.nextLong()

    val w = gcd(W, t)
    val h = gcd(H, t)

    var res = 0L

    val x = H / h
    val y = W / w
    res = (res + pow(2, x)) % mod
    res = (res + pow(2, y)) % mod
    res = (res + pow(2, gcd(x, y))) % mod
    res = (res - 3 + mod) % mod

    res = pow(res, (w * h) % mod)

    println(res)
*/
    val n = sc.nextLong()
    val m = sc.nextLong()
    val T = sc.nextLong()
    val gn = gcd(T, n)
    val gm = gcd(T, m)
    val mod = 1000000007
    val q = gcd(n / gn, m / gm)
    var res = 0L
    res = (res + pow(2, q)) % mod
    res = (res + pow(2, n / gn)) % mod
    res = (res + pow(2, m / gm)) % mod
    res = (res - 3 +mod) % mod
    println(pow(res, gn * gm))
}

fun inv(h: Long): Long = pow(h, (mod - 2).toLong())

fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)
fun pow(a: Long, x: Long): Long {
    var res = 1L
    var x = x
    var a = a
    while (x > 0) {
        if (x % 2 == 1L) res = (res * a) % mod
        a = (a * a) % mod
        x /= 2
    }
    return res
}


class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 31520
#include<bits/stdc++.h>
using namespace std;
int main(){int k,ans=0;cin>>k;for(int a=1;a<=k;a++)for(int b=1;b<=k;b++)for(int c=1;c<=k;c++)ans+=__gcd(__gcd(a,b),c);cout<<ans<<endl;}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	VI h(n);
	rep(i, n) cin >>h[i];
	sort(all(h));
	int ans = 1<<30;
	rep(i, n+1-k){
		int r = i+k-1;
		ans = min(ans, h[r] - h[i]);
	}
	cout <<ans <<"\n";
	return 0;
}


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

int main(){
    int x, y;cin>>x>>y;
    int acc = 0;
    if (x == 1){
        acc += 300000;
    } else if (x == 2){
        acc += 200000;
    } else if (x == 3){
        acc += 100000;
    }

    if (y == 1){
        acc += 300000;
    } else if (y == 2){
        acc += 200000;
    } else if (y == 3){
        acc += 100000;
    }

    if (x == 1 && y == 1){
        acc += 400000;
    }
    cout << acc << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define F(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define VE(i,v) for(int i = 0;i < (v).size();i++)

using namespace std;
#define trace(...) cerr<<__FUNCTION__<<":"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned int ui;
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
typedef pair<ll,ll> pll;
typedef vector<pll> vpll; 
const int nax = 1e5 + 5;

vector<pair<int, int> > adj[nax];
set<int> col[nax];
int N;
vector<int> ans;
int vis[nax];
int maxc ;
void dfs(int u, int p)
{
	vis[u] = 1;
	int tcol = 1;
	for(auto vp:adj[u])
	{
		if(vp.first==p)
			continue;
		if(col[u].find(tcol)!=col[u].end())
			tcol++;
		ans[vp.second] = tcol;
		col[u].insert(tcol);
		col[vp.first].insert(tcol);
		//cout<<vp.first<<" "<<vp.second<<"\n";
		maxc = max(maxc, tcol);
		tcol++;
		if(vis[vp.first]==0)
			dfs(vp.first, u);
	}
}

int main()

{
	//std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	int T;
	T=1;
	for(int tc=1; tc<=T;tc++)
	{
		
		cin >> N;
		ans.resize(N,0);
		fill(vis, vis+N, 0);
		for(int i =0; i < N; i++)
		{
			adj[i].clear();
			col[i].clear();
		}
		maxc = 0;
		int start = -1;
		for(int i =0 ;i< N-1 ; i++)
		{
			int x, y;
			cin >> x >> y;
			//cout<<x<<" "<<y<<" "<<i<<"\n";
			x--;
			y--;
			if(start==-1)
				start = x;
			adj[x].pb({y, i});
			adj[y].pb({x, i});
			//cout<<x<<" "<<y<<" "<<i<<"\n";
		}
		/*for(int i =0; i < N; i++)
		{
			for (auto x: adj[i])
				cout<<x.first<<" "<<x.second<<";";
			cout<<"\n";
		}*/
		dfs(start, -1);
		cout<<maxc<<"\n";
		for(int i =0; i < N-1; i++)
		{
			cout<<ans[i]<<"\n";
		}




	}
 
 
 
	return 0;
}
 
 


Measured memory_bytes: 21376
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

const int MAX_N=1<<18;
const int INF=1e9;
    
int mn[2*MAX_N-1], part[2*MAX_N-1], parta[2*MAX_N-1];
int m;
   
void init(int n){
    m=1;
    while(m<n) m*=2;
    for(int i=0; i<2*m-1; i++){
        mn[i]=INF;
        part[i]=INF;
    }
}
  
void eval(int k, int l, int r){
	if(parta[k]<0){
		mn[k]+=parta[k];
		if(k<m-1){
			parta[2*k+1]+=parta[k];
			parta[2*k+2]+=parta[k];
		}
		parta[k]=0;
	}
	if(part[k]<INF){
        mn[k]=min(part[k], mn[k]);
        if(k<m-1){
            part[2*k+1]=min(part[k], part[2*k+1]);
            part[2*k+2]=min(part[k], part[2*k+2]);
        }
        part[k]=INF;
    }
}
    
void update(int a, int b, int x, int k, int l, int r){
	eval(k, l, r);
	if(r<=a || b<=l) return;
    if(a<=l && r<=b){
        part[k]=min(x, part[k]);
        eval(k, l, r);
    }else{
        update(a, b, x, k*2+1, l, (l+r)/2);
        update(a, b, x, k*2+2, (l+r)/2, r);
        mn[k]=min(mn[2*k+1], mn[2*k+2]);
    }
}

void add(int a, int b, int x, int k, int l, int r){
    eval(k, l, r);
    if(r<=a || b<=l) return;
    if(a<=l && r<=b){
        parta[k]+=x;
        eval(k, l, r);
    }else{
        add(a, b, x, k*2+1, l, (l+r)/2);
        add(a, b, x, k*2+2, (l+r)/2, r);
        mn[k]=min(mn[2*k+1], mn[2*k+2]);
    }
}
    
int find(int a, int b, int k, int l, int r){
	eval(k, l, r);
    if(b<=l || r<=a){
        return INF;
    }
    if(a<=l && r<=b){
        return mn[k];
    }else{
        return min(find(a, b, 2*k+1, l, (l+r)/2), find(a, b, 2*k+2, (l+r)/2, r));
    }
}

int main()
{
	int n;
	cin>>n;
	int s[200001]; s[0]=0;
	for(int i=0; i<n; i++){
		int b; cin>>b;
		s[i+1]=s[i]+b;
	}
	init(n+1);
	for(int i=0; i<=n; i++){
		update(i, i+1, 2*s[i]-i, 0, 0, m);
	}
	int q;
	cin>>q;
	P p[200001];
	for(int i=0; i<q; i++){
		int l, r; cin>>l>>r;
		p[i]=P(r, l);
	}
	sort(p, p+q);
	for(int i=0; i<q; i++){
		int l=p[i].second, r=p[i].first;
		int ml=find(l-1, l, 0, 0, m), mr=find(r, r+1, 0, 0, m);
		update(l, r+1, ml, 0, 0, m);
		int mr2=find(r, r+1, 0, 0, m);
		add(r+1, n+1, mr2-mr, 0, 0, m);
      //for(int i=0; i<=n; i++) cout<<find(i, i+1, 0, 0, m)<<" ";
      //cout<<endl;
	}
	cout<<find(n, n+1, 0, 0, m)+n-s[n]<<endl;
	return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const double pi=3.14159265358979323846;
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> p=input(n);
  sort(p.begin(),p.end());
  int sum=0;
  rep(i,k){
    sum+=p[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 3720
t="abcdefghijklmnopqrstuvwxyz"
n=int(input())
ans=[]
def dfs(s):
  global ans
  if len(s)==n:
    ans.append(s)
    return 
  for i in range(len(set(s))+1):dfs(s+t[i])
  return
dfs("")
ans.sort()
for i in ans:print(i)

Measured memory_bytes: 12704
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
S = input()

# dp[i][j] := iからとjから始めた時に、一致する最大の長さ
dp = list2d(N+1, N+1, 0)
# 後ろから埋めていく
for i in range(N-1, -1, -1):
    for j in range(N-1, -1, -1):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1

mx = 0
for i in range(N+1):
    for j in range(N+1):
        # 最大値更新の際は、iとjがその値以上離れていることを確認する
        if dp[i][j] > mx and abs(i-j) >= dp[i][j]:
            mx = dp[i][j]
print(mx)


Measured memory_bytes: 230152
import java.util.*;class Main{public static void main(String[]r){Scanner sc=new Scanner(System.in);int i,n=sc.nextInt(),m=sc.nextInt(),x=sc.nextInt(),w=999999,q=w;int[]a=new int[n],b=new int[m];for(i=0;i<n;i++)w=(w<(a[i]=sc.nextInt()))?w:a[i];for(i=0;i<m;i++)q=(q<(b[i]=sc.nextInt()))?q:b[i];n=q+w;for(i=0;i<x;i++)n=(n<(q=a[sc.nextInt()-1]+b[sc.nextInt()-1]-sc.nextInt()))?n:q;System.out.println(n);}}

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

int main(){
    string s;
    int c=0;
    cin >> s;
    if(s[0] == '1'){
        for(int i=0; i < s.size();i++){
            if(i % 2 == 0 and s[i] == '0'){
                c++;
            }
            if(i % 2 != 0 and s[i] == '1'){
                c++;
            }
        }
    }else{
        for(int i=0;i< s.size();i++){
            if(i % 2 == 0 and s[i] == '1'){
                c++;
            }
            if(i % 2 != 0 and s[i] == '0'){
                c++;
            }
        }
    }
    cout << c << endl;
}



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

vector<int> eratos(int MAX) {
	std::vector<int> prime;
	std::vector<int> factor(MAX + 1);
	std::iota(factor.begin(), factor.end(), 0);
	for (int i = 2; i <= MAX; i++) {
		if (factor[i] == i) prime.push_back(i);
		for (size_t j = 0; j < prime.size() && static_cast<int_fast64_t>(i) * prime[j] <= MAX && prime[j] <= factor[i]; j++) {
			factor[i * prime[j]] = prime[j];
		}
	}
	return factor;
}

signed main(){
	int N; cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	const int MAX = *max_element(A.begin(), A.end());
	vector<int> f(MAX + 1);
	vector<int> g(MAX + 1);
	for (int_fast64_t i = 1; i <= MAX; i++) {
		for (int_fast64_t j = 0; j <= MAX; j += i * i) {
			g[j] = i;
		}
	}
	iota(f.begin(), f.end(), 0);
	for (int i = 1; i <= MAX; i++) {
		f[i] = f[i / g[i]];
	}
	auto factor = eratos(MAX);
	vector<int> v(MAX+1);
	for (auto a : A) {
		a = f[a];
		while (a != 1) {
			if (v[factor[a]]++) {
				int g = 0;
				for (auto b : A) {
					g = gcd(g, b);
				}
				if (g == 1) cout << "setwise coprime" << endl;
				else cout << "not coprime" << endl;
				return 0;
			}
			a /= factor[a];
		}
	}
	cout << "pairwise coprime" << endl;
	return 0;
}


Measured memory_bytes: 22924
# -*- coding: utf-8 -*-

def swap(A, i, j):
    tmp  = A[i]
    A[i] = A[j]
    A[j] = tmp

def bubbleSort(A, N):
    """N 個の要素を含む 0-オリジンの配列 A"""
    nswap = 0
    flag = True # 逆の隣接要素が存在する
    while flag:
        flag = False
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                swap(A, j, j-1) # A[j]とA[j-1]を交換
                nswap += 1
                flag = True
    return nswap

N = int(input())
A = [int(t) for t in input().split()]
if len(A) != N: raise

nswap = bubbleSort(A, N)
print(' '.join(map(str, A)))
print(nswap)



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

using namespace std;

int main(){
  string s,t;
  cin >> s >> t;
  int n1=s.length();
  int n2=t.length();
  vector<string> w(n1-n2+1);
  if(n1<n2){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  for(int i=0;i<n1-n2+1;i++){
    bool flag=true;
    for(int j=0;j<n2;j++){
      if(s[i+j]=='?'){
        continue;
      }
      else if(s[i+j]==t[j]){
        continue;
      }
      else {
        flag=false;
      }
    }
    if(flag){
      for(int j=0;j<n1;j++){
        if(i<=j && j<=i+n2-1){
          w[i]+=t[j-i];
        }
        else{
          if(s[j]=='?'){
            w[i]+='a';
          }
          else{
            w[i]+=s[j];
          }
        }
      }
    }
  }
  sort(w.begin(),w.end());
  bool ans=false;
  for(int i=0;i<n1-n2+1;i++){
      if(w[i].length()){
          cout << w[i] << endl;
          ans=true;
          return 0;
      }
  }
  if(!ans){
      cout << "UNRESTORABLE" << endl;
  }
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int K; cin >> K;
  ll A[K]; rep(i,K) cin >> A[i];
  ll ma = 2, mi = 2;
  per(i,K) {
    if (ma<A[i]) { cout << -1 << endl; return 0; }
    if (ma%A[i]&&mi%A[i]&&ma/A[i]==mi/A[i]) { cout << -1 << endl; return 0; }
    ma = (ma/A[i]+1)*A[i]-1;
    mi = ((mi-1)/A[i]+1)*A[i];
    // cout << mi << " " << ma << endl;
  }
  cout << mi << " " << ma << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
  
void MCXI(char* mcxi,int num){                         //十進数をMCXI文字列に変換
  if(num>=1000){
    if(num>=2000)*(mcxi++)=(num/1000)+'0';             //千の位の値が2以上の場合　*mcxiの値が千の位の値と等しくなるまでインクリメント
    *(mcxi++)='m';                                     //千の位の値を表す数字の後ろにmを書き込み
    num%=1000;                                         //1000で割った余りをnumに更新　次のステップに進む
  }
  if(num>=100) {                                       //百の位の変換　理論は千の位と同じ
    if(num>=200)*(mcxi++)=(num/100)+'0';
    *(mcxi++)='c';
    num%=100;
  }
  if(num>=10) {                                        //十の位の変換　理論は千の位と同じ
    if(num>=20)*(mcxi++)=(num/10)+'0';
    *(mcxi++)='x';
    num%=10;
  }
  if(num>=1) {                                         //一の位の変換　理論は千の位と同じ
    if(num>=2)*(mcxi++)=(num/1)+'0';
    *(mcxi++)='i';
    num%=1;
  }
  *mcxi=0;                                             //*mcxiの値を0に初期化する
}
  
int decimal(const char* mcxi) {
  const char* nowp=mcxi;
  int num=1;
  int decimal=0;
  for(;*nowp;nowp++) {
    switch(*nowp) {
    case 'm':
      decimal+=1000*num;                               //返り値decimalに千の位の値を1000倍して加算
      num=1;                                           //numを1にリセット
      break;
    case 'c':                                          //百の位の変換　理論は千の位と同じ
      decimal+=100*num;
      num=1;
      break;
    case 'x':                                          //十の位の変換　理論は千の位と同じ
      decimal+=10*num;
      num=1;
      break;
    case 'i':                                          //一の位の変換　理論は千の位と同じ
      decimal+=1*num;
      num=1;
      break;
    default:
      if(isdigit(*nowp))num=*nowp-'0';                 //各位に前置きされた数字をnumに読み込み
    }
  }
  return decimal;                                      //変換された十進数を返り値として返す
}
  
int main(void) {
  int num,i;
  char MCXI_1[100],MCXI_2[100];
  
  struct{                                              //出力用の構造体配列
    char sum[100];
  }SUM[9999];
  
  scanf("%d",&num);                                    //先頭nを読み込み
  
  for(i=0;i<num;i++){
    scanf("%s%s",MCXI_1,MCXI_2);                       //2つのMCXI文字列を読み込み
    MCXI(SUM[i].sum,decimal(MCXI_1)+decimal(MCXI_2));  //2つのMCXI文字列をdecimal関数を使って十進数に変換
  }                                                    //MCXI関数を使ってMCXI文字列に変換　変換結果をi番目構造体配列に入れる
  
  for(i=0;i<num;i++){
    printf("%s\n", SUM[i].sum);                        //出力
  }
  
  return 0;
}

Measured memory_bytes: 784
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        long x=sc.nextLong(), y=sc.nextLong();
        sc.close();
        if((x*2-y)%3!=0 || (y*2-x)%3!=0){
            System.out.println(0);
            return;
        }
        long mod=1_000_000_007;
        long a=(x*2-y)/3;
        long b=(y*2-x)/3;
        if(a>=0 && b>=0) System.out.println(comb(a+b, a, mod));
        else System.out.println(0);
    }
    public static long modinv(long a, long MOD){
        long b=MOD, u=1, v=0;
        long tmp;
        while(b>=1){
            long t=a/b;
            a-=t*b;
            tmp=a; a=b; b=tmp;
            u-=t*v;
            tmp=u; u=v; v=tmp;
        }
        u%=MOD;
        return u>=0?u:u+MOD;
    }
    public static long comb(long n, long r, long MOD){
        if(n<r) return 0;
        r=Math.min(r, n-r);
        long res=1;
        for(int d=1;d<=r;d++){
            res*=n;
            res%=MOD;
            n--;
            res*=modinv(d, MOD);
            res%=MOD;
        }
        return res;
    }
}


Measured memory_bytes: 22612
parseInt(x) = parse(Int,x)

function main()
  N = parseInt(readline())
  H = map(parseInt,split(readline()))
  tmp = 0
  c = 0
  for i = (N-1):-1:1
    if H[i+1] <= H[i]
      tmp += 1
      if tmp >= c
        c = tmp
      end
     else 
      tmp = 0
    end
  end
  println(c)
end

main()

Measured memory_bytes: 166632
fn main(){
    let mut sc = Scanner::new();
    while let Ok(n) = sc.wrapped() {
        let l : i32 = sc.next();
        let mut a = vec![0; n];
        for i in 0..n {
            a[i] = sc.next();
        }
        let mut ok = false;
        for i in 0..n-1 {
            if a[i+1] + a[i] >= l {
                println!("Possible");
                for j in (i+1..n-1).rev() { println!("{}", j+1) }
                for j in 0..i { println!("{}", j+1) }
                println!("{}", i+1);
                ok = true;
                break;
            }
        }
        if !ok { println!("Impossible"); }
    }
}

// Scanner

#[allow(dead_code)]
struct Scanner {
    token_buffer : Vec<String>,
    index : usize,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner{
        Scanner { token_buffer: vec![], index: 0 }
    }

    fn wrapped<T>(& mut self) -> Result<T,&str> where T: std::str::FromStr {
        let s = try!(self.fetch_token());
        let t = try!(s.parse::<T>().map_err(|_| "Parse error"));
        Ok(t)
    }
    fn next<T>(& mut self) -> T where T: std::str::FromStr {
        self.wrapped::<T>().unwrap()
    }

    fn fetch_token(&mut self) -> Result<&String,&str> {
        while self.index >= self.token_buffer.len() {
            let mut st = String::new();
            while st.trim() == "" {
                match std::io::stdin().read_line(&mut st) {
                    Ok(l) if l > 0 => continue,
                    Ok(_)  => return Err("End of file"),
                    Err(_) => return Err("Failed to read line"),
                }
            }
            self.token_buffer = st.split_whitespace()
                .map(|x| x.to_string())
                .collect();
            self.index = 0;
        }

        self.index += 1;
        Ok(&self.token_buffer[self.index - 1])
    }
}


Measured memory_bytes: 7548
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

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

using namespace std;

int main(){
    int A, B, T;
    cin >> A >> B >> T;

    cout << (T/A) * B << endl;

    return 0;
}



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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int m, d;
	cin >> m >> d;
	int ans = 0;
	
	for(int i = 1; i <= m; i++) {
		for(int j = 22; j <= d; j++) {
			if(j % 10 < 2) continue;
			ans += (j/10)*(j%10) == i;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define FOR(i,m,n) for(i=m;i<n;i++)

int main(void)
{
	int a,b[22],i,c=0,d=0;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%d",&b[i]);
	}
	for(i=0;i<a;i++){
		if(d<=b[i]){
			c++;
			d=b[i];
		}
	}
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 128
from collections import deque

N, K = map(int, input().split())
A = list(map(int, input().split()))

check = [-1] * N
q = deque([1])
now = A[0]
check[0] = 0

for i in range(K):
    if check[now - 1] != -1:
        break
    check[now - 1] = i + 1
    q.append(now)
    now = A[now - 1]

x = check[now - 1]

if x > K:
    ans = q[K]
else:
    r = list(q)[x:]
    ans = q[(K - x) % len(r) + x]

print(ans)


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

const int MAX = 5000009;
int a[MAX];
struct Query
{
	int l, r, idx;
};
Query queries[MAX];
int bit[MAX];
int last_visit[MAX];
int ans[MAX];
bool cmp(Query x, Query y)
{
	return x.r < y.r;
}
void update(int idx, int val, int bit[], int n)
{
	for (; idx <= n; idx += idx&-idx)
		bit[idx] += val;
}
int query(int idx, int bit[], int n)
{
	int sum = 0;
	for (; idx>0; idx-=idx&-idx)
		sum += bit[idx];
	return sum;
}
void answeringQueries(int arr[], int n, Query queries[], int q)
{

	// holds the rightmost index of any number
	// as numbers of a[i] are less than or equal to 10^
	memset(last_visit, -1, sizeof(last_visit));

	// answer for each query
	int query_counter = 0;
	for (int i=0; i<n; i++)
	{
		// If last visit is not -1 update -1 at the
		// idx equal to last_visit[arr[i]]
		if (last_visit[arr[i]] !=-1)
			update (last_visit[arr[i]] + 1, -1, bit, n);

		// Setting last_visit[arr[i]] as i and updating
		// the bit array accordingly
		last_visit[arr[i]] = i;
		update(i + 1, 1, bit, n);

		// If i is equal to r of any query store answer
		// for that query in ans[]
		while (query_counter < q && queries[query_counter].r == i)
		{
			ans[queries[query_counter].idx] =
					query(queries[query_counter].r + 1, bit, n)-
					query(queries[query_counter].l, bit, n);
			query_counter++;
		}
	}

	// print answer for each query
	for (int i=0; i<q; i++)
		cout << ans[i] << endl;
}

// driver code
int main()
{
  int n,q;
  cin>>n>>q;
  for(int i=0;i<n;i++)cin>>a[i];
	queries[0].l = 0;
	queries[0].r = 4;
	queries[0].idx = 0;
	queries[1].l = 1;
	queries[1].r = 3;
	queries[1].idx = 1;
	queries[2].l = 2;
	queries[2].r = 4;
	queries[2].idx = 2;
  for(int i=0;i<q;i++)
  {
    int r,s;
    cin>>r>>s;
    r--;
    s--;
    queries[i].l = r;
    queries[i].r = s;
    queries[i].idx = i;
  }
	sort(queries, queries+q, cmp);
	answeringQueries(a, n, queries, q);
	return 0;
}


Measured memory_bytes: 34968
#include <stdio.h>

main(void)
{
	int A[4][3][10],n,b,f,r,v,a,bb,c;
	
	scanf("%d",&n);
	
	for(a=0;a<4;a++){
		for(bb=0;bb<3;bb++){
			for(c=0;c<10;c++){
				A[a][bb][c]=0;
			}
		}
	}
	
	for(a=1;a<=n;a++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		A[b-1][f-1][r-1]+=v;
		if(A[b-1][f-1][r-1]<0) A[b-1][f-1][r-1]=0;
		if(A[b-1][f-1][r-1]>9) A[b-1][f-1][r-1]=9;
	}
	
	for(a=0;a<4;a++){
		for(bb=0;bb<3;bb++){
			for(c=0;c<10;c++){
				printf(" %d",A[a][bb][c]);
			}
			printf("\n");
		}
		if(a!=3) printf("####################\n");
	}
	return 0;
}

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

#define print cout <<
#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)

template <typename T>
vector<T> getValues(int num){
    vector<T> values(num);
    for(int i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

int main(){
    int X,Y;
    cin >> X >> Y;
    if(Y%2!=0){
      printl("No");
      return 0;
    }
    int kame = (Y-2*X)/2;
    if(kame>X || kame<0){
      printl("No");
      return 0;
    }
    int tsuru = X - kame;
    if(tsuru>X || tsuru<0){
      printl("No");
      return 0;
    }
    printl("Yes");
}


Measured memory_bytes: 3604
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()
    a_li = LI()

    bunbo = 0
    for a in a_li:
        bunbo += (1/a)
    print(1/bunbo)


main()

Measured memory_bytes: 3064
alpha = 'abcdefghijklmnopqrstuvwxyz'

n = int(input())
ans =''
a = []
while n > 0:
    t = n%26-1
    if t < 0:
        t = 25
    a.append(t)
    n -= t+1
    n //= 26
a.reverse()
for i in a:
    ans += alpha[i]
print(ans)

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;
using tTree = __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

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

#define FACSIZE 200002

ll invfac[FACSIZE];
ll fac[FACSIZE];

template <class T>
bool chmax(T &, const T &);
template <class T>
bool chmin(T &, const T &);
ll gcd(ll, ll);
ll powLL(ll x, ll y);

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
ll comb(ll, ll);
void make_fact(ll);
void make_invfact(ll);
void fact_init();

int main(void)
{
  ll n;
  cin >> n;
  vector<ll> P(n);
  rep(i, n)
  {
    ll x;
    cin >> x;
    P[x - 1] = i + 1;
  }

  rep(i, n)
  {
    cout << 30000LL * (i + 1LL) << " ";
  }
  cout << endl;
  rep(i, n)
  {
    cout << 30000LL * (n - i - 1LL) + P[i] << " ";
  }
  cout << endl;

  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return mod_mul(t, t);
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = mod_mul(t, t);
    return (k % mod) * (x % mod);
  }
}
ll mod_add(ll a, ll b)
{
  return ((a % mod) + (b % mod)) % mod;
}

ll mod_mul(ll a, ll b)
{
  return ((a % mod) * (b % mod)) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void fact_init()
{
  make_fact(FACSIZE - 1);
  make_invfact(FACSIZE);
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

ll comb(ll n, ll r)
{

  return mod_mul(mod_mul(fac[n], invfac[r]), invfac[n - r]);
}
template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}

ll qp(ll a, ll b)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * mod_mul(ans, a) % mod;
    a = 1LL * mod_mul(a, a) % mod;
  } while (b >>= 1LL);
  return ans;
}
ll qp(ll a, ll b, ll mo)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * (ans % mo) * (a % mo);
    a = 1LL * (a % mo) * (a % mo);
  } while (b >>= 1LL);
  return ans;
}
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
ll powLL(ll x, ll y)
{
  ll ans = 1LL;
  for (ll i = 0LL; i < y; i++)
    ans *= x;
  return ans;
}

Measured memory_bytes: 768
int main(void){
	char letter[21];
	char result[21];
	int length;
	int i, n, l;

	scanf("%s", letter);

	// 文字数を調べる
	for(i=0; i<=21; i++){
		//printf("%c", letter[i]);
		if(letter[i] == '\0'){
			i -= 1;
			break;
		}
	}
	//
	l = 0;
	for(n=i; n>=0; n--){
		//printf("%c", letter[n]);
		result[l] = letter[n];
		l ++;
		//printf("%c", letter[n]);
	}
	result[l] = '\0';
	//printf("\n", result);
	printf("%s\n", result);
	return 0;
}

Measured memory_bytes: 0
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    vi64 ln(87);
    ln[0]=2, ln[1] = 1;
    for(int i=2;i<87;i++)   ln[i] = ln[i-1] + ln[i-2];
    int n;
    cin>>n;
    cout<<ln[n]<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.math.*;
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] nhw = scanner.nextLine().split(" ", 3);
        long n = Long.parseLong(nhw[0]);
        long h = Long.parseLong(nhw[1]);
        long w = Long.parseLong(nhw[2]);

        long cnt = 0;
        for (long i = 0; i < n; i++) {
            String[] ab = scanner.nextLine().split(" ", 2);
            long a = Long.parseLong(ab[0]);
            long b = Long.parseLong(ab[1]);

            if (a >= h && b >= w) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 24276
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    string s; cin >> s;
    bool used[26]; REP(i,26) used[i] = false;
    for(char c : s){
        if(used[c-'a']){
            cout << "no" << endl;
            return 0;
        }
        used[c-'a'] = true;
    }
    cout << "yes" << endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  int N = atoi(S.c_str());
  int sum=0;

  for (int i=0; i<S.size(); i++) {
    sum += S[i] - '0';
  }

  if (N % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
char b[2];

scanf("%s",&b[0]);

if('A'==b[0]){
printf("T\n");
}
else if('T'==b[0]){
printf("A\n");
}
else if('C'==b[0]){
printf("G\n");
}
else if('G'==b[0]){
printf("C\n");
}

return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int a[10000];
for(int i=0;i<n;i++) cin>>a[i];

int mn = a[0], mx = a[0];
long long sum = 0;
for(int i=0;i<n;i++){
mn = min(mn, a[i]);
mx = max(mx, a[i]);
sum += a[i];
}
cout<<mn<<" "<<mx<<" "<<sum<<endl;

return 0;
}


Measured memory_bytes: 3124
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define pb push_back


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 1000100010010010;
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> auto cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int factorial(int n){
    if(n == 1 or n == 0) return 1;
    else return n * factorial(n - 1) % mod;
}


signed main(){


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

    int n;
    vec<pi> arr;
    cin >> n;

    rep(i,0,n) arr.push_back(pi(input(), 1));
    rep(i,0,n) arr.push_back(pi(input(), -1));

    sort(all(arr));
    
    int a = 0, b = 0, ans = 1;
    rep(i,0,2 * n){

        if(arr[i].second == 1){ // pc
            if(b == 0) a++;
            else{
                ans *= b;
                b--;
            }
        }else{
            if(a == 0) b++;
            else{
                ans *= a;
                a--;
            }
        }
        ans %= mod;

    }

    print(ans);
    

    


    


	
	

	



	
	


	




	




    



	








    



    





    


    

}



Measured memory_bytes: 6256
s = input()
K = int(input())

N = len(s)

d = dict()
for i in range(N):
    for j in range(i, min(N, i+K)):
        sub = s[i:j+1]
        if d.get(sub) == None:
            d[sub] = 1

d2 = sorted(d.items())
print(d2[K-1][0])


Measured memory_bytes: 11396
my $n = <>;
my @a = glob<>;

foreach my $i (@a) {
    if ($i % 2 == 1) {
        next;
    }
    if (not ($i % 3 == 0 or $i % 5 == 0)) {
        print('DENIED');
        exit;
    }
}

print('APPROVED');

Measured memory_bytes: 768