akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using static System.Console;

namespace ABC124B
{
    static class Program
    {
        static void Main(string[] args)
        {
            var n = ReadLine().TryParse<int>();
            var Hlist = ReadLine().SplitTryParseToList<int>();
            int a = 0;
            for (int i = 0; i < Hlist.Count; i++)
            {
                a += Check(Hlist, i);
            }


            WriteLine(a);
        }

        static int Check(List<int> list, int index)
        {
            for (int i = 0; i < index; i++)
            {
                if (list[i] > list[index])
                {
                    return 0;
                }
            }
            return 1;
        }


        public static T TryParse<T>(this String input)
        {
            try
            {
                var converter = TypeDescriptor.GetConverter(typeof(T));
                if (converter != null)
                {
                    return (T)converter.ConvertFromString(input);
                }
                else
                {
                    throw new InvalidCastException("");
                }
            }
            catch
            {
                throw new InvalidCastException(typeof(T) + " is not supported.");
            }
        }

        public static List<T> SplitTryParseToList<T>(this String input)
        {
            return input.Split().Select(n => n.TryParse<T>()).ToList();
        }

        public static List<T> ListSwap<T>(this List<T> list, Int32 index1, Int32 index2)
        {
            var t = list[index1];
            list[index1] = list[index2];
            list[index2] = t;
            return list;
        }

        public static List<Tuple<T, int>> DuplicateCount<T>(this IEnumerable<T> list)
        {
            return list
                .GroupBy(i => i)
                .Where(g => g.Any())
                .Select(g => Tuple.Create(g.Key, g.Count()))
                .ToList();
        }
        public static List<Tuple<T, int>> DuplicateSort<T>(this IEnumerable<Tuple<T, int>> list)
        {
            return list.OrderByDescending((x) => x.Item2).ToList();
        }
        public static List<T> ReadLineOne<T>(int n)
        {
            var list = new List<T>();
            foreach (var i in Enumerable.Range(1, n))
            {
                list.Add(Console.ReadLine().TryParse<T>());
            }
            return list;
        }
        public static void PrintAll<T>(this IEnumerable<T> list)
        {
            foreach (var i in list)
            {
                Console.Write($"{i} ");
            }

            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 14432
def solve(N, LIM):
    ax = list(map(int, input().split()))
    ans = 0
    left = ax[0]

    for i in range(N-2):
        # left right
        right = ax[i+1]
        total = left + right
        should_eat = total - LIM
        if should_eat > 0:
            ans += should_eat
            if should_eat < right:
                left = right - should_eat
            else:
                left = 0
        else:
            left = right

    ans += (left + ax[-1]) - LIM if (left+ax[-1]) > LIM else 0
    return ans


if __name__ == '__main__':
    n, x = map(int, input().split())
    print(solve(n, x))


Measured memory_bytes: 14472
N = int(input())
S = list(input())
A = ["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"]
output = ""
for i in range(len(S)):
    num = ord(S[i])-65
    output += A[(N+num)%26]
print(output)

Measured memory_bytes: 3064
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
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();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

main(){
	string s;
	cin>>s;
	if(s.size()==2){
		if(s[0]==s[1])cout<<1<<' '<<2;
		else cout<<-1<<' '<<-1;
		return 0;
	}
	rep(i,s.size()-3){
		string t;
		for(int j=i;j<i+3;j++){
			t+=s[j];
		}
		if(t[0]==t[1]||t[0]==t[2]||t[1]==t[2]){
			dump(i+1,i+3);
			return 0;
		}
	}
	dump(-1,-1);
}




Measured memory_bytes: 512
n=int(input())
for i in range(n):
    x1,y1,x2,y2,x3,y3,x4,y4=map(float,input().split())
    print('YES' if abs((y1-y2)*(x3-x4)-(y3-y4)*(x1-x2))<1e-10 else 'NO')


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int dp[110][100010];

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

    int n, W, V = 0;
    cin >> n >> W;
    vector<int> w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];
    rep(i, n) V += v[i];
    rep(i, n + 1) rep(j, V + 1) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i, n) rep(j, V + 1)
    {
        dp[i + 1][j] = dp[i][j];
        if (j >= v[i])
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
    }
    int ans = 0;
    rep(i, V + 1) if (dp[n][i] <= W) ans = max(ans, i);
    cout << ans << endl;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
ll dp[100010][3];
char op[100010];
ll A[100010];

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

	int N;
	cin >> N;
	op[0] = '+';
	for(int i = 0; i < N; i++) {
		cin >> A[i];
		if(i != N - 1) cin >> op[i + 1];
	}

	fill((ll*)begin(dp), (ll*)end(dp), -INF);
	dp[0][0] = 0;
	for(int i = 0; i < N; i++) {
		for(int j = 0; j <= 2; j++) {
			if(dp[i][j] == -INF) continue;
			ll d = dp[i][j];
			int nj = j + (op[i] == '-');
			nj = min(2, nj);
			for(int k = 0; k <= nj; k++) {
				if(nj % 2 == 0) {
					dp[i + 1][k] = max(dp[i + 1][k], d + A[i]);
				}
				else {
					dp[i + 1][k] = max(dp[i + 1][k], d - A[i]);
				}
			}
		}
	}

	cout << dp[N][0] << endl;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>

using namespace std;

void Solution()
{
    int w, n;
    
    int temp; //data for swapping
    int a, b;
    char c;
        
    
    cin>>w;
    cin>>n;
    
    vector<int> v;
    
    for(int i = 0; i <= w; i++) // the smallest digit is 1
    {
        v.push_back(i);
    }
    
    for(int i = 0; i < n; i++)
    {
        cin>>a>>c>>b;
        
        temp = v[a]; //swap the position
        v[a] = v[b];
        v[b] = temp;
    }
    
    for(int i=1; i <= w; i++)
    {
        cout<<v[i]<<endl;
    }
}

int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <vector>

using namespace std;

/*
 * 言語ごとにノードを作る
 * 人ごとのノードを使える言語に繋ぐ
 * グラフが連結か調べる(ある人からすべての人に行けるか)
 */

vector<vector<int>> Person(1e5);
vector<vector<int>> Language(1e5);
vector<bool> Reachable(1e5, false);
vector<bool> ReachedLang(1e5, false);

void dfs(int p){
  if (Reachable[p]) {
    return;
  }
  Reachable[p] = true;
  for (auto l : Person[p]) {
    if(ReachedLang[l]){
      continue;
    }
    ReachedLang[l] = true;
    for (auto p2 : Language[l]) {
      dfs(p2);
    }
  }
}

bool connectivity(int N) {
  dfs(0);
  for (int i=0; i<N; i++) {
    if (!Reachable[i]) return false;
  }
  return true;
}

int main() {
  int N, M, K, lang;
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> K;
    for (int k = 0; k < K; k++) {
      cin >> lang;
      Person[i].push_back(lang - 1);
      Language[lang - 1].push_back(i);
    }
  }
  if (connectivity(N)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 8576
#include<iostream>

using namespace std;

int main()
{
	while(1)
	{
		int data[11][11] = {0};
		int n;
		cin >> n;
		if(n == 0) break;
		for(int y = 0;y <= n;y++)
		{
			for(int x = 0;x <= n;x++)
			{
				if(y < n && x < n) cin >> data[y][x];
				if(x < n) data[y][n] += data[y][x];
				if(y < n) data[n][x] += data[y][x];
				cout.width(5);
				if(x < n || y < n) cout << data[y][x];
				else cout << data[y][x] / 2;
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
	int n,sum,x,k,r;
	scanf("%d",&n);
	r=n;
	sum=0;
	for(k=0;n!=0;k++)
	{
		x=n%10;
		n/=10;
		sum+=x;
		
	}
	if(r%sum==0)printf("Yes\n" );
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 128
//بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيمِ
//لا إله إلا الله محمد رسول الله

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")

#define ll long long
#define pb push_back
#define fr first
#define sc second
#define in freopen("input.txt", "r" , stdin)
#define out freopen("snakes.out", "w", stdout)
using namespace std;

string s , t;
ll dp[3005][3005];
int main(){
    //in;
    //out;

    cin >> s >> t;
    if (s[0] == t[0]) {
        dp[0][0] = 1;
    }
    for (int i = 1; i < t.length(); i++) {
        if (s[0] == t[i]) dp[0][i] = 1;
        else dp[0][i] = dp[0][i-1];
    }

    for (int i = 1; i < s.length(); i++) {
        if (t[0] == s[i]) dp[i][0] = 1;
        else dp[i][0] = dp[i-1][0];
    }

    for (int i = 1; i < s.length(); i++) {
        for (int j = 1; j < t.length(); j++) {
            if (s[i] == t[j]) {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else dp[i][j] = max (dp[i-1][j], dp[i][j-1]);
        }
    }
    ll n = s.length()-1, m = t.length()-1;
    string ans = "";
    if (!dp[n][m]) {
        cout << ans;
        return 0;
    }
    //cout << dp[n][m] << endl;

    while (n > 0 and m > 0) {
        if (dp[n][m] == dp[n-1][m]) n--;
        else if (dp[n][m] == dp[n][m-1]) m--;
        else ans += s[n], n--,m--;
    }

    if (m > 0) {
        for (int i = 0; i <= m; i++) {
            if (s[0] == t[i]){
                ans += s[0];
                break;
            }
        }
    }
    else if (n > 0) {
        for (int i = 0; i <= n; i++) {
            if (t[0] == s[i]) {
                ans += t[0];
                break;
            }
        }
    }else if (s[n] == t[m]) ans += s[n];


    reverse(ans.begin(), ans.end());
    cout << ans;
}



Measured memory_bytes: 70656
n,m = map(int, input().split())
ac = [False for i in range(n)]
pen = [0 for i in range(n)]
s = list()
p = list()
for i in range(m):
    a,b = input().split()
    a = int(a)
    s.append(a)
    p.append(b)
for i in range(m):
    if ac[s[i]-1] == True:
        pass
    else:
        if p[i] == "AC":
            ac[s[i]-1] = True
        else:
            pen[s[i]-1] += 1
wa = 0
for i in range(n):
    if ac[i] == True:
        wa += pen[i]
print(sum(ac), wa)


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int h, w; cin >> h >> w;
	for (int i = 0; i < w+2; ++i) cout << '#';
	cout << '\n';
	for (int i = 0; i < h; ++i) {
		cout << '#';
		string s; cin >> s;
		cout << s << "#\n";
	}
	for (int i = 0; i < w+2; ++i) cout << '#';
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll mod = 1e9+7;
const ll INF = 2e9;
const double PI = 3.1415926535;


int main(void){
    int a, b, c; cin >> a >> b >> c;
    cout << max(0, c-a+b) << endl;
	return 0;
}

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

int main()
{
    int a, b, pro;

    while(scanf("%d%d",&a,&b) == 2)
    {
        pro = a * b;
        if(pro % 2 == 0)
        {
            printf("Even\n");
        }

        else
            printf("Odd\n");
    }

    return 0;
}


Measured memory_bytes: 256
/**
 *    author: gxfireball       
**/
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
using namespace std;

void solve(){
   string str;
   ll n;
   cin >> n;
   cin >> str;
   if(str.length() > n){
       ll i = 0;
       while(i < n){
           cout << str[i];
           i++;
       }
       cout << "...";
   }
   else{
       cout << str;
   }

}

int main(){
    fastio;
    int t;
    t = 1;
    //cin>>t;
    while(t--){
    	solve();
    }
    return 0;
}



Measured memory_bytes: 3648
N = int(input())
c1 = 0
c2 = 0
for i in range(N):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        c1 += 1
    else:
        c1 = 0
    if c1 == 3:
        c2 += 1
if c2 > 0:
    print("Yes")
else:
    print("No")

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

template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }

    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }

    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};

using mint = ModInt<1000000007>;

constexpr int MAX_FACTORIAL = 202020;

mint fact[MAX_FACTORIAL];
mint factinv[MAX_FACTORIAL];

void init() {
    fact[0] = 1;
    for (int i = 1; i < MAX_FACTORIAL; i++) {
        fact[i] = fact[i - 1] * i;
    }
    factinv[MAX_FACTORIAL - 1] = fact[MAX_FACTORIAL - 1].inv();
    for (int i = MAX_FACTORIAL - 2; i >= 0; i--) {
        factinv[i] = factinv[i + 1] * (i + 1);
    }
    assert(factinv[0] == 1);
}

mint ncr(int n, int r) { return fact[n] * factinv[r] * factinv[n - r]; }

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

    int n, m;
    cin >> n >> m;
    vector<int> cs;
    for (int i = 2; i * i <= m; i++) {
        if (m % i == 0) {
            int cnt = 0;
            while (m % i == 0) {
                m /= i;
                cnt++;
            }
            cs.push_back(cnt);
        }
    }
    if (m > 1) {
        cs.push_back(1);
    }
    mint ans = 1;
    for (int c : cs) {
        ans *= ncr(n + c - 1, c);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI T(N);
	REP(i, N)cin >> T[i];
	rSORT(T);
	int n = T[0];
	int ans = 0;
	VI ret;
	for (int i = 1; i*i <= n; ++i){
		if (n%i == 0){
			ret.push_back(i);
			if (i*i != n)ret.push_back(n / i);
		}
	}
	SORT(ret);
	//REP(i, ret.size())cout << ret[i] << " ";
	FOR(i, 1, N) {
		REP(j, ret.size()) {
			//cnt = min(cnt, abs(ret[j] - T[i]));
			if (T[i] <= ret[j]) {
				ans += (ret[j] - T[i]);
				break;
			}

		}
	}
	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 3596
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = Integer.parseInt(sc.next());
    int a = Integer.parseInt(sc.next());
    
    if(x<a){
      System.out.println(0);
    }else{
      System.out.println(10);
    }
  }
}

Measured memory_bytes: 23124
import static java.lang.System.out;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import java.util.List;
import java.io.File;
import java.util.Scanner;

public class Main extends BaseExe {

    public static void main(String[] args) {
        new Main().exeSysIn();
    }

    @Override
    protected void execute() throws Exception {
        List<Integer> nums = asList(nextLine().split(" ")).stream().map(Integer::parseInt)
                .collect(toList());
        out.println(getDivCount(getDivs(nums.get(2)), nums.get(0), nums.get(1)));
    }

    private boolean[] getDivs(int target) {
        boolean[] divisors = new boolean[10001];
        for (int num = 1; num <= target; num++)
            divisors[num] = (target % num == 0) ? true : false;
        return divisors;
    }

    private int getDivCount(boolean[] divisors, int start, int end) {
        int divisorCount = 0;
        for (int index = start; index <= end; index++)
            divisorCount += divisors[index] ? 1 : 0;
        return divisorCount;
    }
}

abstract class BaseExe {

    private Scanner scan;

    private String inData;

    public void exeSysIn() {
        try (Scanner scan = new Scanner(System.in)) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void exeFileIn(String inDataPath) {
        try (Scanner scan = new Scanner(new File(inDataPath))) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void exeCtrl(Scanner scan) throws Exception {
        this.scan = scan;
        execute();
    }

    protected abstract void execute() throws Exception;

    protected String nextLine() {
        return scan.nextLine();
    }

    protected boolean judgeInData() {
        return hasNextLine() && isNotEmptyInData();
    }

    protected boolean hasNextLine() {
        return scan.hasNextLine();
    }

    protected boolean isNotEmptyInData() {
        inData = nextLine();
        return !inData.isEmpty();
    }

    protected String getInData() throws Exception {
        if (inData.isEmpty())
            throw new Exception("inData is Empty.");
        return inData;
    }
}

Measured memory_bytes: 32368
import fractions
import sys
input = sys.stdin.readline

P = 10**9 + 7
N = (10**6)+1
inv_t = [0]+[1]
for i in range(2, N):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

N = int(input())
A = tuple(map(int, input().split()))

mod = 10**9+7
lcm = 1
B = [0]*N

for i in range(N):
    lcm = (lcm // fractions.gcd(lcm, A[i])) * A[i]

ans = 0
lcm %= mod
for i in range(N):
    ans += (lcm * inv_t[A[i]]) % mod
    ans %= mod

print(ans)


Measured memory_bytes: 45752
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    cout << (N- (N % 3))/3 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ITP1_1_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var ts = new TimeSpan(0, 0, int.Parse(Console.ReadLine()));
            Console.WriteLine("{0}:{1}:{2}", ts.Hours, ts.Minutes, ts.Seconds);
        }
    }
}

Measured memory_bytes: 9136
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;

    map<ll, ll> mp;
    set<ll> st;
    rep(i, n) {
        ll a;
        cin >> a;
        st.insert(a);
        mp[a]++;
    }

    ll cnt = 0;
    for(auto p : mp) {
        cnt += p.second - 1;
    }

    if(cnt%2 == 0) {
        out(st.size());
    }
    else {
        out(st.size() - 1);
    }

    re0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string N;
    cin >> N;
    int sum = 0;
    for (auto& c : N) {
        sum += (int)(c - '0');
    }
    if (sum % 9) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3748
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int n;
vector<int> data;

int q;
vector<int> target;

bool solve (int i, int m)
{
    if (m == 0)
        return true;
    if (i >= n)
        return false;
    return solve(i + 1, m) || solve(i + 1, m - data[i]);
}

int main()
{

    while (cin >> n)
    {
        data.resize(n);
        for (int i = 0; i < n; ++i)
        {
            cin >> data[i];
        }
        cin >> q;
        target.resize(q);
        for (int i = 0; i < q; ++i)
        {
            cin >> target[i];
        }
        for (int i = 0; i < q; ++i)
        {
            cout << (solve(0, target[i]) ? "yes" : "no") << endl;
        }
    }
}


Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
using namespace std;
#define MAX(X,Y) ((X)>(Y)?(X):(Y))

double inline f(int p){
  int s;
  s = p*(p+1)/2;
  return double(s)/p;
}
int main(void){
  int n,k;
  int p[200000];
  double t,ans;
  
  cin >> n >> k;
  t = 0;
  for (int i=0; i<k; i++){
    cin >> p[i];
    t += f(p[i]);
  }
  ans = t;
  for (int i=k; i<n; i++){
    cin >> p[i];
    t += f(p[i]);
    t -= f(p[i-k]);
    ans = MAX(ans, t);
  }
  printf("%.8f\n",ans);
  return 0;
}
  

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

int main() {
	string s,a,b;
	int y,i;
	cin >> s;
	y=0;
	b = "o";
	for (i = 0; i < 3; i++){
		a = s[i];
		if (a == b)
			y+=100;
	}
	cout << 700+y;
	
	return 0;
}

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

/*
#pragma GCC optimize("-Ofast")
//#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")*/

#define I inline void 
#define S struct 
#define vi vector<int> 
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std ; 
using ll = long long ; 
using ld = long double ; 

const int N = 1e5 + 7 , mod = 1e9 + 7 ; 
const int inf = N ; 
// How interesting!

int n ;

int main(){
        ios_base::sync_with_stdio(0) ; 
        cin.tie(0) ;
        //freopen("in.in" , "r" , stdin) ; 
        cin >> n; 
        vector<int> v1 , v2, v3 ; 
        for(int i = 0 ;i < n;i++){
                int x , y ; 
                cin >> x >> y ; 
                v1.push_back(x + y) ; 
                v2.push_back(x - y) ; 
                v3.push_back(y - x) ;
        }
        sort(v1.begin() , v1.end()) ; 
        sort(v2.begin() , v2.end()) ; 
        sort(v3.begin() , v3.end()) ; 

        int ans = v1[n -1] - v1[0] ; 
        ans = max(ans, v2[n-1] - v2[0]) ; 
        ans = max(ans , v3[n -1] - v3[0]) ; 
        cout<< ans; 


        return 0 ; 
}

Measured memory_bytes: 5824
N = int(input())
A = list(map(int, input().split()))
D = 0
for i in range(N):
  D += A[i] * ((-1) ** i)
two_x1 = D
for i in range(N - 1):
  print(two_x1, end = ' ')
  two_x1 = -two_x1 + 2 * A[i]
print(two_x1)

Measured memory_bytes: 14156
/******************************************
*    AUTHOR:         julianferres         *
******************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define SZ(x) ((int)x.size())
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
const int INF = 2000000000;
const int mod = 1e9 + 7;

typedef vector<vector<ll> > Matrix;
Matrix ones(int n) {
	Matrix r(n,vector<ll>(n));
	forn(i,n)r[i][i]=1;
	return r;
}
Matrix operator*(Matrix &a, Matrix &b) {
	int n=SZ(a),m=SZ(b[0]),z=SZ(a[0]);
	Matrix r(n,vector<ll>(m));
	forn(i,n)forn(j,m)forn(k,z)
		r[i][j]+=a[i][k]*b[k][j],r[i][j]%=mod;
	return r;
}
Matrix be(Matrix b, ll e) {
	Matrix r=ones(SZ(b));
	while(e){if(e&1LL)r=r*b;b=b*b;e/=2;}
	return r;
}

void add( ll &a, ll b){
    a += b;
    if(a>=mod)
        a -= mod;
}

int main(){
    FIN;
    ll n,k; cin >> n >> k;

	Matrix g(n,vi(n,0));

	forn(i,n) forn(j,n) cin >> g[i][j];

	Matrix ansMat = be(g,k);

    ll ans = 0;
    forn(i, n) forn(j, n) add(ans, ansMat[i][j]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=300005;
int n,w,h;
pin a[maxn];
namespace seg{
	int tag[maxn<<2],maxi[maxn<<2],l[maxn<<2],r[maxn<<2];
	inline void build(int x,int lq,int rq){
		l[x]=lq;r[x]=rq;tag[x]=0;
		if(lq==rq){
			maxi[x]=-a[lq-1].w1;return;
		}int md=(lq+rq)>>1;
		build(ls,lq,md);build(rs,md+1,rq);
		maxi[x]=max(maxi[ls],maxi[rs]);
	}
	inline void modify(int x,int lq,int rq,int val){
		if(lq<=l[x]&&r[x]<=rq){
			tag[x]+=val;maxi[x]+=val;return;
		}int md=(l[x]+r[x])>>1;
		if(lq<=md)modify(ls,lq,rq,val);
		if(rq> md)modify(rs,lq,rq,val);
		maxi[x]=max(maxi[ls],maxi[rs])+tag[x];
	}
	inline int get(){return maxi[1];}
}int ans=0;
int S1[maxn],top1;
int S2[maxn],top2;
inline void solve(){
	sort(a+1,a+1+n);
	if(a[n].w1!=w)a[++n]=mk(w,-1);
	seg::build(1,1,n);top1=top2=0;
	rep(i,1,n)if(a[i].w2>h/2){
		seg::modify(1,i,i,h);
		ans=max(ans,2*(a[i].w1+seg::get()));
		seg::modify(1,S1[top1]+1,i,a[i].w2-h);
		while(top1&&a[S1[top1]].w2>a[i].w2){
			seg::modify(1,S1[top1-1]+1,S1[top1],a[i].w2-a[S1[top1]].w2);
			top1--;
		}
		S1[++top1]=i;
	}else{
		seg::modify(1,i,i,h);
		ans=max(ans,2*(a[i].w1+seg::get()));
		seg::modify(1,S2[top2]+1,i,-a[i].w2);
		while(top2&&a[S2[top2]].w2<a[i].w2){
			seg::modify(1,S2[top2-1]+1,S2[top2],a[S2[top2]].w2-a[i].w2);
			top2--;
		}
		S2[++top2]=i;
	}if(a[n].w2<0)n--;
}
int main(){
	read(w);read(h);read(n);
	rep(i,1,n)read(a[i].w1),read(a[i].w2);
	solve();
	rep(i,1,n)swap(a[i].w1,a[i].w2);swap(w,h);
	solve();
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 22272
public class Main {
	static java.util.Scanner scan = new java.util.Scanner(System.in);
	public static void main(String[] args) {
		while (scan.hasNextInt()) {
			int a = scan.nextInt();
			int b = scan.nextInt();
			print(String.valueOf(a + b).length());
		}
	}
	
	public static void print(Object out) {
		System.out.println(out);
	}
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) ((int) x.size())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define makeunique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define endl '\n'

typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<string> vs;

template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }

const double pi = acos(-1.);
const int mod = 1e9 + 7;
const int N = 3e5 + 17;

int n, m;
int a[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	vi w;
	for (int i = 0; i < n; i++) cin >> a[i], w.pb(a[i]);
	sort(all(w));
	for (int i = 0; i < n; i++) a[i] = lower_bound(all(w), a[i]) - w.begin();
	int ans = 0;
	for (int i = 0; i < n; i += 2)
		if (a[i] & 1) ans++;
	cout << ans;
}


Measured memory_bytes: 4272
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define ll long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}
#define N 1000005
char a[N];
int f[N][2];
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	scanf("%s",a+1);
	int n=strlen(a+1);
	a[0]='0';
	int ans=0;
	f[n+1][1]=N*100;
	for(int i=n;i>=0;i--)
	{
		if(a[i]=='9')
		{
			f[i][0]=min(f[i+1][0]+9,f[i+1][1]+10);
			f[i][1]=min(f[i+1][0]+1,f[i+1][1]);
		}
		else
		{
			int d=a[i]-'0';
			f[i][0]=min(f[i+1][0]+d,f[i+1][1]+d+1);
			f[i][1]=min(f[i+1][0]+10-d,f[i+1][1]+10-d-1);
		}
	}
	cout<<f[0][0]<<endl;
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n;
    cin >> n;
    long long a;
    set<long long> st;
    map<long long,long> mp;
    rep(i,n){
        cin >> a;
        st.insert(a);
        if(mp.find(a)==mp.end()){
            mp[a]=1;
        }
        else{
            mp[a]++;
        }
    }
    if(st.size()==1){
        if(*st.begin()==0){
            cout << "Yes" << endl;
            return 0;
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    if(n%3!=0){
        cout << "No" << endl;
        return 0;
    }
    if(st.size()==2){
        auto itrr = st.begin();
        long long k = *itrr;
        itrr++;
        long long w = *itrr;
        if(k!=0){
            cout << "No" << endl;
            return 0;
        }
        if(mp[0]*2==mp[w]){
            cout << "Yes" << endl;
            return 0;
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    if(st.size()>3 || st.size()==0){
        cout << "No" << endl;
        return 0;
    }
    auto itr = st.begin();
    long long p,q,r;
    p = *itr;
    itr++;
    q = *itr;
    itr++;
    r = *itr;
    if(mp[p] != n/3 || mp[q] != n/3 || mp[r] != n/3){
        cout << "No" << endl;
        return 0;
    }
    if((p^q) == r){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 8704
n, m = map(int, input().split())
d = list(map(int, input().split()))

T = [50001]*(n+1)
T[0] = 0
for i in range(m):
    for j in range(d[i],n+1):
        T[j] = min(T[j], T[j-d[i]]+1)
print(T[n])


Measured memory_bytes: 7520
inputs=[int(input()) for _ in range(5)]

ans=0
ans=1000000000000000
for i in range(len(inputs)):
  tmp=0
  for j in range(len(inputs)):
    no=(i+j)%len(inputs)
    if j!=len(inputs)-1 and inputs[no]%10!=0:
      tmp+=inputs[no]+(10-inputs[no]%10)
    else:
      tmp+=inputs[no]
  if ans>tmp:
    ans=tmp
print(ans)

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

signed main() {
  int N, K;
  cin >> N >> K;
  
  double ans = 0;
  
  int ten = 0;
  int sai = 0;
  double renzoku = 1;
  for( int i = 1; i <= N; i++ ){
    ten = i;
    sai = 0;
    while( ten < K ){ 
      ten *= 2;
      sai++;
    }
    renzoku = 1.00000000000;
    for( int j = 0; j < sai; j++ ) renzoku /= 2;
    ans += 1.00000000000 / (double)N * renzoku;
  }
  
  cout << fixed << setprecision(10);
  cout << ans << endl;
    
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr long long MOD = 1000000007;
constexpr long long INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    long long N,K;cin >> N >> K;
    vector<pair<long long,long long>> V;
    REP(i,N){
        long long x,y;cin >> x >> y;
        V.pb({x,y});
    }
    sort ALL(V);
    long long cnt = 0;
    REP(i,N){
        if(cnt <= K && K <= cnt + V[i].second){
            cout << V[i].first << endl;
            return 0;
        }
        cnt += V[i].second;
    }
}

Measured memory_bytes: 2420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        int H, W, D;
        int[][] A;

        Map<Integer, int[]> index = new HashMap<>();
        List<List<Integer>> accum = new ArrayList<>();

        int Q;

        void solve(InputReader in, PrintWriter out) {
            H = in.nextInt();
            W = in.nextInt();
            D = in.nextInt();

            A = new int[H][W];
            for (int i = 0; i < H; ++i) {
                for (int j = 0; j < W; ++j) {
                    A[i][j] = in.nextInt() - 1;
                    index.put(A[i][j], new int[] { i, j });
                }
            }

            for (int i = 0; i < D; ++i) {
                List<Integer> cm = new ArrayList<>();
                cm.add(0);
                accum.add(cm);
            }

            for (int i = D; i < H * W; ++i) {
                List<Integer> cm = accum.get(i % D);
                int prev = cm.get(cm.size() - 1);
                int[] p1 = index.get(i - D); int[] p2 = index.get(i);
                int mp = Math.abs(p1[0] - p2[0]) + Math.abs(p1[1] - p2[1]);
                accum.get(i % D).add(prev + mp);
            }

            Q = in.nextInt();
            for (int i = 0; i < Q; ++i) {
                int l = in.nextInt() - 1;
                int r = in.nextInt() - 1;
                int ans = accum.get(l % D).get(r / D) - accum.get(l % D).get(l / D);
                out.println(ans);
            }
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 60964
#include <cstdio>
#include <cstring>

int num[100];long long int dp[99][21];

int main() {
	int n;scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&num[i]);
	memset(dp,0,sizeof(dp));
	dp[0][num[0]]=1;
	for(int i=1;i<n-1;i++) {
		for(int j=0;j<=20;j++) {
			int tmp1=j-num[i],tmp2=j+num[i];
			if(tmp1>=0&&dp[i-1][tmp1]) dp[i][j]+=dp[i-1][tmp1];
			if(tmp2<=20&&dp[i-1][tmp2]) dp[i][j]+=dp[i-1][tmp2];
		}
	}
	printf("%lld\n",dp[n-2][num[n-1]]);
}

Measured memory_bytes: 1052
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

string s;
i64 k;
int main() {
  cin >> s >> k;
  i64 n = s.size();
  set<string> t;
  for (i64 i = 0; i < n; ++i) {
    for (i64 l = 1; l <= k && i + l <= n; ++l) {
      t.insert(s.substr(i, l));
    }
  }
  auto it = t.begin();
  for (i64 i = 1; i < k; ++i) ++it;
  cout << *it << '\n';
  return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in);) {

			while (true) {
				int a = sc.nextInt();
				String op = sc.next();
				int b = sc.nextInt();

				if (op.equals("?")) break;

				switch (op) {
				case "+":
					System.out.println(a + b);
					break;
				case "-":
					System.out.println(a - b);
					break;
				case "*":
					System.out.println(a * b);
					break;
				case "/":
					System.out.println(a / b);
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 26212
#include<bits/stdc++.h>
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
#define vs              v.size()
#define sot(v)        sort(v.begin(),v.end())
#define rev(v)        reverse(v.begin(),v.end())
#define ii                pair<int,int>
#define ll                long long
#define ull              unsigned long long
#define pb              push_back
#define mpp          make_pair
#define Okay         0
#define pi               3.14159

const int inf = 1e9;
const int cont = 10e5+10;
using namespace std;


void solve(){
    ll int a, b,c;
     cin>>a>>b>>c;
     if(a <= b*c){
        cout<<"Yes"<<endl;
     }
     else cout<<"No"<<endl;

}

int main(){
    solve();
    return Okay;
}



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

int main() {
  int n,l;
  cin >> n >> l;
  
  int ans = 0;
  int mini=1000;
  int eat;
  for(int i=0; i<n; i++){
    int aji = l+i;
    ans+=aji;
    int aji2=pow(pow(aji,2),0.5);
    mini=min(mini,aji2);
    if(mini==aji2) eat=aji;
    
  }
  
  cout << ans-eat << endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
	
	int n, i;
	int s[1000];
	double m, sum, siguma;
	
	while(1) {
		scanf("%d", &n);
		if(n == 0){ break;
		}else {
			m = 0; 
			sum = 0;
			for(i=0; i<n; i++) {
				scanf("%d", &s[i]);
				m+=s[i];
			}
			m=(double)m/n;
			
			for(i=0; i<n; i++)
				sum+=pow(s[i]-m, 2);
				sum/=n;
				siguma=sqrt(sum);
				printf("%f\n", siguma);
		}
	}
	return 0;
}



Measured memory_bytes: 2112
s = input()
t = input()

ans = len(t)

for i in range(len(s) - len(t) + 1):
    sub = s[i:i+len(t)]
    cnt = 0
    for j in range(len(t)):
        if sub[j] != t[j]:
            cnt = cnt + 1
    ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 9120
import numpy as np
#S= str(input())
#T= str(input())
N = int(input())
#A,B,M= map(int,input().split())
A = list(map(int,input().split()))
#B = list(map(int,input().split()))
A=np.array(A)
c=0
for i in range(10**6):
    for n in A:
        if n%2!=0:
            print(c)
            exit()
    A=A/2
    c+=1


Measured memory_bytes: 22564
import string
s = input()
t = input()
l = []
alp = string.ascii_lowercase
G = dict([(alp[i],-1) for i in range(len(alp))])
for i in range(len(s)-1,-1,-1):
  l.append(G.copy())
  G[s[i]] = i
l = l[::-1]  
stG = G.copy()

cnt = 0
ind = 0
while ind < len(t): 
  if stG[t[ind]] == -1:
    cnt = -1
    break
  else:
    lind = stG[t[ind]]
    ind += 1
    if ind >= len(t):
      cnt += 1
      break 
    while l[lind][t[ind]] != -1:   
      lind = l[lind][t[ind]]
      ind += 1
      if ind >= len(t):
        break          
    cnt += 1

###    
if cnt != -1:      
  print(cnt*len(s)-(len(s)-(lind+1)))
else:
  print(cnt)  

Measured memory_bytes: 169596
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll 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};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> A >> B;
    if (A > 9 || B > 9)
        cout << -1 << endl;
    else
        cout << A * B << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string a,b;
  int x;
  cin >> a >> b;
  x = stoi(a+b);
  int i = 4;
  while(x>=i*i){
    if(x==i*i){
      cout << "Yes" << endl;
      return 0;
    }
	i++;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
(N, ) = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]

NUM = 1000000007
inv2 = 500000004
assert (inv2 * 2) % NUM == 1

As2 = 0
A2s = 0

for a in A:
    As2 += a
    As2 %= NUM
    
    A2s += a ** 2
    A2s %= NUM

As2 = (As2 ** 2) % NUM

ans = (As2 + NUM - A2s) % NUM
ans *= inv2
ans %= NUM

print(ans)




Measured memory_bytes: 31436
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>

int main()
{
    long A,B;
    std::cin >> A >> B;
    long result;
    for(long i=1; i<=1000; i++){
        if((int)((double)i*(double)0.08) == A && (int)((double)i*(double)0.1) == B){
            result=i;
            break;
        }
        if(i==1000){
            result=-1;
        }
    }
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 256