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

int main() {
    string s;
    cin >> s;

    int x = (s[0]-'0')*100 + (s[1]-'0')*10 + (s[2]-'0');
    int y = 753;

    int ans = abs(x - y);
    for (int i = 3; i < s.length(); i++) {
        x = (x%100)*10 + (s[i]-'0');
        ans = min(ans, abs(x-y));
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(int i=0;i<N;i++)
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin>>S;
    cout<<(S=="ABC"?"ARC":"ABC")<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
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; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0;
    int cnt = 0;
    ll mini = INF;
    rep(i, n)
    {
        if (a[i] < 0) cnt++;
        chmin(mini, abs(a[i]));
        ans += abs(a[i]);
    }

    if (cnt & 1) cout << ans - mini * 2 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 1024
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val product = List
    .fill(3)(List.fill(2)(sc.nextInt()))
    .flatten
    .groupBy(identity)
    .values
    .map(_.length)
    .product
  println(if (product == 4) "YES" else "NO")
}


Measured memory_bytes: 55676
import math
 
A, B, H, M = map(int, input().split())
 
th_h = 360 // 12 * H + 360 / 12 / 60 * M
th_m = 360 // 60 * M
 
ans = A ** 2 + B ** 2 - 2*A*B*math.cos(math.radians(abs(th_h - th_m)))
print(math.sqrt(ans))

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

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

  ll n, ans = 1;

  cin >> n;

  for (int i = 1; i <= n; i++) {
    ans *= i;
    ans %= 1000000007;
  }

  cout << ans << "\n";
}

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

using namespace std;

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	for (int i = 0; i < n - 1; ++i) {
		if (s[i] != s[i + 1]) { ans++; i++; }
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3344
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    int n; cin >> n;
    vi a(n);
    FOR(i, 0, n - 1) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = a[n - 1];
    int cnt = n - 2, p = n - 2;
    while (cnt) {
        if (cnt > 1) ans += a[p] * 2, cnt -= 2, p--;
        else ans += a[p], cnt--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4036
#include<cstdio>
#include<algorithm>
using namespace std;

const int Maxn=100;
int N,M,X,Y;
int A[Maxn+5],B[Maxn+5];

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d %d %d %d",&N,&M,&A[0],&B[0]);
	for(int i=1;i<=N;i++)
		scanf("%d",&A[i]);
	for(int i=1;i<=M;i++)
		scanf("%d",&B[i]);
	int maxa=*max_element(A,A+N+1);
	int minb=*min_element(B,B+M+1);
	if(maxa<minb)
		puts("No War");
	else puts("War");
	return 0;
}

Measured memory_bytes: 128
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif


ll dp[MAX];
int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int N; cin >> N;
	memr(dp, 0);
	vector<int> v(N);
	rep(i, N) cin >> v[i];
	int Q; cin >> Q;
	vector<int> B(Q), C(Q);
	rep(i, Q){
		cin >> B[i] >> C[i];
	}

	ll ans = 0;
	rep(i, N){
		ans += v[i];
		dp[v[i]]++;
	}

	rep(i, Q){
		dp[C[i]] += dp[B[i]];
		ans += (C[i] - B[i]) * dp[B[i]];
		dp[B[i]] = 0;
		cout << ans << endl;
	}



	// map<int, int> mp;

	// rrep(i, Q){
	// 	if(mp.find(C[i]) != mp.end()){
	// 		mp[B[i]] = mp[C[i]];
	// 	}
	// 	else{
	// 		mp[B[i]] = C[i];
	// 	}
	// }

	// ll ans = 0;
	// rep(i, N){
	// 	if(mp.find(v[i]) != mp.end()){
	// 		ans += mp[v[i]];
	// 	}
	// 	else{
	// 		ans += v[i];
	// 	}
	// }

	// cout << ans << endl;

	return 0;
}


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

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

int main(){
  int n;
  string s;
  cin >> n >> s;

  //string ans;
  rep(i, s.size()){
    int suuji = s.at(i)+n;
    //cout << suuji;
    if(suuji>'Z'-0) suuji -= 26;
    cout << char(suuji);
  }

  
}


Measured memory_bytes: 256
n, ma, mb = map(int, input().split())
abc = [tuple(map(int, input().split())) for _ in range(n)]
csup = sum(_abc[2] for _abc in abc) + 1
dp = [[[csup for _ in range(400)] for _ in range(400)] for _ in range(n+1)]
dp[0][0][0] = 0

for i in range(n):
  for _a in range(400):
    for _b in range(400):
      if dp[i][_a][_b] != csup:
        dp[i+1][_a][_b] = min(dp[i+1][_a][_b], dp[i][_a][_b])
        dp[i+1][_a + abc[i][0]][_b + abc[i][1]] = min(dp[i+1][_a + abc[i][0]][_b + abc[i][1]], dp[i][_a][_b] + abc[i][2])

ans = csup
for ai in range(1, 400):
  for bi in range(1, 400):
    if ai * mb == bi * ma:
      ans = min(ans, dp[n][ai][bi])
if ans == csup:
  print(-1)
else:
  print(ans)


Measured memory_bytes: 59860
#include<iostream>
#include<string>
using namespace std;
int main(){
	int f = 0;
	for(int i = 0; i < 3; i++){
		char a;
		cin >> a;
		if(i == 1 && a == 'R'){
			f = 1;
			}
		}
		
	if(f == 0){
		cout << "ARC";
		}
		else{
			cout << "ABC";
			}
		}

Measured memory_bytes: 3584
import sys
from collections import Counter
from collections import deque
import math
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
b=list(map(int,input().split()))
a=[0]
a.extend(b)

s=abs(a[-1])
l=[0]*(n+1)
for i in range(1,n):
    s+=abs(a[i]-a[i-1])
    l[i]=abs(a[i]-a[i-1])+abs(a[i]-a[i+1])-abs(a[i+1]-a[i-1])


s+=abs(a[n]-a[n-1])
l[n]=abs(a[n]-a[n-1])+abs(a[n]-a[0])-abs(a[0]-a[n-1])


for i in range(1,n+1):
    print(s-l[i])


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

typedef long long int ll;
typedef double d;

#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<b; i++)
#define rlo(i, a) for(int i=a; i>0; i--)

#define be(a) a.begin(),a.end()
#define sz(x) x.size()

#define nl cout<<"\n";
#define sp cout<<" ";

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    su;
    char a,b;
    cin>>a>>b;
    int c = a- '0';
    int d = b - '0';
    string s(c,b),t(d,a);
    cout<<min(s,t);
    nl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

unsigned int randxor() {
  static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
  unsigned int t;
  t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}



int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  rep(i,26) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26));
  vector<int> last_day(26, 0);
  vector<int> t(D);
  rep(i,D) t[i] = randxor() % 26;
  rep(i,D) rep(j,26) cin >> s[i][j];

  int score = 0;
  auto Scoring = [&](int d, int id) {
    score += s[d - 1][id];
    last_day[t[d - 1]] = d;
    for (int i = 0; i < 26; i++) score -= c[i] * (d - last_day[i]); 
  };


  //計算  

  rep(p, 10000000) {

    int d = randxor() % D;
    int change_q = randxor() % 26;    
    int old_q = t[d];
    t[d] = change_q;
    int old_score = score;
    Scoring(d + 1, change_q);
    if (score< old_score) t[d] = old_q;
  }

  rep(i,D) cout << t[i] + 1 << endl;
  return 0;
} 

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

using namespace std;

int main(int argc, char* argv[])
{
    if(argc == 2 or argc == 3) freopen(argv[1], "r", stdin);
    if(argc == 3) freopen(argv[2], "w", stdout);
    ios::sync_with_stdio(false);
    string n;
    cin >> n;
    if (n[0] == n[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    for (int i = 0; i < n; i++){
        cin >> l[i];
    }
    vector<int> d(n + 1);
    int steps = 0;
    for (int i = 1; i <= n; i++){
        d[i] = d[i - 1] + l[i - 1];
    }
    int ans = upper_bound(d.begin(), d.end(), x) - d.begin();
    cout << ans;
    return 0;
}


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

int main() {

    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }

    vector<pair<ll, int>> d;
    rep(i, m){
        int b;
        ll c;
        cin >> b >> c;
        d.emplace_back(c, b);
    }

    sort(all(a));
    sort(all(d));

    ll ans = 0;
    int idx = m-1;
    rep(i, n){
        if(a[i] < d[idx].first){
            ans += d[idx].first;
            d[idx].second--;
        }
        else{
            ans += a[i];
        }
        if(d[idx].second == 0){
            --idx;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2804
///created: 13/Jun/2019 11:54:50

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
#define db(x) cerr << "debug: " << #x << " = " << x << '\n';
template<class __Ty> bool minimize(__Ty& a, __Ty b) {
	if (a > b) { a = b; return true; }
	return false;
}
template<class __Ty> bool maximize(__Ty& a, __Ty b) {
	if (a < b) { a = b; return true; }
	return false;
}

const int N = 1e2 + 5;
ll x[N], y[N], h[N];
int n;

int main() {
	///ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	int t = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] > 0)
			t = i;
 	}
 	for (int cx = 0; cx <= 100; ++cx)
 		for (int cy = 0; cy <= 100; ++cy) {
 			int H = h[t] + abs(cx - x[t]) + abs(cy - y[t]);
 			bool ts = 1;
 			for (int i = 1; i <= n; ++i)
 				if (max(H - abs(cx - x[i]) - abs(cy - y[i]), 0LL) != h[i])
 					ts = 0;
 			if (ts) {
 				cout << cx << ' ' << cy << ' ' << H;
 				return 0;
 			}
 		}
	return 0;
}


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

int main(){
    int a,b; cin >> a >> b;
    if(a>=10 || b>= 10){
        cout << -1 << endl;
        return 0;
    }
    cout << a*b << endl;

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = [0] + list(map(int, input().split()))
maxh = [0] * (n + 1)
for i in range(m):
	a, b = map(int, input().split())
	maxh[a] = max(maxh[a], h[b])
	maxh[b] = max(maxh[b], h[a])
	
cnt = 0
for i in range(1, n + 1):
	if h[i] > maxh[i]:
		cnt += 1
print(cnt)

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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  vector<int> Q(N);
  
  for(int i = 0; i < N; i++) cin >> P[i];
  for(int i = 0; i < N; i++) cin >> Q[i];
  
  vector<int> p(N);
  for(int i = 0; i < N; i++) p[i] = i + 1;
  
  int a = 0;
  int b = 0;
  int i = 1;
  do{
    if(p == P) a = i;
    if(p == Q) b = i;
    i++;
  }while(next_permutation(p.begin(), p.end()));
  
  cout << abs(a - b) << endl;
  
  return 0;
}

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

using namespace std;

int main(){
    int N,A,B;
    int residue=N%10;
    int division=N/10;
    int sum=0;
    int res=0;

    cin >> N >> A >> B;

    for (int i=1;i<=N;i++){
        division=i;
        sum=0;
        while (division!=0){
            residue=division%10;
            sum+=residue;
            division/=10;
        }
        if(A<=sum and sum<=B){
            res+=i;
        }
    }
    cout<<res;
}

Measured memory_bytes: 3568
/*#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
*/

/*
ID: febrian3 
LANG: C++11 
PROB: task 
*/

#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(x) cerr<<#x<<": "<<(x)<<'\n'
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9+7;
const ll inf = 0x3f3f3f3f;
const ll nax = 0;
ll n;

int main(){
		/*freopen("filename.in","r",stdin); 
		freopen("filename.out","w",stdout);*/ 
		IOS	
		cin >> n;
		vector<ll>arr(n+1);
		for(int i=0;i<n;++i){
			cin >> arr[i];
		}
		vector<ll>pref(n, 0);
		for(int i=n-1;i>=0;--i){
			pref[i]=arr[i]%mod;
			if(i<n-1) pref[i]=(pref[i]%mod+pref[i+1]%mod)%mod;
		}
		ll ans=0;
		for(int i=0;i<n-1;++i){
			ll cur=((arr[i]%mod)*(pref[i+1]%mod))%mod;
			ans=(ans+cur)%mod;
		}
		cout << ans << '\n';
	}


Measured memory_bytes: 6432
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int count = 0;
    string s;
    cin >> s;
    for(int i = 0;i < 6;i++)
    {
        if(s[i] == '1'){count++;}
    }
    cout << count << 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;

int main() {
  
  string s;
  int max = 0;
  int temp = 0;
  cin >> s;

  for(int i=0;i<3;i++){
    if(s[i]=='R'){
      temp+=1;
    }
    else{
      if(temp>=max){
        max=temp;
      }
    }
  }
  if(max == 0){
    max = temp;
  }

  cout << max << endl;
  return 0;
}

Measured memory_bytes: 3592
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
line = lines.shift().split(' ')
N = line[0] * 1
K = line[1] * 1
sum = 0
for (i=1; i <= N; i++) {
    x = i
    c = 0
    while (x < K) {
        x  = x * 2
        c++
    }
    sum += (1 / N) * (1 / Math.pow(2, c)) 
}
console.log(sum)

Measured memory_bytes: 8524
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N, K, S;
  cin >> N >> K >> S;
  ll foo = 1000000000ll;
  vector<ll> ans(N);
  rep (i, N) {
    if (i < K) ans[i] = S;
    else if (S == foo) ans[i] = foo - 1;
    else ans[i] = foo;
  }
  bool flag = false;
  rep (i, N) {
    if (flag) cout << " ";
    flag = true;
    cout << ans[i];
  }
  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main() {
	int a;cin>>a;
	string s;cin>>s;
	cout << (a >= 3200? s: "red") << endl;
}



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

const int N = 26;
const int M = 365;

int main()
{
    int d;
    cin >> d;
    vector<int> c(N);
    rep(i, 0, N) cin >> c[i];
    vector<vector<int>> s(d, vector<int> (N));
    rep(i, 0, d) rep(j, 0, N) cin >> s[i][j];
    vector<int> ans;
    int mx = 0, mx_i = 0;
    rep(i, 0, d){
        mx = 0; mx_i = 0;
        rep(j, 0, N){
            if(s[i][j] > mx){
                mx_i = j;
                mx = s[i][j];
            }
        }
        ans.push_back(mx_i+1);
    }
    for(int i : ans) cout << i << endl;
    return 0;
}


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

using namespace std;

int main(){
    long long n,a,b;
    cin >> n >> a >> b;
    if(abs(a-b)%2==0){
        cout << abs(a-b)/2 << endl;
        return 0;
    }
    else{
        if(b-1>=n-a){
            cout << (2*n-a-b+1)/2 << endl;
        }
        else{
            cout << (a+b-1)/2 << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#define MAX_BITS	(80)

class LargeNumber
{
public:
	LargeNumber() : bits({0}) {}
	~LargeNumber() {}
	void fromString(const std::string& str) {
		int size = str.length();
		int max = size < MAX_BITS ? size : MAX_BITS;
		for (int i=0; i<max; i++) {
			bits[i] = str[size-1-i] - '0';
		}
		for (int i=max; i<size; i++) {
			if (str[size-1-i] - '0' > 0) {
				bits[MAX_BITS] = 1;
				break;
			}
		}
	}
	std::string toString() {
		std::string str = "";
		bool b = false;
		for (int i=MAX_BITS-1; i>0; i--) {
			if (!b) {
				if (!bits[i]) {
					continue;
				}
				b = true;
			}
			str.push_back(bits[i] + '0');
		}
		str.push_back(bits[0] + '0');
		return str;
	}
	bool isOverflow() {
		if (bits[MAX_BITS]) return true;
		return false;
	}
	const LargeNumber operator+(const LargeNumber& rhs) const {
		LargeNumber ret;
		for (int i=0; i<MAX_BITS; i++) {
			ret.bits[i]  += bits[i] + rhs.bits[i];
			ret.bits[i+1] = ret.bits[i] / 10;
			ret.bits[i]   = ret.bits[i] % 10;
		}
		ret.bits[MAX_BITS] += bits[MAX_BITS] + rhs.bits[MAX_BITS];
		return ret;
	}
private:
	unsigned char bits[MAX_BITS+1];
};

int main() {
	int n; std::cin >> n;
	std::string line;
	for (int i=0; i<n; i++) {
		LargeNumber in1; std::cin >> line; in1.fromString(line);
		LargeNumber in2; std::cin >> line; in2.fromString(line);
		LargeNumber out = in1 + in2;
		if (out.isOverflow()) {
			std::cout << "overflow" << std::endl;
		} else {
			std::cout << out.toString() << std::endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}

int32_t main()
{
	int t=1;
	while(t--)
	{
		int k,n;
		cin >> k >> n;
		int a[n];
		for(int i=0;i<n;i++)
		cin >> a[i];
		
		sort(a,a+n);
		int mn=INT_MAX;
		for(int i=0;i<n;i++)
		{
			if(i==0)
			{
				mn=min(mn,a[n-1]-a[i]);
			}
			else
			{
				mn=min(mn,k+a[i-1]-a[i]);
			}
		}
		cout << mn;
	}
}




Measured memory_bytes: 5192
#include <bits/stdc++.h>
//#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<double,double> P;
const ll INF = 1e18;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}

int n,m,x[1100],y[1100],z[1100];
signed main(){
  cin>>n>>m;
  rep(i,n)cin>>x[i]>>y[i]>>z[i];
  int ans = 0;
  rep(bit, 1<<3){
    priority_queue<int> q;
    rep(i,n){
      int s = 0;
      s += x[i] * (bit&1? 1 : -1);
      s += y[i] * (bit&2? 1 : -1);
      s += z[i] * (bit&4? 1 : -1);
      q.push(s);
    }
    int sum = 0;
    rep(i,m)sum += q.top(), q.pop();
    chmax(ans, sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	double money =0;


       	for(int i =1 ;i<=N;i++){

       		double A = sc.nextDouble();
           	String B =sc.next();

           	if(B.equals("JPY")){
           		money +=A;
           	}else if (B.equals("BTC") ){
           		money += A*380000.0;
           	}
       	}

       	System.out.println( money);


}
}


Measured memory_bytes: 23252
// Problem : E - Red Scarf
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)
#define int long long

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
    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 * 10 + c - '0', c = getchar();
    return f * x;
}

inline LL gl()
{
    LL 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 * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 1000003, M = N << 1;

int n, m;
int a[N];

signed main()
{
    //File("");
    n = gi();
    int sum = 0;
    for (int i = 1; i <= n; i+=1) a[i] = gi(), sum ^= a[i];
    for (int i = 1; i <= n; i+=1) cout << (sum ^ a[i]) << ' ';
    return 0;
}


Measured memory_bytes: 5108
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n;
    in(n);
    vector<ll> vec(n),sumvl(n,0);
    ll sum=0;
    rep(i,n){
        in(vec[i]);
        sum+=vec[i];
        sumvl[i]=sum;
    }
    ll x,y,minv=2000000001;
    for(int i=0;i<n-1;i++){
        x=sumvl[i];
        y=sum-sumvl[i];
        minv=min(minv,abs(x-y));
    }
    out(minv);
}

Measured memory_bytes: 6412
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int a,b;
    cin>>a>>b;
    cout<<max(a+b, max(a-b, a*b))<<endl;
    return 0;
}



Measured memory_bytes: 256
H,W = (int(i) for i in input().split())

goal = []
for i in range(H):
    goal.append(input())

canComplete = True

for row in range(H):
    for column in range(W):
        above = row - 1
        bottom = row + 1
        left = column - 1
        right = column + 1
        
        if goal[row][column] == "#":
            if above >= 0 and goal[above][column] == "#":
                continue
            elif bottom < H and goal[bottom][column] == "#":
                continue
            elif left >= 0 and goal[row][left] == "#":
                continue
            elif right < W and goal[row][right] == "#":
                continue
            else:
                canComplete = False
                break

if canComplete:
    print("Yes")
else:
    print("No")

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

int main()
{
	int X,A,B;
	cin >> X >> A >> B;
	cout << (X-A) % B << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

int s[100000] = {0};

int binary_search(int key,int left,int right)
{
	int center;

	while(left < right)
	{
		center = (left + right) / 2;

		if (s[center] == key)
		{
			return 1;
		}else if (s[center] < key)
		{
			left = center+1;
		}else
		{
			right = center;
		}
	}

	return 0;
}

int main()
{
	int n,q, t[50000] = {0};
	int count = 0;

	cin >> n;

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

	cin >> q;

	for(int i = 0; i < q; i++)
	{
		cin >> t[i];
		count += binary_search(t[i],0,n);
	}

	cout << count << endl;

	return 0;
}
	

Measured memory_bytes: 3672
using System;

namespace SmallLargeorEqual
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			string input = Console.ReadLine();
			char[] CharSeparators = new char[] {' '};
			string[] array = input.Split(CharSeparators);

			string array1 = array[0];
			string array2 = array[1];

			int a = int.Parse (array1);
			int b = int.Parse (array2);

			if (a < b) {
				Console.WriteLine ("a < b");
			} else if (a > b) {
				Console.WriteLine ("a > b");
			} else {
				Console.WriteLine ("a == b");
			}
		}
	}
}

Measured memory_bytes: 5284
import sys
sys.setrecursionlimit(10**5)
def main():
    n = int(input())
    h = [int(x) for x in input().split()]
    memo = [None for i in range(n)]

    # def rec(n):
    #     if memo[n-1] == None:
    #         if n <= 1:
    #             memo[n-1] = 0
    #         elif n == 2:
    #             memo[n-1] = abs(h[1]-h[0])
    #         else:
    #             d1 = rec(n-2)+abs(h[n-1]-h[n-3])
    #             d2 = rec(n-1)+abs(h[n-1]-h[n-2])
    #             memo[n-1] = min(d1,d2)
    #     return memo[n-1]
        
    # print(rec(n))

    def f(n):
        if memo[n-1] == None:
          if n <= 1:
              memo[n-1] = 0
          elif n == 2:
              memo[n-1] = abs(h[1]-h[0])
          else:
              d2 = f(n-2) + abs(h[n-1]-h[n-3])
              d1 = f(n-1) + abs(h[n-1]-h[n-2])
              
              memo[n-1] = min(d1,d2)
        return memo[n-1]

    print(f(n))


if __name__ == "__main__":
    main()


Measured memory_bytes: 60668
import numpy as np

L=np.array(list(map(int,input().split())))
ans=0

while True:
  if L[0]==L[1] and L[1]==L[2]:
    break
  L=sorted(L-max(L))
  if L[1]<L[2]:
    L[0]+=1
    L[1]+=1
    ans+=1
  else:
    L[0]+=2
    ans+=1
    
print(ans)

Measured memory_bytes: 27216
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, vs, n, m) vector<vector<T>> vs(n, vector<T>(m))

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cin(int, nc);
    Vec2(int, d, nc, nc);
    For(i, nc) For(j, nc) cin >> d[i][j];
    Vec2(int, c, n, n);
    For(i, n) For(j, n){ cin >> c[i][j]; c[i][j] --; }
    
    Vec2(int, ns, 3, nc);
    For(i, n) For(j, n){
        ns[(i+j)%3][c[i][j]] ++;
    }
    int ans = 1e9;
    For(c0, nc) For(c1, nc) For(c2, nc){
        if(c0 == c1 || c1 == c2 || c2 == c0) continue;
        int a = 0;
        For(ci, nc){
            a += ns[0][ci] * d[ci][c0] + ns[1][ci] * d[ci][c1] + ns[2][ci] * d[ci][c2];
        }
        ans = min(ans, a);
    }
    Cout(ans);
}


Measured memory_bytes: 1280
#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>;



int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  //aが1 bが0 cが-1
  int ans = 0;
  for(int i = 0; i < k; i++){
    if(a > 0){
      ans++;
      a--;
    }else if(b > 0){
      ans += 0;
      b--;
    }else if(c > 0){
      ans -= 1;
      c--;
    }
  }
  cout << ans << endl;



}


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll a, b, c, x, y; cin >> a >> b >> c >> x >> y;
  ll ans = infll;

  chmin(ans, a * x + b * y);
  chmin(ans, c * max(x, y) * 2);

  ll tmp = c * min(x, y) * 2;
  if (x > y) chmin(ans, tmp + (x - y) * a);
  else chmin(ans, tmp + (y - x) * b);

  cout << ans << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for (int i = 0; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
#define keta(n) cout << fixed << setprecision((n));
using ll = int64_t;
using v = vector<int>;
 
 
int main() {
  int x, y, jud=0;
  cin >> x >> y;
  for (int i = 0; i<x; i++) {
    if (i*2+(x-i)*4==y || i*4+(x-i)*2==y) {
      jud++;
    }
  }
  
  if (jud==0) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }

}

Measured memory_bytes: 3636
#include<algorithm>
#include<chrono>
#include<climits>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
 

typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;


const int MAXN = 1e5 + 20;

int n;
long long a[MAXN];

long long xor_gauss() {
	int cur = 0;
	for(long long mask = 1LL << 62; mask && cur < n; mask >>= 1) {
		for(int i = cur; i < n; i++) {
			if(mask & a[i]) {
				swap(a[i], a[cur]);
				break;
			}
		}
		if(!(mask & a[cur]))
			continue;
		for(int i = 0; i < n; i++)
			if(i != cur && (mask & a[i]))
				a[i] ^= a[cur];
		cur++;
	}
	long long res = 0;
	printn(a, n);
	for(int i = 0; i < n; i++)
		res ^= a[i];
	debug << res << endl;
	return res;
}

int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;

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

    long long res = 0;
    for(int i = 0; i <= 60; i++) {
    	long long mask = 1LL << i;
    	int cnt = 0;
    	for(int j = 0; j < n; j++)
    		cnt += bool(a[j] & mask);
    	if(cnt % 2 == 1) {
    		res += mask;
    		for(int j = 0; j < n; j++) {
    			if(a[j] & mask)
    				a[j] -= mask;
    		}
    	}
    }
    debug << res << endl;
    res += xor_gauss() * 2;
    cout << res << endl;

    return 0;
}






















Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#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 per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string s; cin >> s;
	set<string> Set;
	rep(l, 1, 6) rep(i, 0, sz(s) + 1 - l) Set.insert(s.substr(i, l));
	auto it = Set.begin();
	int k; cin >> k;
	rep(i, 1, k) it++;
	cout << *it;
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dwn(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
inline int read() {
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
const int maxn=21;
const int maxm=1<<20;
const int mod=1000000007;
int f[2][maxm],trans[maxm][maxn];
int g[maxn][maxn];
int n,m,k;
int main() {
	n=read();m=read();k=read();
	memset(g,-1,sizeof(g));
	rep(i,1,k) {
		int a=read()-1,b=read()-1;
		g[a][b]=read();
	}
	rep(S,0,(1<<n)-1) {
		rep(i,0,n-1) if(!(S>>i&1)) {
			int k=n;
			rep(j,i+1,n-1) if(S>>j&1) {k=j;break;}
			if(k==n) trans[S][i]=S^(1<<i);
			else trans[S][i]=S^(1<<i)^(1<<k);
		}
	}
	int cur=0;f[0][0]=1;
	rep(i,0,m-1) {
		rep(j,0,n-1) {
			cur^=1;
			memset(f[cur],0,sizeof(f[cur]));
			int ok1=(g[i][j]<0||g[i][j]==1),ok2=g[i][j]<=0;
			rep(S,0,(1<<n)-1) if(f[cur^1][S]) {
				if(ok1) {
					if(S>>j&1) (f[cur][S]+=f[cur^1][S])%=mod;
					else (f[cur][trans[S][j]]+=f[cur^1][S])%=mod;
				}
				if(ok2) {
					if(!(S>>j&1)) (f[cur][S]+=f[cur^1][S])%=mod;
				}
			}
		}
		cur^=1;
	}
	int ans=0;
	rep(S,0,(1<<n)-1) (ans+=f[cur][S])%=mod;
	printf("%d\n",ans);
  	return 0;
}


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

int n;

void CountingSort(int A[],int B[],int k){
	int C[k+1]={};
	
	for(int i=0;i<n;i++) C[A[i]]++;
	
	for(int i=1;i<=k;i++) C[i]+=C[i-1];
	
	for(int i=n-1;i>=0;i--){
		B[C[A[i]]-1]=A[i];
		C[A[i]]--;
	}
}

int main(){
	scanf("%d",&n);
	int A[n],B[n];
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	
	CountingSort(A,B,10000);
	
	for(int i=0;i<n;i++){
		if(i) printf(" ");
		printf("%d",B[i]);
	}
	printf("\n");
	
	return 0;
}



Measured memory_bytes: 18368
// Try  AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let h = get!(usize);
    let w = get!(usize);
    let mut xs = vec![];
    for _ in 0..h {
    	let x = get().as_bytes();
        if x.contains(&b'#') {
        	xs.push(x);
        }
    }
    
    let mut flag = vec![];
    for i in 0..w {
    	let mut ok = false;
        for j in 0..xs.len() {
        	if xs[j][i] == b'#' {
            	ok = true;
                break;
            }
        }
        flag.push(ok);
    }
    
    for i in 0..xs.len() {
    	for j in 0..w {
        	if flag[j] {
            	print!("{}", xs[i][j] as char);
            }
        }
        println!();
    }
    
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define int long long
#define sz(x) (int)x.size()
#define mp make_pair
#define fi first
#define se second
#define io ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;



signed main()
{
	string s,t;
	cin >> s >> t;
	int n = s.length();
	int m = t.length();
	int ans = hell;
	rep(i,0,n-m+1)
	{
		int j=i;
		int ct=0;
		rep(k,0,m)
		{
			if(t[k]!=s[j]) ct++;
			j++;
		}
		ans = min(ans,ct);
	}
	cout << ans<<endl;

}
 
	
		



Measured memory_bytes: 3624
#include <iostream>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#define ll long long
using namespace std;
const int N=1e6+10;
ll a,b,c,m,ans;


int main(){
  cin>>a>>b;
   if(a>b)   swap(a,b);
   m=a*b;
   c=b%a;
while(c!=0){
        b=a;
      a=c;
      c=b%a;
}
  ans=m/a;
  cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
### C

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

X = list(map(int , sorted(list(map(int , input().split())))))

#print("X = " + str(X))

D = []

R = 0

if M-1 > 0 :
	for i in range(M-1):
		D.append(int(X[i+1]) - int(X[i]))


#print("D = " + str(D))

if D !=[]:
	D = sorted(D)
	D = D[::-1]
	D = D[N-1:]
#print("D = " + str(D))

if D != []:
	for d in D:
		R += d


print(R)






Measured memory_bytes: 13968
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <cstring>
#include <set>
#include <map>
#include <algorithm>  
#include <cmath>
#include <iomanip>
#define ll long long
using namespace std;
ll mod=pow(10,9)+7;
ll dp[105][100005];
ll n,k;
ll arr[105];
ll calc(ll idx,ll candy)
{
    if(candy==k)
    {
        return 1;
    }
    if(candy>k)
    {
        return 0;
    }
    if(idx==n && candy!=k)
    {
        return 0;
    }
    if(dp[idx][candy]!=-1)
    {
        return dp[idx][candy];
    }
    ll total=arr[idx];
    //cout<<total<<endl;
    ll ans1=calc(idx+1,candy)+calc(idx,candy+1)-calc(idx+1,candy+1+total);
    dp[idx][candy]=(ans1+mod)%mod;
    return dp[idx][candy] %=mod;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    memset(dp,-1,sizeof(dp));
    cin>>n>>k;
    for(ll i=0;i<n;++i)
    {
        cin>>arr[i];
    }
    cout<<calc(0,0)<<endl;
}






































Measured memory_bytes: 93424
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    int counter = 0;

    for(size_t i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    int h_max = 0;
    for(size_t i = 0; i < v.size(); i++)
    {
        if(h_max <= v[i]){
            counter ++;
            h_max = v[i];
        }
    }
    cout << counter << endl;
    


    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [input() for _ in range(n)]
ans1 = float('inf')
for i in range(n):
    for j in range(n):
        if a[j][i] == '#':
            break
    else:
        continue
    break
else:
    print(-1)
    exit(0)
for i in range(n):
    cnt = 1
    for j in range(n):
        if a[j][i] == '#':
            cnt -= 1
            break
    for j in range(n):
        if a[i][j] == '.':
            cnt += 1
    ans1 = min(ans1, cnt)
ans2 = 0
for i in range(n):
    for j in range(n):
        if a[j][i] == '.':
            ans2 += 1
            break
if ans1 == float('inf'):
    print(-1)
else:
    print(ans1 + ans2)


Measured memory_bytes: 3444
#include<cstdio>
int main(){
int n;
scanf("%d",&n);
int a=n/1000;
int b=(n/100)%10;
int c=(n/10)%10;
int d=n%10;
for(int i=0;0==0;i++){

if(a+b+c+d==7){
printf("%d+%d+%d+%d=7\n",a,b,c,d);
break;
}

if(a+b+c-d==7){
printf("%d+%d+%d-%d=7\n",a,b,c,d);
break;
}

if(a+b-c+d==7){
printf("%d+%d-%d+%d=7\n",a,b,c,d);
break;
}

if(a+b-c-d==7){
printf("%d+%d-%d-%d=7\n",a,b,c,d);
break;
}

if(a-b+c+d==7){
printf("%d-%d+%d+%d=7\n",a,b,c,d);
break;
}

if(a-b+c-d==7){
printf("%d-%d+%d-%d=7\n",a,b,c,d);
break;
}

if(a-b-c+d==7){
printf("%d-%d-%d+%d=7\n",a,b,c,d);
break;
}

if(a-b-c-d==7){
printf("%d-%d-%d-%d=7\n",a,b,c,d);
break;
}
}
return 0;
}

Measured memory_bytes: 128