akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
   int n;
   cin>>n;
   vi a(n-1);
   rep(i,n-1)cin>>a[i];
   vector<int>ans(n+1,0);
   rep(i,n-1){
       ans[a[i]]++;
   }
   rep(i,n){
       cout<<ans[i+1]<<endl;
   }
}


Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string n,m;
  cin>>n>>m;
  if(n.at(0)==m.at(2)&&n.at(1)==m.at(1)&&n.at(2)==m.at(0)){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

ll N, K;
vector<ll> a;

bool solve(ll mid) {
    ll cnt = 0;
    for (int i = 0; i < N - 1; i++) {
        ll y = a[i];
        if (y >= 0) {
            auto p = [&](ll x) { return y * x <= mid; };
            auto ite = partition_point(a.begin(), a.end(), p);
            int j = ite - a.begin() - 1;
            cnt += max(0, j - i);
        } else {
            auto p = [&](ll x) { return y * x > mid; };
            auto ite = partition_point(a.begin(), a.end(), p);
            int j = ite - a.begin();
            if (j <= i)
                cnt += N - i - 1;
            else
                cnt += N - j;
        }
    }
    return (cnt >= K);
}

ll binary_search(ll ok, ll ng) {
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (solve(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    return ok;
}

int main() {
    cin >> N >> K;
    a.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << binary_search(1000000000000000000 + 1, -1000000000000000000 - 1) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair

int main()
{
  ll a;
  long double b;
  cin>>a>>b;
  long double ans=(long double)a*b;
  //cout<<ans<<endl;
  cout<<(ll)ans<<endl;
}


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

std::vector<int> A;
int n;

int maxHeapify(int i){
    int l, r, largest;
    l = 2 * i;
    r = 2 * i + 1;
    if(l <= n && A[l] > A[i]){
        largest = l;
    }else{
        largest = i;
    }

    if(r <= n && A[r] > A[largest]){
        largest = r;
    }

    if(largest != i){
        int tmp;
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
    }else{
        return 0;
    }

    maxHeapify(largest);
}

int main(void){
    std::cin >> n;
    A.resize(n+1);

    for(int i = 1; i <= n; i++){
        std::cin >> A[i];
    }

    for(int i = n/2; i > 0; i--){
        maxHeapify(i);
    }

    for(int i = 1; i <= n; i++){
        std::cout << " " << A[i];
    }
    std::cout << std::endl;
    
    return 0;
}


Measured memory_bytes: 4680
fun main(args:Array<String>){
    var (n,k)=listOfInt()
    var ans=0
    while(n>0){
        ans++
        n/=k
    }
    println(ans)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

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

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

  for (size_t i = 0; i < t.length(); i++) {
    if (t[i] == '?') t[i] = 'D';
  }

  cout << t << endl;
  return 0;
}


Measured memory_bytes: 3748
#include<iostream>
using namespace std;
 
int main(void){
    long long int N,n10=1,n9=1,n8=1,div=1000000007;
    cin>>N;
    for(int i=0;i<N;i++){
        n10=(n10*10)%div;
        n9=(n9*9)%div;
        n8=(n8*8)%div;
    }
    cout<<(n10-2*n9+n8+div*5)%div<<endl;    
    return 0;
}

Measured memory_bytes: 3620
#pragma GCC optimize(2)
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <list>
#include <climits>
#include <bitset>
#include <fstream>
#include <algorithm>
#include <functional>
#include <stack>
#include <string>
#include <cmath>
#define fi first
#define se second
#define re register
#define ls i << 1
#define rs i << 1 | 1
#define pb push_back
#define pii pair<int,int>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007

//#define int long long

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);

inline int rd(){
  int x = 0, f = 1; char ch = getchar();
  while (ch < '0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
  while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
  return x * f;
}

void out(int a) {
  if (a < 0) putchar('-'), a = -a;
  if (a >= 10) out(a / 10);
  putchar(a % 10 + '0');
}

//signed main(){
int main() {
  string s;
  cin >> s;
  if (s=="RRR") cout << "3\n";
  else if (s == "RRS" || s == "SRR") cout << "2\n";
  else if (s == "SSS") cout << "0\n";
  else cout << "1\n";
  return 0;
}


Measured memory_bytes: 3596
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BSs {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string s;
	    in >> s;

	    int res = 0;
	    int len = s.length()-2;
	    s = s.substr(0, len);
	    while(len >= 0){
	        string f = s.substr(0, len/2);
	        string b = s.substr(len/2, len);
	        if(f == b){
	            res = len;
	            break;
	        }
	        len -= 2;
	        s = s.substr(0, len);
	    }
	    out << res << endl;
	}
};


int main() {
	BSs solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
 
int main() {
  string s, t;
  cin >> s;
  cin >> t;
  
  int res = t.length();
  for(int i=0; i<s.length()-t.length()+1; i++){
    int op = 0;
    for(int j=0; j<t.length();j++){
      if(t.at(j) != s.at(i+j)){
        op++;
      }
    }
    res = min(res, op);
  }
  
  cout << res << endl;

  return 0; 
}

Measured memory_bytes: 3604
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long li;

const int maxn = 1e5;
int n, t[maxn];
int c, k;

int main(void) {
  scanf("%d%d%d", &n, &c, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", t + i);
  }
  sort(t, t + n);
  int satis = 0, ans = 0;
  while (satis < n) {
    int tick = t[satis] + k;
    int rest = c;
    while (satis < n && rest > 0 && t[satis] <= tick) {
      ++satis;
      --rest;
    }
    ++ans;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
s=0

for i in range(len(a)):
    for j in reversed(range(1,n)):
        if a[j]<a[j-1]:
            a[j-1],a[j]=a[j],a[j-1]
            s+=1
for i in range(n):
    if i==0:
        print(a[i],end="")
    else:
        print("{: }".format(a[i]),end="")
print()
print(s)



Measured memory_bytes: 5624
N = int(input())
A = [int(a) for a in input().split()]

def calc(X):
    if len(X) == 0:
        return [0, []]
    Y = [x for x in X]
    m = -1
    for i in range(len(Y)):
        if i+1 == Y[i]:
            m = i
    if m < 0:
        return [-1]
    
    del Y[m]
    r = calc(Y)
    if r[0] < 0:
        return [-1]
    
    return [0, r[1] + [m+1]]
    
r = calc(A)
if r[0] < 0:
    print(-1)
else:
    print(*r[1])
    
    

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

int main(){
  int a, b;
  cin >> a >> b;
  if((a == 1 && b == 2) || (a == 2 && b == 1)){
    cout << 3 << endl;
  }else if((a == 2 && b == 3) || (a == 3 && b == 2)){
    cout << 1 << endl;
  }else{
    cout << 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long int
#define f(i,a,b) for (int i= a; i <b; ++i)
using namespace std;


signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    int dp[n][m];
    char c;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>c;
            if(c=='#')
                dp[i][j]=-1;
            else
                dp[i][j]=0;
        }
    }
    for(int i=0;i<m;i++)
    {
        if(dp[0][i]==-1)
            break;
        dp[0][i]=1;
    }
    for(int i=0;i<n;i++)
    {
        if(dp[i][0]==-1)
            break;
        dp[i][0]=1;
    }
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<m;j++)
        {
           if(dp[i][j]==-1)
            continue;
           if(dp[i-1][j]!=-1)
            dp[i][j]+=dp[i-1][j];
           if(dp[i][j-1]!=-1)
            dp[i][j]+=dp[i][j-1];
           dp[i][j]=dp[i][j]%1000000007;
        }
    }
    cout<<dp[n-1][m-1];
}



Measured memory_bytes: 8064
#include"stdio.h"
int main()
{
	int a,b,max;
	int add,minus,m;
	while(scanf("%d%d",&a,&b)!=EOF)
	{
	max=add=a+b;
	minus=a-b;
	m=a*b;
	if(minus>max)
		max=minus;
	if(m>max)
		max=m;
	printf("%d\n",max);
	}
}

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

using namespace std;

int main() {
	string n;
	cin >> n;
	string s = n;
	reverse(s.begin(), s.end());
	if (n == s) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
CD = [list(map(int, input().split())) for _ in range(M)]
for i in range(N):
    res = 1000000000
    tidx = 0
    for j in range(M):
        dist = abs(AB[i][0]-CD[j][0]) + abs(AB[i][1]-CD[j][1])
        if res > dist:
            res = dist
            tidx = j+1
    print(tidx)


Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
using namespace std;
int A[210000];
int main(){
    int N;scanf("%d",&N);
    for(int i=0;i<N;i++)scanf("%d",A+i);
    std::sort(A,A+N);
    for(int i=0;i<N-1;i++){
        if(A[i]==A[i+1]){
            printf("NO\n");return 0;
        }
    }
    printf("YES\n");
}

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

int main() {
    string S, T;
    cin >> S >> T;

    if(S.size()+1!=T.size()) {
        cout << "No" << endl;
        return 0;
    }
    string ans = "Yes";
    for (int i = 0; i < S.size(); i++) {
        if(S[i]!=T[i]) ans="No";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <sstream>
using namespace std;
#define rep(i,n) for (int i=0; i<n; i++)
typedef long long ll;


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

    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> b(n);
    rep(i,n) cin >> b[i];
    vector<int> c(n-1);
    rep(i,n-1) cin >> c[i];
    rep(i,n) a[i]--;
    int ans = 0;

    rep(i,n){
        ans += b[a[i]];
        if (a[i]+1 == a[i+1]){
            ans += c[a[i]];
        }
    }

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

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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 end

void solve(){
    ll a,b; scanf("%lld%lld",&a,&b);
    if(a==b){
        printf("%lld\n",2*a-2); return;
    }
    ll n=a*b-1,lb=1,rb=inf*2;
    while(rb-lb>1){
        ll mid=(lb+rb)/2;
        ll sum=(mid+1)/2*(mid+1-(mid+1)/2);
        (sum>n?rb:lb)=mid;
    }
    printf("%lld\n",lb-1);
}

int main(){
    int q; scanf("%d",&q);
    rep(rot,0,q)solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t; cin >> s >> t;
  auto test = [](string s, string t) {
                assert(s.size() == t.size());
                rep(i, s.size()) {
                  if(s[i] != '?' && s[i] != t[i]) return false;
                }
                return true;
              };
  string ans;
  rep(i, s.size()-t.size()+1) {
    string sub = s.substr(i, t.size());
    if(test(sub, t)) {
      string s2 = s;
      rep(j, t.size()) s2[i+j] = t[j];
      rep(j, s2.size()) if(s2[j] == '?') s2[j] = 'a';
      if(ans == "") {
        ans = s2;
      } else {
        chmin(ans, s2);
      }
    }
  }
  if(ans == "") cout << "UNRESTORABLE" << endk;
  else cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3640
<?php
// D
fscanf(STDIN, '%d', $n);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
sort($a);
$l = $a[$n - 1];
unset($a[$n - 1]);
$d = PHP_INT_MAX;
foreach ($a as $v) {
    $td = abs($l / 2 - $v);
    if ($td < $d) {
        $d = $td;
        $r = $v;
    }
}
echo implode(' ', [$l, $r]);

Measured memory_bytes: 17012
x = int(input())
p_list = {}

# nの素因数のリストを作るn=4で[2,2]
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

# 階乗なので1からxまでやる
for i in range(1,x+1):
  #print("------------i, prime_factors(i)", i, prime_factors(i))
  # iの素因数を何がいくつあるかカウントしていくi=4で[2,2]でp_list[2]=2
  for k in prime_factors(i):
    p_list[k] = p_list.get(k, 0) + 1
    #print("===i, k:", i, k)
    #print("p_list[k], p_list.get(k, 0):", p_list[k], p_list.get(k, 0))
#print("=======")
#print("p_list", p_list)


divn = 1e9+7
ans = 1
# 素因数の数に1を足して乗じていく(約数の数)
for k in p_list.keys():
    ans *= p_list[k] + 1
    ans = ans % divn

print(int(ans))

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

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

const i64 mod = 1e9 + 7;
i64 fact_memo[300001];
i64 fact(i64 x) {
  if (x == 0) return 1;
  if (fact_memo[x]) return fact_memo[x];
  return fact_memo[x] = x * fact(x - 1) % mod;
}
i64 ipow(i64 a, i64 b) {
  return (b & 1 ? a : 1) * (b > 1 ? ipow(a * a % mod, b >> 1) : 1) % mod;
}
i64 inv(i64 x) {
  return ipow(x, mod - 2);
}
i64 n, x, y;
vector<vector<i64>> bs;
int main() {
  cin >> n >> x >> y;
  init_n(bs, n + 1);
  for (i64 i = 0; i < n; ++i) {
    i64 c, w;
    cin >> c >> w;
    bs[c].push_back(w);
  }

  // (c, w)
  vector<pair<i64, i64>> mins;
  for (i64 c = 1; c <= n; ++c) {
    if (bs[c].empty()) continue;
    sort(begin(bs[c]), end(bs[c]));
    mins.emplace_back(c, bs[c][0]);
  }
  sort(begin(mins), end(mins), [](auto p, auto q) 
      { return p.second < q.second; });

  i64 cnt = 0, q = 1;
  for (i64 c = 1; c <= n; ++c) {
    if (bs[c].empty()) continue;
    i64 min_w;
    if (c == mins[0].first) min_w = mins[1].second;
    else min_w = mins[0].second;
    if (bs[c][0] + min_w > y) continue;
    i64 cnt_c = 0;
    for (i64 i = 0; i < bs[c].size(); ++i) {
      if ((i > 0 && bs[c][i] + bs[c][0] <= x) || bs[c][i] + min_w <= y) {
        ++cnt_c;
      }
    }
    cnt += cnt_c;
    (q *= fact(cnt_c)) %= mod;
  }

  i64 ans = fact(cnt) * inv(q) % mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 16496
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod 1000000007
#define pb emplace_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define test(t) ll t;cin>>t;while(t--)
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
#define fr(i,n) for(ll i=0;i<(n);++i)
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
const int N = 401;
ll dp[N][N];
ll pre[N][N];
ll n,c;
ll arr[N];
ll brr[N];
ll func(ll ind,ll rem)
{
    if(ind==n)
        return rem==0;
    ll &ret = dp[ind][rem];
    if(ret!=-1)
        return ret;
    ret = 0;
    for(ll i=0;i<=rem;i++)
    {
        ll temp = pre[i][brr[ind]]-pre[i][arr[ind]-1];
        temp+=mod;
        temp%=mod;
        ret = ret+temp*func(ind+1,rem-i)%mod;
        ret%=mod;
        // pr(ret,temp,func(ind+1,rem-i),rem,i,ind);
    }
    return ret;
}
signed main()
{
    fast;
    ll i,j;
    for(i=0;i<N;i++)
    {
        for(j=1;j<N;j++)
        {
            pre[i][j] = power(j,i);
            pre[i][j]+=pre[i][j-1];
            pre[i][j]%=mod;
        }
    }
    cin>>n>>c;
    fr(i,n)cin>>arr[i];
    fr(i,n)cin>>brr[i];
    mem(dp,-1);
    cout<<func(0,c);
    
}


Measured memory_bytes: 2816
package main

import (
	. "fmt"
)

// func init() { Println("----------------------------------------") }

func main() {
    var a, b, c int
    Scanf("%d %d %d", &a, &b, &c)
    if a + b >= c {
        Println("Yes")
    } else {
        Println("No")
    }
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
   int l,r,d;
   cin>>l>>r>>d;
   int x=l/d;
   int ans=0;
   for(;x*d<=r;x++)
   {
       if(x*d>=l&&x*d<=r)
        ans++;
   }
   cout<<ans;

}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            var stack = new Stack<string>(10);
            for(string num; (num = Console.ReadLine()) != null; ) {
                if(num == "0") {
                    Console.WriteLine(stack.Pop());
                } else {
                    stack.Push(num);
                }
            }
        }
    }
}

Measured memory_bytes: 5580
// aribon3-5_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1ll << 40)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

// dinic
template <typename T = long long>
struct Dinic {
    struct edge { int to; T cap; int rev; };
    vector<vector<edge>> G;
    vector<int> itr, level;
    int n;
    T inf;

    explicit Dinic(int n): n(n), G(n) {inf=numeric_limits<T>::max();}

    void add_edge(int from, int to, T cap) {
        G[from].push_back((edge) {to, cap, (int) G[to].size()});
        G[to].push_back((edge) {from, 0, (int) G[from].size()-1});
    }

    void bfs(int s) {
        level.assign(n, -1);
        queue<int> q;
        level[s] = 0;
        q.push(s);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (auto &e: G[v]) {
                if (e.cap > 0 and level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    q.push(e.to);
                }
            }
        }
    }

    T dfs(int v, int t, T f) {
        if (v == t) return f;
        for (int& i = itr[v]; i < (int) G[v].size(); ++i) {
            edge& e = G[v][i];
            if (e.cap > 0 and level[v] < level[e.to]) {
                T d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    T max_flow(int s, int t) {
        T ret = 0, f;
        while (bfs(s), level[t] >= 0) {
            itr.assign(n, 0);
            while ((f = dfs(s, t, inf)) > 0) ret += f;
        }
        return ret;
    }
};

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> A(N+1);
    REPN(i, 1, N+1) cin >> A[i];

    auto dinic = Dinic<ll>(N+3);

    int s = N+1, t = s+1;
    ll ans = 0;
    REPN(n, 1, N+1) {
        if (A[n] > 0) {
            ans += A[n];
            dinic.add_edge(n, t,  A[n]);
        } else {
            dinic.add_edge(s, n, -A[n]);
        }
        int a = n;
        while ((a+=n) <= N) {
            dinic.add_edge(n, a, INF);
        }
    }

    ans -= dinic.max_flow(s, t);
    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
using namespace std;
using llong = long long;

llong n, m, v, p;
llong a[100005];
llong sum[100005];
llong b;
llong ans;
llong upsum;
llong eqsum;

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

    sort(a, a + n);
    b = a[n - p];
    for (int i = 0; i < n; i++) {
        if (a[i] > b) upsum++;
        if (a[i] == b) eqsum++;
        sum[i + 1] = sum[i] + a[i];
    }

    for (int i = 0; i < n; i++) {
        if (a[i] >= b) {
            ans++;
            continue;
        }
        llong s = a[i] + m;
        llong tmp = m * v;
        
        tmp -= m;
        tmp -= (p - 1) * m;
        tmp -= i * m;
        if (tmp <= 0 && s >= b) {
            ans++;
            continue;
        }
        
        llong idx = upper_bound(a, a + n - p + 1, s) - a;
        idx--;
        tmp -= s * (idx - i) - (sum[idx + 1] - sum[i + 1]);
        if (tmp <= 0 && s >= b) {
            ans++;
            continue;
        }
    }

    //cout << a[i] << ' ' << tmp << endl;

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


Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))
A = [val - 1 for val in A]
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = B[A[0]]
for i in range(1, N):
    ans += B[A[i]]
    if A[i] == A[i - 1] + 1:
        ans += C[A[i - 1]]

print(ans)

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

int main() {
  int d, t, s;
  string result;
  cin >> d >> t >> s;
  
  if(d <= t*s){
    result = "Yes";
  }else{
    result = "No";
  }
    

  cout << result << endl;
}


Measured memory_bytes: 3620
n = int(input())

a = []
b = []

for i in range(n):
    A, B = [int(i) for i in input().split()]
    a.append(A)
    b.append(B)

works = []

for i in range(n):
    works.append((b[i], a[i]))

works.sort()

t = 0
end = False

for b, a in works:
    t += a
    if t > b:
        print('No')
        end = True
        break

if not end:
    print("Yes")

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

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

    int sum = 0;
    for (int i = 0; i < 3; i++) { 
        if (str.at(i) == '1') {
            sum++;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n;
  cin >> n;
  int k;
  cin >> k;
  int l[k];
  int r[k];
  rep(i,k)cin >> l[i] >> r[i];
  ll p=998244353;
  ll dp[n];
  dp[0]=1;
  rep(i,n-1)dp[i+1]=0;
  ll m[n+1];
  rep(i,n+1)m[i]=0;
  m[0]=0;
  m[1]=1;
  rep(i,n-1){
    m[i+2]=m[i+1];
    rep(j,k){
      if(i+2-l[j]>0){
        m[i+2]=(m[i+2]+m[i+2-l[j]]-m[max(0,i+1-r[j])]+p)%p;
      }
    }
  }
  //rep(i,n+1)cout << m[i] << endl;
  cout << (m[n]-m[n-1]+p)%p << endl;
}


Measured memory_bytes: 6712
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	string N;
	cin >> N;
	if (N[0] == '9' || N[1] == '9') {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
/* Author:- Neel_Patel */
#include <bits/stdc++.h>
#define ff first 
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vll vector<long long>
#define pri priority_queue
#define sp fixed<<setprecision
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
const long double pi=3.14159265358979323846;
const int inf=INT_MAX;
////////////////////////////////////////
void solve()
{
	int n;
  cin>>n;
  int ans1=n%1000;
  int ans2=1000-ans1;
  
  //cout<<min(ans1%1000,ans2%1000)<<endl;
  cout<<(1000-n%1000)%1000<<endl;
}
////////////////////
int main() {
    fast;
	int t=1;
	 //cin>>t;
	while(t--)   solve();

	return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <queue>

int main(){
	int n,m;
	while(std::cin >> n >> m){
		if(n == 0 && m == 0){
			break;
		}
		std::priority_queue<int> que;
		int vegetable;
		for(int i = 0; i < n; ++i){
			std::cin >> vegetable;
			que.push(vegetable);
		}
		int price = 0;
		for(int i = 0; i < n; ++i){
		    if((i % m) != (m - 1)){
	  	        price += que.top();
		    }
		    que.pop();
		}
		std::cout << price << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <complex>
 
using namespace std;
 
int main()
{
    string s;
    char m[13]={0},p=0,d,pm;
    cin>>s;
 
    for(unsigned int i=0;i<s.size();i++){
        d=s[i]/10-p;
 
        for(int j=0;j<abs(d);j++){
            if(d>0) cout<<">";
            else cout<<"<";
        }
        if(m[d+p]==0){
            for(int j=0;j<(d+p)*10;j++) cout<<"+";
            m[d+p]=(d+p)*10;
        }
 
        pm=(s[i]>m[d+p]) ? '+' : '-';
        for(char j=0;j<abs(s[i]-m[d+p]);j++){cout<<pm;}
        cout<<"."; m[d+p]=s[i]; p+=d;
    }
 
    return 0;
}

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

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

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

int main(){
    int n,m;
    int t;
    int sum = 0;

    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> t;
        sum += t;
    }
    if(n-sum >= 0){
        cout << n-sum << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

int n,m,q;
int query[55][4];

ll score(vector<int> &A) {
    ll ret = 0;
    rep(i,q) {
        if(A[query[i][1]-1] - A[query[i][0]-1] == query[i][2]) ret += query[i][3];
    }
    return ret;
}

ll dfs(vector<int> &A) {
    if(A.size() == n) {
        return score(A);
    }
    ll ret=0;
    int last;
    if(A.size()==0) last = 1;
    else last = A[A.size()-1];

    for(int i = last;i<=m;i++) {
        A.push_back(i);
        ret = max(ret,dfs(A));
        A.pop_back();
    }
    return ret;
}

int main() {
    // int n,m,q;
    cin>>n>>m>>q;
    // int query[55][4];
    rep(i,q) {
        rep(j,4) {
            cin>>query[i][j];
        }
    }
    vector<int> A;
    cout<<dfs(A)<<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int n;
	cin >> n;
	vector<int> a(n), b(n);

	rep(i, n) cin >> a[i] >> b[i];

	sort(begin(a), end(a));
	sort(begin(b), end(b));

	if(n % 2 == 0) {
		int amid = a[n / 2 - 1] + a[n / 2];
		int bmid = b[n / 2 - 1] + b[n / 2];
		cout << bmid - amid + 1 << endl;
	} else {
		int amid = a[n / 2];
		int bmid = b[n / 2];
		cout << bmid - amid + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 4824
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
void chmin(int &a, int b) { if (a > b) a = b; }

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
char da[4] = { 'R', 'L', 'D', 'U' };
char dax[4] = { -1, 1, -1, 1 };
char dax2[4] = { 1, -1, 1, -1 };
ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }



int main() {
	ll N, A, B, C, D;
	string S;


	cin >> N >> A >> B >> C >> D;
	cin >> S;
	A--, B--, C--, D--;
	bool flag = false;
	rep(i, S.size() - 1) {

		if (S[i] == '#' && S[i + 1] == '#' && ((A < i && i < C) || (B < i && i < D))) {
			cout << "No" << endl;
			return 0;
		}



	}

	if (C < D) {
		cout << "Yes" << endl;

	}

	else {

		rep(i, S.size() - 2) {
			if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.' && (B-1 <= i && i <= D-1)) {
				flag = true;
				break;
			}

		}

		if (flag == true)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;

	}


	return 0;

}

Measured memory_bytes: 640
import sys
def fin_then_output(i):
  if count==n:
    print(ll[i][-1])
    sys.exit()
    
n=int(input())
if n<10:
  print(n)
  sys.exit()
count=9
ll=[[] for _ in [0]*10]#最大10ケタ
ll[0]=[str(i) for i in range(1,10)] #1~9
for i in range(1,10): #貰う
  for j in range(len(ll[i-1])):#前の行の1つ1つの要素にアクセス。
    #1つ小さいケトを持つルンルン数を小さい順に取り出し、
    #末尾の数字-1,±0,+1した数字を順番に末尾に追加する。
    #-1した数字
    m = int(ll[i-1][j][-1])
    if m!=0:
      ll[i].append(ll[i-1][j]+str(m-1))
      count+=1
      fin_then_output(i)
    ll[i].append(ll[i-1][j]+str(m))
    count+=1
    fin_then_output(i)
    if m!=9:
      ll[i].append(ll[i-1][j]+str(m+1))
      count+=1
      fin_then_output(i)

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

const int maxn=2e5+5;
int a[maxn];
int dp[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}	
	int tot=0;
	dp[1] = 1;
	int sml = a[1];

	for(int i=2;i<=n;i++)
	{
		if(a[i]>=sml) 
		{
			dp[i] = dp[i-1];
		}
		else
		{
			sml = a[i];
			dp[i] = dp[i-1]+1;
		}
	}	
	cout<<dp[n]<<"\n";
}

Measured memory_bytes: 1792
N, K = map(int, input().split())
A = list(map(int, input().split()))

np = [0]*40

for i in range(40):
  for j in A:
    if j&(1<<i):
      np[i] += 1

v = 0
for i in range(39,-1,-1):
  if v + (1<<i) > K:
    continue
  elif np[i] < N - np[i]:
    v += (1<<i)
    
ans = 0
for i in A:
  ans += (v^i)

print(ans)


Measured memory_bytes: 15272
require 'set'
s = gets.chomp.chars
K = gets.to_i

set = SortedSet.new()
used = {}
(0...(s.size)).each do |i|
  (i...([i + K, s.size].min)).each do |j|
    subs = s[i..j]
    set.add(subs)
  end
end
puts set.to_a[K - 1].join('')


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

int gcd(int a,int b){
    if(a>=b){
        if(b==0){return a;}
        else{
            return gcd(a%b,b);
        }
    }
    else{
        return gcd(b,a);
    }
}

int main(){
    int a,b;
    while(cin>>a>>b){
        int gcd_=gcd(a,b);
        long long lcm=a/gcd(a,b)*b;
        cout<<gcd_<<" "<<lcm<<"\n";
    }
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert
#ifdef LOCAL
template <class T, class S>
ostream &operator<<(ostream &str, const pair<T, S> &p) {
  return (str << "{" << p.fi << ", " << p.se << "}");
}
template <template <class...> class Container, class... T>
ostream &operator<<(ostream &str, const Container<T...> &vec) {
  str << '[';
  for (auto it = vec.begin(); it != vec.end(); it++) {
    if (it != vec.begin())
      str << ", ";
    str << *it;
  }
  str << ']';
  return str;
}
#define var(x) "[" << #x << ": " << x << "] "
struct dbg {
  dbg() { cout << "  "; }
  ~dbg() { cout << endl; }
  template <class T> dbg &operator<<(T oth) {
    cout << oth;
    return *this;
  }
};
#else
#define var(x) 0
struct dbg {
  template <class T> dbg &operator<<(T oth) { return *this; }
};
#endif
using ll = long long;
using ull = unsigned long long;
using ld = long double;
int main(int argc, char **argv) {
  //ios::sync_with_stdio(false), cin.tie(0);
  auto solve = [&]() {
    ll n;
    cin >> n;
    map<string, int> ans;
    string r[] = { "AC", "WA", "TLE", "RE" };
    while (n--) {
      string s;
      cin >> s;
      ++ans[s];
    }
    
    for (int i = 0; i < 4; i++) {
      printf("%s x %d\n", r[i].c_str(), ans[r[i]]);
    }
  };
  int t;
  t = 1;
  while (t--)
    solve();
  return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, A, B;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> A >> B;
    N %= 2 * 2 * 2 * 2 * 2 * 2 * 3 * 3 * 3 * 3;
    for(int i = 1; i <= N; i++) {
        if(i & 1) {
            A = A - B;
        } else {
            B = A + B;
        }
    }
    cout << A << " " << B << endl;
    return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

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

    ll x1=1000000000;
    ll x2=1;

    ll y2=(s+x1-1)/x1;
    ll y1=(x1*y2-s);

    cout<<0<<" "<<0<<" "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<endl;

}

Measured memory_bytes: 3612
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))
cnt = 0
new = [0 for i in range(N)]
for ab in AB:
    if H[ab[0]-1] <= H[ab[1]-1]:
        new[ab[0]-1] += 1
    if H[ab[0] - 1] >= H[ab[1] - 1]:
        new[ab[1]-1] += 1
print(new.count(0))

Measured memory_bytes: 31964
import Data.Array
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine

getIntList = readIntList <$> BS.getLine

ela a b
  | a == b = a
  | a > b && ab == 0 = b
  | a > b = ela ab b
  | a < b && ba == 0 = a
  | a < b = ela a ba
  where
    ab = a `mod` b
    ba = b `mod` a

calc :: [Int] -> Int -> Int
calc [] k = k
calc (a : as) k
  | k == 1 = 1
  | k == (-1) = calc as a
  | otherwise = calc as (ela a k)

main = do
  n <- getInt
  as <- getIntList
  let as' = sort as
  print $ calc as' (-1)


Measured memory_bytes: 21068
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n+1,0);
    vector<ll> b(n+1);
    for(ll i=1;i<=n;i++)
    cin>>a[i]>>b[i];

    vector<vector<ll> > dp(n+1,vector<ll> (k+1,0));
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<=k;j++)
        {
            if(a[i]<=j)
            {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i]]+b[i]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
            
        }
    }

    // for(ll i=1;i<=n;i++)
    // {
    //     for(ll j=1;j<=k;j++)
    //     cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    cout<<dp[n][k]<<endl;

    
}

Measured memory_bytes: 83140
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から
#define REP(i,N) for(int j=i;j<N;j++) //iから

typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

#define MOD ((ll)1e+9 + 7)




//cout<<fixed<<setprecision(10);
int main(){
    int n;
    cin>>n;
    vector<pair<string,pair<int,int>>> m(n);
    rep(i,n){
        cin>>m[i].first>>m[i].second.first;
        m[i].second.first*=-1;
        m[i].second.second=i+1;
    }
    sort(m.begin(),m.end());
    rep(i,n){
        cout<<m[i].second.second<<endl;
    }

    return 0;
}



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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    string s;
    cin >> s;
    int cnt0 = 0, cnt1 = 0;
    rep(i, s.size())
    {
        if (s[i] == '0')
            cnt0 += 1;
        else
            cnt1 += 1;
    }

    OP(2 * min(cnt0, cnt1));
    return 0;
}

Measured memory_bytes: 512
# coding: utf-8
# hello worldと表示する
import sys
import numpy
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
from copy import deepcopy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

d,g=MI()
lis=[LI() for i in range(d)]
answers=[]
for i in product([0,1],repeat=d):
    new_lis=deepcopy(lis)
    point=0
    problems=0
    for j in range(d):
        if i[j]==1:
            point+=lis[j][1]+100*(j+1)*(lis[j][0])
            problems+=lis[j][0]
            new_lis[j][0]=0
        else:
            if new_lis[j][0]>0:
                new_lis[j][0]-=1
    #print(new_lis)
    flag=True
    for j in range(d):
        k=d-j-1
        if point>=g:
            answers.append(problems)
            flag=False
            break
        else:
            req=(g-point)//(100*(k+1))
            #print(req)
            if new_lis[k][0]>=req:
                problems+=req
                point+=req*100*(k+1)
            else:
                problems+=new_lis[k][0]
                point+=new_lis[k][0]*100*(k+1)
    if point>=g and flag==True:
        answers.append(problems)
#print(answers)
print(min(answers))            

Measured memory_bytes: 20688