akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int N, M, K, A[300006], B[300006], ans;
int main() {
	scanf("%d %d %d", &N, &M, &K);
	int k = K;
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	for (int i = 0; i < M; i++) {
		scanf("%d", &B[i]);
	}
	for (int i = 0; i < N; i++) {
		if (K >= A[i]) {
			K -= A[i];
			ans++;
		} else {
			break;
		}
	}
	int pos = 0;
	/*if (ans == N) {
		for (int i = 0; i < M; i++) {
			if (K >= B[i]) {
				K -= B[i];
				ans++;
			} else {
				pos = i;
				break;
			}
			if (i == M - 1) {
				pos = i;
			}
		}
	}*/
	int cou = ans;
	for (int i = ans - 1; i >= 0; i--) {
		//printf("%d\n", ans);
		//if (pos == M - 1) {
		//	break;	
		//}
		for (int j = pos; j < M; j++) {
			if (K >= B[j]) {
				K -= B[j];
				cou++;
			} else {
				pos = j;
				break;
			}
			if (j == M - 1) {
				pos = M;
			}
		}
		ans = max(ans, cou);
		cou--;
		K += A[i];
	}
	cou = 0;
	K = k;
	for (int i = 0; i < M; i++) {
		if (K >= B[i]) {
			K -= B[i];
			cou++;
		} else {
			ans = max(ans, cou);
			break;
		}
		if (i == M - 1) {
			ans = max(ans, cou);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5392
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] X = new long[N];
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextLong();
		}
		long x1 = 0;
		for(int i = 0; i < N; i++) {
			x1 += ((i%2 == 0)?X[i]:-X[i]);
		}
		System.out.print(x1);
		for(int i = 0; i < N - 1; i++) {
			x1 = X[i] * 2 - x1;
			System.out.print(" "+x1);
		}
		System.out.println();
	}
}

Measured memory_bytes: 66160
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX =200000;

int main(){
	int R[MAX],n;
	
	cin>>n;
	for(int i=0;i<n;i++) cin >> R[i];
	
	int maxv = -2000000000;
	int minv = R[0];
	
	for(int i=1;i<n;i++){
		maxv = max(maxv,R[i] - minv);
		minv = min(minv,R[i]);
	}
	
	cout << maxv << endl;
	
	return 0;
}


Measured memory_bytes: 3868
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
using namespace std;
using namespace __gnu_pbds;

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

int n;
set<string> ans;

void solve(int ind, char c, string str)
{
    if(ind>n) return ;
    if(c-'a'>n) return ;
    if(ind==n)
    {
        if(str.length()!=n)
        {
            return ;
        }
        
        ans.insert(str);
    }

    for(char i = c; i>='a'; --i)
    {
        solve(ind+1, max(char(i+1), char(c)), str+string(1, i));
    }
}

int main()
{
    fastio
    cin>>n;
    if(n==1)
    {
        cout<<"a"<<endl;
        return 0;
    }

    solve(0, 'a', "");
    for(auto& it : ans)
    {
        cout<<it<<endl;
    }
}

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

using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];  
    }
    vector<ll> s(n+1);
    for (int i = 0; i < n; i++) {
        s[i+1] = s[i] + a[i];
    }
    map<ll, ll> mp;
    for (int i = 0; i < n+1; i++) {
        mp[s[i]]++;
    }

    ll res = 0;
    for (auto i : mp) {
        ll n = i.second;
        res += n*(n-1)/2;
    }
    cout << res << endl;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,count=0;
    string s,t;
    cin>>n;
    cin>>s>>t;
    rep(i,n*2){
        if(i%2==0){
            cout<<s[count];
        }
        else{
            cout<<t[count];
            count++;
        }
    }
    return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<1000000007> mint;
//------------------------------------------------------------------------------
mint dp[10010][110][2];

void _main()
{
    string K;
    int D;
    cin >> K >> D;

    dp[0][0][0] = 1;
    rep(i, 0, K.size())
    {
        rep(j, 0, D)
        {
            rep(k, 0, 2)
            {
                const int d = k == 0 ? K[i] - '0' : 9;
                for (int l = 0; l <= d; ++l)
                {
                    dp[i + 1][(j + l) % D][k | (l < d)] += dp[i][j][k];
                }
            }
        }
    }
    cout << dp[K.size()][0][0] + dp[K.size()][0][1] - 1 << endl;
}


Measured memory_bytes: 8832
#include<stdio.h>

int main(){
  char a[1];
  char b[1];
  scanf("%s %s", a,b);
  if(a[0] == 'H'){
    printf("%s", b);
  }
  else if(a[0] == 'D'){
    if(b[0] == 'H'){
      printf("D\n");
    }else
    printf("H\n");
  }

  return 0;
}

Measured memory_bytes: 128
# ABC173c


def main():
    import sys
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    h, w, k = map(int, input().split())
    c = [list(input()) for _ in range(h)]

    def yoko(i):
        if i >= w:
            return 1 if sum([c[i].count('#') for i in range(h)]) == k else 0
        ans = yoko(i+1)
        for j in range(h):
            t = c[j][i]
            if t == '#':
                c[j][i] = 1
            elif t == 1:
                c[j][i] = 2
        ans += yoko(i + 1)
        for j in range(h):
            t = c[j][i]
            if t == 1:
                c[j][i] = '#'
            elif t == 2:
                c[j][i] = 1
        return ans

    def tate(i):
        if i >= h:
            return yoko(0)
        ans = tate(i+1)
        for j in range(w):
            t = c[i][j]
            if t == '#':
                c[i][j] = 1
        ans += tate(i + 1)
        for j in range(w):
            t = c[i][j]
            if t == 1:
                c[i][j] = '#'
        return ans

    print(tate(0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9220
import java.util.Arrays;
import java.util.Scanner;

//Overlaps of Seals
public class Main{

	static class P{
		public double x, y;
		public P(double x, double y) {
			this.x = x;
			this.y = y;
		}
	}
	
	static class R implements Comparable<R>{
		public double minx, maxx, miny, maxy;
		public P[] p;
		public int prob;
		boolean[] mark;
		public R(boolean[] u, double minx, double maxx, double miny, double maxy) {
			this.minx = minx;
			this.maxx = maxx;
			this.miny = miny;
			this.maxy = maxy;
			p = new P[4];
			p[0] = new P(minx, miny);
			p[1] = new P(minx, maxy);
			p[2] = new P(maxx, miny);
			p[3] = new P(maxx, maxy);
			mark = new boolean[n];
			prob = 0;
			for(int i=0;i<n;i++){
				if(u[i]){
					if(minx<=seal[i].x&&seal[i].x<=maxx && miny-1<=seal[i].y&&seal[i].y<=maxy+1){
						mark[i]=true;
						prob++;
					}
					else if(minx-1<=seal[i].x&&seal[i].x<=maxx+1 && miny<=seal[i].y&&seal[i].y<=maxy){
						mark[i]=true;
						prob++;
					}
					else {
						boolean f = false;
						for(int j=0;j<4;j++){
							if(Math.hypot(seal[i].x-p[j].x, seal[i].y-p[j].y)<=1){
								f = true;
								break;
							}
						}
						if(f){
							mark[i] = true;
							prob++;
						}
					}
				}
			}

		}
		public void find(){
			if(prob<=max)return;
			if(maxx-minx<0.000001){
				max = Math.max(max, prob);
				return;
			}
			R[] r = new R[4];
			double midx = (minx+maxx)/2;
			double midy = (miny+maxy)/2;
			r[0] = new R(mark, minx, midx, miny, midy);
			r[1] = new R(mark, midx, maxx, miny, midy);
			r[2] = new R(mark, minx, midx, midy, maxy);
			r[3] = new R(mark, midx, maxx, midy, maxy);
			Arrays.sort(r);
			for(int i=0;i<4;i++)r[i].find();
		}
		public int compareTo(R o) {
			return o.prob-prob;
		}
	}
	
	static int n;
	static int max;
	static P[] seal;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			if(n==0)break;
			seal = new P[n];
			for(int i=0;i<n;i++){
				String[] s = sc.next().split(",");
				seal[i] = new P(Double.parseDouble(s[0]), Double.parseDouble(s[1]));
			}
			boolean[] u = new boolean[n];
			Arrays.fill(u, true);
			max = 0;
			R r = new R(u, 0, 10, 0, 10);
			r.find();
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> v(N);
  vector<int> w(N);
  vector<int> a(N);
  rep(i,N)cin >> v[i];
  rep(i,N)cin >> w[i];
  rep(i,N)a[i] = i+1;
  int i = 0;
  int x = 0;
  int y = 0;
  do{
    if(a==v) x = i;
    if(a==w) y = i;
    ++i;
  }while(next_permutation(all(a)));
  cout << abs(x-y) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;

char mat[][8] = {{'\'',',','.','!','?',' ',' ',' '},
		 {'a','b','c','A','B','C',' ',' '},
		 {'d','e','f','D','E','F',' ',' '},
		 {'g','h','i','G','H','I',' ',' '},
		 {'j','k','l','J','K','L',' ',' '},
		 {'m','n','o','M','N','O',' ',' '},
		 {'p','q','r','s','P','Q','R','S'},
		 {'t','u','v','T','U','V',' ',' '},
		 {'w','x','y','z','W','X','Y','Z'}
		};

int main(){
	string line;
	while(cin>>line){
		int t;
		string ret = "";
		for(int x=0;x<line.size();++x){
			t=0;
			while(x<line.size()-1 && line[x]==line[x+1]){
				++x;
				++t;	
			}	
			if(line[x]=='0' && t!=0){
				while(t>0){
					ret += ' ';--t;
				}	
			}else if(line[x]!='0'){
				ret += mat[line[x]-1-48][t];
			}
		}
		cout<<ret<<endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>

int main(void)
{
    long n,k,q,i,j,sc,cnt=0,maxup=0;
    scanf("%ld %ld %ld",&n,&k,&q);
    long a[n];
    for(i=0;i<n;i++)
        a[i]=k;
    for(j=0;j<q;j++)
    {
        scanf("%ld",&sc);
        a[sc-1]++;
    }
    for(i=0;i<n;i++)
    {
        if(a[i]-q<=0)
            printf("No\n");
        else
            printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 1280
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        // Your code here!
        
        int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int X = a[0];
        int Y = a[1];
        Console.WriteLine(X + Y/2);
        
    }
}

Measured memory_bytes: 11348
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	string s; ll k;
	cin >> s >> k; k--;
	int len = s.length();
	rep(i, len + 1) {
		if (i == len) {
			cout << '1' << endl; break;
		}
		if ((ll)i == k) {
			cout << s[i] << endl; break;
		}
		if (s[i] != '1') {
			cout << s[i] << endl; break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
	int a,b;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op=='?')break;
		if(op=='+')printf("%d\n",a+b);
		if(op=='*')printf("%d\n",a*b);
		if(op=='-')printf("%d\n",a-b);
		if(op=='/')printf("%d\n",a/b);
	}
	return EXIT_SUCCESS;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(void)

{
	char c;
	scanf("%c",&c);
	
	if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
		printf("vowel\n");
	} else{
		printf("consonant\n");
	}
	return 0;
}

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

int main()
{
    int n, k; cin>>n>>k;
    vector<int> a(n); for(auto& e: a) cin>>e;

    int x=find(begin(a), end(a), 1)-begin(a);
    int res=n;
    for(int L=max(0, x-(k-1)); L<=x; ++L) {
        int R=L+k-1;
//        cout<<L<<", "<<R<<", "<<(L+k-2)/(k-1)+(n-1-R+k-2)/(k-1)+1<<endl;
        res=min(res, (L+k-2)/(k-1)+(n-1-R+k-2)/(k-1)+1);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 640
from math import log
 
def exp(n, base):
    e = int(log(n, base))
    if base ** (e + 1) <= n:
        return e + 1
    else:
        return e
 
def min_withdraw(n):
    if n < 6:
        return n
    else:
        exp_nine = exp(n, 9)
        exp_six = exp(n, 6)
        return 1 + min(min_withdraw(n - (6 ** exp_six)), min_withdraw(n - (9 ** exp_nine)))
    
    
if __name__ == '__main__':
    n = int(input())
    print(min_withdraw(n))

Measured memory_bytes: 60092
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int mv[3] = {1, 0, -1};

int h, w;
int atlas[50][50];

void dfs(int y, int x){

    rep(i, 3)rep(j, 3){
        int dx = x + mv[i];
        int dy = y + mv[j];

        if(dx < 0 || dx >= w || dy < 0 || dy >= h)continue;

        if(atlas[dy][dx] == 1){
            atlas[dy][dx] = 0;
            dfs(dy, dx);
        }
    }
}

int main(){
    vector<int> ans;
    while(true){
        cin >> w >> h;

        if(h + w == 0)break;

        rep(i, h)rep(j, w){
            cin >> atlas[i][j];
        }

        int res = 0;
        rep(i, h)rep(j, w){
            if(atlas[i][j] == 1){
                atlas[i][j] = 0;
                res++;

                dfs(i, j);
            }
        }

        ans.push_back(res);
    }

    rep(i, ans.size()){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3260
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let ell = read_as_vec::<f64>()[0];
    let lengh = ell/3.0;
    println!("{:6}", lengh*lengh*lengh);
}


Measured memory_bytes: 4352
def lcs(X, Y):
    dp = [0]*(len(Y)+1)
     
    for x in X:
        tmp = dp[:]
        for j, y in enumerate(Y):
            if x == y:
                dp[j+1] = tmp[j] + 1
            elif dp[j+1] < dp[j]:
                dp[j+1] = dp[j]
                                
    return dp[-1]
 
n = int(input()) 

for i in range(n):
    X = input()
    Y = input()
    print(lcs(X, Y))


Measured memory_bytes: 5628
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define MAX_N 25
using namespace std;

int vec[MAX_N];
int n, k;
long int sum = 0;
string s;

int main()
{
    cin >> s;
    // reverse(s.begin(), s.end());
    for (int i = 0; i < s.length(); i++)
    {
        vec[i] = s[i] - '0';
    }

    for (int bit = 0; bit < (1 << s.length() - 1); ++bit)
    {
        int anc = 0;
        for (int i = 0; i < s.length() - 1; ++i)
        {
            if (bit & (1 << i))
            {
                sum += stol(s.substr(anc, i + 1 - anc));
                anc = i + 1;
            }
        }
        sum += stol(s.substr(anc, s.length() - anc));
    }

    cout << sum << endl;
}

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

int arr[300003];
int n;
bool check(int a,int b)
{
	assert((b-a)%2==0);
	for(int i = a;i <= b;++i) if(arr[i] < a || arr[i] > b) return false;
	for(int i = a+1;i < b;i += 2) if(arr[i] != i) return false;
	int ia = -1, ib = -1;
	for(int i = a;i <= b;i += 2) {
		if(arr[i] >= i) {
			if(arr[i] < ia) return false;
			ia = arr[i];
		}
		if(arr[i] <= i) {
			if(arr[i] < ib) return false;
			ib = arr[i];
		}
	}
	return true;
}
int main()
{
	scanf("%d",&n);
	for(int i = 0;i < n;++i) {
		scanf("%d",&arr[i]);
		--arr[i];
	}
	for(int i = 0;i < n;++i) {
		if(arr[i] == i) continue;
		if(i+2>=n || arr[i+1] != i+1 || arr[i+2] == i+2) {
			printf("No\n");
			return 0;
		}
		int j = i+2;
		while(j+2<n && arr[j+1]==j+1 && arr[j+2]!=j+2) j += 2;
		if(!check(i,j)) {
			printf("No\n");
			return 0;
		}
		i = j;
	}
	printf("Yes\n");
}


Measured memory_bytes: 1536
#include <stdlib.h>
#include <stdio.h>

int counter = 0;

int Bin(int arr[], int size, int k)
{
    int low = 0;
    int high = size - 1;
    int mid;

    while (low <= high)
    {
        mid = (low + high) / 2;
        if (arr[mid] == k){
            counter++;
            return mid;
        }
        if (arr[mid] > k)
            high = mid - 1;
        else
            low = mid + 1;
    }
}

int main(int argc, char** argv) {
    int n1, n2;
    scanf("%d", &n1);
    int arr1[n1];
    for(int i=0; i<n1; i++){
        scanf("%d", &arr1[i]);
    }

    scanf("%d", &n2);
    int arr2[n2];
    for(int i=0; i<n2; i++){
        scanf("%d", &arr2[i]);
    }

    int key;
    for(int j=0; j<n2; j++){
        key = arr2[j];
        Bin(arr1, n1, key);
    }

    printf("%d\n", counter);
}



Measured memory_bytes: 2324
// HTTF.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 330;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 30;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;

#define endl "\n" //インタラクティブでは消す
ut N, M, K, L, Q, D, H, W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
LL DP[SIZE];
bool finished[SIZE];
LL DP2[SIZE2][SIZE2];
LL DP3[SIZE3][SIZE3][SIZE3];
LL A[SIZE];
LL solve2(int x) {
	if (finished[x]) return DP[x];
	if (x== 0) return INF;
	if (x == 1) return 0;
	finished[x] = true;
	return DP[x] = min(solve2(x - 1) + abs(A[x - 1] - A[x]), solve2(x - 2) + abs(A[x - 2] - A[x]));
}
LL solve() {
	cin >> N;
	REP(i, N) {
		cin >> A[i+1];

	}
	cout << solve2(N)<<endl;
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(12);
	solve();
	cin >> N;
	return 0;

}

Measured memory_bytes: 19072
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int a[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  fill(a, a + 100005, 0);
  
  REP(i, n) {
    int b;
    cin >> b;
    a[b]++;
  }

  int ans = 0;
  FOR(i, 1, 100000) {
    ans = max(ans, a[i - 1] + a[i] + a[i + 1]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i]%2!=0){
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
 
using namespace std;
 
int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x-r>=0 && y-r>=0 && x+r<=w && y+r<=h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3108
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int main(){
	int W,n,temp,num=1,q,p;
	int dp[2000];
	int w[1005],v[1005];
	while(cin>>W,W){
		cin>>n;
		for(int i=0;i<n;i++)
		scanf("%d,%d",&v[i],&w[i]);
		for(int i=0;i<=W;i++)
		dp[i]=0;
		for(int i=0;i<n;i++){
			for(int j=W;j>=w[i];j--){
				dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
			}
		}
		temp=W;
		while(dp[temp]==dp[W])
			temp--;
		cout<<"Case "<<num<<':'<<endl;
		cout<<dp[W]<<endl;
		cout<<temp+1<<endl;
		num++;
	}
	return 0;
}

Measured memory_bytes: 0
<?php

fscanf(STDIN, "%d", $x);

for ($i = -300; $i <= 300; ++$i) {
    for ($j = -300; $j <= 300; ++$j) {
        $tmp = pow($i, 5) - pow($j, 5);
        if ($tmp == $x) {
            echo "$i $j", PHP_EOL;
            break 2;
        }
    }
}



Measured memory_bytes: 16120
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(int[]), w = rd[0], a = rd[1], b = rd[2];
  if (a > b) swap(a, b);
  writeln(b <= a+w ? 0 : b-(a+w));
}


Measured memory_bytes: 256
class Factorials:
    def __init__(self, n, mod):
        self.mod = mod

        # self.fac[i] ≡ i! (factorial:階乗)
        self.fac = [1]
        num = 1
        for i in range(1, n+1):
            num *= i
            num %= mod
            self.fac.append(num)

        # self.rec[i] ≡ 1 / i! (reciprocal:逆数)
        num = pow(num, mod-2, mod)
        self.rec = [1 for i in range(n+1)]
        self.rec[n] = num
        for i in range(n-1, 0, -1):
            num *= i + 1
            num %= mod
            self.rec[i] = num

    # comb(n, r) ≡ nCr
    def comb(self, n, r):
        return self.fac[n] * self.rec[r] * self.rec[n - r] % self.mod
    
    # perm(n, r) ≡ nPr
    def perm(self, n, r):
        return self.fac[n] * self.rec[n-r] % self.mod

def main():
    n, m = map(int, input().split())
    mod = 10**9 + 7

    f = Factorials(m, mod)

    ans = 0
    for i in range(n+1):
        if i % 2 == 0:
            ans += f.comb(n, i) * f.perm(m, i) * f.perm(m-i, n-i) * f.perm(m-i, n-i) % mod
        else:
            ans -= f.comb(n, i) * f.perm(m, i) * f.perm(m-i, n-i) * f.perm(m-i, n-i) % mod
        ans %= mod

    print(ans)

main()

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

int main(){
    //先端の座標
    double x1, y1, x2, y2;
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    x1=A*cos( (2*M_PI)*((double)(H*60+M)/720) );
    y1=A*sin( (2*M_PI)*((double)(H*60+M)/720) );

    x2=B*cos( (2*M_PI)*((double)(M)/60) );
    y2=B*sin( (2*M_PI)*((double)(M)/60) );

    printf("%.15f", sqrt(pow(x1-x2, 2)+pow(y1-y2, 2)));    
}

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

int main(){
	int n ; cin >> n ;
	vector<int> h(n) ;
	for(int i=0;i<n;i++) cin >> h.at(i) ;
	int cnt = 0 ;
	for(int i=0;i<n;){
		if(h.at(i)==0){
			i++ ;
			continue ;
		}
		cnt++ ;
		for(int j=i;j<n;j++){
			if(h.at(j)==0) break ;
			h.at(j)-- ;
		}
	}
	cout << cnt << endl ;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.bigint;

long P = 998244353L;

long[10^^5*3+50] F, RF;

void init()
{
    F[0] = F[1] = 1;
    foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;

    {
        RF[$-1] = 1;
        auto x = F[$-1];
        auto k = P-2;
        while (k) {
            if (k%2 == 1) RF[$-1] = (RF[$-1] * x) % P;
            x = x^^2 % P;
            k /= 2;
        }
    }
    foreach_reverse(i, ref x; RF[0..$-1]) x = (RF[i+1] * (i+1)) % P;
}

long comb(N)(N n, N k)
{
    auto n_b = F[n];    // n!
    auto nk_b = RF[n-k]; // 1 / (n-k)!
    auto k_b = RF[k];    // 1 / k!

    auto nk_b_k_b = (nk_b * k_b) % P; // 1 / (n-k)!k!

    return (n_b * nk_b_k_b) % P;  // n! / (n-k)!k!
}

void main()
{
    init();

    auto nabk = readln.split.to!(long[]);
    auto N = nabk[0];
    auto A = nabk[1];
    auto B = nabk[2];
    auto K = nabk[3];

    long r;
    foreach (i; 0..N+1) {
        auto l = K-A*i;
        auto j = l/B;
        if (l%B != 0 || j > N || j < 0) continue;

        auto s = (comb(N, i) * comb(N, j)) % P;
        r = (r + s) % P;
    }

    writeln(r);
}

Measured memory_bytes: 4992
def main():
    n, m = map(int, input().split())

    d = [-1] * n
    for _ in range(m):
        it = map(int, input().split())
        i = next(it) - 1
        x = next(it)
        if ~d[i] and d[i] != x:  # d[i]は代入済かつcではない
            print(-1)
            return
        d[i] = x

    for x in range(10 ** n):
        y = x
        for j in range(n):
            i = n - 1 - j
            y, cand = divmod(y, 10)
            if ~d[i] and d[i] != cand:
                break
        else:
            if len(str(x)) == n:
                print(x)
                return

    print(-1)


if __name__ == '__main__':
    main()


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

int main(){
  int n,T;
  cin >> n >> T;
  int p;
  cin >> p;

  long long sum = T;
  for (int i = 1; i < n; i++)
  {
    int t;
    cin >> t;

    sum+=min(t-p,T);
    p=t;
  }

  cout << sum << endl;
  
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  int n,sum,ans,left,right;
  while(cin >> n){
    if(!n)break;
    left=1;right=2;ans=0;
    sum = left + right;
    if(n<3){
      cout<<0<<endl;
      continue;
    }
    while(n-1>left){
      if(n==sum)ans++;
      if(sum<=n&&right<n){
	right++;
	sum += right;
      }else if(right-left<2 && right<n){
	right++;
	sum += right;
      }else if(sum>n && right-left>=2){
	sum -= left;
	left++;
      }
    }
    cout << ans << endl;
  }
    return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,k;
	cin>>k;
	string strr;
	cin>>strr;
	n=strr.length();
	//cout<<n<<endl;
	if(n<=k){
		cout<<strr<<endl;
	}
	else{
		string nee;
		nee=strr.substr(0,k);
		nee+="...";
		cout<<nee<<endl;
		

	}
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <cmath>
using i64 = long long;

int main() {
    int a, b, h, m;
    std::cin >> a >> b >> h >> m;
    const double x = 6 * m, y = 30 * h + 0.5 * m;
    double arg = x - y;
    if (arg < 0) arg = -arg;
    if (arg > 180) arg = 360 - arg;
    arg = arg / 180 * acos(-1);
    std::cout << std::fixed << std::setprecision(12) << sqrt(a * a + b * b - 2 * a * b * cos(arg)) << std::endl;

    return 0;
}


Measured memory_bytes: 4228
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int a[10][10];
    rep(i,10){
        rep(j,10){
            a[i][j]=0;
        }
    }
    int n;
    cin>>n;

    ll nn = n;

    int keta2=0;
    while(nn>=1){
        nn/=10;
        keta2++;
    }
    int man = n/pow(10,keta2-1);
    int keta=1;

    for(int i=1;i<pow(10,keta2-1);i++){
        if(i==10){
            keta++;
        }else if(i==100){
            keta++;
        }else if(i==1000){
            keta++;
        }else if(i==10000){
            keta++;
        }else if(i==100000){
            keta++;
        }

        int sita=i%10;
        int ue = i/pow(10,keta-1);
        if(sita!=0) {
            a[sita][ue]++;
        }

    }


    for(ll k=pow(10,keta2-1);k<=n;k++){
        int ue=k/pow(10,keta2-1);
        int sita=k%10;
        if(ue==sita){
            a[ue][sita]++;
        }else{
            if(sita!=0){

//                if(sita<ue){
//                    swap(sita,ue);
//                }
                a[sita][ue]++;
            }
        }
    }


//    rep(i,10){
//        rep(j,10){
//           cout<< a[i][j]<<" ";
//        }
//        cout<<endl;
//    }




    ll ans = 0;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(i==j){
                if (a[i][j] == 1) {
                    ans += a[i][j];
                } else {
                    ans += a[i][j]+(a[i][j]*(a[i][j]-1));
                }
            }else {
                ans += a[i][j]*a[j][i];
            }

        }

    }
    cout<<ans<<endl;



    
return 0;
}


Measured memory_bytes: 256
import os
import sys
import numpy as np

def solve(N, K, S, P, R, T):
    dp = np.zeros((N+1, 3), dtype=np.int64)
    for i in range(1, N+1):
        c = T[i]
        dp[i, 0] = max(dp[i-K, 1], dp[i-K, 2]) + (c == "r") * R
        dp[i, 1] = max(dp[i-K, 0], dp[i-K, 2]) + (c == "s") * S
        dp[i, 2] = max(dp[i-K, 0], dp[i-K, 1]) + (c == "p") * P
    #d = dp.max(1)
    d = np.zeros(N+1, dtype=np.int64)
    for i in range(N+1):
        d[i] = dp[i].max()
    ans = d[-K:].sum()
    return ans


# >>> numba compile >>>
numba_config = [
    [solve, "i8(i8,i8,i8,i8,i8,string)"],
]
if sys.argv[-1] == "ONLINE_JUDGE":
    from numba import njit
    from numba.pycc import CC
    cc = CC("my_module")
    for func, signature in numba_config:
        vars()[func.__name__] = njit(signature)(func)
        cc.export(func.__name__, signature)(func)
    cc.compile()
    exit()
elif os.name == "posix":
    exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
else:
    from numba import njit
    for func, signature in numba_config:
        vars()[func.__name__] = njit(signature, cache=True)(func)
    print("compiled!", file=sys.stderr)
# <<< numba compile <<<


def main():
    N, K = map(int, input().split())
    S, P, R = map(int, input().split())
    T = "_" + input()
    ans = solve(N, K, S, P, R, T)
    print(ans)

main()


Measured memory_bytes: 30276
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

int BE(int b,int e){
    int r=1;
    while(e){
        if(e&1){
            r=(r*b)%MOD;
        }
        b=(b*b)%MOD;
        e >>=1;
    }
    return r;
}


int fact(int x){
    int k=1;
    for(int i=1;i<=x;i++){
        k=(k*i)%MOD;
    }
    return k;
}

signed main(void){
    int N;
    int x[114514];
    cin >> N;
    REP(i,N){
        cin >> x[i];
    }
    
    int d[114514];
    d[0]=fact(N-1);
    
    REP(i,N-1){
        if(i==0)continue;
        int c=d[i-1];
        c*=i;c%=MOD;
        c*=BE(i+1,MOD-2);c%=MOD;
        d[i]=c;d[i]%=MOD;
    }
    
    REP(i,N-1){
        d[N-1]+=d[i];d[N-1]%=MOD;
        d[i]=MOD-d[i];
    }
    int Ans=0;
    REP(i,N){
        int c=x[i]*d[i];c%=MOD;
        Ans+=c;Ans%=MOD;
    }
    //REP(i,N){cout << d[i] << " ";}cout << endl;
    //REP(i,N){cout << MOD-d[i] << " ";}cout << endl;
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()
typedef long long ll;



int main() {
    int a, b;
    cin >> a >> b;
    dunk(a*b);
    return 0;
}



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


int main(){
    string S;
    cin >> S;
    int MIN = 10000;
    for(int i = 0; i < S.size()-2; i++)
    {
        int s1 = S[i] - '0';
        int s2 = S[i+1] - '0';
        int s3 = S[i+2] - '0';
        int num = abs(s1*100+s2*10+s3 - 753);
        MIN = min(num,MIN);
    }
    cout << MIN << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) FOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    string s;
    int K;
    cin >> s >> K;
    int N = s.size();
    vector<string> v;
    REP(n, N) {
        REP(k, K) {
            v.push_back(s.substr(n, k + 1));
        }
    }
    SORT(v);
    UNIQ(v);
    cout << v[K - 1] << endl;
    return 0;
}


Measured memory_bytes: 1660
import sys

def gcd(a, b):
    return gcd(b, a%b) if b else a 

def lcm(a, b):
    return a // gcd(a, b) * b

def f(n):
    res = 0
    
    while not n % 2:
        n //= 2
        res += 1
        
    return res

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

for i in range(N):
    A[i] //= 2
    
t = f(A[0])
A[0] >> t
M >> t

for i in range(1, N):
    if f(A[i]) != t:
        print(0)
        sys.exit()
        
    A[i] >> t
    
l = 1
for a in A:
    l = lcm(l, a)
    
if l > M: 
    print(0)
    sys.exit()
    
M /= l

print(int((M+1)/2))


Measured memory_bytes: 14244
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  int n  , m ;
  cin >> n >> m ;
  int A[n+1] ;
  rep(i,n){
    int a ;
   	cin >> a ;
	A[i] = a ;
  }
  A[n] = A[0] + n ;
  int ans = 0 ;
  int sum ;
  rep(i,n){
    sum = A[i+1] - A[i] ;
    ans = max(ans,sum)  ;
  }
  cout << n - ans << endl;
}


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

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    if(b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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 <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b; cin >> n >> a >> b;
    ll ans = 0;
    ans += (n / (a + b)) * a;
    ans += min(((n - ((n / (a + b)) * (a + b))) % (a + b)), a);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;
 
void testCase() {
    db r;
    cin >> r;
    db val = (M_PI)*2*r;
    cout << fixed << setprecision(15) << val << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

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

int main() {
    int n;
    int i;
    cin >> n;
    vector<int> a(n);
    for (i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (i = 0; i < n; i++) {
        if (a[i] % 2 ==0) {
            if ((a[i] % 3 == 0) || (a[i] % 5 == 0))
                continue;
            else {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}



Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)
for i in 1..w+2 do
	print "#"
end
	puts

for i in 1..h do
	print "#"
	s = gets.chomp
	print s
	puts "#"
end

for i in 1..w+2 do
	print "#"
end
puts



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MAX int( 1e5 +5)


int main(){
    int n;
    int k;
    llong A[MAX];
    cin >> n >> k;
    REP(i,n) scanf("%lld",&A[i]);
    llong dp[MAX];
    REP(i,n) dp[i] = llong(1e15);
    dp[0] = 0;
    dp[1] = abs(A[1] - A[0]);
    FOR(i,2,n){
        FOR(j,max(0,i - k),i){
            dp[i] = min(dp[i], abs(A[i] - A[j]) + dp[j]);
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a,b,c;
        a =sc.nextInt();
        b =sc.nextInt();
        c =sc.nextInt();
        int max =0;
        if(max<10*a+b+c)max=10*a+b+c;
        if(max<10*a+c+b)max=10*a+c+b;
        if(max<10*b+c+a)max=10*b+c+a;
        if(max<10*b+a+c)max=10*b+a+c;
        if(max<10*c+a+b)max=10*c+a+b;
        if(max<10*c+b+a)max=10*c+b+a;
        System.out.println(max);
    }
}


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

int main() {
  int a;
  int b;
  int c;
  
  cin >> a >> b;
  
  c = a * b % 2;
  
  if (c == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}


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

bool isPrime(int N){
    for (int i = 2; i < sqrt(N); i++){
        if (N % i == 0) return false;
    }
    return true;
}


int main(){
    int X;
    cin >> X;
    while (true)
    {   if (isPrime(X)){
            cout << X << endl;
            return 0;
        }
        X++;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
signed main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	//MessageBox(GetForegroundWindow(),"标题","内容",MB_YESNO);
	int n;
	cin>>n;
	while(n--){
		cout<<"ACL";
	}
	return 0;
}


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

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;

    string S[H];
    for (int i = 0; i < H; ++i) {
        cin >> S[i];
    }

    int u[H][W], d[H][W], l[H][W], r[H][W];
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (S[i][j] == '#') {
                u[i][j] = l[i][j] = 0;
            } else {
                if (i == 0) {
                    u[i][j] = 1;
                } else {
                    u[i][j] = u[i - 1][j] + 1;
                }
                if (j == 0) {
                    l[i][j] = 1;
                } else {
                    l[i][j] = l[i][j - 1] + 1;
                }
            }
        }
    }

    for (int i = H - 1; i >= 0; --i) {
        for (int j = W - 1; j >= 0; --j) {
            if (S[i][j] == '#') {
                d[i][j] = r[i][j] = 0;
            } else {
                if (i == H - 1) {
                    d[i][j] = 1;
                } else {
                    d[i][j] = d[i + 1][j] + 1;
                }
                if (j == W - 1) {
                    r[i][j] = 1;
                } else {
                    r[i][j] = r[i][j + 1] + 1;
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            ans = max(ans, u[i][j] + d[i][j] + l[i][j] + r[i][j] - 3);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 66816