akhauriyash/Code-Regression huggingface dataset:
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).end()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

int nC2(int k){
    int res = 1; 
    if(k & 1) res = (((k+1)/2) * k)%mod ;
    else res = ((k/2)*(k+1))%mod ;
    return res;
}
void solve()
{
    int n , k ;
    cin >> n >> k; 
    set<pii> s;
    int ans = 0 ;
    for(int ch = k ; ch <= n + 1; ++ch){
        // int brem = (po(10 , 100) * ch) % mod ;
        // int l = (ch * (ch - 1) / 2);
        int l = nC2(ch-1);
        int r = nC2(n) - nC2(n-ch) + mod;
        // int r = (n * (n + 1)/2)- ((n - ch) * (n - ch + 1) / 2);
        // cout << l << ' ' << r << ' ';
        ans += (r - l + 1) ;
        ans %= mod ; 
        // l = brem + l % mod ;
        // r = brem + r% mod ; 
        // l %= mod ; r %= mod ;
        // if(l < 0 ) l += mod ;
        // if(r < 0) r += mod ;
        // if(l > r){
        //     s.insert({l , mod - 1});
        //     s.insert({0 , r});
        // }else s.insert({l , r});
    }
    // int ans = 0;
    // while(!s.empty()){
    //     auto u = *s.begin();
    //     s.erase(u);
    //     cout << u.ff << '\n';
    //     int r = u.ss ;
    //     while(!s.empty() && r >= s.begin()->ff){
    //         r = max(r , s.begin()->ss);
    //         s.erase(*s.begin());
    //     }
    //     cout << u.ff << ' ' << r << '\n';
    //     ans += (r - u.ff + 1);
    // }
    if(ans < 0) ans += mod ;
    cout << ans ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

class Dice{
private:
	int top, bottom, north, east, west, south;
public:
	void setNumber(){
		int n1, n2, n3, n4, n5, n6;
		cin >> n1 >> n2 >> n3 >> n4 >> n5 >> n6;
		top = n1;
		south = n2;
		east = n3;
		west = n4;
		north = n5;
		bottom = n6;
	}

	void roll(){
		string command;
		cin >> command;
		for(int i = 0; i < command.length(); i++){
			switch(command[i]){
				case 'N': rollNorth(); break;
				case 'E': rollEast(); break;
				case 'W': rollWest(); break;
				case 'S': rollSouth(); break;
			}
		}
	}

	void rollNorth(){
		int tmp = north;
		north = top;
		top = south;
		south = bottom;
		bottom = tmp;
	}

	void rollEast(){
		int tmp = east;
		east = top;
		top = west;
		west = bottom;
		bottom = tmp;
	}

	void rollWest(){
		int tmp = west;
		west = top;
		top = east;
		east = bottom;
		bottom = tmp;
	}

	void rollSouth(){
		int tmp = south;
		south = top;
		top = north;
		north = bottom;
		bottom = tmp;
	}

	void showTop(){
		cout << top << endl;
	}
};

int main(){
	Dice dice1;
	dice1.setNumber();
	dice1.roll();
	dice1.showTop();

	return 0;
}

Measured memory_bytes: 1204
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    s = list(map(int, rl().split()))
    
    ans = 0
    for c in range(1, N):
        cur = 0
        tmp = 0
        i, j = 0, N - 1
        if (N - 1) % c == 0:
            while i < j:
                cur += s[i] + s[j]
                tmp = max(tmp, cur)
                i += c
                j -= c
        else:
            while i < N - 1 and c < j:
                cur += s[i] + s[j]
                tmp = max(tmp, cur)
                i += c
                j -= c
        ans = max(ans, tmp)
    print(ans)


if __name__ == '__main__':
    solve()


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

int main()
{
    string s;
    cin >> s;
    // string y = s.substr(0, 4);
    // string m = s.substr(5, 2);
    // string d = s.substr(8, 2);
    // s = y + m + d;
    if (s > "2019/04/30")
        cout << "TBD" << endl;
    else
        cout << "Heisei" << endl;
    return 0;
}

Measured memory_bytes: 3600
using System;using System.Linq;class A{static void Main(){
int n=int.Parse(Console.ReadLine());
int []a=Console.ReadLine().Split().Select(int.Parse).ToArray();
int ans=0;Array.Sort(a);
for(int i=0;i<n;i++)
{
ans+=a[i*2];
}Console.WriteLine(ans);
}}

Measured memory_bytes: 13268
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  if(n/100==9) printf("1");
  else printf("9");
  n%=100;
  if(n/10==9) printf("1");
  else printf("9");
  if(n%10==9) printf("1");
  else printf("9");
  return 0;
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

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.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

vector< vector<PII> > G, G1;
bool visited[100004], visited1[100005];
int dist[100005];
bool fail;

void dfs1(int v);

void dfs(int v) {
    if (visited[v]) return;
    visited[v] = true;
    for (auto p : G[v]) {
        if (dist[p.first] != -1) {
            if (dist[p.first] != dist[v] + p.second) {
                fail = true;
                return;
            }
        } else {
            dist[p.first] = dist[v] + p.second;
            dfs(p.first);
            dfs1(p.first);
        } 

    }

}

void dfs1(int v) {
    if (visited1[v]) return;
    visited1[v] = true;
    for (auto p : G1[v]) {
        if (dist[p.first] != -1) {
            if (dist[p.first] != dist[v] - p.second) {
                fail = true;
                return;
            }
        } else {
            dist[p.first] = dist[v] - p.second;
            dfs1(p.first);
            dfs(p.first);
        }
    }
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N, M;
    cin >> N >> M;
    G.assign(N + 3, vector<PII>());
    G1.assign(N + 3, vector<PII>());
    REP(i, M) {
        int l, r, d;
        cin >> l >> r >> d;
        G[r].pb({l, d});
        G1[l].pb({r, d});
    }
    memset(dist, -1, sizeof(dist));
    FOR(i, 1, N) {
        if (dist[i] == -1) {
            dist[i] = 0;
        }
        if (!visited1[i]) {
            dfs1(i);
        }
        if (!visited[i]) {
            dfs(i);
        }
    }
    if (fail) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }

}

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    REP(i,m)cin >> a[i];

    int sum = 0;
    REP(i,m)sum += a[i];
    int ans = n - sum;
    ans = ans < 0 ? -1 : ans;

    cout << ans << endl;
    return 0;
}

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

int main(void) {
    int n, m, t;
    cin >> n >> m;
    int a[n][m];
    int b[m];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }

    for (int i = 0; i < n; i++) {
        t = 0;
        for (int j = 0; j < m; j++) {
            t += a[i][j] * b[j];
        }
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    string a;
    cin >> a;
    vector<ll> z(26);
    for (int i = 0; i < a.size(); i++) {
        z[a[i] - 'a']++;
    }
    string ans = "Yes";
    for (int i = 0; i < 26; i++) {
        if (z[i] % 2 != 0)ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(){

	char  in[7];
	int i,res=0;
	
	scanf("%s",&in);
	
	
	for(i=0;i<6;i++)
	{
		if(in[i]=='1')
		{
			res++;
		}
	}
	
	printf("%d",res);
	
	return 0;
	
	
}

Measured memory_bytes: 128
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <unordered_map>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

 const ll MOD = 998244353;
//const ll MOD = 1e9 + 7;

//非再帰累乗(mod付き)
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,a,b,k,ans=0;
  std::cin>>n>>a>>b>>k;

  std::vector<ll> conbi(n+1);
  conbi[0]=1;
  rep(i,1,n+1)conbi[i]=(((conbi[i-1]*(n+1-i))%MOD)*pow_mod(i,MOD-2,MOD))%MOD;

  rep(i,0,std::min(n,k/a)+1){
    if((k-i*a)%b==0&&(k-i*a)/b<=n){
      ans=(ans+(conbi[i]*conbi[(k-i*a)/b])%MOD)%MOD;
    }
  }

  std::cout<<ans;

  return 0;
}


Measured memory_bytes: 2560
from collections import deque
K = int(input())
q = deque(range(1,10))
n = 0
while n < K:
  n += 1
  x = q.popleft()
  if x%10!=0: q.append(10*x+x%10-1)
  q.append(10*x+x%10)
  if x%10!=9: q.append(10*x+x%10+1)
print(x)

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

int main(){
	int h,w;	cin>>h>>w;
	char map[h+2][w+2];
	for(int y=0;y<h;y++){
		for(int x=0;x<w;x++)cin>>map[y][x];
	}
	int vecx[3]={-1,0,1};
	int vecy[3]={-1,0,1};

	for(int y=0;y<h;y++){
		for(int x=0;x<w;x++){
			if(map[y][x]=='.'){
				map[y][x]='0';
				for(int i=0;i<3;i++){
					for(int j=0;j<3;j++){
						if(map[y+vecy[i]][x+vecx[j]]=='#')map[y][x]++;;
					}
				}

			}
		}
	}
	for(int y=0;y<h;y++){
		for(int x=0;x<w;x++){
			cout<<map[y][x];
		}
		cout<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    def int():
        return int(sys.stdin.readline().rstrip())

    def string():
        return sys.stdin.readline().rstrip()

    def map_int():
        return [int(x) for x in Scanner.string().split()]

    def string_list(n):
        return [input() for i in range(n)]

    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

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

    def roundUp(a, b):
        return -(-a // b)

    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    def toLowerMultiple(a, x):
        return (a // x) * x

    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7


def main():
    # sys.stdin = open("sample.txt")
    N = Scanner.int()
    A = Scanner.map_int()
    A.insert(0, 0)
    A.append(0)
    sum = 0
    for i in range(N+1):
        sum += abs(A[i] - A[i+1])
    for i in range(1, N+1):
        ans = sum - abs(A[i] - A[i-1]) - abs(A[i] -
                                             A[i+1]) + abs(A[i-1] - A[i+1])
        print(ans)


if __name__ == "__main__":
    main()


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

int main(){
    int n,m;
    cin >> n >> m;
    int hoge = (int) m / n;
    int ans = 1;
    for(int i = hoge; i >= 1; i--){
        if(m % i == 0){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

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

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		BigInteger low = BigInteger.ZERO;
		BigInteger up = new BigInteger("9999");

		while(sc.hasNext()){
			String s = sc.next();
			for(int i=s.length()-1;i>=0;i--){
				if(!Character.isDigit(s.charAt(i)) && (i-1<0 || !Character.isDigit(s.charAt(i-1)))){
					s = s.substring(0,i) + "0" + s.substring(i);
				}
			}

			String[] val = s.split("\\+|-|\\*|=");
			String[] op = s.split("[0-9]+");

			BigInteger cal = new BigInteger(val[0]);
			boolean flg = cal.compareTo(up) <= 0 && cal.compareTo(low) >= 0;

			for(int i=1;flg && i<val.length;i++){
				BigInteger next = new BigInteger(val[i]);
				flg = next.compareTo(up) <= 0 && next.compareTo(low) >= 0;
				if(!flg) break;

				if(op[i].equals("+")) cal = cal.add(next);
				else if(op[i].equals("-")) cal = cal.subtract(next);
				else cal = cal.multiply(next);

				flg = cal.compareTo(up) <= 0 && cal.compareTo(low) >= 0;
			}

			System.out.println(flg ? cal : "E");
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A.at(i);
    }
    sort(A.begin(),A.end());
    int count=1;
    for(int i=0; i<N-1; i++){
        if (A.at(i)<A.at(i+1)) {count++;}
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
long long a[200001];
int main()
{
	long long n, total = 0;
	scanf("%lld", &n);
	for(long long i = 0; i < n; ++i)
	{
		scanf("%lld", &a[i]);
	}
	for(long long i = 0, j = 0, sum = 0; i < n; ++i)
	{
		for( ; j < n && (sum ^ a[j]) == (sum + a[j]); sum += a[j++]){}
		total += j - i;
		sum -= a[i];
	}
	printf("%lld\n", total);
}

Measured memory_bytes: 1792
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String result = "";
		if(a.equals(b)){
			result = "EQUAL";
		}else if(a.length() > b.length()){
			result = "GREATER";
		}else if(a.length() < b.length()){
			result = "LESS";
		}else{
			if(a.compareTo(b) < 0){
				result = "LESS";
			}else{
				result = "GREATER";
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 35668
n,k = map(int,input().split())
a = list(map(int,input().split()))

a.sort()
ans = 0
a.append(-1)
x = []
tmp = 0
for i in range(n):
  if a[i] != a[i+1]:
    tmp += 1
    x.append(tmp)
    tmp = 0
  else:
    tmp += 1
    
x.sort(reverse=True)
print(sum(x[k:]))

Measured memory_bytes: 97612
// AtCoder template
// 見た奴全員saba!
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

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

    ll n; int k; cin >> n >> k;
    int ans = 0;
    while(n > 0){
        n /= k;
        ans++;
    }
    cout << ans << endl;
}

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

struct Node {
  int id;
  Node *child;
  Node *sibling;

  int depth;
  Node *parent;

  Node(int id) : id(id), child(NULL), sibling(NULL), depth(-1), parent(NULL) {};

  ~Node() {
    delete sibling;
    delete child;
  }
};

Node* getNode(map<int, Node*> &nodes, int id) {
  map<int, Node*>::iterator it = nodes.find(id);
  if (it == nodes.end()) {
    Node *node = new Node(id);
    nodes[id] = node;
    return node;
  } else {
    return it->second;
  }
}

Node *findRoot(Node *node) {
  Node *p = node;
  while (p->parent) {
    p = p->parent;
  }
  return p;
}

void parse(Node *node, int depth) {
  node->depth = depth;
  if (node->child) {
    parse(node->child, depth + 1);
  }
  if (node->sibling) {
    parse(node->sibling, depth);
  }
}

void printNode(Node *node) {
  cout << "node " << node->id << ": parent = ";
  if (!node->parent) {
    cout << -1;
  } else {
    cout << node->parent->id;
  }
  cout << ", depth = " << node->depth << ", ";
  if (!node->parent) {
    cout << "root";
  } else if (node->child) {
    cout << "internal node";
  } else {
    cout << "leaf";
  }
  cout << ", [";
  if (node->child) {
    Node *child = node->child;
    cout << child->id;
    while (true) {
      child = child->sibling;
      if (!child) {
        break;
      }
      cout << ", " << child->id;
    }
  }
  cout << "]" << endl;
}

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

  int N;
  cin >> N;

  map<int, Node*> nodes;
  for (int i = 0; i < N; ++i) {
    int id, m;
    cin >> id >> m;

    Node *n = getNode(nodes, id);
    Node *p = n;

    int childId;
    for (int j = 0; j < m; ++j) {
      cin >> childId;

      Node *child = getNode(nodes, childId);
      if (!j) {
        p->child = child;
        child->parent = n;
        p = child;
      } else {
        p->sibling = child;
        child->parent = n;
        p = child;
      }
    }
  }

  Node *root = findRoot(nodes.begin()->second);

  // attach depth
  parse(root, 0);

  for (map<int, Node*>::iterator it = nodes.begin(); it != nodes.end(); ++it) {
    printNode(it->second);
  }

  delete root;

  return 0;
}



Measured memory_bytes: 15640
#include<stdio.h>
#include<string.h>
int main(){
    char str[100];
    int i,j;
    while(gets(str)){
        j = strlen(str);
        for(i=j-1;i>=0;i--){
            printf("%c",str[i]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 908
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define inf 10000000
ll h[100005];
ll fr[100005];
ll n;

int frg( int cr )
{

	if(cr==n) return 0;
	if(cr>n) return inf;

   if (fr[cr]!=-1)
   {
   	return fr[cr];
   }

	return fr[cr]=min(abs(h[cr]-h[cr+1])+frg(cr+1),abs(h[cr]-h[cr+2])+frg(cr+2));
}


int main()
{

	cin>>n;
	// memset(h, 0, sizeof(n));
	memset(fr, -1, sizeof(fr));
	for (int i = 1; i <= n; ++i)
	{
		cin>>h[i];
	}
	ll ans=frg(1);
	cout<<ans;
	
	
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define fd(i,a,b) for(int i=a;i>b;i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pw 1000000000
#define pi 3.141592653589793238

int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
       int n;
       cin>>n;
       cout<<2*pi*n;
       //string s;
       /*f(i,0,n)
       cin>>a[i];
       sort(a,a+n);*/
       cout<<endl;
    }
    return 0;
}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "yes" : "no");}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arr(s,n);
  int q;
  cin >> q;
  arr(t,q);

  ll ans=0;
  rep(i,q){
    ll k = upper_bound(all(s), t[i]) - lower_bound(all(s), t[i]);
    if(k>0) ans++;
  }
  prt(ans);
}



Measured memory_bytes: 3260
import java.util.*;
public class Main{public static void main(String[] args){Scanner c = new Scanner(System.in);String[] a = c.nextLine().split("[ ,\\.]");int i=0,j;for(String o : a){j=o.length();if(j>2&&j<7){if(i==0)i=1;else System.out.print(" ");System.out.print(o);}}System.out.println();}}

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



int main(){
	
	vector<char> c(6);
	for(int i = 0; i < 6; i++)
	{
		cin >> c[i];
	}
	
	string ans = "NO";
	if(c[0] == c[5] && c[1] == c[4] && c[2] == c[3]) ans = "YES";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
import bisect


A, B, Q = map(int, input().split())

INF = float("inf")

s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]

for i in range(Q):
    ans = INF
    x = int(input())
    s_right = bisect.bisect_right(s, x)
    t_right = bisect.bisect_right(t, x)

    s_left = s_right - 1
    t_left = t_right - 1

    for S in (s[s_left], s[s_right]):
        for T in (t[t_left], t[t_right]):
            ans = min(ans, abs(x-S) + abs(T-S), abs(x-T) + abs(S-T))

    print(ans)

Measured memory_bytes: 72284
import java.util.Scanner;

/**
 * Weather Prediction
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            String S = sc.next();

            if (S.equals("Sunny")) {
                System.out.println("Cloudy");
            } else if (S.equals("Cloudy")) {
                System.out.println("Rainy");
            } else {
                System.out.println("Sunny");
            }
        }
    }

}


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

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	string s;
  	cin >> s;
	for(int i=0;i<s.length();i++){
    	if((i+1)%2 == 0 && s[i] == 'R'){
    		cout << "No";
    		return 0;
		}else if((i+1)%2 == 1 && s[i] == 'L'){
			cout << "No";
			return 0;
		}
    }
    cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string inp;
    cin>>inp;
    if(inp=="ABC") cout<<"ARC"<<endl;
    if(inp=="ARC") cout<<"ABC"<<endl;
}


Measured memory_bytes: 3580
#ifndef DEBUG
#pragma GCC optimize("O3,unroll-loops")
#pragma loop_opt(on)
#endif
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define cerr
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define All(v) v.begin(),v.end()
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, int>;
constexpr ll MOD = 998'244'353;

signed main() {
    FAST;

    int n, m;
    cin >> n >> m;
    Fr(i, 0, m/2) cout _ i+1 _ m/2*2+1-i _ endl;
    Fr(i, 0, (m+1)/2) cout _ m/2*2+2+i _ m*2+1-i _ endl;

}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <map>
#define MOD 1000000007
using namespace std;


int main(){

char c;
for(int i = 0; i< 3;i++){
 for(int j = 0; j< 3; j++){
 cin >> c;
if(i==j) cout << c;
 }
}


return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

public class Program
{
    public static void Main()
    {
        string s = Console.ReadLine();
        Console.WriteLine(s.Length - (Atcoder.strReverce(s).IndexOf("Z"))-(s.IndexOf("A")));
    }

}




public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s) {
        string s_ = new string(s.Reverse().ToArray());
        return s_;
    }

    public static List<int> IndexOfPlural(string a, string b)
    {
        List<int> list = new List<int>();
        if (a.Length == 0 || b.Length == 0) { list.Add(-1); return list; }
        if (a.IndexOf(b) == -1) { list.Add(-1); return list; }
        int box = 0;
        int revision = 0;
        while (true)
        {
            if (a.Length == 0) break;
            box = a.IndexOf(b);
            if (box == -1) { break; }
            else
            {
                list.Add(box + revision);
                a = a.Remove(box, b.Length);
                revision += b.Length;
            }
        }
        return list;
    }
}

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

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

using namespace std;

signed main(){
  map<char,vector<long long>> dic;
  map<char,vector<long long>> origin_dic;
  map<char,int> check_dic;
  long long count=0;
  long long chousei;
  long long check=0;

  string s, t;
  cin>>s>>t;
  
  rep(i, s.length()){
    origin_dic[s[i]].push_back(i);
  }
  rep(i, t.length()){
    if (origin_dic.count(t[i])==0){
      cout << -1 << endl;
      return 0;
    }
  }

  string alphabet = "abcdefghijklmnopqrstuvwxyz";
  rep(i, alphabet.length()) check_dic[alphabet[i]] = 0;
  rep(i, t.length()){
    if (origin_dic[t[i]].size()==check_dic[t[i]]){
      rep(i, alphabet.length()) check_dic[alphabet[i]] = 0;
      count++;
    }else{
      while(check > origin_dic[t[i]][check_dic[t[i]]]){
        check_dic[t[i]]++;
        if (origin_dic[t[i]].size()==check_dic[t[i]]){
          rep(i, alphabet.length()) check_dic[alphabet[i]] = 0;
          count++;
          break;
        }
      }
    }
    check = origin_dic[t[i]][check_dic[t[i]]];
    check_dic[t[i]]++;
  }
  cout << count*s.length()+check+1 << endl;
  return 0;
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll MAX=500000;
const ll INF=(1ll<<62)-1;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
    int N;
    vi bit;
    Binary_indexed_tree(int n):N(n){
        bit.resize(N+1,0);
    }
    void add(int x,int a){
        for(x;x<=N;x+=(x&-x)) bit[x]+=a;
    }
    ll sum(int x){
        ll ret=0;
        for(x;x>0;x-=(x&-x)) ret+=bit[x];
        return ret;
    }
};
ll modpow(ll X,ll Y){
    ll sum=X,cnt=1;
    vi A;
    while(cnt<=Y){
        A.pb(sum);
        sum*=sum;
        sum%=MOD;
        cnt*=2;
    }
    int M=A.size();
    ll ret=1;
    REP(i,1,M){
        if(Y>=(1ll<<M-i)){
            Y-=(1ll<<M-i);
            ret*=A[M-i];
            ret%=MOD;
        }
    }
    return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=finv[1]=finv[0]=inv[0]=inv[1]=1;
    rep(i,2,MAX){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=modpow(i,MOD-2);
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(ll n,ll r){
    if(n<r||n<0||r<0) return 0;
    return fac[n]*finv[r]%MOD*finv[n-r]%MOD;
}
signed main(){
    int N,M; cin>>N>>M;
    vii Data(M+1);
    rep(i,0,N){
        int X,Y; cin>>X>>Y;
        Data[Y].pb(X);
    }
    Binary_indexed_tree BIT(M);
    vi memo(M+1);
    rep(i,1,M){
        rep(j,0,Data[i].size()) BIT.add(Data[i][j],1);
        int Sum=BIT.sum(i);
        int X=i+1;
        std::set<int> set;
        REP(j,2,sqrt(X)){
            if(X%j==0){
                set.insert(j);
                set.insert(X/j);
            }
        }
        for(auto p:set){
            memo[p]+=Sum-BIT.sum(X-p);
        }
        memo[X]+=Sum;
    }
    rep(i,0,Data[M].size()) BIT.add(Data[M][i],1);
    int Sum=BIT.sum(M);
    cout<<N<<endl;
    REP(i,2,M){
        int X=M-M%i;
        memo[i]+=Sum-BIT.sum(X);
        cout<<N-memo[i]<<endl;
    }
}

 

Measured memory_bytes: 9216
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int n,s,result;

void saiki(int summed,int maxi,int sum)
{
	if(summed < n)
	{
		for(int a = maxi;a>=0;a--)
		{
			if(sum + a < s)
			{
 				saiki(summed + 1,a - 1,sum + a);
			}
			else if(sum + a == s)
			{
				if(summed + 1 == n)
				{
					result++;
				}
				else
				{
					saiki(summed + 1,a-1,sum+a);
				}
			}
		}
	}
}

int main()
{
	for(int i = 0;;i++)
	{
		cin >> n >> s;

		if(n == 0 && s == 0)
		{
			break;
		}

		result = 0;

		saiki(0,9,0);

		cout << result << endl;
	}
}

Measured memory_bytes: 1160
#include <cstdio>
#include <iostream>
#define N 200010
using namespace std;
typedef long long i64;
i64 n, X, x[N], sum[N], Ans = 1LL << 62;

int main() {
    cin >> n >> X;
    for (int i = 1; i <= n; ++i)
        scanf("%lld", x + i),
        sum[i] = sum[i - 1] + x[i];
    for (i64 k = 1; k <= n; ++k) {
        i64 res = k * X; 
        for (int j = 0; j < (n - 1) / k + 1; ++j) {
            i64 M = n - j * k, m;
            m = max(M - k, 0LL);
            i64 c = j == 0 ? 5 : j * 2 + 3;
            res += (i64) c * (sum[M] - sum[m]);
            if (res < 0) break;
        }
        if (res > 0) Ans = min(Ans, res);
    }
    cout << Ans + n * X;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/math/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os, &vc](T value) {
    os << value;
    if (value != vc.back())
      os << ' ';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream&
operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  //string S{}; std::cin >> S;
  ui N{}; std::cin >> N;

  typedef pair<string, pair<ui, ull>> Pair;
  vector<Pair> S(N);
  rep(0, N)
  {
    std::cin >> S[i].first
      >> S[i].second.second;
    S[i].second.first = i + 1;
  }
  boost::sort(S, [](Pair p1, Pair p2){
    if (p1.first != p2.first)
    {
      return p1.first < p2.first;
    }
    else
    {
      return p1.second.second > p2.second.second;
    }
    });
  boost::for_each(S, [](auto p) {
    std::cout << p.second.first << '\n';
    });

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

using Graph = vector<vector<int>>;

// 出次数と入次数が全て1の誘導部分グラフを求める問題。
// 上の条件はつまりグラフの中でサイクルになっている部分を探す。更に、サイクルの中に邪魔なエッジがあってはいけない。
// よって、極小サイズのサイクルを見つければ良い。その理由は、最小サイズのサイクルには邪魔なエッジがないと言えるため。
// 最小サイズのサイクルはBFSで見つけられる。
vector<int> bfs(int s, Graph g) {
    queue<vector<int>> q;
    q.push({s});
    vector<bool> visited(g.size(), false);
    while(!q.empty()) {
        vector<int> v = q.front(); q.pop();
        int now = v[v.size()-1];
        for (int next_node : g[now]) {
            if (next_node == s) return v;
            if (visited[next_node]) continue;
            vector<int> tmp = v;
            tmp.insert(tmp.end(), next_node);
            q.push(tmp);
            visited[next_node] = true;
        }
    }
    vector<int> fallback(g.size()+1);
    return fallback;
}

int main() {
    int n, m;
    cin >> n >> m;
    Graph g(n);
    for(int i = 0; i < m; i++) {
        int from, to;
        cin >> from >> to;
        from--; to--;
        g[from].push_back(to);
    }

    vector<int> ans(n+1);
    for(int i = 0; i < n; i++) {
        vector<int> curr = bfs(i, g);
        if (curr.size() < ans.size()) ans = curr;
    }
    
    if (ans.size() == n + 1) cout << -1 << endl;
    else {
        cout << ans.size() << endl;
        for(int i = 0; i < ans.size(); i++) {
            cout << ans[i] + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long int ll;
#define code                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define int long long
#define MM(a, b) memset(a, b, sizeof(a))
const ll MOD = 1000000007;
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}

int32_t main()
{
	code;

	int n; cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	for(int i=1;i<n;i++){
		if(arr[i]==arr[i-1]){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
        char s[5];
        scanf("%s", s);

        int i, ans = 0; 
        for(i = 0; i < 3; i++) {
                if (s[i] == '1')
                        ans++;
        }

        printf("%d\n", ans);
        return 0;
}


Measured memory_bytes: 128
#include <iostream>

inline int abs(int a) {
  return (a<0) ? -a : a;
}

int main()
{
  int N;

  std::cin >> N;
  
  int t_now = 0, x_now = 0, y_now = 0;
  int t_next, x_next, y_next;

  bool is_ok = true;
  
  for (int ii=0; is_ok && ii<N; ++ii) {
    std::cin >> t_next >> x_next >> y_next;
    int t_diff = t_next - t_now;
    int d_diff = abs(x_next - x_now) + abs(y_next - y_now);
    is_ok = (t_diff >= d_diff && (t_diff - d_diff)%2 == 0);
    t_now = t_next; x_now = x_next; y_now = y_next;
  }
  
  std::cout << ((is_ok) ? "Yes" : "No") << std::endl;
  return 0;
}

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

Measured memory_bytes: 1712
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    vector<int> N(4);
    cin >> N[0] >> N[1] >> N[2] >> N[3];
    sort(N.begin(), N.end());

    if (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
// Author: 23forever
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
typedef long long LL;
const int MAXN = 200000;
using namespace std;

inline void enableFileIO() {
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
}

inline int read() {
  int x = 0, w = 1;
  char c = ' ';

  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }

  return x * w;
}

string s;
string str;
int k;

void init() {
  //enableFileIO();

  cin >> s;
  k = read();
}

bool f;

void dfs(string str) {
  if (f) return;
  if (!k) {
    cout << str << endl;
    f = true;
    return;
  }
  
  for (int i = 'a'; i <= 'z' && !f; ++i) {
    string tmp = str + char(i); 
    if (s.find(tmp) != string::npos) {
      --k;
      dfs(tmp);
    } 
  }
}

int main() {
  init();

  dfs("");

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>

using namespace std;

typedef vector< vector< pair<int, string> > > Graph;

class Node{
public:
	int pos; string str; int prev;
	Node(int pos, string str, int prev) : pos(pos), str(str), prev(prev) {}
	bool operator < (const Node &nd) const { return str > nd.str; }
};

int main(){
	int n, a, s, g;
	bool con[40][40];
	bool reach[40];
	bool visit[240][40];
	string str[240][40];
	while(cin >> n >> a >> s >> g, n){
		Graph graph(n);
		memset(con, false, sizeof(con));
		memset(reach, false, sizeof(reach));
		for(int i=0;i<a;i++){
			int x, y; string lab; cin >> x >> y >> lab;
			graph[x].push_back(make_pair(y,lab));
			con[y][x] = true;
		}
		queue<int> quG; quG.push(g);
		while(!quG.empty()){
			int cur = quG.front(); quG.pop();
			if(reach[cur]) continue;
			reach[cur] = true;
			for(int i=0;i<n;i++)
				if(!reach[i]&&con[cur][i]) quG.push(i);
		}
		memset(visit, false, sizeof(visit));
		for(int i=0;i<6*n;i++)
			for(int j=0;j<n;j++) str[i][j] = "";
		priority_queue<Node> qu; qu.push(Node(s, "", -2));
		while(!qu.empty()){
			Node nd = qu.top(); qu.pop();
			int pos = nd.pos, size = nd.str.size();
			if(visit[size][pos]) continue;
			visit[size][pos] = true;
			for(int i=0;i<graph[pos].size();i++){
				int npos = graph[pos][i].first;
				if(size + graph[pos][i].second.size() >= 6*n) continue;
				string nstr = nd.str + graph[pos][i].second;
				if(str[nstr.size()][npos]==""||str[nstr.size()][npos]>nstr){
					str[nstr.size()][npos] = nstr;
					qu.push(Node(npos, nstr, size*n+pos));
				}
			}
		}
		string ans = "";
		for(int i=0;i<6*(n-1);i++){
			if(str[i][g] == "") continue;
			if(ans == ""||ans > str[i][g]) ans = str[i][g];
		}
		if(ans != ""){
			for(int i=0;i<n;i++){
				if(!reach[i]) continue;
				for(int j=6*(n-1);j<6*n;j++){
					if(str[j][i]=="") continue;
					if(str[j][i]<ans) ans = "";
				}
			}
		}
		cout << (ans!="" ? ans : "NO") << endl;
	}
}

Measured memory_bytes: 3672
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

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

const double EPS = 1e-9;
const double PI = acos(-1.0);

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }

int N;
VI d;

int main() {
    cin >> N;
    REP (i, N) {
        int tmp;
        cin >> tmp;
        d.PB(tmp);
    }
    sort(ALL(d));
    
    cout << d[N / 2] - d[N / 2 - 1] << endl;
    return 0;
}


Measured memory_bytes: 892
n = int(input())
l = []
for i in range(n):
    l.append(int(input()))

l_b = sorted(l)
max_a = l_b[-1]
max_b = l_b[-2]

for j in range(len(l)):
    if max_a == l[j]:
        print(max_b)
    else:
        print(max_a)


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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[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; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    long double l;
    cin >> l;

    if (fmod(l, 3.0) == 0.0) {
        cout << setprecision(10) << (l/3.0)*(l/3.0)*(l/3.0) << endl;
    } else {
        //cout << (l/3.0) << " " << l-2.0*(l/3.0) << endl;
        cout << setprecision(10) << (l/3.0)*(l/3.0)*(l-2.0*(l/3.0)) << endl;
    }
    return 0;
}



Measured memory_bytes: 256
from collections import defaultdict
def inpl(): return list(map(int, input().split()))
MOD = 10**9 + 7
N = int(input())
S = []

x = 0
for a in map(int, input().split()):
    x ^= a
    S.append(x)

A = defaultdict(int)
B = defaultdict(int)
L = defaultdict(int)
Z = 0

if S[-1] != 0:
    sr = S[-1]
    a, b = 0, 0
    for s in S:
        if s == sr:
            b =  (b + a + 1)%MOD
        elif s == 0:
            a = (a + b)%MOD
    print(a+1)
else:
    for s in S:
        if s == 0:
            Z += 1
        else:
            A[s] = (A[s] + (Z - L[s])*B[s])%MOD
            B[s] = (A[s] + B[s] + 1)%MOD
            L[s] = Z
    print((sum(B.values()) + pow(2, Z-1, MOD))%MOD)

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

int main() {
    string S;
    cin >> S;
    if (S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}


Measured memory_bytes: 3632
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Array.Unboxed

main :: IO ()
main = do
  n <- getl toInt
  solve n <$> getl (wrds toInt) >>= print

solve :: Int -> [Int] -> Int
solve n xs = foldl f 0 [1..n] `div` 2
  where
    ar = listArray (1,n) xs :: UArray Int Int
    f c ix
      | ar ! (ar ! ix) == ix = c + 1
      | otherwise = c

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine


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

using namespace std;
 
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector <string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pi;

#define int ll
#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
#define MOD 1000000007
#define loop(n) for(int i = 0; i < n; i++)
#define rloop(n) for(int i = n-1; i >= 0; i--)

void io() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

void solve() {
    int n, m;
    cin>>n>>m;
    vl h(n), hm(n);
    loop(n) cin>>h[i];
    //vector <pair<ll,ll>> ab(m,{0,0});
    map <ll,set<ll>> roads;
    loop(m) {
        ll x, y;
        cin>>x;
        cin>>y;
        hm[x-1] = max(hm[x-1],h[y-1]);
        hm[y-1] = max(hm[y-1],h[x-1]);
    }
    int ans=0;
    loop(n) {
        if(h[i]>hm[i]) ans++;
    }
    cout<<ans<<"\n";
    return;
}
int32_t main() {
    io();
    int t=1;
    //cin>>t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4740