akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	string a;
	cin>>a;
	a[3]='8';
	cout<<a<<endl;
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n, d;

    cin>> n>> d;

    d= (d*2) +1;

    cout<< (n+ d-1)/ d<< '\n';

    return 0;
}




Measured memory_bytes: 3652
N = int(input())
A = list(map(int, input().split()))
#print(A)

total = 0
left = 0
sum = sum(A)
#print(end)

for i in range(N - 1):
    #print(i, A[i])
    left = left + A[i]
    #start = i + 1
    #for j in range(start, N):
        #print(i, j)
        #sum = sum + A[j]
    #print(A[i], sum)
    right = sum - left
    #print(i, left, right, A[i])
    total = (total + A[i] * right) % 1000000007

print(total)

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

#define ull unsigned long long int
#define ll long long int
#define vll vector<ll>
#define vi vector<int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define itr vll::iterator
#define all(c) c.begin(),c.end()
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define inf 1000000000000000001

#define rep(i, n)      for(ll i = 0; i <  n; ++i)
#define repA(i, a, n)  for(ll i = a; i <= n; ++i)
#define repD(i, a, n)  for(ll i = a; i >= n; --i)

using namespace std;

bool func(const pll &a, const pll &b){
    return a.s < b.s;
}

ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}

void solve(){
    ll n, k; cin >> n >> k;
    vll v(n); rep(i, n) cin >> v[i];
    rep(i, n) v[i]--;
    if(k <= n){
        ll curr = 0;
        while(k--){
            curr = v[curr];
        }
        cout << curr+1;
    }else{
        int vis[n] = {0};
        ll curr = 0, tmp;
        vis[0] = 1;
        while(k--){
            curr = v[curr];
            if(vis[curr]){ tmp = curr; break;}
            vis[curr] = 1;
        }
        // cout << tmp << ' ' << curr << '\n';
        vll rs;
        ll cnt = 0;
        while(1){
            rs.pb(v[curr]);
            cnt++;
            curr = v[curr];
            if(curr == tmp) break;
        }
        // cout << cnt;
        // cout << rs[0] << rs[1] << rs[2];
        if(k%cnt == 0) cout << rs[cnt-1]+1;
        else cout << rs[k%cnt-1]+1;
    }
}
    

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

    int t = 1, tmp = 0;
    // cin >> t;
    while(t--){
        // cout << "Case #" << ++tmp << ": ";
        solve();
        if(t) cout << "\n";
    }
    cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 6416
//O(N^0.5)
#include<stdio.h>
#include<math.h>

long long sum(long long n){return n*(n+1)/2;}
int main(){
	int n;
	scanf("%d",&n);
	long long ans=0;
	int sqN=sqrt(n);
	for(int i=1;i<=sqN;i++)ans+=sum(n/i)*i;
	for(int i=1;i<=sqN;i++)if(i!=n/i)ans+=sum(i)*(sum(n/i)-sum(n/(i+1)));
	printf("%lld\n",ans);
}


Measured memory_bytes: 2112
#include <cstdio>

int gcd(int a, int b) {
  if(a == 0 || b == 0)
    return a + b;
  int r = a % b;
  while(r > 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main() {
  int n, k, x, biggie;
  int g = 0;
  scanf("%d%d", &n, &k);
  biggie = 0;
  for(int i = 0; i < n; ++i) {
    scanf("%d", &x);
    g = gcd(g, x);
    if(x > biggie)
      biggie = x;
  }
  if(k % g == 0 && biggie >= k)
    printf("POSSIBLE");
  else
    printf("IMPOSSIBLE");
  return 0;
}


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

int main(){
  int N;
  int i;
  bool expressable = false;
  
  cin >> N;
  
  i = 1;
  while(i < 10){
    if(N%i == 0 && N/i <= 9){
      expressable = true;
      break;
    }
    i++;
  }
  
  if(expressable==true){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
       int a;
       int b;
       cin>>a;
       cin>>b;
      if(a<b){
          cout<<"a < b"<<endl;
      }
          if(a>b){
          cout<<"a > b"<<endl;
      }
          if(a==b){
          cout<<"a == b"<<endl;
      }
}


Measured memory_bytes: 3048
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL H, W, M;
	cin >> H >> W >> M;
	map<LL, int> HM, WM;
	map<pair<LL, LL>, int> MM;
	vector<LL> V1, V2;
	for(int i=0; i<M; i++){
		LL h, w;
		cin >> h >> w;
		//h--; w--;
		if(HM.count(h) == 0){
			HM[h] = 1;
		}
		else{
			HM[h]++;
		}
		if(WM.count(w) == 0){
			WM[w] = 1;
		}
		else{
			WM[w]++;
		}
		V1.push_back(h);
		V2.push_back(w);
		MM[make_pair(h, w)] = 1;
	}
	
	int hmax = 0;
	for(auto itr = HM.begin(); itr != HM.end(); itr++){
		LL k = itr->first;
		int v = itr->second;
		if(hmax < v){
			hmax = v;
		}
	}
	map<LL, int> M1;
	for(auto itr = HM.begin(); itr != HM.end(); itr++){
		LL k = itr->first;
		int v = itr->second;
		if(v == hmax){
			M1[k] = v;
		}
	}

	int wmax = 0;
	for(auto itr = WM.begin(); itr != WM.end(); itr++){
		LL k = itr->first;
		int v = itr->second;
		if(wmax < v){
			wmax = v;
		}
	}
	map<LL, int> M2;
	for(auto itr = WM.begin(); itr != WM.end(); itr++){
		LL k = itr->first;
		int v = itr->second;
		if(v == wmax){
			M2[k] = v;
		}
	}
	if(M1.size() * M2.size() > M){
		printf("%d\n", hmax + wmax);
		return 0;
	}

	int exist = 0;
	for(auto itr1 = M1.begin(); itr1 != M1.end(); itr1++){
		for(auto itr2 = M2.begin(); itr2 != M2.end(); itr2++){
			LL a = itr1->first;
			LL b = itr2->first;
			if(MM.count(make_pair(a, b)) == 0){
				exist = 1;
				break;
			}
		}
		if(exist == 1){
			break;
		}
	}
	if(exist == 1){
		printf("%d\n", hmax + wmax );
	}
	else{
		printf("%d\n", hmax + wmax - 1);
	}
	return 0;
}



Measured memory_bytes: 101768
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
const int MOD = 1000000009;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  double ans = 0;

  cin >> n >> k;

  for(int i = 1;i <= n;i++){
    double cnt = 0;
    for(int j = i;j < k;j *= 2){
      cnt ++;
    }

    ans += ((1.0 / n) * pow(0.5, cnt));
  }

  cout << setprecision(13) <<  ans << endl;
  return 0;
}


Measured memory_bytes: 256
K = int(input())
table = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in table:
  if len(table) > K:
    break
  x = i % 10
  for j in range(max(0, x - 1), min(x + 2, 10)):
    table.append(i * 10 + j)
print(table[K-1])

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

int main(){
  int H, W;

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

}

Measured memory_bytes: 3112
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <vector>
using namespace std;

namespace zyt
{
	template<typename T>
	inline bool read(T &x)
	{
		char c;
		bool f = false;
		x = 0;
		do
			c = getchar();
		while (c != EOF && c != '-' && !isdigit(c));
		if (c == EOF)
			return false;
		if (c == '-')
			f = true, c = getchar();
		do
			x = x * 10 + c - '0', c = getchar();
		while (isdigit(c));
		if (f)
			x = -x;
		return true;
	}
	template<typename T>
	inline void write(T x)
	{
		static char buf[20];
		char *pos = buf;
		if (x < 0)
			putchar('-'), x = -x;
		do
			*pos++ = x % 10 + '0';
		while (x /= 10);
		while (pos > buf)
			putchar(*--pos);
	}
	const int N = 2010, INF = 0x3f3f3f3f;
	char w[N];
	vector<int> e[N];
	int n, ans = INF, f[N], g[N], num[N], dep[N];
	void dfs(const int u, const int fa)
	{
		int id = 0, mx = 0;
		g[u] = 0;
		if (w[u] == '1')
			num[u] = 1;
		else
			num[u] = 0;
		for (auto v : e[u])
		{
			if (v == fa)
				continue;
			dep[v] = dep[u] + 1;
			dfs(v, u);
			num[u] += num[v];
			g[u] += g[v] + num[v];
			if (g[v] + num[v] > mx)
				id = v, mx = g[v] + num[v];
		}
		if (mx <= g[u] - mx || mx * 2 - g[u] <= f[id])
			f[u] = g[u] / 2 * 2;
		else
			f[u] = 2 * (g[u] - mx) + f[id];
	}
	void solve(const int r)
	{
		dep[r] = 0;
		dfs(r, 0);
		if (f[r] == g[r])
			ans = min(ans, g[r] / 2);
	}
	int work()
	{
		read(n);
		scanf("%s", w + 1);
		for (int i = 1; i < n; i++)
		{
			int a, b;
			read(a), read(b);
			e[a].push_back(b), e[b].push_back(a);
		}
		for (int i = 1; i <= n; i++)
			solve(i);
		if (ans == INF)
			puts("-1");
		else
			write(ans);
		return 0;
	}
}
int main()
{
	return zyt::work();
}

Measured memory_bytes: 3376
p=0
z= [0,0,0,0,0]
a,b=input().split( )
c,d=input().split( )
e,f=input().split( )
x = [a,b,c,d,e,f]
for i in range(6):
  x[i]=int(x[i])
  z[x[i]]=z[x[i]]+1
for i in range(1,5):
  if z[i] == 3:
    p = 1
if p==1:
  print ("NO")
else:
  print("YES")

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

class Main
{
	public static void main(String[] args) throws Exception
	{
		invoke(System.in);
//		invoke(new FileInputStream("/tmp/test.txt"));
	}

	public static void	invoke(InputStream is) throws IOException
	{
		// input
		BufferedReader	reader = new BufferedReader(new InputStreamReader(is));
		String	line = reader.readLine();

		String[]	va = line.split(" ");
		int	n = Integer.parseInt(va[0]);
		int a = Integer.parseInt(va[1]);
		int b = Integer.parseInt(va[2]);

		int	resultSum = 0;
		for (int x = 1; x <= n; ++x)
		{
			int y = x;
			int	sum = 0;
			while (y > 0)
			{
				sum += y % 10;
				y /= 10;
			}

			if (a <= sum && sum <= b)
			{
				resultSum += x;
			}
		}

		System.out.println(resultSum);
	}


}

Measured memory_bytes: 21204
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=3005;
const double EPS=1e-6;

string dp[2][SIZE];
int p=0,q=1;

int main(){
	/*main function start*/
	string s,t;
	cin>>s>>t;
	int n=s.size(),m=t.size();
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(dp[q][j-1].size()>dp[p][j].size()) dp[q][j]=dp[q][j-1]; else dp[q][j]=dp[p][j];
			if(s[i-1]==t[j-1] && dp[p][j-1].size()+1>dp[q][j].size()) dp[q][j]=dp[p][j-1]+s[i-1];
		}
		swap(p,q);
	}
	cout<<dp[p][t.size()]<<endl;
	return 0;
}


Measured memory_bytes: 8288
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, m, a, b;
  cin >> n >> m >> a >> b;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if ((i < b && j < a) || (i >= b && j >= a)) cout << "1";
      else cout << "0";
    }
    cout <<endl;
  }
  return 0;
}

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

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

    vector<int> a(n+1);
    vector<int> adj[n+1];

    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int ans=0;

    for(int v=1;v<=n;v++)
    {
        bool flag=true;
        for(int x=0;x<adj[v].size();x++)
        {
            if(a[v]<=a[adj[v][x]])
            {
                flag=false;
                break;
            }
        }
         if(flag)++ans;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 8800
/**
 *    author: gxfireball       
**/
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
using namespace std;

void solve(){
   ll k,a,b;
   cin >> k >> a >> b;
   for(ll i=a; i<=b; ++i){
	   if(i%k == 0){
		   cout << "OK" << endl;
		   return;
	   }
   }
   cout << "NG" << endl;
}

int main(){
    fastio;
    int t;
    t = 1;
    //cin>>t;
    while(t--){
    	solve();
    }
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool c = false;
    rep (i, s.size()) {
        if (s[i] == 'C') c = true;
        else if (c && s[i] == 'F') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
    return 0;
}



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

using namespace std;
using namespace atcoder;
typedef long long ll;
typedef long double Double;
#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;
}

bool check(long long k, long long N) {
    if (k <= 0) return false;
    return (__int128) k * (k + 1) / 2 % N == 0;
}

long long f(long long N) {
    int k = 1;
    while (true) {
        if (k * (k + 1) / 2 % N == 0) {
            return k;
        }
        k++;
    }
    return -1;
}


vector<long long> g(long long N) {
    vector<long long> X;
    for (long long i = 2; i * i <= N; i++) {
        if (N % i == 0) {
            int c = 0;
            long long W = 1;
            while (N % i == 0) {
                c++;
                N /= i;
                W *= i;
            }
            X.push_back(W);
        }
    }
    if (N > 1) {
        X.push_back(N);
    }
    sort(X.begin(), X.end());

    return X;
}

typedef long long Int;

Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

// a x + b y = gcd(a, b)
Int extgcd(Int a, Int b, Int &x, Int &y) {
    Int g = a;
    x = 1;
    y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

void solve(long long N) {
    auto X = g(2 * N);
    ll ans = 1e18;
    for (int i = 0; i < (1 << X.size()); i++) {
        long long x = 1;
        long long y = 1;
        for (int j = 0; j < X.size(); j++) {
            if (i >> j & 1) {
                x *= X[j];
            } else {
                y *= X[j];
            }
        }
        long long aa, bb;
        extgcd(x, y, aa, bb);
        long long W = max(x * aa, y * bb);
        if (check(W, N)) ans = min(W, ans);
        if (check(W - 1, N)) ans = min(W - 1, ans);
        if (check(W + 1, N)) ans = min(W + 1, ans);

    }
    cout << ans << endl;

}

int main() {
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s ;
int D;
const int N = 1e5 + 2  , MOD = 1e9 + 7;
ll mem[N][102][2];
ll solve(int idx , int sum , int flag){
    if(idx == s.size()){
        return (sum == 0);
    }
    int dig = s[idx] -'0';
    if(flag)
        dig = 9;
    ll &ret = mem[idx][sum][flag];
    if(~ret)
        return ret;
    ret = 0;
    for(int i = 0 ; i <= dig ; ++i){
        bool ok = flag;
        if(i < dig)
            ok = 1;
        ret+=(solve(idx +1 , (sum + i)  % D , ok)%MOD);

    }

    return ret % MOD;

}
int main ()
{
    memset(mem , -1 , sizeof mem);
    cin >> s >> D;
    cout << (solve(0 , 0 , 0) -1 + MOD ) % MOD << endl;

    return 0;
}


Measured memory_bytes: 160512
N, W, H = [int(x) for x in input().split()]

map_x = [0] * W
map_y = [0] * H

for _ in range(N):
    x, y, w = [int(x) for x in input().split()]
    map_x[max(0, x - w)] = max(map_x[max(0, x - w)], x + w - max(0, x - w))
    map_y[max(0, y - w)] = max(map_y[max(0, y - w)], y + w - max(0, y - w))


def check_wifi(wifi):
    m = 0
    end = len(wifi)

    for i, x in enumerate(wifi):
        if x:
            m = max(m, i + x)

        if m >= end:
            return True

        if i < m:
            continue

        return False

    return False

print('Yes' if check_wifi(map_x) or check_wifi(map_y) else 'No')

Measured memory_bytes: 11484
/*  -*- coding: utf-8 -*-
 *
 * 2920.cc: Tea Party
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int INF = 1 << 30;

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  int sum = 0, mino = INF;
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    sum += ai;
    if ((ai & 1) && mino > ai) mino = ai;
  }

  if (sum & 1) sum -= mino;
  printf("%d\n", sum / 2);
  return 0;
}



Measured memory_bytes: 3204
// A B C D H F E I G K L M N P S O Q R J U Z Y X T V W

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pq priority_queue<int> 
#define pqs priority_queue<int,vector<int>, greater<int>>
#define setbits(x) __builtin_popcountll(x)  // no of ones in setbit
#define zrobits(x) __builtin_ctzll(x)       //101000 here 3..no of 0 aftrer 1sr right one 
#define mod 1000000007
#define inf 1e18
#define ps(x,y)  fixed<<setprecision(y)<<x  // ans upto 5 decimal place 
#define mk(ar,n,type) type *arr=new type[n];
#define w(x) int x;cin>>x;while(x--)



void fn(int arr[],int n)
{
	int dp[n+1]; 
	dp[0]=0;
	dp[1]= abs(arr[1]-arr[0]); 
	// cout<<dp[1]; 

	for(int i=2; i<n; i++)
	{
		int x=dp[i-2]+abs(arr[i]-arr[i-2]); 
		int y=dp[i-1]+abs(arr[i]-arr[i-1]) ; 
		dp[i]=min(x, y); 
	} 
	cout<<dp[n-1]; 
}



int32_t main()
{
	int n ; 
	cin>>n ; 
	int arr[n+1] ; 

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

	fn(arr, n) ; 

}

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

int DP[10002] = {100000000};
int main(){
    int H,N;
    cin >> H >> N;
    //vector<int> v(N),w(N);
    int a,b;
    rep(i,10003){
        DP[i] = 1000000000;
    }
    DP[0] = 0;
    rep(i,N){
        cin >> a >> b;
        rep(j,H+1){
            if(0 <= j-a){
                DP[j] = min(DP[j],DP[j-a]+b);
            }else{
                DP[j] = min(DP[j], b);
            }
        }
    }
    cout << DP[H] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>


#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
	int X,A,B;
	cin >> X >> A >> B;
	int ans = (X - A) % B;
	cout << ans << endl;
}




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

#define int long long
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()

#define fast ios::sync_with_stdio(0); cin.tie(0)

int sq(int num){
  return num*num;
}

int32_t main(){
  
    fast;
    int n; cin >> n;
    int ar[n];

    set<int> se;
    for(int i=0;i<n;i++){
      cin >> ar[i];
      se.insert(ar[i]);
    } 

    if(se.size()==1){
      cout << 0;
      return 0;
    }

    int ans = 1e18;
    
    for(int y=-100;y<=100;y++){
      int cost = 0;
      for(int i=0;i<n;i++) cost+=sq(ar[i]-y);
      ans=min(ans,cost);
    }
  
    cout << ans;

    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    string s, t;
    cin>>s>>t;
    int ans = 0;
    for(int i =0 ; i < s.size() ; i++) {
        if(s[i] != t[i]) ans++;
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n, in;
	cin >> n;
	list<int> l;
	bool s = true;
	rep(i, n) {
		cin >> in;
		if (s)l.push_back(in);
		else l.push_front(in);
		s = !s;
	}
	if(s){
		rep(i, n) {
			cout << l.front();
			l.pop_front();
			if (!l.empty())cout << " ";
		}
	}
	else {
		rep(i, n) {
			cout << l.back();
			l.pop_back();
			if (!l.empty())cout << " ";
		}
	}
	cout << endl;
}

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


int a[200010],vis[200010],pass[200010];

int main()
{
long double a,b,c;
cin>>a>>b>>c;
long double sum=a+b-c;
long double sq=-1.0*2.0*sqrt(a*b);
if(sum<sq)cout<<"Yes";
else cout<<"No";
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define mod (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int gcd(int A,int B) {if(!B)return A;return gcd(B,A%B);}
int val[200005];
vii adj(200005);
void dfs(int v,int u)
{
	val[v]+=val[u];
	for(int x:adj[v])
	{
	  if(x == u)continue;
      dfs(x,v);
	}	
}
int main()
{
	
	int n,q;
	cin>>n>>q;
	for(int i=0;i<n-1;i++){
		int v,u;
		cin>>v>>u;
		adj[v].pb(u);
		adj[u].pb(v);
	}
	for(int i=0;i<q;i++)
	{
		int a,b;
		cin>>a>>b;
		val[a]+=b;
	}
    dfs(1,0);
    for(int i=1;i<=n;i++)cout<<val[i]<<" ";
	
}

Measured memory_bytes: 23424
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    INF = 10**8
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()
    key = [0]
    box = [0]
    for _ in range(M):
        k,_ = LI()
        key.append(k)
        b = 0
        for c in LI():
            b += 2**(c-1)
        box.append(b)

    dp = [[INF] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(1,M+1):
        for j in range(2**N):
            dp[i][j] = min(dp[i-1][j],dp[i-1][j - (j&box[i])]+key[i])
    if dp[-1][-1] == INF:
        print(-1)
    else:
        print(dp[-1][-1])
if __name__ == '__main__':
    main()

Measured memory_bytes: 74708
#coding=UTF-8
shimo_wake_ten=list(range(0,10,1))
for idx in range(0,10,1):
    shimo_wake_ten[idx]=None
shimo_wake_ten[0]=0

N=int(input())


for idx in range(0,N,1):
    s=int(input())
    tugi_wake_ten=[None]*10
    for idy in range(0,10,1):
        tgt=(idy+s)%10
        if shimo_wake_ten[idy] != None:
            if shimo_wake_ten[tgt] == None:
                tugi_wake_ten[tgt]=shimo_wake_ten[idy]+s
            else:
                tugi_wake_ten[tgt]=max(shimo_wake_ten[tgt],shimo_wake_ten[idy]+s)
    for idy in range(0,10,1):
        if tugi_wake_ten[idy] != None:
            shimo_wake_ten[idy]=tugi_wake_ten[idy]

#    print(shimo_wake_ten)

ans=0
for mono in shimo_wake_ten[1:10]:
    if mono != None:
        ans=max(ans,mono)
print(ans)


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

void swap(int *, int *);

int main(){
  int N,*A,i,j,k,count=0,minj;
  scanf("%d",&N);
  A=(int *)malloc(sizeof(int)*N);

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

  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j]<A[minj]) minj=j;
    }
    if(minj!=i){
      swap(&A[i],&A[minj]);
      count++;
    }
  }

  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i!=N-1) printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}

void swap(int *x,int *y){
  int tmp;
  tmp=*x;
  *x=*y;
  *y=tmp;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  int a;
  cin>>a;
  vector<int> b(a),c(a);
  rep(i,a)
    cin>>b[i];
  rep(i,a)
    c[i]=b[i];
  sort(all(c));
  int d=0;
  rep(i,a){
    if(b[i]!=c[i])
      d++;
  }
  if(d==2||d==0)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;


int main(){
	int N;
	cin >> N;
    vector<ll> A;
    for(int i = 0; i < N; i++){
        ll a;
        cin >> a;
        A.push_back(a);
    }

	ll result;

    result = *max_element(A.begin(), A.end()) - *min_element(A.begin(), A.end());

    cout << result << endl;

	return 0;
}


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

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int l=0,r=a[n-1];

    while(r-l>1){
        int x=(r+l)/2;
        ll sum=0;
        for(int i = 0; i < n; i++) {
            sum += (a[i]-1)/x;
        }
        if(sum<=k) r=x;
        else l=x;
    }
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3996
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

#define ll long long int
#define INF (ll) 1e14
ll n;

int main() {
        cin >> n;
        ll end = sqrt(n);

        ll steps = INF;
        for (int i = 1; i <= end; i++) {
                if (n % i == 0) {
                        steps = min(steps, (n / i) - 1 + i - 1);
                }
        }
        cout << steps << endl;
        return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
    int N;
    int V[20], C[20];
    int ans = 0;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &V[i]);
    }
    for (int j = 0; j < N; j++) {
        scanf("%d", &C[j]);
    }
    for (int k = 0; k < N; k++) {
        if (V[k] - C[k] > 0) {
            ans += V[k] - C[k];
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
#入力
n,k=map(int,input().split())
a=list(map(int,input().split()))
bits=list(bin(k+1)[2:])
bits=list(map(int,bits))
stack=[0]*40
ans=0
#各bitごとの1の総数を保存
for i in a:
  num=bin(i)[2:]
  for j in range(len(num)):
    if num[j]=="1":
      stack[len(num)-j-1]+=1
#xがk+1より小さいならば、どこかのbitでxが0、k+1が1となるところがあるはず
#さらにそれより下位のbitでは1と0どちらにしても大小関係が変化しないので貪欲に求まる
for i in range(len(bits)):
  possible_ans=[q for q in bits]
  ans_stack=0
  #上からi番目のbitが変換点であると仮定
  #もしそのbitが0なら変換点にはなり得ない
  if possible_ans[i]==0:
    continue
  possible_ans[i]=0
  #stackは一番最初が一番小さいbitとなる
  #possible_ansのi桁目はstackのlen(bits)-i+1桁目に相当
  for j in range(40):
    if j<len(bits)-i-1:
      ans_stack+=max(stack[j]*2**j,(n-stack[j])*2**j)
    elif j<len(bits) and possible_ans[len(bits)-j-1]==1:
      ans_stack+=(n-stack[j])*2**j
    else:
      ans_stack+=stack[j]*2**j
  ans=max(ans,ans_stack)
#出力
print(ans)

Measured memory_bytes: 14708
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N;
  cin>>N;
  int H[N];
  rep(i,N) cin>>H[i];
  int M=H[0],ans=1;
  rep(i,N){
    if(i){
      if(M>H[i]){
        ans=-1;
        break;
      }else if(H[i]>M) H[i]--;
      M=max(M,H[i]);
    }
  }
  if(ans==1) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>

using namespace std;

int main(){
	string code;
	string train;
	int i,j;

	while(cin >> code){
		if(code == "10") code = 'A';

		if(code == "0"){
			if(train[train.size()-1] == 'A'){
				cout << "10" << endl;
			}else{
				cout << train[train.size()-1] << endl;
			}
			string temp;
			for(i=0 ; i<train.size()-1 ; i++){
				temp += train[i];
			}
			train = temp;
		}else{
			train += code;
		}
	}

} 

Measured memory_bytes: 1188
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

n = getN()
nums = getList()

dp = [100000000000] * n

dp[0] = 0

def cost(step1, step2):
    return abs(nums[step1] - nums[step2])

def finddp(start, goal):
    for i in range(start,goal):
        if i+1 <= goal:
            dp[i+1] = min(dp[i+1], dp[i] + cost(i, i+1))
        if i+2 <= goal:
            dp[i + 2] = min([dp[i + 2], dp[i] + cost(i, i + 2)])

finddp(0,n-1)
print(dp[-1])

Measured memory_bytes: 13924
import java.util.*;
import java.io.*;
public class Main {

	private static final int mod =(int)1e9+7;
	public static void main(String[] args) throws Exception  {
	      Scanner  sc=new Scanner(System.in);
	      PrintWriter out=new PrintWriter(System.out);
	      sieve();
	  long h=sc.nextLong();
	  long w=sc.nextLong();
	  long c=h*w;
	  long ans=Long.MAX_VALUE;
	  if(h%3==0||w%3==0){
	    System.out.println(0);
	  }else {
	 for(long i=1;i<=h;i++) {
	   long A1=i*w;
	   long A2=(h-i)*(w/2);
	   long A3=(h-i)*((w+1)/2);
	   long max1=Math.max(A1,A2);
	   long max2=Math.max(A3,max1);
	   long min1=Math.min(A1,A2);
    long min2=Math.min(A3,min1);
    ans=Math.min(ans,max2-min2);
	 }

  for(long i=1;i<=w;i++) {
    long A1=i*h;
    long A2=(w-i)*(h/2);
    long A3=(w-i)*((h+1)/2);
    long max1=Math.max(A1,A2);
    long max2=Math.max(A3,max1);
    long min1=Math.min(A1,A2);
    long min2=Math.min(A3,min1);
    ans=Math.min(ans,max2-min2);
  }
  ans=Math.min(ans,h);
  ans=Math.min(ans,w);
  System.out.println(ans);
	}
	}
	static int  prime[]=new int[100001];
	static void sieve() {
	  Arrays.fill(prime,1);
	  prime[0]=0;
	  prime[1]=1;
	  for(int i=2;i*i<100001;i++) {
	   if(prime[i]!=0) {
	     for(int j=i;j<10001;j+=i) {
	       prime[j]=0;
	     }
	   }
	  }
	}
	      static long gcd(long a, long b) 
	      { 
	          if (a == 0) 
	              return b; 
	          return gcd(b % a, a); 
	      } 

static long nCr(int n,int r) {
  int dp[][]=new int[2001][2001];
  for(int i=0;i<2001;i++) {
    dp[0][i]=0;
  }
  for(int i=0;i<2001;i++) {
    dp[i][0]=1;
  }
  for(int i=1;i<2001;i++) {
    for(int j=1;j<2001;j++) {
      if(i==j) {
        dp[i][j]=1;
      }else {
        dp[i][j]=dp[i-1][j-1]+dp[i][j-1];
      }
    }
  }
  return dp[n][r];
}


      
}
class pair {
  int src;
 int  des;
 long val;
  pair(int src,int des,long val){
    this.src=src;
    this.des=des;
    this.val=val;
    
  }

//  @Override
//  public int compareTo(pair o) {
//   
//    return this.wt-o.wt;
//  }
}

Measured memory_bytes: 36532
n = int(input())
s = input()
cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        if s[i] == s[j]:
            continue
        k = 2*j - i
        if j < k < n and s[i] != s[k] and s[j] != s[k]:
            cnt += 1
print(s.count('R') * s.count('G') * s.count('B') - cnt)

Measured memory_bytes: 9196
#include<cstdio>
int n;
int a[100100];
int main()
{
	scanf("%d", &n);
	bool flag = false;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		if (a[i] & 1) flag = true;
	}
	if (flag) printf("first\n");
	else printf("second\n");
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	vector<int>v;
	while(k--){
		int d;
		cin>>d;
		for(int i=0;i<d;i++){
		int x;
		cin>>x;
		v.push_back(x);
		}
	}
	sort(v.begin(), v.end()); 
	int count=0;
	for(int i=1;i<=n;i++){
		if(binary_search(v.begin(),v.end(),i)){
			
		}
		else{
			count++;
		}
	}
	cout<<count;
	return 0;
}
	

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void chey(){ cout <<"hey" <<endl; }


int main() {
  int N,M; cin >>N >>M;
  int sum = 0;
  vector<int> A(N); rep(i, N) cin >>A[i];
  rep(i, N) sum += A[i];
  int res = 0;
  rep(i, N){
    if(A[i]*4*M >= sum) res++;
  }
  cout <<(res >= M ? "Yes" : "No") <<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
const int B = 27;

int N;
char Sleft[20];
char Sright[20];

vector<pair<string, string>> solve(char *src) {
  vector<pair<string, string>> ret;
  rep(S, 1<<N) {
    string red, blue;
    rep(i, N) {
      if ((S>>i)&1) red += src[i];
      else blue += src[i];
    }
    ret.pb(make_pair(red, blue));
  }
  return ret;
}
__int128 f(string S) {
  __int128 h = 0;
  for (char c : S) h = 1LL*h*B+(c-'a');
  return h;
}

map<__int128, int> ctr[20];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> Sleft[i];
  rep(i, N) cin >> Sright[i];
  vector<pair<string, string>> mp1 = solve(Sleft);
  vector<pair<string, string>> mp2 = solve(Sright);

  for (pair<string, string> p : mp2) {
    string red = p._1, blue = p._2;
    reverse(all(blue));
    __int128 r = f(red), b = f(blue);
    rep(_, red.size()) b *= B;
    ctr[red.size()][b-r]++;
  }
  long long s = 0;
  for (pair<string, string> p : mp1) {
    string red = p._1, blue = p._2;
    reverse(all(blue));
    __int128 r = f(red), b = f(blue);
    rep(_, blue.size()) r *= B;
    s += ctr[blue.size()][r-b];
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 108268
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll N, X; cin >> N >> X;
	ll m, minV = 1 << 21;
	rep(i, 0, N)
	{
		cin >> m;
		X -= m;
		minV = min(minV, m);
	}
	cout << N + X / minV << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
const ll mo=1000000007;
ll ans=0;
ll dp[0][0];

int main()
{ 
ll n;
cin >> n; 
ll v[n]={};
rep(i,n) {
    cin >> v [i];
}
ll c[n]={};
rep(i,n) {
    cin >> c [i];
}
rep(i,n){
    if(v[i]-c[i]>0)
    ans+=v[i]-c[i];
}

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

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

int main()
{
  	uint64_t K;
    std::string S;
 
  	std::cin >> K >> S;
  
  	if (S.size() <= K)
    	std::cout << S;
  	else
      	std::cout << S.substr(0, K) << "...";
}

Measured memory_bytes: 3044
def straight?(b)
  (0..8).each { |i| return true if b.slice(i, 5) == [1, 1, 1, 1, 1] }
  return b[0] == 1 && b.slice(9, 4) == [1, 1, 1, 1]
end

while s = gets
  b = Array.new(13, 0)
  s.split(',').map(&:to_i).each { |c| b[c - 1] += 1 } 

  d = b.clone.sort
  d.delete_if { |c| c == 0 } 

  if d == [1, 1, 1, 1, 1] && straight?(b)
    puts 'straight'
  elsif d == [1, 4]
    puts 'four card'
  elsif d == [2, 3]
    puts 'full house'
  elsif d == [1, 1, 3]
    puts 'three card'
  elsif d == [1, 2, 2]
    puts 'two pair'
  elsif d == [1, 1, 1, 2]
    puts 'one pair'
  else
    puts 'null'
  end 
end

Measured memory_bytes: 2436
#include<iostream>
#include<string>
using namespace std;
string m[15];
int solve(int x,int y){
  if(m[x][y]=='1'){
    m[x][y]='0';
    for(int i=-3;i<=3;i++){
      if(x+i>=0 && x+i<=7 && m[x+i][y]=='1') solve(x+i,y);
      if(y+i>=0 && y+i<=7 && m[x][y+i]=='1') solve(x,y+i);
    }
    return 1;
  }
  else return 1;
}
int main(void){
  int n,x,y;
  cin >> n;
  for(int k=1;k<=n;k++){
    for(int i=0;i<8;i++){
      cin >> m[i];
    }
    cin >> x >> y;
    solve(y-1,x-1);
    cout << "Data " << k << ":" << endl;
    for(int i=0;i<8;i++){
      cout << m[i] << endl;
    }
  }
}


Measured memory_bytes: 1212
A=[]
x=1.0
y=0.0
for i in range(1,1001):
    A.append([x,y])
    tmp = i**.5
    x, y = x-y/tmp, y+x/tmp

while 1:
    n = input()
    if n==-1:break
    a,b = A[n-1]
    print "%.2f\n%.2f" % (a,b)

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


int main()
{
while(true) {
int n, k;
vector<int> x;
scanf("%d%d", &n, &k);
if(n == 0)
break;
x.resize(n);
for(int i = 0; i < n; ++i)
scanf("%d", &x[i]);
int cur = 0, ans;
for(int i = 0; i < k; ++i)
cur += x[i];
ans = cur;
for(int i = k; i < n; ++i) {
cur += x[i];
cur -= x[i - k];
ans = max(ans, cur);
}
printf("%d\n", ans);
}
return 0;
}

Measured memory_bytes: 1268
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    s = input()
    k = I()
    l = []
    n = len(s)
    alp = list("abcdefghijklmnopqrstuvwxyz")
    for i in alp:
        for j in range(n):
            if s[j] == i:
                l.append(s[j])
                for m in range(j+1,min(j+k,n)):
                    l.append(s[j:m+1])
        l = sorted(list(set(l)))
        if len(l) >= k:break
    print(l[k-1])
#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 40816
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int A,B,C,D,E,F; cin>>A>>B>>C>>D>>E>>F;

    int ans_sum, ans_sugar;
    double thick = -1;

    REP(a,101)
    {
        REP(b,101)
        {
            REP(c,101)
            {
                REP(d,101)
                {
                    int water = 100*A*a + 100*B*b;
                    int sugar = C*c+D*d;
                    if(sugar*100 <= E*water && (water+sugar <= F) && water != 0)
                    {
                        double tmp = sugar*1.0 / (water+sugar);
                        if(tmp > thick)
                        {
                            dump(water)
                            dump(sugar)
                            dump(c)
                            dump(d)
                            thick = tmp;
                            ans_sugar = sugar;
                            ans_sum = sugar + water;
                        }


                    }
                }
            }
        }

    }
    cout << ans_sum << " " << ans_sugar << endl;


}


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

using namespace std;

int main()
{
	int a, b;
	string c, d, e;
	cin>>c>>d;
	cin>>a>>b;
	cin>>e;
	if(c==e) a--;
	else if(d==e) b--;
	cout<<a<<" "<<b<<endl;
	


	return 0;
}

Measured memory_bytes: 384
/*
 * Author: Anmol Choudhary
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<"["<<#x<<"="<<x<<"] , ["<<#y<<"="<<y<<"]"<<"\n"
const ll mod = 1000000007;
const ll maxn = 100005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
void solve()
{
    int n,m;
    cin>>n>>m;
    if(n==m) cout<<"Yes";
    else cout<<"No";
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nextl;
    }
    return 0;
}


Measured memory_bytes: 256