akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    string s;
    cin >> n >> k >> s;
    if (s[k - 1] == 'A')
    {
        s[k - 1] = 'a';
    }
    else if (s[k - 1] == 'B')
    {
        s[k - 1] = 'b';
    }
    else
    {
        s[k - 1] = 'c';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
signed main() {
    int n,m;cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
	int h1, h2, k1, k2, a, b, c, d;
	int hiroshi, kenjiro;
	cin >> h1 >> h2;
	cin >> k1 >> k2;
	cin >> a >> b >> c >> d;

	hiroshi = h1 * a + h2 * b + (h1 / 10)*c + (h2 / 20)*d;
	kenjiro = k1 * a + k2 * b + (k1 / 10)*c + (k2 / 20)*d;

	if (hiroshi == kenjiro)
		cout << "even" << endl;
	else {
		if (hiroshi > kenjiro)
			cout << "hiroshi" << endl;
		else
			cout << "kenjiro" << endl;
	
	}
	return 0;
}


Measured memory_bytes: 3068
def sameintegers(x):
    if (x[1]-x[0]) == 0:
        return x[2] - x[0]
    elif ((x[1]-x[0])%2) == 0:
        return ((x[1] - x[0])//2) + (x[2] - x[1])
    elif ((x[1]-x[0])%2) != 0:
        return ((1 + x[1] - x[0])//2) + (1 + x[2] - x[1])
    
A, B, C = map(int, input().split())
x = sorted([A, B, C])
print(sameintegers(x))


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define MAXK 26
#define MAXX 15000006
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, dp[MAXN][2], A[MAXN];
int main()
{
	FAST
	cin>>n;
	FOR(i,1,n+1) cin>>A[i];
	dp[0][1] = -LLINF;
	FOR(i,1,n+1) {
		// stays current
		dp[i][0] = max(dp[i-1][0] + A[i], dp[i-1][1] - A[i]);
		dp[i][1] = max(dp[i-1][0] - A[i], dp[i-1][1] + A[i]);
	}
	cout << (dp[n][0]);
}


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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int64_t gcd(int64_t p, int64_t q)
{
    if (p < q)
        swap(p, q);

    if (p % q == 0)
        return q;
    else
        return gcd(q, p % q);
}

int main()
{
    int N, ans = 0;
    cin >> N;
    vector<int> list(N), L(N), R(N);
    for (int i = 0; i < N; i++)
        cin >> list[i];

    L[0] = list[0], R[N - 1] = list[N - 1];
    for (int i = 1; i < N; i++)
        L[i] = gcd(L[i - 1], list[i]);
    for (int i = N - 2; i >= 0; i--)
        R[i] = gcd(R[i + 1], list[i]);

    for (int i = 0; i < N; i++)
    {
        int tmp;
        if (i == 0)
            tmp = R[1];
        else if (i == N - 1)
            tmp = L[N - 2];
        else
            tmp = gcd(L[i - 1], R[i + 1]);

        ans = max(ans, tmp);
    }
    cout << ans;
}

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

using namespace std;
const int INF = 0x3f3f3f3f;


int main() {
	int N;
	cin >> N;
	vector<int> h(N), dp(N);
	for (int i = 0; i<N; i++){
		cin >> h[i];
	}
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i<N; i++){
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n, cn=0; cin>>n;  
 for(int i=1; i<=n;i++){int c=0;
  for(int j=1; j<=n;j++){
   if(i%2==1 && i%j==0)c++; if(c==8)break;
  }
 if(i%2==1 && c==8) cn++;
 
 } 
  cout<<cn;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORS(i, m, n) for (int i = m; i <= n; i++)
#define bit(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int gcd(int m, int n)
{
    return m % n == 0 ? n : gcd(n, m % n);
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, ans;
    cin >> N >> ans;
    REPS(i, N - 1)
    {
        int a;
        cin >> a;
        ans = gcd(ans, a);
    }
    cout << ans << "\n";
}

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


class UnionFind {
public:
    std::vector<int> data;
    UnionFind( int n ) {
        data.resize( n, -1 );
    }
    int find( int x ) {
        if ( data[x] < 0 ) {
            return x;
        } else {
            int r = find( data[x] );
            data[x] = r;
            return r;
        }
    }
    void unite( int x, int y ) {
        int r = find( x );
        int s = find( y );
        if ( r != s ) {
            data[r] += data[s];
            data[s] = r;
        }
    }
};

ll solve() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(M), B(M);
    for ( int i = 0; i < M; i++ ) {
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
    }
    ll ans = 0;
    for ( int i = 0; i < M; i++ ) {
        UnionFind uf(N);
        for ( int j = 0; j < M; j++ ) {
            if ( j == i ) continue;
            uf.unite(A[j], B[j]);
        }
        int v = uf.find(0);
        if ( -uf.data[v] != N ) ans++;
    }

    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let _: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let ans = if s.chars().filter(|&c| c == 'Y').count() > 0 {
        "Four"
    } else {
        "Three"
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1,_2,_3,name,...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (ll i=(a); i<(n); ++i)
#define rep(...) _overload3(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<class T> inline void print(const T& x) {cout << x << "\n";}
template<class T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
struct Init {Init() {cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

const int m = 1000010;

int main() {
    ll n; cin >> n;
    vi a(n); rep(i, n) cin >> a[i];
    vi cnt(m, 0);
    vb valid(m, false);
    rep(i, n) {
        ++cnt[a[i]];
        valid[a[i]] = true;
    }
    rep(i, m) if (valid[i]) for (ll k = 2; k * i < m; ++k) valid[k * i] = false;
    ll ans = 0;
    rep(i, m) if (cnt[i] == 1 && valid[i]) ++ans;
    print(ans);
}

Measured memory_bytes: 12912
package main

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

const mod = 1000000007

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := make([]int, n)
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}

	ac, cc := 0, 0
	for i := range a {
		for j := range a {
			if a[i] <= a[j] {
				continue
			}
			ac++
			if j >= i {
				cc++
			}
		}
	}
	ans := k * (k - 1) / 2 % mod
	ans = (ans*ac + k*cc) % mod
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
//max=({});
//条件式が真ならwhileの中身を回し続ける



int main() {
	int n, k;
	cin >> n >> k;
	vector<ll>H(n);
	rep(i, n) {
		cin >> H[i];
	}
	sort(H.begin(), H.end());
	ll ans = 0;
	if (n > k) {
		for (int i = 0;i < n - k;++i) {
			ans += H[i];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
// #include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
typedef long long ll;
using namespace std;
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)

// ------------------ ベクター表示 ------------------ //
void printVec(vector<int>& vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
int sumVec(vector<int> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int K;
	string S;
	cin >> K >> S;
	
	if (S.size() <= K) cout << S << endl;
	else {
		rep(i, K) cout << S[i];
		cout << "..." << endl;
	}

	return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> 
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

int main(){
    int A,B;cin>>A>>B;
    if(A%2==0 or B%2==0){
        cout<<"No";
    }else{
        cout<<"Yes";
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int a = Math.max(x,y);
        int b = Math.min(x,y);
        while(!(a ==0 || b == 0)){
            a = a%b;
            if(a == 0){
                break;
            }
            b = b%a;
        }
        System.out.println(Math.max(a,b));
    }
}

Measured memory_bytes: 26168
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=100005;

int n,m,cnt,last[N],dep[N],len,sx,sy,a[N],odd,even,s[N],k[N];
bool vis[N];
struct edge{int to,next;}e[N*2];

int read()
{
    int x=0,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();}
    return x*f;
}

void addedge(int u,int v)
{
    e[++cnt].to=v;e[cnt].next=last[u];last[u]=cnt;
    e[++cnt].to=u;e[cnt].next=last[v];last[v]=cnt;
}

void dfs1(int x,int fa)
{
    vis[x]=1;
    if (dep[x]&1) even++;
    else odd++;
    for (int i=last[x];i;i=e[i].next)
    {
        if (e[i].to==fa) continue;
        if (vis[e[i].to]&&dep[e[i].to]<dep[x]) len=dep[x]-dep[e[i].to]+1,sx=x,sy=e[i].to;
        else if (!vis[e[i].to]) dep[e[i].to]=dep[x]+1,dfs1(e[i].to,x);
    }
}

void dfs2(int x)
{
    vis[x]=1;
    for (int i=last[x];i;i=e[i].next)
        if (!vis[e[i].to]) dfs2(e[i].to),s[x]+=s[e[i].to],k[x]+=k[e[i].to];
}

int main()
{
    n=read();m=read();
    for (int i=1;i<=m;i++)
    {
        int x=read(),y=read();
        addedge(x,y);
    }
    dfs1(1,0);
    if (odd!=even&&!(len&1)||(abs(odd-even)&1)&&(len&1)) {puts("-1");return 0;}
    for (int i=1;i<=n;i++) s[i]=(dep[i]&1)?1:-1;
    int ans=0;
    if (len&1) s[sx]+=(odd-even)/2,s[sy]+=(odd-even)/2,ans+=abs(odd-even)/2;
    else k[sx]=1,k[sy]=-1;
    memset(vis,0,sizeof(vis));
    dfs2(1);
    int tot=1;
    for (int i=1;i<=n;i++)
        if (!k[i]) ans+=abs(s[i]);
        else if (k[i]==1) a[++tot]=-s[i];
        else a[++tot]=s[i];
    sort(a+1,a+tot+1);
    int mid=a[(tot+1)/2];
    ans+=abs(mid);
    for (int i=1;i<=n;i++) if (k[i]) ans+=abs(k[i]*mid+s[i]);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 13524
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

bool is_prime(int a)
{
    if(a<2) return false;
    else if(a==2) return true;
    else if(a%2==0) return false;

    int d = int(sqrt(a));
    for(int i=3;i<=d;i+=2)
        if(a%i==0) return false;
    
    return true;
}

int main()
{    
    int n;
    cin >> n;
    rep2(i,5,55556)
        if(is_prime(i) && i%5==1)
        {
            cout << i << " ";
            if(--n<=0) break;
        }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100009
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;

void e_gcd(LL a, LL b, LL &x, LL &y)
{
    if(b == 0)
    {
        x = 1;
        y = 0;
        return ;
    }
    e_gcd(b, a%b, x, y);
    LL t = x; x = y;
    y = t - a/b*y;
}

int main()
{
    LL m, n;
    cin >> m >> n;
    if(abs(m - n) >= 2) puts("0");
    else
    {
        if(m>n) swap(m,n);
        LL ans = 1ll;
        for(LL i = 1; i <= m; i++) ans = ans * i % mod;
        for(LL i = 1; i < m; i++)
        {
            ans = ans * (n-i+1) % mod;
        }
        n -= m - 1;
        if(n == 1 || n == 2) ans = ans * 2 % mod;
//        LL a, b;
//        a = b = 1ll;
//        for(int i = 1; i <= n; i++)
//        {
//            a = a * i % mod;
//            b = (m-i+1) * b % mod;
//        }
//        LL x, y;
//        e_gcd(a, mod, x, y);
//        x = ((x%mod)+mod)%mod;
//        b = b*x%mod;
//        ans = ans * b % mod;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
 
#in_N = [int(i) for i in input().split()];
in_N = int(input());
in_S = str(input());
#in_S = [str(i) for i in input().split()];
S = [str(s) for s in in_S]
#print(in_N);
#print(in_S);
#print(S);

#calc
total = 0;
for i in range(in_N-1):
    if(S[i] == S[i+1]):
        total +=1;
#    for j in range(len(in_d)-1):
        #print(i);
        #print(j);
#        if(i+j+1 == len(in_d)):break;
#        total += in_d[i]*in_d[i+j+1];
 
print(in_N - total);

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,a = 0,b,c = 0;
  cin >> N >> K;
  a = K / 2;
  a += K % 2 + 1;
  for(int i = 0; i < N; i++){
  	cin >> b;
    if(b < a){
      c += b;
      c += b;
    } else {
      c += K - b;
      c += K - b;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int k;
		int sum;

		k = sc.nextInt();
		while (k != 0) {
			sum = 0;
			for (int i = 0; i < k * (k - 1) / 2; i++) {
				sum += sc.nextInt();
			}
			if (1 < k) {
				sum /= (k - 1);
			}

			System.out.println(sum);
			k = sc.nextInt();
		}
	}
}

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

int main() {
  int N;
  string s;
  cin >> N;
  cin >> s;
  int r = 0, b = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'R')
      r++;
    else
      b++;
  }
  if (r > b)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
using namespace std;
static const int MAX=1400;

struct Rectangle{int height;int pos;};

int getLargestRectangle(int size,int buffer[]){
    stack<Rectangle> S;
    int maxv=0;
    buffer[size]=0;
    
    for(int i=0;i<=size;i++){
        Rectangle rect;
        rect.height=buffer[i];
        rect.pos=i;
        if(S.empty()){
            S.push(rect);
        }else{
            if(S.top().height<rect.height){
                S.push(rect);
            }else if(S.top().height>rect.height){
                int target=i;
                while(!S.empty()&&S.top().height>=rect.height){
                    Rectangle pre=S.top();S.pop();
                    int area=pre.height*(i-pre.pos);
                    maxv=max(maxv,area);
                    target=pre.pos;
                }
                rect.pos=target;
                S.push(rect);
            }
        }
    }
    return maxv;
}

int H,W;
int buffer[MAX][MAX];
int T[MAX][MAX];

int getLargestRectangle(){
    for(int j=0;j<W;j++){
        for(int i=0;i<H;i++){
            if(buffer[i][j]){
                T[i][j]=0;
            }else{
                T[i][j]=(i>0)?T[i-1][j]+1:1;
            }
        }
    }
    int maxv=0;
    for(int i=0;i<H;i++){
        maxv=max(maxv,getLargestRectangle(W,T[i]));
    }
    return maxv;
}

int main(void){
    scanf("%d %d",&H,&W);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            scanf("%d",&buffer[i][j]);
        }
    }
    
    cout<<getLargestRectangle()<<endl;
    
    return 0;
}



Measured memory_bytes: 18440
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        String s = sc.next();
        int n = sc.nextInt();
        TreeSet<String> li = new TreeSet<String>();
        int len = s.length();
        for(int i = 0; i < len; i++){
            for(int j = 1; j <= n; j++){
                if(i+j > len) break;
                li.add(s.substring(i,i+j));
            }
        }
        ArrayList<String> ans = new ArrayList<>(li);
        System.out.println(ans.get(n-1));
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 27092
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define vec vector
#define ref(a) &(a)

typedef long long ll;

using namespace std;

int n;
vec<int> a;

int solve() {
  int res = 0;
  int s = 0;
  rep(i, n) {
    if (i - s + 1 != a[i]) {
      s++;
      res++;
    }
  }
  if (s == n) return -1;
  return res;
}

int main() {
  cin >> n;
  rep(i, n) {
    int x; cin >> x;
    a.pb(x);
  }
  cout << solve() << endl;
  return 0;
}

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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
class segtree {
 private:
  int n;
  vector<T> data, lazy;

 public:
  segtree(int n_) {
    n = pow(2, ceil(log2(n_)));
    data.resize(n);
    lazy.resize(n);
    auto __x = data[0];
    repi(n) {
      data[i] = __vmin(__x);
      lazy[i] = 0;
    }
  }
};

int ps[101];
void pf(int n) {
  if (n <= 1) return;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      ps[i]++;
      pf(n / i);
      return;
    }
  }
  ps[n]++;
}
int main() {
  int n;
  cin >> n;
  repi(n) pf(i + 1);
  int p2u = 0, p4u = 0, p14u = 0, p24u = 0, p74u = 0;
  repi(101) {
    if (ps[i] >= 2) p2u++;
    if (ps[i] >= 4) p4u++;
    if (ps[i] >= 14) p14u++;
    if (ps[i] >= 24) p24u++;
    if (ps[i] >= 74) p74u++;
  }
  int re = 0;
  re += max(0, p4u * (p4u - 1) * (p2u - 2) / 2);
  re += max(0, p14u * (p4u - 1));
  re += max(0, p24u * (p2u - 1));
  re += max(0, p74u);
  cout << re << endl;
}


Measured memory_bytes: 256
N = int(input())

INF = 99999999

P = list(map(int, input().split()))

mins = [INF] * N

ans = 1
mins[0] = P[0]

for i in range(1,N):

    if (mins[i-1] > P[i]):
        ans += 1
        mins[i] = P[i]
#        print("i:" + str(i));
#        print(mins);
    else:
        mins[i] = mins[i-1]

print(ans)

Measured memory_bytes: 25716
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ll a;
  double b;
  cin >> a >> b;
  ll B = round(b*100);
  
  cout << (ll)(a*B)/100 << endl;
}

Measured memory_bytes: 3720
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	int n;
	std::cin >> n;
	std::vector<std::vector<int> > g(n);
	rep(i,n-1) {
		int a,b;
		std::cin >> a >> b;
		a--;b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	lnt ans=0;
	for(lnt i=0;i<n;i++) {
		ans+=(i+1)*(n-i)*2;
		for(lnt to:g[i]) {
			lnt l=to,r=i;
			if(l>r) std::swap(l,r);
			ans-=(l+1)*(n-r);
		}
	}
	print(ans/2);
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    string S; cin >> S;
    i64 N = S.length();

    i64 nwin, nlose; nwin = nlose = 0;
    i64 sg, sp; sg = sp = 0;
    REP(i, N) {
        if (sp < sg) {
            if (S[i] == 'g') {
                sp++, nwin++;
            } else {
                sp++;
            }
        } else {
            sg++;
            if (S[i] == 'p') nlose++;
        }
    }
    cout << (nwin - nlose) << endl;

    return 0;
}

Measured memory_bytes: 3736
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;


int main(){
  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;
  int hai = 0;
  rep(i, s.size()){
    if (s[i] == '-') hai++;
  }
  if (s[a] == '-' && hai == 1) cout << "Yes\n";
  else cout << "No\n";

}


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

bool check(string s, string t)
{
    bool r = true;
    unordered_map<char, int> m;
    for (int i = 0; i < s.size(); i++)
    {
        char c = s[i];
        if (m.find(c) != m.end())
        {
            int tt = m[c];
            if (t[i] != t[tt])
            {
                r = false;
                break;
            }
        }
        m[c] = i;
    }
    return r;
}
int main()
{
    string s, t;
    cin >> s >> t;

    cout << ((check(s, t) && check(t, s)) ? "Yes" : "No");
}

Measured memory_bytes: 1544
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
//typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

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

    while(true){
        int N;
        cin>>N;
        if(N==0) return 0;
        int C[21][21];
        for(int i=0;i<21;i++){
            for(int j=0;j<21;j++) C[i][j]=0;
        }
        for(int i=0;i<N;i++){
            int x,y;
            cin>>x>>y;
            C[y][x]++;
        }
        int M;
        cin>>M;
        int x=10,y=10;
        while(M--){
            char d;
            int l;
            cin>>d>>l;
            if(d=='N'){
                for(int i=0;i<l;i++){
                    y++;
                    if(C[y][x]){
                        C[y][x]--;
                        N--;
                    }
                }
            }else if(d=='W'){
                for(int i=0;i<l;i++){
                    x--;
                    if(C[y][x]){
                        C[y][x]--;
                        N--;
                    }
                }
            }else if(d=='S'){
                for(int i=0;i<l;i++){
                    y--;
                    if(C[y][x]){
                        C[y][x]--;
                        N--;
                    }
                }
            }else{
                for(int i=0;i<l;i++){
                    x++;
                    if(C[y][x]){
                        C[y][x]--;
                        N--;
                    }
                }
            }
        }
        if(N==0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}



Measured memory_bytes: 3036
#include<stdio.h>
int main(){
 int W,H,x,y,r;
 scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
 if((W<x+r)||(H<y+r)||(0>x-r)||(0>y-r)){
 printf("No\n");
}else{
 printf("Yes\n");
}
return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll A, B, C, D, ma = 0;
        in >> A >> B >> C >> D;
        out << max(ma, min(D, B) - max(C, A)) << endl;
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <vector>
#define FORi(N) for(int i = 0; i < N; ++i)
#define FORj(N) for(int j = 0; j < N; ++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

vector<vector<ll>> child;
vector<bool> co(100001);
void nuru(bool iro, ll parent, ll i, vector<ll> &w) {
    co[i] = iro;
    //cout << i << endl;
    for(int j = 0; j < child[i].size() / 2; ++j) {
        if(child[i][j * 2] != parent) {
            if(child[i][j * 2 + 1] % 2 == 0) {
                nuru(iro, i, child[i][j * 2], w);
            } else {
                nuru(!iro, i, child[i][j * 2], w);
            }
        }
    }
}
int main() {
    ll N;
    cin >> N;
    vector<ll> u(N - 1), v(N - 1), w(N - 1);
    FORi(N+1) { child.push_back(vector<ll>()); }
    FORi(N - 1) {
        cin >> u[i] >> v[i] >> w[i];
        child[u[i]].push_back(v[i]);
        child[v[i]].push_back(u[i]);
        child[u[i]].push_back(w[i]);
        child[v[i]].push_back(w[i]);
    }
    nuru(true, 0, 1, w);
    FORi(N) { cout << co[i + 1] << endl; }
    return 0;
}


Measured memory_bytes: 12272
#include <cstdio>
#include <utility>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n';)s+=c;return s;}
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;if((c=gcu())=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);T t=move(in);o=move(t);return true;}}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H &&h, T... t){out(h);out(t...);}
template <typename... T> _OUTL(T... t){out(t...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

int main() {
	for (int A, B; A = in, B = in;) {
		int n = (B - A) / 100;
		outl(n % 5, ' ' , n % 10 / 5, ' ', n / 10);
	}
}


Measured memory_bytes: 2516
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	int ans = x / 500 * 1000 + (x % 500) / 5 * 5;
	cout << ans << endl;
}

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

void chmax(int& a, int b) {
  if (a < b) a = b;
}
void chmin(int& a, int b) {
  if (a > b) a = b;
}
int main() {
  int N;
  cin >> N;
  
  int MAX = 1;
  int MIN = 1000;
  
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    chmax(MAX, a);
    chmin(MIN, a);
  }
  
  cout << MAX - MIN << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 101010 * 2;
char ch[maxn];
long long ans;
int main(){
    scanf("%s", ch + 1);
    int cnt = 0;
    for(int i = 1; ch[i]; i ++){
        if(ch[i] == 'A') cnt ++;
        else{
            if(ch[i] == 'B' && ch[i+1] == 'C'){
                ans += cnt;
                i ++;
            } 
            else{
                cnt = 0;
            }
        }
    }
    printf("%lld\n", ans);
}

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

		List<String> firstList = Arrays.asList(s.split(""));

		Set<String> set = new HashSet<String>();

		for (int i=0; i<s.length(); i++) {
			for (int e=i+1; e<=i+K && e<s.length()+1; e++) {
				set.add(s.substring(i,e));
			}
		}

		List<String> subStrList = new ArrayList<>(set);
		Collections.sort(subStrList);
		System.out.println(subStrList.get(K-1));
	}
}



Measured memory_bytes: 26172
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		String[] A = new String[N];
		String[] B = new String[M];

		for(int i = 0; i < N; i++) {
			A[i] = sc.next();
		}
		for(int i = 0; i < M; i++) {
			B[i] = sc.next();
		}

		int count = 0;
		Serch: {
			for(int i = 0; i < N-M+1; i++) {
				for(int j = 0; j < N-M+1; j++) {
					for(int k = 0; k < M; k++) {
						if(A[i+k].substring(j,j+M).equals(B[k].substring(0))) {
							count++;
						}else {
							count = 0;
							break;
						}
						if(count == M) {
							break Serch;
						}
					}
				}
			}
		}

		if(count == 0) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 27432
#include<bits/stdc++.h>
using  namespace std;
int main(){
    string s;
    cin >> s;
    int f,e;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'A'){
            f = i; break;
        }
    }
    for(int i = s.length(); i >= 0; i--){
        if(s[i] == 'Z'){
            e = i; break;
        }
    }
    cout << e-f+1 << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
ll h, w, d, n, k;
vector<ll>x, y, z;
struct A {
	ll x1, y1, d1, x2, y2, d2;
};
struct P {
	ll i, j;
};
vector<A>v;
int a[200][200][200];
int main() {
	while (cin >> n >> k) {
		x.clear();
		y.clear();
		z.clear();
		v.clear();
		x.push_back(0);
		y.push_back(0);
		z.push_back(0);
		x.push_back(1000000);
		y.push_back(1000000);
		z.push_back(1000000);
		for (ll i = 0; i < n; i++) {
			ll x1, y1, d1, x2, y2, d2;
			cin >> x1 >> y1 >> d1 >> x2 >> y2 >> d2;
			x.push_back(x1);
			x.push_back(x2);
			y.push_back(y1);
			y.push_back(y2);
			z.push_back(d1);
			z.push_back(d2);
			v.push_back(A{ x1,y1,d1,x2,y2,d2 });
		}
		for (int i = 0; i < x.size(); i++) {
			for (int j = 0; j < y.size(); j++) {
				for (int w = 0; w < z.size(); w++)
					a[i][j][w] = 0;
			}
		}
		sort(x.begin(), x.end());
		sort(y.begin(), y.end());
		sort(z.begin(), z.end());
		for (ll l = 0; l < n; l++) {
			ll o, p, q, r, s, u;
			o = lower_bound(x.begin(), x.end(), v[l].x1) - x.begin();
			p = lower_bound(y.begin(), y.end(), v[l].y1) - y.begin();
			q = lower_bound(z.begin(), z.end(), v[l].d1) - z.begin();
			r = upper_bound(x.begin(), x.end(), v[l].x2) - x.begin() - 1;
			s = upper_bound(y.begin(), y.end(), v[l].y2) - y.begin() - 1;
			u = upper_bound(z.begin(), z.end(), v[l].d2) - z.begin() - 1;
			for (int i = o; i < r; i++) {
				for (int j = p; j < s; j++) {
					for (int w = q; w < u; w++)
						a[i][j][w]++;
				}
			}
		}
		ll sum = 0;
		for (int i = 0; i < x.size() - 1; i++) {
			for (int j = 0; j < y.size() - 1; j++) {
				for (int w = 0; w < z.size() - 1; w++) {
					if (a[i][j][w] >= k) {
						sum += ((x[i + 1] - x[i])*(y[j + 1] - y[j])*(z[w + 1] - z[w]));
					}
				}
			}
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 11648
import sys

sys.setrecursionlimit(10 ** 6)

mod = 10 ** 9 + 7

input = sys.stdin.readline


def rec(v, bf):
    global ans
    gs[v] += 1
    gs[bf] += 1
    ans = ans * (K - gs[bf]) % mod
    for nv in es[v]:
        if nv == bf: continue
        rec(nv, v)
    return


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

es = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    es[a].append(b)
    es[b].append(a)

gs = [0] * (N + 1)
gs[0] = -1
gs[N] = -1

ans = 1

rec(0, N)
print(ans)


Measured memory_bytes: 88112
#include <stdio.h> 
#define MAX 1000000
int main(void){
int prime[MAX];
int n,i,j,cnt; 
prime[0]=prime[1]=0;
for(i=2;i<MAX;i++) prime[i]=1;
for(i=2;i*i<MAX;i++)
if(prime[i])
for(j=2*i;j<MAX;j+=i)
prime[j]=0; 
while(scanf("%d",&n)!=EOF){
cnt=0;
for(i=2;i<=n;i++)
cnt+=prime[i]; 
printf("%d\n",cnt);
} 
return 0;
}

Measured memory_bytes: 4500
#include <stdio.h>

int main(void) {
	int m,f,r;
    while(1)
    {
        scanf("%d %d %d",&m, &f, &r);
      if(m == -1 && f == -1 && r == -1) {
          break;
      }else if(m == -1 || f == -1){
          printf("F\n");
      }
      else if(m+f<30){
          printf("F\n");
      }
      else if(m+f>=80){
        printf("A\n");  
      }
      else if(65<= m+f && m+f <80){
          printf("B\n");
      }
      else if(50<= m+f && m+f <65){
          printf("C\n");
      }
      else if(r>=50){
          printf("C\n");
      }
      else if (30<= m+f && m+f <50){
          printf("D\n");
      }
    }
	return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
// #define int long long
using namespace std;
vector <int> g[100009],h[100009];
int c[100009];
void dfs(int u,int e){
	int x=c[e];
	for(int i=0;i<g[u].size();i++)
		c[h[u][i]]=i+1;
	if(x<=g[u].size())
		swap(c[e],c[h[u][x-1]]);
	else
		c[e]=x;
	for(int i=0;i<g[u].size();i++){
		if(h[u][i]==e)
			continue;
		dfs(g[u][i],h[u][i]);
	}
}
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	for(int i=1;i<n;i++){
		int u,v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
		h[u].push_back(i);
		h[v].push_back(i);
	}
	int m=0;
	for(int i=1;i<=n;i++){
		int tmp=g[i].size();
		m=max(m,tmp);
	}
	cout << m << endl;;
	dfs(1,0);
	for(int i=1;i<n;i++)
		cout << c[i] << endl;
}


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

int main() {
    string s;
    cin >> s;
    if (s[s.size() - 1] == 'h') {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < s.size(); ++i) {
        if (i % 2 == 0) {
            if (s[i] != 'h') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (s[i] != 'i') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
  long long n,ac = 0,wa = 0,tle = 0, re = 0;
  vector<string> s;
  cin >> n;
  s.resize(n);
  for(long long i = 0; i < n;i++){
    cin >> s[i];
    if(s[i] == "AC"){
      ac++;
    }
    else if(s[i] == "WA"){
      wa++;
    }
    else if(s[i] == "TLE"){
      tle++;
    }
    else{
      re++;
    }
  }
  cout << "AC x " << ac << endl << "WA x " << wa << endl << "TLE x " << tle << endl << "RE x " << re << endl;
  
  return 0;
}

Measured memory_bytes: 6336
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define endl '\n'
#define pi 3.14159265
int main()  
{     
    ll n,k;
    cin>>n>>k;
    vector<ll> d(k);
    for(ll i=0;i<k;i++)
        cin>>d[i];
    for(ll i=n;;i++)
    {
        ll num=i;
        ll flag=0;
        while(num>0)
        {
            ll dig=num%10;
            num/=10;
            ll check=0;
            for(ll j=0;j<k;j++)
            {
                if(dig==d[j])
                    check=1;
            }
            if(check==1)
            {
                flag=1;
                break;
            }
        }
        if(flag==0)
        {
            cout<<i;
            return 0;
        }
    }
}   

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

int a,b,n;

int main()
{
	cin>>n;
	if(n>81)
	{
		cout<<"No\n";
		return 0;
	}
	for(int i=1;i<=9;i++)
	{
		if(n%i==0 && n/i<=9)
		{
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
	return 0;
}

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


int main(){
  int d, n;
  cin >> d >> n;
  int ans = 1;
  for(int i=0;i<d;i++){
    ans*=100;
  }
  if(n==100){
    cout << (n+1) * ans << endl;
  }
  else{
    cout << n * ans << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = br.readLine().split(" ");
		int a = Integer.parseInt(strs[0]);
		int b = Integer.parseInt(strs[1]);
		
		if((a*b) % 2 == 0){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 23124