akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

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



int main() {
    int N;
    cin >> N;
    int M = 100;
    vector<ll> L(M,0);
    
    L[0] = 2LL; L[1] = 1LL;
    for ( int i = 2; i < M; ++i){
        L[i] = L[i-1] + L[i-2];
    }
    cout << L[N] << endl;
    
    
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int kai=n;
    if(kai==2){
        cout<<2<<endl;
        return 0;
    }
    if(kai%2==0){
        kai=kai+1;
    }
    
    int con;
    for(int i=kai;;i+=2){
        con=0;
        for(int j=3;j<i;j+=2){
            if(i%j==0){
                con++;
            }
            if(con>=1){
                break;
            }
            
        }
        if(con==0){
            cout<<i<<endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
using namespace std;

int main(void) {
	double R,G,P;
	cin >> R >> G;

	P = (2 * G) - R;
	cout << P << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define f first
#define s second
#define mk make_pair
#define MOD 1000000007
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin>>n;
  vector<pair<string,ll>> m;
  string s;
  ll tem;
  for(ll i=0;i<n;i++)
  {
    cin>>s;
    cin>>tem;
    m.pb({s,tem});
  }
  string x;
  cin>>x;
  ll gotit,ans=0;
  for(ll i=0;i<n;i++)
  {
    if(m[i].f==x)
    {
      gotit=i;
      break;
    }
  }
  for(ll i=gotit+1;i<n;i++)
  {
    ans+=m[i].s;
  }
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict


n, m = map(int, input().split())
*h, = map(int, input().split())
d = defaultdict(list)
for i in range(m):
    a, b = map(int, input().split())
    d[a - 1].append(b - 1)
    d[b - 1].append(a - 1)
# print(d)
ans = 0

for i in range(n):
    is_good = True
    for lighthouse in d[i]:
        # print(f"{i}: {h[i]} vs. {lighthouse}: {h[lighthouse]}")
        if h[i] > h[lighthouse]:
            continue
        is_good = False
        # print(f"{i} is not good.")
        break

    if is_good:
        # print(f"{i} is good.")
        ans += 1

print(ans)

Measured memory_bytes: 39648
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<ll>a(n); 
  rep(i,n)cin>>a[i];
  ll sum=0;
  rep(i,n)sum+=a[i];
  ll tmp=0;
  vector<ll>ans(n);
  for(int i=1;i<n;i+=2){
    tmp+=a[i];
  }
  ans[0]=sum-2*tmp;
  for(int i=1;i<n;i++){
    ans[i] = 2*a[i-1]-ans[i-1];
  }
  rep(i,n)cout<<ans[i]<<endl;
}

Measured memory_bytes: 4836
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var buf = new string[h];
        var ha = new bool[h];
        var wa = new bool[w];
        for (int i = 0; i < h; i++)
        {
            var s = Console.ReadLine().Trim();
            buf[i] = s;
            for (int j = 0; j < w; j++)
                if (s[j] == '#') { wa[j] = true; ha[i] = true; }
        }
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++)
                if (ha[i] && wa[j])
                    if (j != w - 1) Console.Write(buf[i][j]);
                    else Console.WriteLine(buf[i][j]);
                else if (ha[i] && j == w - 1) Console.WriteLine();
    }
}

Measured memory_bytes: 13140
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
//#define ll long long
#define ull  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 340000;
int K = 25;
int a[N], b[N], used[N], c[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        a[i] = -a[i];
    }
    int ans = 0;
    K = 25;
    for (int i = 0; i < K; i++){
        for (int j = i + i + 2; j <= K; j += (i + 1))
            c[i] |= (1 << (j - 1));
    }
    for (int i = 0; i < (1 << K); i++){
        int q = 1;
        for (int j = 0; j < K; j++) if ((i & (1 << j)) != 0 && (c[j] & i) != 0){
          	q = 0;
          	break;
        }
        if (!q) continue;
        int s = 0;
        for (int j = 1; j <= n; j++){
            b[j] = a[j];
            used[j] = 0;
        }
        for (int j = 0; j < K; j++) if (i & (1 << j))
        for (int l = j + 1; l <= n; l += (j + 1)){
            s += b[l];
            b[l] = 0;
        }
        for (int j = K + 1; j <= n; j++){
            if (used[j]) continue;
            int x, y, z, t;
            if (3 * j <= n){
                x = b[j];
                y = b[j + j];
                z = b[j + j + j];
                if (j % 2 == 0){
                    t = b[3 * j /2];
                    s += max({1LL * 0, y,  z, y + z, x + y + z, x + y + z + t, z + t, y + z + t});
                    used[j] = used[j + j] = used[j + j + j] = used[(j + j + j) / 2] = 1;
                } else
                {
                    s += max({1LL * 0, y, z, y + z, x + y + z});
                    used[j] = used[j + j] = used[j + j + j] = 1;
                }
            } else
            if (j + j <= n){
                x = b[j];
                y = b[j + j];
                s += max({1LL * 0, x + y, y});
                used[j] = 1;
                used[j + j] = 1;
            } else{
                x = b[j];
                used[j] = 1;
                s += max(1LL * 0, x);
            }
        }
        ans = max(ans, s);
    }
    for (int i = 1; i <= n; i++) ans -= a[i];
    cout << ans << endl;
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 1e18+1
const ll mod=998244353;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n,k;
    cin>>n>>k;
    map<ll,ll> mp;
    fr(i,0,k)
    {
        ll d;
        cin>>d;
        fr(i,0,d)
        {
            ll x;
            cin>>x;
            mp[x]=1;
        }
    }
    ll ct=0;
    fr(i,1,n+1)
    {
        if(!mp.count(i))
        {
            ct++;
        }

    }
    cout<<ct<<endl;
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <string>
#include <cmath>
#define PI 3.14159265359
using namespace std;

int main()
{
	char tmpstr[20] = { NULL };

	cin >> tmpstr;
	int len = 0;
	while (tmpstr[len] != NULL) {
		++len;
	}

	for (int i = len - 1; i >= 0; --i) {
		cout << tmpstr[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

/* 探索
void solve() {
  int m;
  cin >> m;
  int n = 1 << (m + 1);
  vector<int> v;
  rep(i, n / 2) rep(j, 2) v.eb(i);
  do {
    int ans = -1;
    [&]() {
      rep(i, n) {
        rep3(j, i + 1, n) {
          if (v[j] == v[i]) {
            int tmp = 0;
            rep3(k, i, j + 1) tmp ^= v[k];
            if (ans == -1) ans = tmp;
            else {
              if (ans != tmp) return;
            }
          }
        }
      }
      cout << ans << "  " << v << endl;
    }();
  } while (next_permutation(all(v)));
}
*/

void solve() {
  int m, k;
  cin >> m >> k;
  int n = 1 << (m + 1);

  if (k >= n / 2) {
    cout << -1 << endl;
    return;
  }
  if (k == 0) {
    rep(i, n / 2) rep(j, 2) cout << i << " ";
    cout << endl;
    return;
  }
  int ans = 0;
  rep(i, n / 2) {
    if (i == k) continue;
    ans ^= i;
  }
  if (ans != k) {
    cout << -1 << endl;
    return;
  }
  cout << k << " ";
  rep(i, n / 2) {
    if (i == k) continue;
    cout << i << " ";
  }
  cout << k << " ";
  for (int i = n / 2 - 1; i >= 0; --i) {
    if (i == k) continue;
    cout << i << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
	int n, b, f, r, v;
	int hotel[5][4][11] = {0};

	fflush(stdout);
	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		scanf("%d %d %d %d", &b, &f, &r, &v);
		hotel[b][f][r] += v;
	}

	for(b = 1; b < 5; b++){
		for(f =1 ; f < 4; f++){
			for(r = 1; r < 11; r++){
				printf(" %d", hotel[b][f][r]);
			}
			printf("\n");
		}
		if (b != 4) puts("####################");
	}

	return 0;
}


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

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b) swap(a,b);
    if(b>c) swap(b,c);
    if(a>b) swap(a,b);
    a=a*a;
    b=b*b;
    c=c*c;
    if(a+b==c)
      cout<<"YES"<<endl;
    else 
      cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;
const int MOD = 1000000007;

const int MAX_N = 2010;
const int MAX_M = 2010;
ll d[MAX_N][MAX_M + 1];

int main() {
  ll n,k;
  cin >> n >> k;
  ll x,y;
  x = n%k;
  y = k-x;
  cout << min(x,y) << endl;
}

Measured memory_bytes: 256
n = int(input())
list_a = list(map(int, input().split()))
dict_a = {}
for i in range(n):
    try:
        dict_a[list_a[i]] += 1
    except KeyError:
        dict_a[list_a[i]] = 1
key_list = []
for key,value in dict_a.items():
    if 2 <= value <= 3:
        key_list.append(key)
    elif 4 <= value:
        key_list.append(key)
        key_list.append(key)
key_list.sort()
try:
    print(key_list[-1] * key_list[-2])
except IndexError:
    print(0)


Measured memory_bytes: 17960
package main

import (
	"fmt"
)

func main() {
	var x, k, d int
	fmt.Scan(&x, &k, &d)
	if k <= abs(x)/d {
		fmt.Println(abs(x) - k*d)
	} else {
		a := abs(x) % d
		b := (abs(x) - a) / d
		if (k-b)%2 == 0 {
			fmt.Println(a)
		} else {
			fmt.Println(abs(d - a))
		}
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1772
import java.util.Scanner;

public class Main {
	
	public static void main( String[]args ){
		
		Scanner sc = new Scanner( System.in );
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] ball_count = new int[n];
		boolean[] red_flag = new boolean[n];
		
		for( int t = 0;t < n;t++ ){
			ball_count[t] = 1;
			if( t == 0 )
				red_flag[0] = true;
			else
				red_flag[t] = false;
		}
		
		
		for( int i = 0;i < m;i++ ){
			int x_i = sc.nextInt();//移動元
			int y_i = sc.nextInt();//移動先
			
			if( red_flag[x_i - 1] )
				red_flag[y_i - 1] = true;
			
			ball_count[x_i - 1] -= 1;
			ball_count[y_i - 1] += 1;
			
			if( ball_count[x_i - 1] == 0 )
				red_flag[x_i - 1 ] = false;
			
		}
		
		int count = 0;
		
		for( boolean a : red_flag ){
			
			if( a )
				count++;
			
		}
		
		System.out.println(count);
		
	}

}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const int N = 1e6+5;
string s;
int v[N];
int n,k;
int l[N],r[N];
priority_queue<int> pq;

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> k;
  rep(i,n) cin >> v[i];
  int ans = 0;
  rep(i,n+1) {
    for(int j=0; i+j <= min(k,n); j++) {
      vector<int> vec;
      rep(x,i) vec.push_back(v[x]);
      rep(x,j) vec.push_back(v[n-x-1]);
      sort(vec.rbegin(), vec.rend());
      int k2 = k - i - j;
      while(k2 > 0 && !vec.empty() && vec.back() < 0) {
        vec.pop_back(); k2--;
      }
      int sum = 0;
      for(int x : vec) sum += x;
      ans = max(ans, sum);
    }
  }


  cout << ans << endl;
}


Measured memory_bytes: 2304
#include<stdio.h>
#define N 10

int main(void)
{
    int w[N], k[N];
    int i, j, temp1, temp2;

    for(i=0; i<N; i++) scanf("%d", &w[i]);
    for(i=0; i<N; i++) scanf("%d", &k[i]);

    for(i=0; i<N-1; i++) {
        for(j=1; j<N-i; j++) {
            if(w[j-1] < w[j]) {
                temp1 = w[j-1];
                w[j-1] = w[j];
                w[j] = temp1;
            }
            if(k[j-1] < k[j]) {
                temp2 = k[j-1];
                k[j-1] = k[j];
                k[j] = temp2;
            }
        }
    }

    printf("%d %d\n", w[0]+w[1]+w[2], k[0]+k[1]+k[2]);

    return (0);
}

Measured memory_bytes: 596
import sys
input = sys.stdin.readline

MOD = 1000003
MAX = MOD + 2
fac, finv, inv = [], [], []

def initCombTable():
  fac.append(1)
  fac.append(1)
  finv.append(1)
  finv.append(1)
  inv.append(0)
  inv.append(1)
  for i in range(2, MAX):
    fac.append(fac[-1] * i % MOD)
    inv.append(MOD - inv[MOD % i] * (MOD // i) % MOD)
    finv.append(finv[-1] * inv[-1] % MOD)


def main():
  initCombTable()
  q = int(input())
  for _ in range(q):
    x, d, n = map(int, input().split())
    if d == 0:
      print(pow(x, n, MOD))
    else:
      xd = x * pow(d, MOD-2, MOD) % MOD
      if xd+n-1>=MOD or xd == 0:
        print(0)
      else:
        ans = fac[xd+n-1] * finv[xd-1] % MOD
        ans = ans * pow(d, n, MOD) % MOD
        print(ans)


if __name__ == '__main__':
  main()


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

		for (int i=1; i<=9; i++){
			if((n%i==0) && (n/i<=9)){
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 35868
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/23.
//  Copyright © 2019 yuya. All rights reserved.
//

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



int main()
{
    int i;
    int j;
    
    int H,W;
    cin >> H >> W;
    vector<vector<char>> image(2*H);
    
    for(i=0;i<2*H;i++) image[i].assign(W, '0');
    
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            cin >> image[2*i][j];
            image[2*i+1][j] = image[2*i][j];
        }
    }
    for(i=0;i<2*H;i++){
        for(j=0;j<W;j++){
            cout << image[i][j];
        }
        cout << endl;
    }
    
    
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<int> C(N+1),S(N+1),F(N+1);
  for(int i=1; i<N; i++){
    cin >> C[i] >> S[i] >> F[i];
  }
  vector<int> ans;
  for(int j=1; j<N; j++){
    int T=0;
    for(int i=j; i<N; i++){
      if(T <= S[i]){
        T = S[i];
      }else{
        if((T-S[i])%F[i]){
          T += F[i]-(T-S[i])%F[i];
        }
      }
      T += C[i];
    }
    ans.push_back(T);
  }
  for(int i=0; i<ans.size(); i++){
    cout << ans[i] << endl;
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
broken = []
for i in range(m):
    broken.append(int(input()))
    
num = [-1] * (n + 1)
num[0] = 1
num[1] = 1


for i in broken:
    num[i] = 0

for i in range(2, n):
    if num[i] == -1:
        num[i] = (num[i-1] + num[i-2])%1000000007
        
if n <= 1:
    print(num[n])
else:
    print((num[n-1]+num[n-2])%1000000007)

Measured memory_bytes: 7976
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*
願はくは花の下にて春死なんそのきさらぎの望月のころ（西行 1118-1190）
--This is old Japanese poem expressing the desire to die under tree on the full moon night.(written by Saigyo)
In my research, there is possibility that the tree may be seg-tree.
*/

/*Coding Space*/
int main(){
  string s; cin >> s;
  map<char,int> m;
  for(auto c:s) m[c]++;
  for(char c = 'a'; c <= 'z'; c++)
    if(m[c] % 2){
      cout << "No" << endl;
      exit(0);
    }
  cout << "Yes" << endl;
}

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

typedef long long ll;
const int MAXN=20;
const int MOD=1e9+7;

int n,m;
int cnt[MAXN][1<<MAXN],d[1<<MAXN];
vector<int> E[MAXN];

int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        E[u].push_back(v);
    }
    int tot=(1<<n)-1;
    for(int i=1;i<=n;i++)
        for(int j=0;j<=tot;j++)
            for(int k=0;k<(int)E[i].size();k++){
                int v=E[i][k];
                if(j&(1<<(v-1))) cnt[i][j]++;
            }
    for(int s=0;s<=tot;s++)
        if((s&1)==((s>>1)&1)){
            d[s]=1;
            for(int ns=(s-1)&s;ns;ns=s&(ns-1))
                if((ns&1)==((ns>>1)&1)){
                    int s1=s-ns;
                    ll inc=d[s1];
                    for(int i=1;i<=n;i++)
                        if(s1&(1<<(i-1)))
                            (inc*=(1<<cnt[i][ns])-1)%=MOD;
                        else if(ns&(1<<(i-1)))
                            (inc<<=cnt[i][s1])%=MOD;
                    d[s]=(d[s]+inc)%MOD;
                }
        }
    ll ans=1;
    for(int i=1;i<=m;i++) ans=ans*2%MOD;
    ans-=d[tot];
    ans=(ans+MOD)%MOD;
    printf("%lld",ans);
}


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

const int N = 302, K = 302, M = 0;
const long long inf = 1e18;
int n, k, h[N], s[N];
long long dp[N][N][N], pd[N][N][K][2];

void minimize(long long &a, long long b) {
 	a = min(a, b);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	for(int i = 1; i <= n; ++i) {
		cin >> h[i];
		s[i] = h[i];
	}
	sort(s + 1, s + n + 1);
	for(int i = 1; i <= n; ++i) {
		for(int j = M; j <= n; ++j) {
			for(int ii = 0; ii <= k; ++ii) {
				dp[i][j][ii] = inf;
			}
		}
	}
	for(int i = 1; i <= n; ++i) {
		for(int j = M; j <= n; ++j) {
			int gn = (h[i] != s[j] ? 1 : 0);
			for(int ii = 0; ii <= min(i - 1 + gn, k); ++ii) {
				if(ii == 0 && gn == 1) continue;
				dp[i][j][ii] = min(pd[i - 1][j][ii - gn][0] + s[j], (i == 1 ? inf : pd[i - 1][j][ii - gn][1]));
			}
		}
		for(int ii = 0; ii <= k; ++ii) {
			for(int j = M; j <= n; ++j) {
				pd[i][j][ii][0] = dp[i][j][ii] - (dp[i][j][ii] == inf ? 0 : s[j]);
				if(j ^ M)
					minimize(pd[i][j][ii][0], pd[i][j - 1][ii][0]);
			}
			for(int j = n; j >= M; --j) {
				pd[i][j][ii][1] = dp[i][j][ii];
				if(j ^ n)
					minimize(pd[i][j][ii][1], pd[i][j + 1][ii][1]);
			}
		}
	}
	long long fp = pd[n][M][0][1];
	for(int ii = 0; ii <= k; ++ii) {
		minimize(fp, pd[n][M][ii][1]);
	}
	cout << fp << endl;
	return 0;
}


Measured memory_bytes: 643968
n,m,*t=map(int,open(0).read().split())
s=sorted
a=s(t[:n])[::-1]
i=n
for c,b in s(zip(t[n+1::2],t[n::2]))[::-1]:
 while(c>a[i-1])*i*b:a[i-1]=c;b-=1;i-=1
print(sum(a))

Measured memory_bytes: 35420
#include<stdio.h>

int func(char* p, char* t){
    int n = 0;
    while(*(t+n) != '\0'){
        if(*(p+n) != *(t+n)){
            return 0;
        }
        n++;
    }
    return 1;
}

int match(char* p){
    if(*p == '\0'){
        return 1;
    }
    int dream   = 0;
    int dreamer = 0;
    int erase   = 0;
    int eraser  = 0;
    if(func(p, "dream") == 1){
        dream = match(p+5);
    }
    if(func(p, "dreamer") == 1){
        dreamer = match(p+7);
    }
    if(func(p, "erase") == 1){
        erase = match(p+5);
    }
    if(func(p, "eraser") == 1){
        eraser = match(p+6);
    }
    if(dream == 1 || dreamer == 1 || erase == 1 || eraser == 1){
        return 1;
    }else{
        return 0;
    }
}

int main(){
    char s[100001];
    scanf("%s", s);
    int buf = match(s);
    if(buf == 1){
        printf("YES");
    }else{
        printf("NO");
    }

    return 0;
}

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

int main()
{
    string s;

    cin >> s;

    int l = s.length();
    int a, z;
    for (int i = 0; i < l; ++i){
        if (s[i] == 'A'){
            a = i;
            break;;
        }
    }
    for (int i = l-1; i >= 0; --i){
        if (s[i] == 'Z'){ 
            z = i;
            break;
        }
    }
    cout << z-a+1 << endl; 

    return 0;
}


Measured memory_bytes: 832
#include <iostream>
#include <vector>

using namespace std;

int n, m, q;
vector<int> a, b, c, d;

int ans = 0;

void dfs(vector<int> A) {
    if (A.size() == n + 1) {
        int now = 0;
        for (int i = 0; i < q; i++) {
            if (A[b[i]] - A[a[i]] == c[i]) {
                now += d[i];
            }
        }
        ans = max(ans, now);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= m) {
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin >> n >> m >> q;
    
    a = b = c = d = vector<int>(q);

    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    
    dfs(vector<int>(1, 1));

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


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

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

    string s;
    int k;
    cin >> s >> k;

    vector<string> vec;
    vec.push_back(s.substr(0, 1));

    unsigned long max_vec_size = s.size() < 5 ? s.size() : 5;
    for (int i = 0; i < s.length(); i++) {
        unsigned long max_sub_length = min(s.length() - i, max_vec_size);
        for (int j = 1; j <= max_sub_length; ++j) {
            string sub_s = s.substr(i, j);
            if (sub_s == "") break;
            unsigned long vec_length = vec.size();
            for (int n = 0; n < vec_length; n++) {
                if (vec[n] == sub_s) {
                    break;
                } else if (vec[n] > sub_s) {
                    vec.insert(vec.begin() + n, sub_s);
                    if (vec.size() > 5) vec.pop_back();
                    break;
                } else if (n == vec_length - 1 && vec_length < 5 ) {
                    vec.push_back(sub_s);
                }
            }
        }
    }

    cout << vec[k - 1] << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String s = "0" + sc.next();
        char[] n = s.toCharArray();
        int len = n.length;
        
        int[][] dp = new int[len+1][2];
        for(int[] tmp : dp){
            Arrays.fill(tmp, (int)1e9);
        }
        dp[0][0] = 0;
        
        for(int i=0; i<len; i++){
            int t = Integer.parseInt(""+n[len-1-i]);
            dp[i+1][0] = Math.min(dp[i+1][0], dp[i][0]+t);
            dp[i+1][1] = Math.min(dp[i+1][1], dp[i][0]+(10-t));
            if(t+1<10){
                dp[i+1][0] = Math.min(dp[i+1][0], dp[i][1]+(t+1)%10);
            }
            dp[i+1][1] = Math.min(dp[i+1][1], dp[i][1]+(10-t-1));
        }
        
        System.out.println(Math.min(dp[len][0], dp[len][1]));
    }
}


Measured memory_bytes: 105640
#include<stdio.h>
#include<math.h>
void swap(int *x,int *y){
    int temp;
    temp=*x;
    *x=*y;
    *y=temp;
}
    int partition(int array[],int left,int right){
        int i,j,pivot;
        i=left;
        j=right +1;
        pivot=left;
        do{
            do{i++;}while(array[i]<array[pivot]);
            do{j--;}while(array[pivot]<array[j]);
            if(i<j){
                swap(&array[i],&array[j]);
            }
        }while(i<j);
        swap(&array[pivot],&array[j]);
        return j;
    }
void sort(int array[],int left,int right){
    int pivot;
    if(left<right){
        pivot=partition(array,left,right);
        sort(array,left,pivot-1);
        sort(array,pivot+1,right);
    }
}
int main()
{
   int a;
   int v[50];
   double b;
   scanf("%d",&a);
   for(int i=1;i<=a;i++){
   scanf("%d",&v[i]);
   }
   sort(v,1,a);
   b=((double)v[1]+(double)v[2])/2;
   for(int i=3;i<=a;i++){
       b=(b+(double)v[i])/2;
     }
   printf("%lf",b);
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define maxn 200005
using namespace std;
char s[maxn];
int n,a[maxn];
long long ans;
int main ()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    int cur=0,cnt=0;
    for(int i=n;i>=1;i--)
    {
        if(s[i]=='A')
        {
            if(cur==0) ans+=cnt;
            else cnt=0,cur=0;
        }
        else if(cur==0)
        {
            if(s[i]=='C') cur=1;
            if(s[i]=='B') cnt=0,cur=0;
        }
        else if(cur==1)
        {
            if(s[i]=='C') cnt=0,cur=1;
            if(s[i]=='B') cnt++,cur=0;
        }
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
const double PI = 3.14159265359;

int main(void) {
	ll a, b, c; cin >> a >> b >> c;
	a -= c;
	b += c;
	cout << a / b << endl;




	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> Pa;
int INF = 1e16+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>P(N);
    map<int,int>Mp;
    for(int i = 0; i < N; i++) {
        cin >> P[i];
        if(Mp.count(P[i]-1)) {
            Mp[P[i]] = Mp[P[i]-1]+1;
        }
        else {
            Mp[P[i]] = 1;
        }
    }
    int cnt = 0;
    for(Pa x:Mp) {
        cnt = max(cnt,x.second);
    }
    cout << N-cnt << endl;
}


Measured memory_bytes: 17236
#include <stdio.h>
#include <stdlib.h>

int main(void) {
        long long int n, k;
        scanf("%lld %lld",&n,&k);

        if( (n = n%k) > llabs(n -k))
                printf("%lld\n",llabs(n-k));
        else
                printf("%lld\n",n);

        return 0;
}

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

def main():
    n = int(input())
    v = list(map(int, input().split()))
    c = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        if v[i] > c[i]:
            ans += v[i] - c[i]
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9168
n, k = map(int, input().split())
MOD = 10**9+7
dp = [0]*(k+1)
for i in range(k, 0, -1):
    """最大値だけの場合
    例) 3 4 → gcd(4 4 4)=4
    """
    dp[i] = pow((k//i), n, MOD)
    """2*iからk+1まで差iに関して
    例) 3 4 → gcd(a, b, c)=2になるのは
    (a,b,c)=(2or4,2or4,2or4)((a,b,c)=(4,4,4)を除く)
    """
    for j in range(i+i, k+1, i):
        dp[i] -= dp[j]
ans = sum([i*dp[i] for i in range(k+1)])
ans %= MOD
print(ans)

Measured memory_bytes: 15536
/*
https://tyottojuku.com/study/%E6%95%B0%E5%AD%A6/2430
約数の個数の求め方
約数の個数は、それぞれの [ 素数の右肩にのっている乗数 ] + １をかけ合わせるだけで求まります。

また、504 = 2^3 * 3^2 * 7^1 の場合を紹介すると
(3 + 1)(2 + 1)(1 + 1)
= 4 * 3 * 2
= 24
となります。504の約数の個数は24個です。

*/

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

ll n;
vector<ll>list(10000, 0);

/* isPrime関数でnumの値が素数かどうかを判定する。vectorのlistには割る事が出来た数値をカウントしているが、numが素数でない場合は割る事が出来た数値をlistでカウントしている*/
bool IsPrime(ll num)
{

	if (num < 2) return true;
	else if (num == 2) {
		n /= 2;
		list[2]++;
		return true;
	}
	else if (num % 2 == 0) {
		n /= 2;
		list[2]++;
		return false; // 偶数はあらかじめ除く
	}

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			list[i]++;
			n /= i;
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

signed main() {

	cin >> n;
	ll n2 = n - 1;

	while (true)
	{
		bool flag = false;

		if (n < 1000000000) {  // この部分がないとnの約数を見つける時にnを割ってnを小さくする以上に、nが掛け算されて大きくなってlong long の変数に収まらなくなってしまうのでnが一定の値より大きい場合は掛け算をしないようにする
			if (n2 > 1) {
				n *= n2;
				n2--;
			}
		}

		if (IsPrime(n) == true) {  // まだn2が1になるまで全部掛け合わせていなくても素数と判定されてループを抜け出る可能性があるかもしれないと考えたが、テストケースでは全部大丈夫だった。もしかしたらロジック的にも大丈夫なのかもしれない。
			list[n]++;  // 約数はその数自身も約数とみなすので、nが素数だった場合も、nが約数という事で、listのnの部分をプラス１してカウントする
			break;
		}

	}

	ll sum = 1;

	for (int i = 2; i < list.size(); i++) {
		if (list[i] > 0) {
			sum = sum * (list[i] + 1); // 約数の個数は、それぞれの [ 素数の右肩にのっている乗数 ] + １をかけ合わせるだけで求まるのでそのようにする
			sum %= MOD;
		}
	}

	cout << sum << endl;


	return 0;
}

Measured memory_bytes: 384
#include <cstdio> 
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
int n,m;
int p[100000],y[100000]; vector<int> yd[100001];
int main () {

  scanf("%d%d",&n,&m);
  rep(i,m){
    scanf("%d%d",&p[i],&y[i]);
    yd[p[i]].push_back(y[i]);
  }
  rep(i,n){
    sort(ALL(yd[i+1]));
  }
  rep(i,m){
    printf("%012lld\n",ll(p[i])*1000000+int(lower_bound(ALL(yd[p[i]]),y[i])-yd[p[i]].begin())+1);
  }
}


Measured memory_bytes: 7680
using System;
using System.Reflection;

namespace study4
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int[] A = new int[20];
            for (int count = 0; count < N;)
            {
                A[count] = int.Parse(input[count]);
                count++;
            }
            int ans = 1;
            int flag = A[0];
            for (int t = 1; t < N;)
            { if (flag <= A[t]) 
                {
                    ans++;
                    flag = A[t];
                }
                t++;

            }
            Console.WriteLine(ans);
            

        }
    }
}

Measured memory_bytes: 13140
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val A, B, K = ni()
    val d = ArrayBuffer[Int]()
    REP(100, 1) { i =>
      if (A % i == 0 && B % i == 0) {
        d += i
      }
    }

    val ans = d(d.length - 1 - (K - 1))
    out.println(ans)
  }

  def debug(as: Array[Boolean]): Unit = {
    System.err.println(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(s: String): Unit = {
    System.err.println(s)
  }

  def debug(num: Long): Unit = {
    System.err.println(num)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int k;
    cin >> k;
    set<string> sub;
    REP(i,s.size()){
        for(int j=1;j<=k&&i+j<=s.size();j++){
            sub.insert(s.substr(i,j));
        }
    }
    auto itr=sub.begin();
    REP(i,k-1)++itr;
    cout << *itr << endl;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define MOD 1000000007
#define fi(i,a,b) for(ll i = a; i < b; i++)
#define fd(i,a,b) for(ll i = a; i >= b; i--)
#define cfi(container,it) for(auto it = container.begin(); it != container.end(); it++)
#define cfd(container,it) for(auto it = container.rbegin(); it != container.rend(); it++)
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pbx(num) ll temp; cin>>temp; num.pb(temp) 

using namespace std;
typedef long long ll;

struct modll {
	ll num;
	operator ll() {return num;}
};
modll operator *(modll x, modll y) {return {(x.num * y.num) % MOD} ;}
modll operator +(modll x, modll y) {return {(x.num + y.num + MOD) % MOD} ;}

// Optimized solution with bitmask dp

void add_self(int &a, int b) {
	a += b;
	if (a > MOD)
		a -= MOD;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;

	vector<vi> comp(n, vi(n));
	fi(i, 0, n) {
		fi(j, 0, n) {
			cin>>comp[i][j];
		}
	}

	vi dp(1 << n);
	dp[0] = 1;

	fi(mask, 0, (1 << n) - 1) {
		int a = __builtin_popcount(mask);
		fi(b, 0, n) {
			if(comp[b][a] && !(mask & (1 << b))) {
				add_self(dp[mask|(1 << b)], dp[mask]);
			}
		}
	}

	// fi(i, 0, 1 << n) 
	// 	cout<<dp[i]<<' ';
	// cout<<'\n';

	cout<<dp[(1<<n) - 1]<<'\n';

	return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    string s, p;
    cin >> s >> p;
    s += s;
    bool judge = false;
    for (int i = 0; i < s.size() - p.size(); i++) {
        bool flag = true;
        for (int j = 0; j < p.size();j++) {
            if (s.at(i + j) != p.at(j)) {
                flag = false;
                break;
            }
        }
        if (flag) {
            judge = true;
            break;
        }
    }
    if (judge) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



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

int main() {
	int n;
	float a;
	cin>>n;
	priority_queue<float,vector<float>,greater<float>>pq;
	for(int i=0;i<n;i++)
	{
	    cin>>a;
	    pq.push(a);
	}
	
	while(pq.size()!=1)
	{
	    float x, y, z;
	    x=pq.top();pq.pop();y=pq.top();pq.pop();
	    z=(x+y)/2;
	    pq.push(z);
	}
	float ans=pq.top(); pq.pop();
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
*
*	AUTHOR :- @soham01
*		// "WORK HARD AND NEVER GIVE UP" //
*
*/
#include "bits/stdc++.h"

using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> //find_by_order(), order_of_key()
#define pb push_back
#define mp make_pair 
#define vi vector<long long int >
#define vb vector<bool>
#define vs vector<string>
#define vd vector<double>
#define vvi vector<vector<long long int> >
#define vp vector<pair<long long int , long long int > >
#define seti set<long long int >
#define setc set<char>
#define setd set<double>
#define mod 1000000009
#define endl '\n'
typedef long long int lli;

// ITS MY REQUEST TO PLEASE PLEASE DO LOOK AT THE CONSTRAINS GIVEN CAREFULLY
// DO CHECK FOR CORNER CASES

/*-------LET THE GAME BEGIN-----------*/

void solve()
{
	string s,s1,s2,r1,r2,r3;
	cin>>s;
	s1="";
	s2="";
	r1="";
	r2="";
	r3="";
	lli l,a,b;
	l=s.size();
	a=(l-1)/2;
	b=(l+3)/2;
	s1=s.substr(0,a);
	s2=s.substr(b-1,l-1);
	r1=s;
	r2=s1;
	r3=s2;
	reverse(r1.begin(),r1.end());
	reverse(r2.begin(),r2.end());
	reverse(r3.begin(),r3.end());
//	cout<<a<<" "<<b<<" "<<l<<endl;
//	cout<<s1<<" "<<r2<<" "<<s2<<" "<<r3<<endl;
	if(s==r1 && s1==r2 && s2==r3)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
		solve();
	return 0;
}





Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    for( int i = 0; i < a; ++i ) {
        if( s[i] == '-' ) {
            cout << "No" << endl;
            return 0;

        }
    }

    if( s[a] != '-' ) {
        cout << "No" << endl;
        return 0;

    }

    for( int i = a + 1; i < s.size(); ++i ) {
        if( s[i] == '-' ) {
            cout << "No" << endl;
            return 0;

        }

    }

    cout << "Yes" << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i, j, k;
        double a, b, m, n;
        double[] Score = new double[10000];
        for(i = 0; ; i++){
            int Total = 0;
            double Totalup = 0.0;
            n = sc.nextDouble();
            if(n == 0.0){
                break;
            } else{
                for(j = 0; j < n; j++){
                    Score[j] = sc.nextDouble();
                    Total += Score[j];
                }
                m = Total / n;
            }
            for(k = 0; k < n; k++){
                Totalup += Math.pow(Score[k] - m, 2.0);
            }
            a = Totalup / n;
            b = Math.pow(a, 0.5);
            System.out.println(b);
        }
    }
}


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

int main()
{
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;

    vector<int> h(n + 1);
    for (int i = 0; i <= n; i++) cin >> h[i];

    for (int i = 0; i <= n; i++) {
      vector<int> v = h;
      v.erase(v.begin() + i);

      int kanade = v[1] - v[0];
      bool f = false;
      for (int j = 1; j < v.size(); j++) {
        if (kanade != v[j] - v[j - 1]) {
          f = true;
          break;
        }
      }

      if (!f) {
        cout << h[i] << endl;
        break;
      }
    }
  }

  return (0);
}

Measured memory_bytes: 3104