akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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 ll;
using namespace std;
int main(void){
    sp(6);
    double l;cin>>l;
    double res=l/3;
    cout<<res*res*res<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
typedef vector<int> vi;

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int total = 0;
  for (int i=1; i <= N; ++i) {
    int sum = findSumOfDigits(i);
    if (A <= sum && sum <= B) total += i;
  }
  cout << total << endl;

  return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if(x<1200){
      System.out.println("ABC");
    }else if(1200<=x){
      System.out.println("ARC");
    }
  }
}

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

int main(){
	double x1, x2, y1, y2, dist;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << fixed << sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) << endl;
	return 0;
}

Measured memory_bytes: 1280
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2*10**5+100)
from bisect import *

def dfs(v, pv):
    j = bisect_left(dp, a[v])
    prev = dp[j]
    dp[j] = a[v]
    ans[v] = bisect_left(dp, 10**18)-1
    
    for nv in G[v]:
        if nv==pv:
            continue
        
        dfs(nv, v)
    
    dp[j] = prev

N = int(input())
a = list(map(int, input().split()))
G = [[] for _ in range(N)]

for _ in range(N-1):
    u, v = map(int, input().split())
    G[u-1].append(v-1)
    G[v-1].append(u-1)

dp = [10**18]*(N+1)
dp[0] = -10**18
ans = [-1]*N
dfs(0, -1)

for ans_i in ans:
    print(ans_i)

Measured memory_bytes: 348664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, l, r) for(int i = (l); i < (r); ++i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
//-------
const int N = 101;
int n, m;
char ans[N][N];
int main() {
	scanf("%d%d", &n, &m);
	rep(i, 0, 50) rep(j, 0, N - 1) ans[i][j] = '.';
	rep(i, 50, 100) rep(j, 0, N - 1) ans[i][j] = '#';
	for(int cnt = m - 1, i = 0; i < 50 && cnt != 0; i+=2) {
		for(int j = 0; j < N - 1 && cnt != 0; j++) {
			bool ok = 1;
			for(int k = 0; k < 4; k++) {
				int nx = i + (k == 0) - (k == 1), ny = j + (k == 2) - (k == 3);
				if(nx < 0 || nx > 99 || ny < 0 || ny > 99) continue;
				if(ans[nx][ny] == '#') ok = 0;
			}
			if(ok) cnt--, ans[i][j] = '#';
		}
	}
	for(int cnt = n - 1, i = 50; i < N - 1 && cnt != 0; i += 2) {
		for(int j = 0; j < N - 1 && cnt != 0; j++) {
			bool ok = 1;
			for(int k = 0; k < 4; k++) {
				int nx = i + (k == 0) - (k == 1), ny = j + (k == 2) - (k == 3);
				if(nx < 0 || nx > 99 || ny < 0 || ny > 99) continue;
				if(ans[nx][ny] == '.') ok = 0;
			}
			if(ok) cnt--, ans[i][j] = '.';
		}
	}
	printf("%d %d\n", 100, 100);
	rep(i, 0, N - 1) printf("%s\n", ans[i]);
	
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[0]==s[1])
	 {
	 	if(s[1]==s[2])
	 	cout<<"No";
	 	else cout<<"Yes";
	 }
	 else  cout<<"Yes";
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>

#include<string>
#include<iostream>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

z = (Node *)malloc(sizeof(Node));
z->key = k;
z->left = NIL;
z->right = NIL;

while(x != NIL){
    y = x;
    if(z->key < x->key){
        x = x->left;
    }else{
        x = x->right;
    }

}
z->parent = y;
if(y == NIL){
    root = z;
}else{
    if(z->key < y->key){
        y->left = z;
    }else{
        y->right = z;
    }
}
}

void inorder(Node *u){
    if(u == NIL) return;
    inorder(u -> left);
    printf(" %d", u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n,i,x;
    string com;

    scanf("%d",&n);

    for(i = 0;i < n;i++){
        cin >> com;
        if(com == "insert"){
            scanf("%d",&x);
            insert(x);
        }else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 26736
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
using vi  = vector<int>;
using ii  = pair<int,int>;
using vii = vector<ii>;
using ll  = long long;

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

#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) int((x).size())
#define REP(i, a, b) for (auto (i) = (a); (i) <= (b); (i)++)
#define PER(i, a, b) for (auto (i) = (a); (i) >= (b); (i)--)
#define ITR(i, x) for (auto (i) = (x).begin(); (i) != (x).end(); (i)++)

string to_string(string s) { return '\"' + s + '\"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A,B> p)
{ return "(" + to_string(p.F) + ", " + to_string(p.S) + ")"; }
template <typename T> string to_string(T v) {
	int f = 0; string res = "{";
	for (const auto &x: v)
		res += (f++ ? ", " : "") + to_string(x);
	return res + "}";
}
void debug_out() { cerr << "]\n"; }
template <typename T, typename... V>
void debug_out(T a, V... v)
{ cerr << to_string(a); if (sizeof...(v)) cerr << ", "; debug_out(v...); }

#ifdef LOCAL // add -DLOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = [", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif // debug(var1, var2, ...);

const int mxN = 3e3;
const ll MOD = 998244353;
int a[mxN+5];
ll memo[mxN+5][mxN+5];

ll modpow(ll b, ll e)
{
	if (e == 0) return 1;
	if (e & 1) return b*modpow(b, e-1) % MOD;
	return modpow((b*b) % MOD, e/2);
}

ll dp(int i, int s)
{
	// debug(i, s);
	if (s == 0) return modpow(2, i+1);
	if (i == 0)
	{
		if (a[0] == s) return 1;
		else return 0;
	}
	if (memo[i][s] == -1)
	{
		memo[i][s] = (2 * dp(i-1, s)) % MOD;
		if (a[i] <= s)
			memo[i][s] = (memo[i][s] + dp(i-1, s-a[i])) % MOD;
	}
	return memo[i][s];
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	memset(memo, -1, sizeof memo);

	int n, s;
	cin >> n >> s;
	REP(i, 0, n-1) cin >> a[i];
	cout << dp(n-1, s) << '\n';
	return 0;
}

Measured memory_bytes: 74376
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };

int N = 1e3 + 7;


int main() {
	fastIO;
	int n, k;
	cin >> n;
	vector<ll> v,b;
	for (int i = 0; i <= n; i++) {
		ll x;
		cin >> x;
		v.push_back(x);
	}
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		b.push_back(x);
	}

	vector<ll> ans(n+1);
	for (int i = 0; i < n; i++) {
		ll d = min(b[i], v[i] - ans[i]);
		ans[i] += d;
		b[i] -= d;
		ans[i+1] = min(v[i+1], ans[i+1]+b[i]);
	}

	ll sum = 0;
	for (int i = 0; i < n+1; i++)
		sum += ans[i];

	cout << sum;




}


Measured memory_bytes: 2804
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
#include <deque>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
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; }

ll dp[100010];

int main() {

    int n;
    cin >> n;
    vector<pair<ll, ll>> ba;

    for (int i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        ba.push_back(make_pair(b, -a));
    }

    sort(ba.begin(), ba.end());

    ll time = 0;

    for (int i = 0; i < n; i++) {
        time += -ba[i].second;
        if (time > ba[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;

}

Measured memory_bytes: 6384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

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

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}


int main(){
  string s;
  int k;
  cin >> s >> k;
  int cnt = 0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='1') cnt++;
    else break;
  }
  if(cnt >= k) cout<< 1 <<endl;
  else cout<< s[cnt] <<endl;
}


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

cnt = 0
c = sum(A)

b = c /(4 * m)

for a in A:
    if a >= b:
        cnt += 1
    
if cnt >= m:
    print('Yes')
else:
    print('No')


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

#define MODULO 1000000007l
#define INF 100000000
#define FOR(i,j,k) for(int (i)=(j);(i)<=(k);(i)++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
typedef long long ll;

int n;
typedef long long ll;

int main() {

#ifdef CONTEST
    freopen("input.in", "r", stdin);
#endif
    IOS
    cin >> n;
    string s1, s2;
    cin >> s1;
    cin >> s2;
    vector<ll> dp(s1.length());
    int i = 0;
    if (s1[i] == s2[i]) {
        dp[i] = 3;
        i++;
    } else {
        i++;
        dp[i] = 6;
        i++;
    }
    for (; i < n; i++) {
        if (s1[i] == s2[i]) { //ver
            if (s1[i-1] == s2[i-1]) { //ver
                dp[i] = 2*dp[i-1]%MODULO;
            } else { //hor
                dp[i] = dp[i-1]%MODULO;
            }
        } else { //hor
            i++;
            if (s1[i-2] == s2[i-2]) { //ver
                dp[i] = 2*dp[i-2]%MODULO;
            } else { //hor
                dp[i] = 3*dp[i-2]%MODULO;
            }
        }
    }
    cout << dp[n-1] << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

int main() {
	ll N;
	cin >> N;
	vector<ll> A(N), B(N), AS(N), BS(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i] >> B[i];
	}
	sort(all(A));
	sort(all(B));
	ll am, bm;
	if (N & 1) {
		am = A[(N - 1) / 2];
		bm = B[(N - 1) / 2];
		cout << bm - am + 1 << endl;
	}
	else {
		am = (A[N / 2] + A[N / 2 - 1]);
		bm = (B[N / 2] + B[N / 2 - 1]);
		cout << bm - am + 1 << endl;
	}
}


Measured memory_bytes: 9540
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n, h, w;
  cin >> n >> h >> w;

  ll ans = (n - h + 1) * (n - w + 1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
N,K=map(int,input().split())
L=[[0 for i in range(K*2+1)]for j in range(K*2+1)]
for i in range(N):
    x,y,c=list(input().split())
    if c=="W":
        x=int(x)+K
        y=int(y)
    else:
        x=int(x)
        y=int(y)
    L[x%(2*K)+1][y%(2*K)+1]+=1
#print(L)

for h in range(1,2*K+1):
    for w in range(1,2*K+1):
        L[h][w]=L[h-1][w]+L[h][w]
#print(L)
for h in range(1,2*K+1):
    for w in range(1,2*K+1):
        L[h][w]=L[h][w-1]+L[h][w]
#print(L)

ans=0
for h in range(1,K+1):
    for w in range(1,K+1):
        cnt=0
        for a in range(3):
            for b in range(3):
                if (a+b)%2==0:
                    HH=h+a*K
                    if h+a*K>2*K:
                        HH=2*K
                    HL=h+a*K-K
                    if h+a*K-K<0:
                        HL=0
                    WH=w+b*K
                    if w+b*K>2*K:
                        WH=2*K
                    WL=w+b*K-K
                    if w+b*K-K<0:
                        WL=0
                    cnt+=L[HH][WH]+L[HL][WL]-L[HH][WL]-L[HL][WH]
        ans=max(ans,max(cnt,N-cnt))
print(ans)


Measured memory_bytes: 82780
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int counter = 0;
	for (int i = 0; i < n; i++) {
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			counter++;
		}
	}
	cout << counter << endl;
	return 0;
}

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

int N,K;
string S;

int main(){ 

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

cin>>N>>K>>S;

//ABCABC
string s1=S.substr(0,K-1);
string s2=S.substr(K-1,1);
string s3=S.substr(K,N-K);

if(s2=="A"){
	s2="a";
}
if(s2=="B"){
	s2="b";
}
if(s2=="C"){
	s2="c";
}

string ans=s1+s2+s3;

cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main()
{
	int n, k, ans = 1;
	cin >> n >> k;
	while (n--) {
		if (ans < k) {
			ans *= 2;
		}
		else {
			ans += k;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

vector<int> dp; // 頂点 i から始まるパスで最長のものの長さ
multimap<int, int> mp; // 入力値(from, to)

// 一番遠い場所を探す
int rec(int from) {
    if (dp[from] != 0) {
        return dp[from];
    }
    int res = 0;
    // キーを持つ値を列挙する
    auto p = mp.equal_range(from);
    for (auto it = p.first; it != p.second; ++it) {
        res = max(res, rec(it->second) + 1);
    }
    return dp[from] = res;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, ans = 0;
    cin >> n >> m;
    dp.resize(n + 1, 0);
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        mp.emplace(x, y);
    }
    for (int i = 1; i <= n; i++) {
        ans = max(ans, rec(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7424
s = input()
if "01" <= s[:2] <= "12":
    if "01" <= s[2:] <= "12":
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if "01" <= s[2:] <= "12":
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 2940
/**
  @file c.cpp
  @title C - Synthetic Kadomatsu
  @brief https://atcoder.jp/contests/abc119/tasks/abc119_c
**/

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

int dfs(int current, int a, int b, int c, int N, int A, int B, int C, vector<int> l) {
  if (current == N) {
    if (min({a, b, c}) > 0) {
      return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    } else {
      return 1e9;
    }
  }

  int ret0 = dfs(current + 1, a, b, c, N, A, B, C, l);
  int ret1 = dfs(current + 1, a + l[current], b, c, N, A, B, C, l) + 10;
  int ret2 = dfs(current + 1, a, b + l[current], c, N, A, B, C, l) + 10;
  int ret3 = dfs(current + 1, a, b, c + l[current], N, A, B, C, l) + 10;

  return min({ret0, ret1, ret2, ret3});
}

int main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;

  vector<int> l(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }

  cout << dfs(0, 0, 0, 0, N, A, B, C, l) << endl;

  return 0;
}


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

int main () {
	
	long long int x=0, y=0, z=0, i=0, j=0, k=0, aux=0, val=0, tam=0, sa=0, sb=0, sc=0;
	vector <long long int> a, b, c, res, res2;

	cin >> x >> y >> z >> val;

	for (i=0; i<x; i++) { cin >> aux; a.push_back(aux); }
	for (i=0; i<y; i++) { cin >> aux; b.push_back(aux); }
	for (i=0; i<z; i++) { cin >> aux; c.push_back(aux); }

	//for (i=0; i<x; i++) cout << "//" << a[i] << " " << b[i] << " " << c[i] << endl;

	tam = x * y * z;
	
	sort(a.begin(), a.end()); reverse(a.begin(), a.end());
	sort(b.begin(), b.end()); reverse(b.begin(), b.end());
	sort(c.begin(), c.end()); reverse(c.begin(), c.end());

	for (i=0; i<x; i++) {
		for (j=0; j<y; j++) {
			aux = a[i]+b[j];
			res.push_back(aux);
		}
	}

	sort(res.begin(), res.end()); reverse(res.begin(), res.end());

	sa = (long long int)(res.size());
	sa = min(sa, val);
	for (i=0; i<sa; i++) {
		for (k=0; k<z; k++) {
			aux = res[i] + c[k];
			res2.push_back(aux);
		}
	}

	sort(res2.begin(), res2.end()); reverse(res2.begin(), res2.end());

	for (i=0; i<val; i++) cout << res2[i] << endl;

	return 0;
}

Measured memory_bytes: 43128
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count = 800;
		for (int i=0;i<N;i++) {
			long a = sc.nextLong();
			int temp=0;
			while (a%2==0) {
				a/=2;
				temp++;
			}
			if (temp<count) {
				count = temp;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 22736
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
//const ll MOD = 1000000007;
const ld PI = (acos(-1));
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
typedef pair<int, int> pair;
double rad(double a) {return a * 180 / PI;}

//dpTable
int dp[100050];

vector<ll> rsk(100050);

int main(){
    ll N,H,W;
    cin >> N >> H >> W;
    vector<ll> A(N);
    vector<ll> B(N);
    int ans = 0;
    rep (i,N) {
        cin >> A.at(i) >> B.at(i);
        if (A.at(i) >= H && B.at(i) >= W) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

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




ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int ans = 0;
int N, M, Q;

template<typename T>
void showall(vector<T> v){
  rep(i, 0, v.size()){
    cout << v[i] << " ";
  }
  cout << endl;
}

template<typename T>
ll com(T n, T m, T mod){
  ll a = 1, b = 1, ans;
  if(n == m || m == 0){
    ans = 1;
  }else{
    for(ll i = 0;i < m; i++){
      a *= n-i;
      a %= mod;
      b *= i+1;
      b %= mod;
    }
    ans = (a * powmod(b, mod-2, mod)) % mod;
  }
  
  return ans;
}


 
int main() {
  int X, Y;
  cin >> X >> Y;

  int a = (Y-2*X);
  if(a % 2 != 0){
    cout << "No" << endl;
    return 0;
  }
  a /= 2;
  int b = (4*X-Y);
  if(b % 2 != 0){
    cout << "No" << endl;
    return 0;
  }
  b /= 2;

  if(a < 0 || b < 0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  
  // cout << setprecision(8) << ans << endl;  // For double
}



Measured memory_bytes: 3628
n = int(input())
s = input()
a = "SS"
ct=1
while ct<7:    
    for i in range(n-1):
        p=a[i]
        q="A"
        if a[i]=="S":
            q="W"
        else:
            q="S"
        if a[i+1]=="S":
            if s[i+1] == "o":
                a=a+a[i]
            else:
                a=a+q
        else:
            if s[i+1] == "o":
                 a=a+q
            else:
                a=a+a[i]
    if a[0]==a[n]:
        if a[0]=="S" and s[0]=="o" and a[n-1]==a[1]:
            print(a[0:n])
            break
        elif a[0]=="S" and s[0] !="o" and a[n-1]!=a[1]:         
            print(a[0:n])
            break
        elif a[0]=="W" and s[0] =="o" and a[n-1]!=a[1]: 
            print(a[0:n])
            break
        elif a[0]=="W" and s[0] !="o" and a[n-1]==a[1]: 
            print(a[0:n])
            break
        else:
            ct=ct+1
        if ct==2:
            a="SW"
        elif ct==3:
            a="WS"
        elif ct==4:
            a="WW"
        else:
            print(-1)
            break
    else:
        ct=ct+1
        if ct==2:
            a="SW"
        elif ct==3:
            a="WS"
        elif ct==4:
            a="WW"
        else:
            print(-1)
            break

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

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; }

const int MAX=3000;
ll A[MAX+10][MAX+10];
ll dp[MAX+10][MAX+10][4];
 
int main(){
  ll r,c,k;
  cin>>r>>c>>k;
  

  rep(i,MAX+10){
    rep(j,MAX+10) A[i][j]=0;
  }

  ll x,y,z;
  rep(i,k){
    cin>>x>>y>>z;
    A[x][y]=z;
  }
  
  
  rep(i,MAX+10){
    rep(j,MAX+10){
      rep(k,4) dp[i][j][k]=0;
    }
  }
  
  dp[1][1][1]=A[1][1];
  for(int i=1;i<=r;i++){
    for(int j=1;j<=c;j++){
      for(int k=0;k<=3;k++){
        chmax(dp[i][j+1][k],dp[i][j][k]);
        if(k<3 && A[i][j+1]!=0) chmax(dp[i][j+1][k+1],dp[i][j][k]+A[i][j+1]);
        chmax(dp[i+1][j][0],dp[i][j][k]);
        if(A[i+1][j]!=0) chmax(dp[i+1][j][1],dp[i][j][k]+A[i+1][j]);              
      }
    }
  }
  ll ans=0;
  rep(i,4){
    chmax(ans,dp[r][c][i]);
  }
  cout<<ans<<endl;
 
  return 0;
}


Measured memory_bytes: 357504
#include <bits/stdc++.h>
using namespace std;
int g[100005];
int main()
{
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> g[i];
	sort(g+1 , g+n+1 , greater<int>());//g[n+1] = 0
	
	int ans = -1;
	for(int i=1;i<=n && ans == -1;i++) {
		if(g[i+1] == i) {
			int pos = i+1;
			while(pos < n && g[pos+1] == i)
				pos++;
			if(g[i] == i) {
				if((pos-i) % 2 == 0)
					ans = 1;
				else 
					ans = 0;
			} else {
				if((pos-i) % 2 == 0 && (g[i]-i) % 2 == 0)
					ans = 1;
				else 
					ans = 0;
			}
		} else if(g[i+1] < i) {
			if((g[i]-i) % 2 == 0)
				ans = 1;
			else 
				ans = 0;
		}
	}
	if(ans == 0)
		cout << "First" << endl;
	else 
		cout << "Second" << endl;
	return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++)
		cin >> a[i];
	long long ans=0;
	for(int i=0;i<n;i++)
	{
		int count=0;
		while(true)
		{
			if(a[i]%2==1)break;
			count++;
			a[i]/=2;
		}
		ans+=count;
	}
	
	cout << ans << endl;



	
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long INF=INT_MAX/4;
const long long MOD=1'000'000'007;
const double EPS=1e-14;
const bool DEBUG=false;

const string YES = "YES";
const string NO = "NO";
const string Yes = "Yes";
const string No = "No";

template<class T>
void debug(T head){
    if(DEBUG){
        cout<<head<<endl;
    }
}

template <class Head, class... Body>
void debug(Head head, Body... body){
    if(DEBUG){
        cout<<head<<" ";
        debug(body...);
    }
}

/////
class q_set{
public:
    long a, b, c, d;
};

int N, M, Q;
vector<q_set> q;
long max_ans=0;

void calc(vector<int> a){
    long ans = 0;
    for(int i=0; i<Q; ++i){
        if(a[q[i].b-1] - a[q[i].a-1] == q[i].c){
            ans += q[i].d;
        }
    }
    //debug(a[0], a[1], a[2], ans);
    if(max_ans < ans){
        max_ans = ans;
    }
}


void dfs(int d, vector<int> a){
    if(d == N){
        if(a.size() == N){
            calc(a);
        }
    }else if(d == 0){
        for(int i=1; i<=M; ++i){
            a.push_back(i);
            dfs(d+1, a);
            a.pop_back();
        }
    }else{
        for(int i=a[a.size()-1]; i<=M; ++i){
            a.push_back(i);
            dfs(d+1, a);
            a.pop_back();
        }
    }
}


void answer(){
    int a, b, c, d;
    cin>>N>>M>>Q;
    for(int i=0; i<Q; ++i){
        cin>>a>>b>>c>>d;
        q.push_back({a, b, c, d});
    }

    vector<int> aa;
    dfs(0, aa);

    cout<<max_ans<<endl;

    return;
}

/////

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.precision(16);

    answer();

    return 0;
}


Measured memory_bytes: 3592
#include <iostream>

using namespace std;

void solve()
{
	int r, c;
	while(cin >> r >> c, r || c)
	{
		if(r * c % 2)
		{
			cout << "no" << endl;
		}
		else
		{
			cout << "yes" << endl;
		}
	}
}

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

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int n;
  V<int> a;
  cin >> n;
  a.resize(n + 1);
  repf(i, 1, n + 1) {
    cin >> a[i];
  }

  int label = 1;
  int push_count = 0;
  V<bool> visited(n + 1, false);
  bool can = false;
  while(true) {
    if(visited[label]) {
      break;
    }
    if(label == 2) {
      can = true;
      break;
    }

    push_count++;
    visited[label] = true;
    label = a[label];
  }

  if(can) {
    cout << push_count << endl;
  } else {
    cout << - 1 << endl;
  }
}


Measured memory_bytes: 3776
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
queue<int> que;
int d[MAXN],f[MAXN];
vector<PR> e[MAXN];
int main()
{
	int n=read(),m=read(),cnt=0,flag=0;
	for (int i=1,u,v,c;i<=m;i++) u=read(),v=read(),c=read(),e[u].PB(MP(v,c)),d[v]++;
	for (int i=1;i<=n;i++) 
		if (!d[i]) que.push(i),f[i]=0;
		else f[i]=INF;
	while (!que.empty())
	{
		int q=que.front(); que.pop(),cnt++;
		for (auto v:e[q])
			if (f[v.fi]!=f[q]+v.se&&f[v.fi]!=INF) flag=1;
			else 
			{
				f[v.fi]=f[q]+v.se;
				if (!(--d[v.fi])) que.push(v.fi);
			}
	}
	if (cnt<n) flag=1;
	puts(flag?"No":"Yes");
	return 0;
}


Measured memory_bytes: 21696
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <numeric>
#include <chrono>
#include <bitset>
#include <tuple>
#include <queue>
#include <cstring>
#include <cassert>
using namespace std;

const int N = 1e6 + 10, mod = 1e9 + 7;

char buf[N];

void nope() {
    puts("No");
    exit(0);
}


int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1; 
    // scanf("%d", &tc);
    for(int cn = 1; cn <= tc; cn++) {
        int n; scanf("%d", &n);
        int sum = 0;
        int l, r;
        l = r = -1;
        vector<int> v(n, 0), mnp(n, 0);
        set<pair<int, int>, greater<pair<int, int>>> se;
        int cur = 0;
        for(int i = 0; i < n; i++) {
            scanf("%s", &buf);
            string s = buf;
            int mn = 1e9;
            int pref = 0;
            for(int j = 0; j < s.size(); j++) {
                int c = (s[j] == '(' ? 1 : -1);
                pref += c;
                mn = min(mn, pref);
            }
            sum += pref;
            v[i] = pref;
            mnp[i] = mn;
            if(mn >= 0 && s[0] == '(' && (l < 0 || (l >= 0 && v[l] < v[i]))) {
                if(l > -1) cur += v[l];
                l = i;
            }
            else if(mn <= 0 && s.back() == ')' && (r < 0 || (r >= 0 && v[i] < v[r]))) {
                if(r > -1) {
                    if(mnp[r] < 0) se.insert({v[r], r});
                    else cur += v[r]; 
                }
                r = i;
            }
            else {
                if(mn < 0) se.insert({v[i], i});
                else cur += v[i];
            }
        }
        if(sum != 0 || l < 0 || r < 0) nope();
        cur += v[l];
        for(auto x : se) {
            if(cur + mnp[x.second] < 0) nope();
            cur += x.first;
        }
        if(cur + mnp[r] < 0) nope();
        puts("Yes");
    }  
    return 0;
}

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

void print(int time) {
    int second = time % 60;
    int minute = time / 60;
    int hour = minute / 60;
    minute %= 60;
    printf("%02d:%02d:%02d\n", hour, minute, second);
    
}

int main(void) {
    int all = 120 * 60;
    int hour, minute, second;
    while(cin >> hour >> minute >> second, hour != -1 && minute != -1 && second != -1) {
        int time = second + minute * 60 + hour * 60 * 60;
        print(all - time);
        print((all - time) * 3);
    }
    return(0);
}

Measured memory_bytes: 1160
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

// a x + b y = gcd(a, b)
LL extgcd(LL a, LL b, LL &x, LL &y) {
    LL g = a; x = 1; y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

// mod m ?? a ? ??
LL mod_inverse(LL a, LL m){
    LL x, y;
    extgcd(a, m, x, y);
    return (m + x%m)%m;
}

const LL MOD = 998244353;
int n;
LL a[202020];
LL cnt[1010101];
LL c[1010101];

int main(){
    cin >> n;
    REP(i, n)cin >> a[i];
    
    for(int i = 1;i <= 1000000;i++){
        c[i] = mod_inverse(i, MOD);
    }
    for(int i = 1;i <= 1000000;i++){
        for(int j = 2 * i;j <= 1000000;j += i){
            c[j] -= c[i];
            if(c[j] < 0)c[j] += MOD;
        }
    }

    REP(i, n){
        cnt[a[i]]++;
    }

    LL ans = 0;
    for(LL i = 1;i <= 1000000;i++){
        LL s = 0, t = 0;
        for(LL j = i;j <= 1000000;j += i){
            LL num = (j * cnt[j]) % MOD;
            s += num;
            s %= MOD;
            t += (num * j) % MOD;
            t %= MOD;
        }
        ans += (c[i] * (((s * s) % MOD - t + MOD) % MOD)) % MOD;
        ans %= MOD;
    }
    cout << (ans * mod_inverse(2, MOD) % MOD) << endl;
}

Measured memory_bytes: 17792
#include <stdio.h>

#define N 100000
#define Q 50000

int BinarySearch();

int main() {
 
int n,q,S[N],T[Q];
int i,key,num,sum=0;

scanf("%d",&n);
for(i=0; i<n;i++)
  scanf("%d",&S[i]);

scanf("%d",&q); 
for(i=0; i<q;i++)
  scanf("%d",&T[i]);

for (i=0; i<q; i++){

num = BinarySearch(n,S,T[i]);
 if(num != 0)
   sum++;
}

printf("%d\n",sum);


return 0;
}

int BinarySearch(int n,int S[],int key){

  int left,mid,right;
  
  left = 0;
  right = n;

  while (left < right){
    
    mid = (left + right)/2;
    
    if( key == S[mid])
      return 1;

    if( key > S[mid] )
      left = mid +1;
    
    else if( key < S[mid] )
      right = mid;
  }

  return 0;

}

Measured memory_bytes: 1184
#include<iostream>
#include<vector>
#include<string>
#include<tuple>
#include<algorithm>

using namespace std;

int main(){

    bool MM__flag = false;
    bool __MMflag = false;
    int zeroFlag = 0;

    int S;

    cin >> S;

    int before = S / 100;
    int after = S % 100;

    if(before == 0)
    {
        zeroFlag += 1;
    }
    else if(before <= 12)
    {
        MM__flag = true;
    }

    if(after == 0)
    {
        zeroFlag += 1;
    }
    else if(after <= 12)
    {
        __MMflag = true;
    }

    if(zeroFlag == 2)
    {
        cout << "NA" << endl;
        return 0;
    }
    if(MM__flag && __MMflag)
    {
        cout << "AMBIGUOUS" << endl;
        return 0;
    }
    else if(MM__flag)
    {
        cout << "MMYY" << endl;
        return 0;
    }
    else if(__MMflag)
    {
        cout << "YYMM" << endl;
        return 0;
    }
    else
    {
        cout << "NA" << endl;
        return 0;
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

string s[51];
int d[51][51];
int h, w;
bool flg = false;
typedef pair<int, int> P;

void bfs(int y, int x) {
  queue<P> que;
  P p;
  que.push(P(y, x));

  while (que.size()) {
    p = que.front(), que.pop();

    for (int i = 0; i < 4; i++) {
      int nx = p.second + dx[i], ny = p.first + dy[i];

      if (0 <= nx && nx < w && 0 <= ny && ny < h && s[ny][nx] != '#' &&
          d[ny][nx] == INF) {
        que.push(P(ny, nx));
        d[ny][nx] = d[p.first][p.second] + 1;
      }
    }
  }
}

int main() {
  int cnt = 0;
  cin >> h >> w;
  rep(i, h) cin >> s[i];
  rep(i, h) rep(j, w) if (s[i][j] == '#') cnt++;
  rep(i, h) rep(j, w) d[i][j] = INF;
  d[0][0] = 0;

  bfs(0, 0);
  int di = d[h - 1][w - 1];
  cout << (di == INF ? -1 : h * w - di - 1 - cnt) << endl;
  return 0;
}


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

flag = 0
word = input()
wordlist = [word]

for i in range(N-1):
    word = input()
    if flag == 1:
        break
    elif word[0] != wordlist[i][-1]:
        flag = 1
        break
    elif word in wordlist:
        flag = 1
        break
    wordlist.append(word)

if flag == 1:
    print("No")
else: print("Yes")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	const int n = 100000;
	bitset<n+1> prmset; 
	prmset.flip();
	prmset.set(0, false);
	prmset.set(1, false);
	for( int i = 2; i <= n; ++i ){
		for( int j = 2*i; j <= n; j += i ){
			prmset.set(j, false);
		}
	}
	vector<int> sum(n+1, 0);
	for( int i = 3; i <= n; i += 2 ){
		sum[i] = sum[i-2];
		if( prmset.test( i ) && prmset.test( (i+1)/2 ) ){
			++sum[i];
		}
	}
	int q; cin >> q;
	for( int i = 0; i < q; ++i ){
		int l, r; cin >> l >> r;
		cout << sum[r]-sum[l-2] << endl;;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {

    map< char, vector< int > > st;

    string s;
    int kk;

    cin >> s >> kk;

    for(int i = 0; i < s.size(); i++) {
        st[s[i]].push_back(i);
    }

    vector< string > v;
    for(int i = 'a'; i <= 'z'; i++) {
        for(int j = 0; j < st[i].size(); j++) {
            for(int k = 0; st[i][j] + k < s.size(); k++) {
                if(kk > k) v.push_back(s.substr(st[i][j], k + 1));
                else break;
            }
        }
        sort(v.begin(), v.end());
        v.erase(unique(v.begin(), v.end()), v.end());
        if(v.size() >= kk) {
            cout << v[kk - 1] << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }


int main(){
	int N; cin >> N;
	vector<int> a(N);
	for(int i=0;i<N;i++){
		cin >> a[i];
    }
	ll ans=0;
    for(int i=0;i<N;i++){
      ans+=a[i];
    }
    cout << ans-N << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e5+100;
int a[maxn];
int main(){
    int n;
    scanf("%d",&n);
    int mmax=-1;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        mmax=max(mmax,a[i]);
    }
    sort(a,a+n);
    int ans;
    int j=lower_bound(a,a+n,mmax/2)-a;
    if(j==0){
        ans=a[0];
    }
    else if(j==n-1){
        ans=a[n-2];
    }
    else{
        if(a[j]-mmax/2>mmax/2-a[j-1])ans=a[j-1];
        else ans=a[j];
    }
    printf("%d %d\n",mmax,ans);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A, B, ans;
    cin >> A >> B;
    ans = -1;
    for (int i = 1; i <= 1000; i++) {
        if ((int)(i*0.08) == A && (int)(i*0.1) == B) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 3596
s = input()
N = len(s) + 1


def countConsecutive(s, ch):
    consecutive = [0] * N
    for i in range(1, N):
        if s[i - 1] == ch:
            consecutive[i] = consecutive[i - 1] + 1
    return consecutive


# Longest trail of < to the left of an index
consecutiveLeft = countConsecutive(s, "<")
# Longest trail of > to the right of an index
consecutiveRight = countConsecutive(s[::-1], ">")[::-1]

# Value at each index is longest consecutive trail of inequalities to left or right
nums = [max(consecutiveLeft[i], consecutiveRight[i]) for i in range(N)]

print(sum(nums))


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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int[]prices = new int[3];
		prices[0] = sc.nextInt();
		prices[1] = sc.nextInt();
		prices[2] = sc.nextInt();
		Arrays.sort(prices);
		System.out.println(prices[0] + prices[1]);
		
		
		sc.close();
	}

}

Measured memory_bytes: 22996
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <cstring>
#include <string>
#include <set>
#include <map>
using namespace std;
//ifstream cin();
//ofstream cout();
int main(){
	int a,b;
	cin>>a>>b;
	cout<<(a-1)*(b-1)<<endl;
	ios::sync_with_stdio(false);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	for (int n; cin >> n&&n;) {
		int ans = 0;
		double min = INF;
		rep(i, 0, n) {
			double l, h, w; cin >> l >> h >> w;
			h /= 100;
			if (min > abs(w / (h*h) - 22)) {
				ans = l;
				min = abs(w / (h*h) - 22);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3148
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int N = 1e5 + 20 ;
int n , k , a[N] , ans ;
vector <int> g[N] ;

int dfs (int v , int par = -1) {
	int d = 0 ;
	for (int u : g[v]) {
		d = max(d , dfs(u , v)) ;
	}

	if (d == k - 1 && par > 0) ans ++ , d = -1 ;

	return d + 1 ;
}

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

	cin >> n >> k ;

	for (int i = 0 ; i < n ; i ++) {
		cin >> a[i] ;
		a[i] -- ;
		if (i) g[a[i]].push_back(i) ;
	}

	ans += (a[0] > 0) ;

	dfs(0) ;

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


Measured memory_bytes: 10752
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAx = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAx, min_index = -1;

typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
    cin >> A >> B >> K;
    if(A > K) cout << A-K << " " << B;
    else cout << 0 << " " << max(0ll, B-(K-A));
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = input();
    let mut ans: Vec<i32>  = Vec::new();
    for c in s.chars() {
        if c == '0' {
            ans.push(0);
        } else if c == '1' {
            ans.push(1);
        } else {
            ans.pop();
        }
    }
    for n in ans {
        print!("{}", n);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 105, X = 505;
const long long mod = 1000000007ll;

int n, x, cnt[X];
long long c[X][X], f[X][X], g[X][X];

long long qpow (long long a, long long b) {
	long long res = 1ll;
	while (b) {
		if (b & 1) res = res * a % mod;
		a = a * a % mod, b >>= 1;
	}
	return res;
}

int main () {
	cin >> n >> x;
	for (int i = 1; i <= x; i++) cnt[i] = 0;
	for (int i = 1; i <= n; i++) {
		int l;
		cin >> l;
		cnt[l]++;
	}

	for (int i = 0; i <= x; i++) c[i][0] = c[i][i] = 1ll;
	for (int i = 1; i <= x; i++) {
		for (int j = 1; j < x; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
	}

	for (int i = 0; i <= x; i++) {
		for (int j = 0; j <= x; j++) f[i][j] = 0ll;
	}
	f[0][0] = 1ll;


	for (int i = x; i >= 1; i--) {
		for (int j = 0; j <= x; j++) {
			for (int k = i * j; k <= x; k++) {
				long long coef = qpow(k - (i - 1) * j, cnt[i]);
				g[j][k] = 0ll;

				for (int l = 0; l <= min(j, k / i); l++) g[j][k] = (g[j][k] + f[j - l][k - l * i] * c[j][l] % mod * coef) % mod;
			}
		}

		for (int j = 0; j <= x; j++) {
			for (int k = 0; k <= x; k++) f[j][k] = g[j][k];
		}
	}

	long long ans = 0ll;
	for (int i = 0; i <= x; i++) {
		for (int j = 0; j <= min(x, i + 1); j++) {
			if (i & 1) ans = (ans + mod - f[j][x - i] * c[i + 1][j]) % mod;
			else ans = (ans + f[j][x - i] * c[i + 1][j]) % mod;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

int map[10][10] = {{}};

void plot(int x, int y)
{
    if (0<=x && x<10 && 0<=y && y<10)
        ++map[x][y];
}

void small(int x, int y)
{
    plot(x  , y-1);
    plot(x-1, y  );
    plot(x,   y  );
    plot(x+1, y  );
    plot(x,   y+1);
}

void medium(int x, int y)
{
    for (int i = x-1; i <= x+1; ++i)
        for (int j = y-1; j <= y+1; ++j)
            plot(i, j);
}

void big(int x, int y)
{
    medium(x, y);
    plot(x, y-2);
    plot(x-2,y);
    plot(x+2,y);
    plot(x,y+2);
}

int main(void)
{
    int x, y, z;
    char c;
    while(cin >> x >> c >> y >> c >> z) {
        switch (z) {
            case 1:
                small(x, y);
                break;
            case 2:
                medium(x, y);
                break;
            case 3:
                big(x, y);
                break;
        }
    }

    int sum = 0, max = 0;
    for (int i = 0; i < 10; ++i) {
        for(int j = 0; j < 10; ++j) {
            if (map[i][j] == 0) ++sum;
            if (map[i][j] > max) max = map[i][j];
        }
    }
    cout << sum << endl << max << endl;
    return 0;
}



Measured memory_bytes: 3020