akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long int
#define inf 1000000000000
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    set <string> mp;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        mp.insert(s);
    }
    cout<<mp.size();
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 19288
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
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; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int sum=0;
  rep(i,5){
    int p;
    cin >> p;
    if(p>=40)sum+=p;
    else sum+=40;
  }
  cout <<sum/5 << endl;
}



Measured memory_bytes: 3180
cnt = 0


def insertionSort(arr, N, g):
    global cnt
    for i in range(g, N):
        tmp = arr[i]
        j = i - g
        while(j >= 0 and arr[j] > tmp):
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
        arr[j + g] = tmp


def shellSort(arr, N):
    G = []
    h = 0
    m = 0
    while h <= N / 9:
        h = 3 * h + 1
        m += 1
        G.append(h)
    G = G[::-1]
    for g in G:
        insertionSort(arr, N, g)
    return G


N = int(input())
arr = [int(input()) for i in range(N)]

G = shellSort(arr, N)
print(len(G), ' '.join(map(str, G)), cnt, '\n'.join(map(str, arr)), end='\n')



Measured memory_bytes: 125976
#include<iostream>
#include<algorithm>

using namespace std;

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

int main(){
    int mod = 1000000007;
    int n, m;
    cin >> n >> m;
    int a[m];
    rep(i, m) cin >> a[i];
    int dp[n+1];
    
    int stair[n+1];
    rep(i, n + 1) stair[i] = 0;
    rep(i, m) stair[a[i]] = 1;
    dp[0] = 1;
    if (stair[1] == 1) {
        dp[1] = 0;
    }else{
        dp[1] = 1;
    }
    for(int i = 2; i <= n; i++){
        if (stair[i] == 1) {
            dp[i] = 0;
        }else{
            dp[i] = dp[i - 1] + dp[i - 2];
            dp[i] %= mod;
        }
        // cout << dp[i] << endl;
    }

    cout << dp[n] << endl;
}

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

typedef struct {
  double x;
  double y;
} point;

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  std::vector<int> v;
  std::vector<point> p(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> p.at(i).x >> p.at(i).y;
    v.push_back(i);
  }

  double sum = 0;
  int j = 0;
  do {
    ++j;
    for (auto i = v.begin(); i != (v.end() - 1); ++i) {
      sum += sqrt(pow(p.at(*i).x - p.at(*(i + 1)).x, 2) +
                  pow(p.at(*i).y - p.at(*(i + 1)).y, 2));
    }
  } while (std::next_permutation(v.begin(), v.end()));

  std::cout << std::setprecision(10) << std::fixed;
  std::cout << sum / j << std::endl;
}


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



int mod = 1000000007;
int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
template<class... T> int add(int x, T... y) { return add(x, add(y...)); }
int mul(int x, int y) { return 1LL * x * y % mod; }
template<class... T> int mul(int x, T... y) { return mul(x, mul(y...)); }
int sub(int x, int y) { return add(x, mod - y); }
int modpow(int a, long long b) {
    int ret = 1;
    while (b > 0) {
        if (b & 1) ret = 1LL * ret * a % mod;
        a = 1LL * a * a % mod; b >>= 1;
    }
    return ret;
}
int modinv(int a) { return modpow(a, mod - 2); }

int fac[201010], ifac[201010];
void initfac() {
    fac[0] = ifac[0] = 1;
    rep(i, 1, 201010) fac[i] = 1LL * i * fac[i - 1] % mod;
    rep(i, 1, 201010) ifac[i] = modinv(fac[i]);
}
int aCb(int a, int b) {
    if (b < 0 || a < b) return 0;
    return (1LL * fac[a] * ifac[a - b] % mod) * ifac[b] % mod;
}
int N, M, X[101010], Y[101010];
//-----------------------------------------------------------------------------------
int smx, smy;
int x[101010], y[101010];
int dpx[101010], dpy[101010];
void calc_sm() {
    rep(i, 0, N - 1) x[i] = (X[i + 1] - X[i]) % mod;
    rep(i, 0, M - 1) y[i] = (Y[i + 1] - Y[i]) % mod;

    dpx[0] = x[0];
    rep(i, 1, N - 1) dpx[i] = add(dpx[i - 1], mul(i + 1, x[i]));
    rep(i, 0, N - 1) smx = add(smx, dpx[i]);

    dpy[0] = y[0];
    rep(i, 1, M - 1) dpy[i] = add(dpy[i - 1], mul(i + 1, y[i]));
    rep(i, 0, M - 1) smy = add(smy, dpy[i]);
}
//-----------------------------------------------------------------------------------
int main() {
    initfac();

    cin >> N >> M;
    rep(i, 0, N) scanf("%d", &X[i]);
    rep(i, 0, M) scanf("%d", &Y[i]);

    calc_sm();

    cout << mul(smx, smy) << endl;
}

Measured memory_bytes: 4224
EPS = 1e-4


#外積
def OuterProduct(one, two):
	tmp = one.conjugate() * two
	return tmp.imag

#内積
def InnerProduct(one, two):
	tmp = one.conjugate() * two
	return tmp.real

#点が直線上にあるか
def IsOnLine(point, begin, end):
	return abs(OuterProduct(begin-point, end-point)) <= EPS

#点が線分上にあるか
def IsOnSegment(point, begin, end):
	if abs(OuterProduct(begin-point, end-point)) <= EPS and InnerProduct(begin-point, end-point) <= EPS:
		return True
	else:
		return False

#3点が反時計回りか
#一直線上のときの例外処理できていない→とりあえずF
def CCW(p, q, r):
	one, two = q-p, r-q
	if OuterProduct(one, two) > -EPS:
		return True
	else:
		return False

#線分どうし交叉
def Intersect_SS(b1, e1, b2, e2):
	if (CCW(b1, e1, b2) != CCW(b1, e1, e2)) and (CCW(b2, e2, b1) != CCW(b2, e2, e1)):
		return True
	else:
		return False

def solve(a, b, c, d):
	if IsOnSegment(a, c, d) or IsOnSegment(b, c, d) or IsOnSegment(c, a, b) or IsOnSegment(d, a, b):
		return 1
	elif abs(OuterProduct(b-a, d-c)) <= EPS:
		return 0
	elif Intersect_SS(a, b, c, d):
		return 1
	else:
		return 0

n = int(input())
for _ in range(n):
	pp = list(map(int, input().split()))
	p = [complex(pp[i], pp[i+1]) for i in range(0, 8, 2)]
	print(solve(p[0], p[1], p[2], p[3]))


Measured memory_bytes: 5652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+9, INF = 0x3f3f3f3f;
int dt[N];

int main( void ) {
    ios::sync_with_stdio( false );
    int n;
    cin >> n;
    for( int i = 0; i < n; ++i ) cin >> dt[i];
    int maxn = dt[n - 1], ans = -INF;
    for( int i = n - 2; i >= 0; --i ) {
        ans = max( ans, maxn - dt[i] );
        maxn = max( maxn, dt[i] );
    }
    cout << ans << '\n';
    return 0;
}


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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
//
uint64_t dp[101010][13]; // mod13

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    ll N, A, B; cin >> N >> A >> B;
    if (A > B){
        cout << 0 << endl;
    }
    else if(N == 1){
        if(A == B){
            cout << 1 << endl;
        }
        else{
            cout << 0 << endl;
        }
    }
    else{
        ll max_ = A + (N - 1) * B;
        ll min_ = (N - 1) * A + B;
        ll ans = max_ - min_ + 1;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,i,j,g,tmp,r,b,c;
  int a[100000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  b=a[0];c=a[1];
  if(b<c){
    tmp=b;b=c;c=tmp;
  }
  r=b%c;
  while(r!=0){
    b=c;c=r;r=b%c;
  }
  g=c;
  for(i=2;i<n;i++){
    b=a[i];c=g;
    if(b<c){
      tmp=b;
      b=c;
      c=tmp;
    }
    r=b%c;
    while(r!=0){
      b=c;
      c=r;
      r=b%c;
    }
    g=c;
  }
  printf("%d",g);
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define H 1000000007

int main()
{
  ll h,w,i,j;
  cin>>h>>w;
  ll a[h+1][w+1];
  char c;
  memset(a,0,sizeof(a));
  
  for(i=1;i<=h;i++)
  {
    for(j=1;j<=w;j++)
    {
      cin>>c;
      if(i==1&&j==1)
      {  a[i][j]=1;
      continue;}
      if(c=='.')
        a[i][j]=(a[i-1][j]%H+a[i][j-1]%H)%H;
      else
        a[i][j]=0;
    }
  }
  cout<<a[h][w]%H;
  
    
  return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

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

    ll cntR = 0;
    rep(i, n)
    {
        if (s[i] == 'R')
            cntR++;
    }
    ll ans = 0;
    rep(i, cntR)
    {
        if (s[i] == 'W')
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3708
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		char[] S = scanner.next().toCharArray();
		int n = S.length;
		int count = 0;
		char pre = S[0];
		for(int i=1;i<n;i++) {
			if(pre != S[i]) count++;
			pre = S[i];
		}
		System.out.println(count);
		scanner.close();
	}

}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

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

  int n, m;
  cin >> n >> m;

  vector<ll> h(n);
  rep(i, n) cin >> h[i];

  vector<vector<int>> g(n);

  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  int ans = 0;

  rep(i, n){

    ll max_val = -1;
    for(auto v : g[i]){
      chmax(max_val, h[v]);
    }
    if(h[i] > max_val){
      ans++;
    }
  }

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


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

using namespace std;

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

  int H, W;
  cin >> H >> W;
  vector<vector<char>> s(H, vector<char>(W));
  vector<vector<bool>> sb(H, vector<bool>(W, false));
  vector<int> x = {0, 0, -1, 1}, y = {1, -1, 0, 0};

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

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (sb[i][j] == true) {
        continue;
      } else if (s[i][j] == '.') {
        sb[i][j] = true;
      } else {
        for (int k = 0; k < 4; k++) {
          if (i + y[k] >= 0 && i + y[k] < H && j + x[k] >= 0 && j + x[k] < W) {
            if (s[i + y[k]][j + x[k]] == '#') {
              sb[i + y[k]][j + x[k]] = true;
              sb[i][j] = true;
            }
          }
        }
      }
      if (sb[i][j] == false) {
        cout << "No" << '\n';
        return 0;
      }
    }
  }

  // for (int i = 0; i < H; i++) {
  //   for (int j = 0; j < W; j++) {
  //     cerr << sb[i][j];
  //   }
  //   cerr << '\n';
  // }

  cout << "Yes" << '\n';

  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
void main() {
	int n = readln.chomp.to!int;
	int flg = 1;
	int i = 1;
	int x;
	while(flg > 0) {
		if (flg == 1) {
			x = i;
			if (x % 3 == 0) {
				" %d".writef(i);
				flg = 3;
				continue;
			}
			flg = 2;
			continue;
		}

		if (flg == 2) {
			if (x % 10 == 3) {
				" %d".writef(i);
				flg = 3;
				continue;
			}
			x /= 10;
			if (x != 0) {
				flg = 2;
				continue;
			}

			flg = 3;
			continue;
		}

		if (flg == 3) {
			if (++i <= n) {
				flg = 1;
				continue;
			}
			"".writeln;
			break;
		}
	}
}

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

int main(){
  char b;
  cin >> b;
  if(b=='A'){
    cout << 'T' << endl;
  }else if(b=='T'){
    cout << 'A' << endl;
  }else if(b=='G'){
    cout << 'C' << endl;
  }else{
    cout << 'G' << endl;
  }
  return 0;
}


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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d)
		print("Left");
	else if (a + b == c + d)
		print("Balanced");
	else
		print("Right");
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split()))
T = []

for i in range(n):
  t = 0
  for j in range(i):
    t += w[j]
  for j in range(i, n):
    t -= w[j]
  T.append(abs(t))
  
print(min(T))

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<string,int> psi;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF 2147483647
//#define INF (1LL<<59)

typedef string::const_iterator State;


map<psi,int> arr;
map<string,int> a_size;

int get_num(psi x){
    if(x.first=="NUMBER")return x.second;
    else{
        assert(arr.count(x)!=0);
        return arr[x];
    }
}


int num(State &beg){
    int ret = 0;
    while( isdigit(*beg) ){
        ret*=10;
        ret+=*beg-'0';
        beg++;
    }
    return ret;
}


psi eval(State &beg){
    psi ret;
    if( isdigit(*beg) ){
        int p = num(beg);
        return psi("NUMBER",p);
    }
    
    ret.first = *beg;   //テゥツ?催・ツ按療・ツ青?
    beg++;
    
    assert(*beg=='[');
    beg++;
    
    psi res = eval(beg);
    
    assert(*beg==']');
    beg++;
    
    if( res.first == "NUMBER" ){
        ret.second = res.second;
    }else{
        if(a_size.count(res.first)==0)throw -13;   //ティツゥツイテ・ツスツ禿ゥツ?催・ツ按療ァツ?。テ」ツ??
        if(a_size[res.first]<=res.second)throw -23;  //テゥツ?催・ツ按療・ツ、ツ姪・ツ渉づァツ?ァ
        
        if( arr.count(res)==0 )throw -33; //テヲツ慊ェテ・ツョツ堙ァツセツゥテ・ツ?、テ・ツ渉づァツ?ァ
        
        ret.second = get_num(res);
    }
    return ret;
}

int main(){
    string s;
    while(cin>>s && s!="."){
        arr.clear();
        a_size.clear();
        vector<string> vs;
        vs.pb(s);
        while(cin>>s && s!=".") vs.pb(s);
        
        bool f=false;
        
        rep(i,vs.size()){
            int pos = -1;
            rep(j,vs[i].size()){
                if(vs[i][j] == '=')pos = j;
            }
            
            if( pos==-1 ){
                State beg = vs[i].begin();
                psi res = eval(beg);
                a_size[res.first] = res.second;
                
            }else{
                string l = vs[i].substr(0,pos);
                string r = vs[i].substr(pos+1);
                try{
                    State beg = l.begin();
                    psi L = eval(beg);
                    
                    beg = r.begin();
                    psi R = eval(beg);
                    
                    if(a_size.count(L.first)==0)throw -11;   //ティツゥツイテ・ツスツ禿ゥツ?催・ツ按療ァツ?。テ」ツ??
                    if(a_size[L.first]<=L.second)throw -21;  //テゥツ?催・ツ按療・ツ、ツ姪・ツ渉づァツ?ァ

                    if(R.first != "NUMBER" && a_size.count(R.first)==0)throw -12;   //ティツゥツイテ・ツスツ禿ゥツ?催・ツ按療ァツ?。テ」ツ??
                    if(R.first != "NUMBER" && a_size[R.first]<=R.second)throw -22;  //テゥツ?催・ツ按療・ツ、ツ姪・ツ渉づァツ?ァ
                    if(R.first != "NUMBER" && arr.count(R)==0 )throw -31; //テヲツ慊ェテ・ツョツ堙ァツセツゥテ・ツ?、テ・ツ渉づァツ?ァ
                    
                    arr[psi(L)] = get_num(R);
                }catch(int excep){
                    cout<<i+1<<endl;
                    f = true;
                    break;
                }
            }
        }
        if(!f)cout<<0<<endl;
    }
}

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

int main() {
  int k,n;cin>>k>>n;
  vector<int> a(n+1);
  rep(i,n)cin>>a[i];
  a[n]=a[0]+k;
  int cnt=0;
  rep(i,n)cnt=max(a[i+1]-a[i],cnt);
  cout<<k-cnt<<endl;
}

Measured memory_bytes: 4024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	int a[6];
	
	while(true){
		
		int hoge = 0;
		
		for(int i = 0; i < 6; i++){
			cin >> a[i];
			hoge += a[i];
		}
		
		if(hoge == 0){
			break;
		}
		
		a[0] += a[3];
		a[1] += a[4];
		a[2] += a[5];
		
		int ans = 0;
		
		ans = max(ans, a[0] / 3 + a[1] / 3 + a[2] / 3);
		a[0]--;
		a[1]--;
		a[2]--;
		if(a[0] >= 0 && a[1] >= 0 && a[2] >= 0){
			ans = max(ans, a[0] / 3 + a[1] / 3 + a[2] / 3 + 1);
		}
		a[0]--;
		a[1]--;
		a[2]--;
		if(a[0] >= 0 && a[1] >= 0 && a[2] >= 0){
			ans = max(ans, a[0] / 3 + a[1] / 3 + a[2] / 3 + 2);
		}
		
		cout << ans << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3080
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        ABC167 problem = new ABC167(sc);
        problem.solve(out);

        out.flush();
    }

}

class ABC167 {
//    private final int N;
    private final String S, T;
//    private int[] a;

    ABC167(FastScanner sc) {
        S = sc.next();
        T = sc.next();


    }

    void solve(PrintWriter out) {
       String t = T.substring(0,T.length()-1);
        out.println(S.equals(t) ? "Yes" : "No");
        
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 32416
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
using namespace std;
int main(void){
    int K;
    cin >> K;
    string S;
    cin >> S;
    int len = S.length();
    if(K >= len){
        cout << S << endl;
    }
    else{
        for(int i=0;i<K;i++){
            cout << S[i];
        }
        cout << "..." << endl;
    }
}

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

int main() {
    while(1){
        int H,W;
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

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

  vector<int> m(n);
  m[0] = 0;
  REP(i, 1, n){
    if(s[i-1] == 'A' && s[i] == 'C') m[i] = m[i-1] + 1;
    else m[i] = m[i-1];
  }

  rep(i, q){
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    cout << m[r] -m[l] << endl;
  }

  return 0;
}


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


using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;


int main() {

	ll m;
	cin >> m;

	ll ans = -1;
	ll cnt = -1;

	REP(i, m) {
		ll d, c;
		cin >> d >> c;
		ans += c;
		cnt += d * c;
	}
	
	ans += cnt / 9;
	cout << ans << endl;


}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
#define ll long long int
int main()
{
    int t;

    ll a,b,i,j,mx=0,cn=0,k,cn1=0;
    string s,ss;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='R')cn1++;else
        mx=max(cn1,mx),cn1=0;
    }
    cout<<max(mx,cn1)<<endl;

    return 0;
}


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

ll gcd(ll a, ll b) {
    if (b < a) swap(a, b);
    ll r = a % b;
    while (r) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str, T: str):
    cnt = 0
    for s, t in zip(S, T):
        if s!=t:
            cnt += 1
    return cnt


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    print(solve(S, T))

if __name__ == '__main__':
    main()


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

int main() {

int N, K;
cin >> N >> K;

int digit = 1;
int check = 0;

while (check < 1) {
  if ( N < K) check = 1;
  else {
    N = N / K;
	digit++;
  }
}

  // 出力
    cout << digit << endl;
}

Measured memory_bytes: 256
import math

a,b,h,m = map(int, input().split())


a_k = 30*h + (30*m/60)
b_k = 6*m

k = abs(a_k - b_k)

if k > 180:
    k = 360 - k

cos = math.cos(math.radians(k))
print(math.sqrt(a ** 2 + b ** 2 -(2*a*b*cos)))




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

const int M = 1000005;

int main() {
    // 入力
    int n;
    cin >> n;
    vector<int> a(n);
    rep (i, n) cin >> a[i];
    vector<int> cnt(M);
    for (int x : a) {
        if (cnt[x] != 0) { // 同数処理
            cnt[x] = 2;
            continue;
        }
        for (int i = x; i < M; i += x) cnt[i]++; // 倍数計算
    } 
    int ans = 0;
    for (int x : a) {
        if (cnt[x] == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7940
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1e9 + 7;

bool isPrime(int n) {
	for(int i = 2; i * i <= n; i++) {
		if(n % i == 0) {
			return false;
		}
	}
	return true;
}
int f(int n, int p) { return n < p ? 0 : n / p + f(n / p, p); }

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	long long ans = 1;
	int n;
	std::cin >> n;
	for(int i = 2; i <= n; i++) {
		if(isPrime(i)) ans = ans * (1 + f(n, i)) % MOD;
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

    int n,tmp,i;
    int num[1000];
    i = 0;

    scanf("%d", &n);
    tmp = n;
    for(i = 0; i < n;i++){
        scanf("%d", &num[i]);
    }

    for(i = n-1; i >= 0; i--){
        printf("%d", num[i]);
        if(i == 0){
            break;
        }else{
            printf(" ");
        }
    }
    printf("\n");

    return 0;
}



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

int main() {
  int N, K;
  cin >> N >> K;
  int now = 1;
  for (int i = 0; i < N; i++) {
    if(now < K) now *= 2;
    else now +=K;
  }
  cout << now << endl;
}

Measured memory_bytes: 256
Scanf.scanf "%d %d" (fun n k ->
    let p = Array.init n (fun _ -> Scanf.scanf " %d" (fun p -> p)) in
    let module S = Set.Make (struct type t = int let compare = compare end) in

    let rec loop i streak count =
        if i = n then count else
            let streak = if p.(i - 1) < p.(i) then streak + 1 else 0 in
            let count = if streak = k - 1 then count + 1 else count in
            loop (i + 1) streak count
    in
    let count = loop 1 0 0 in

    let rec loop i set acc =
        if i = n then acc else
            let set = S.remove p.(i - k) set in
            let nmi = S.min_elt set in
            let nmx = S.max_elt set in
            let acc = if p.(i - k) > nmi || p.(i) < nmx then acc + 1 else acc in
            let set = S.add p.(i) set in
            loop (i + 1) set acc
    in
    let init =
        let rec loop i set =
            if i = k then set else loop (i + 1) (S.add p.(i) set)
        in
        loop 0 S.empty
    in
    let ans = loop k init 1 in
    Printf.printf "%d\n" (ans - max 0 (count - 1))
)

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

int main()
{
    char c;
    cin >> c;

    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel";
    }else{
        cout << "consonant";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FILL(Itr,n) fill((Itr).begin(),(Itr).end(),n)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

long long pow_mod(long long n, long long k, long long m){
    long long res=1;
    for(;k>0;k>>=1){
        if(k&1)res=((res%m)*(n%m))%m;
        n=((n%m)*(n%m))%m;
    }
    return res;
}
int main(){
    
    ll n,m; cin>>n>>m;
    cout<<pow_mod(n,m,MOD)<<endl;
    
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vpl vector<pair<long long,long long>>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
long long MOD = 1000000007;
const long double pi = 3.1415926535897932;
#define pb push_back
#define mp make_pair
#define mt make_tuple
using Grid = vector<vector<char>>;
#define vc vector<char>
//(mod m)でのaの逆元を計算する
//a/b(mod m)=a(mod m)*modinv(b,m)
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//UF
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll H,W,A,B;
    cin>>H>>W>>A>>B;
    rep(i,B){
        rep(j,A){
            cout<<1;
        }
        rep(j,W-A){
            cout<<0;
        }
        cout<<endl;
    }
    rep(i,H-B){
        rep(j,A){
            cout<<0;
        }
        rep(j,W-A){
            cout<<1;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define alpha_size 26

const int N = 2e5 + 10;
int par[N];
int a[N];

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    

    int n;
    cin >> n;
    for (int i = 2; i <= n; i++){
      int x;
      cin >> x;
      par[x]++;
    }
    for (int i = 1; i <= n; i++)
      cout << par[i] << endl;
}



Measured memory_bytes: 5112
// #include<bits/stdc++.h>
#include<iostream>
#include<queue>
#include<string>

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()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
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; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    string s;
    cin >> s;
    
    int dp[12][2][2][2][2][2] = {0};
    // j : smaller
    // k : leading 0以外0きたらあかん
    // l : 3, m : 5, n : 7
    dp[0][0][0][0][0][0] = 1;
    
    rep(i, sz(s)) rep(j, 2) rep(k, 2) rep(l, 2) rep(m, 2) rep(n, 2) rep(o, 10) {
        if (o != 0 && o != 3 && o != 5 && o != 7) continue;
        if (j == 0 && o > s[i] - '0') continue; // bigger
        if (k == 1 && o == 0) continue;
        
        dp[i + 1][j | (o < s[i] - '0')][k | (o != 0)][l | (o == 3)][m | (o == 5)][n | (o == 7)] += dp[i][j][k][l][m][n];
    }
    cout << dp[sz(s)][0][1][1][1][1] + dp[sz(s)][1][1][1][1][1] << endl;
}


Measured memory_bytes: 256
n, *a = map(int, open(0).read().split())
ans = 0
if a[0] != 0:
	print(-1)
	exit()
for x, y in zip(a, a[1:]+[0]):
	if x + 1 < y:
		print(-1)
		exit()
	if x >= y:
		ans += x
print(ans)


Measured memory_bytes: 25132
// AOJ ITP1_2_D
#include<cstdio>

int W, H;
int x, y, r;

int main()
{
	scanf( "%d%d%d%d%d", &W, &H, &x, &y, &r );

	puts( x >= r && x <= W-r && y >= r && y <= H-r ? "Yes" : "No" );

	return 0;
}

Measured memory_bytes: 1012
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int t, p, r;
int tid, pid, TIME;
string m;
P team[100];//????´???°???tid;first:correct,second:penalty
int inco[100][100];
vector< P > vp;
bool used[100];

bool flag(P p1, P p2){
	if (p1.first == p2.first)return p1.second < p2.second;
	return p1.first > p2.first;
}

int main(){
	while (cin >> t >> p >> r&&t + p + r){
		vp.clear();
		fill(used, used + 100,0);
		REP(i, 100)team[i] = P(0, 0);
		REP(i, 100)REP(j, 100)inco[i][j] = 0;
		REP(i, r){
			cin >> tid >> pid >> TIME >> m;
			if (m == "CORRECT"){
				team[tid].first++;
				team[tid].second += inco[tid][pid] * 1200 + TIME;
			}
			else{
				inco[tid][pid]++;
			}
		}
		FOR(i, 1, t + 1){
			vp.push_back(team[i]);
		}
		sort(ALL(vp), flag);
		REP(i, vp.size()){
			FOR(j, 1, t + 1){
				if (vp[i] == team[j] && !used[j]){
					cout << j << " " << vp[i].first
						<< " " << vp[i].second << endl;
					used[j] = 1;
				}
			}
		}
	}
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int64_t n, k;
    cin >> n >> k;
    if(n%k == 0){
        cout << 0 << '\n';
        exit(0);
    }
    if(n < k){
        cout << min(n, abs(n-k)) << '\n';
        exit(0);
    }
    int64_t temp = n/k;
    temp++;
    temp *= k;
    cout << temp-n << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    int a, b;
    cin >> a >> b;
    char tmp;
    while(a--){
        cin>>tmp;
        if(tmp<'0'||'9'<tmp){
            cout << "No" << endl;
            return 0;
        }
    }

    cin >> tmp;
    if(tmp!='-'){
        cout << "No" << endl;
        return 0;
    }
    while(b--){
        cin>>tmp;
        if(tmp<'0'||'9'<tmp){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

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

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = a * c;
    chmax(ans, a * d);
    chmax(ans, b * c);
    chmax(ans, b * d);
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)


int main(){
  string s;
  ll k,res=0;
  cin >> s >> k;
  string sub,ans;
  map<string,int>mp;
  for(int i=1;i<=k;i++){//引き抜く文字数
    rep(j,s.size()-i+1){//開始地点
      sub=s.substr(j,i);
      if(mp.find(sub)==mp.end()){
        mp[sub]=1;
    //    cout << sub << endl;
      }
    }
  }
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    res++;
  //  cout << res << ":"<< key << endl;
    if(res==k){
      ans=itr->first;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1920
n = int(input())
#簡単のため、プリム法で回答する
data = []
for _ in range(n):
    line = list(map(int,input()[1:].split(' ')))
    for i in range(len(line)):
        if line[i] == -1:
            line[i] = 2001
    data.append(line)

been = [0]
unBeen = []
count = 0
while True:
    minIndex = [0,0]
    min = 2001
    for ele in been:
        for i in range(len(data[ele])):
            if min > data[ele][i] and not i in been:
                min = data[ele][i]
                minIndex = [ele,i]

    count += data[minIndex[0]][minIndex[1]]
    data[minIndex[0]][minIndex[1]] = 2001
    data[minIndex[1]][minIndex[0]] = 2001
    been.append(minIndex[1])
    if len(been) == n:
        break

print(count)



Measured memory_bytes: 5896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);

			int b = Integer.parseInt(chr[2]);
			System.out.println(chr[1].equals("+")? a+b
							  :a-b);

		}
	}
}


Measured memory_bytes: 25264
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/
constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,g;
	cin>>a>>b;
	g=gcd(a,b);
	set<ll> p;
	p.insert(1);
	ll mx=ceil(sqrt(g));
	range(i,2,mx){
		if(g%i==0){
			g/=i;
			p.insert(i);
			i--;
		}
	}

	if(g!=1)p.insert(g);
	puta(p.size());
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

typedef long long ll;
constexpr ll INF = 1001001001;

vector<vector<ll>> to;
vector<vector<int>> dist;
int n, m; ll l;

int main()
{
	cin >> n >> m >> l;
	to.resize(n, vector<ll>(n, INF));
	dist.resize(n, vector<int>(n, n));
	rep(i, m) {
		int a, b; ll c;
		cin >> a >> b >> c;
		if (c > l) continue;
		a--; b--;
		to[a][b] = to[b][a] = c;
	}
	rep(k, n)rep(i, n)rep(j, n)
		to[i][j] = min(to[i][j], to[i][k] + to[k][j]);
	rep(i, n)rep(j, n)
		if (to[i][j] <= l) dist[i][j] = 1;
	rep(k, n)rep(i, n)rep(j, n)
		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
	int q; cin >> q;
	rep(i, q) {
		int s, t;
		cin >> s >> t;
		s--; t--;
		int res = dist[s][t];
		if (res == n) cout << -1 << endl;
		else cout << res - 1 << endl;
	}

	//rep(i, n) {
	//	rep(j, n) {
	//		cout << "to[" << i << "][" << j << "]=" << to[i][j] << " ";
	//	}	cout << endl;
	//}

	//rep(i, n) {
	//	rep(j, n) {
	//		cout << "dist[" << i << "][" << j << "]=" << dist[i][j] << " ";
	//	}	cout << endl;
	//}

	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  
 int count =0;
  for(int i=1;i<N+1;i++){
    if(i<10){
      count++;
    }else if(i<100){
      count=count;
    }else if(i<1000){
      count++;
    }else if(i<10000){
      count=count;
    }else if(i<100000){
      count++;
    }
  }
  cout << count <<endl;
}

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

int main(){
    int X,Y;
    cin>>X>>Y;
    if (Y%2==0 && 2*X<=Y && 4*X>=Y) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

int main(){fastio
    string s;cin>>s;
    rep(i,0,s.size()-9){
        cout<<s[i];
    }
    
    return 0;
}


Measured memory_bytes: 256
//2019.5.16 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-10
#define RG register
inline int read() {
    res s=0,ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline LL Read() {
    RG LL s=0;
    res ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=4e5+10;
namespace MAIN {
    int n,m,a[N];
    inline bool check(const res &lim){
        for(res i=n-lim*2+1,j=n,p=lim;p;p--,i++,j--)if(a[i]+a[j]<m)return 0;
        return 1;
    }
    int ans;
    inline void MAIN(){
        n=read()<<1,m=read();
        for(res i=1;i<=n;i++)a[i]=read();
        sort(a+1,a+n+1);
        res l=0,r=n>>1,ret=-1;
        while(l<=r){
            res mid=(l+r)>>1;
            if(check(mid))l=mid+1,ret=mid;
            else r=mid-1;
        }
        for(res i=n-ret*2+1,j=n,p=ret;p;p--,i++,j--)ans=max(ans,a[i]+a[j]-m);
        for(res i=1,j=n-ret*2,p=n/2-ret;p;p--,i++,j--)ans=max(ans,a[i]+a[j]);
        printf("%d\n",ans);
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("graph.in","r",stdin);
//    freopen("graph.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 1024