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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N, K;
    vector<int> ans;
    while(true){
        int res = -1;
        cin >> N;
        if(N == 0) break;
        vector<int> work[N];
        vector<int> leak;
        rep(i, N){
            int M; cin >> M;
            rep(j, M){
                int temp; cin >> temp;
                work[i].push_back(temp);
            }
        }
        cin >> K;
        rep(i, K){
            int temp; cin >> temp;
            leak.push_back(temp);
        }
        rep(i, N){
            bool all_ok = true;
            rep(j, leak.size()){
                bool part_ok = false;
                rep(k, work[i].size()){
                    if(leak[j] == work[i][k]) part_ok = true;
                }
                if(!part_ok) all_ok = false;
            }
            if(all_ok && res != -1){
                res = -1;
                break;
            }
            else if(all_ok) res = i+1;
        }
        ans.push_back(res);
    }
    rep(i, ans.size()){
        cout << ans[i] << endl;
    }
    return 0;
}


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

int main()
{
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	for (int i = 0, x = 0, y = 1; i < n; ++i) {
		if (s[i] == 'a') {
			if (x < a + b) {
				++x;
				cout << "Yes" << endl;
			}
			else cout << "No" << endl;
		}
		else if (s[i] == 'b') {
			if (x < a + b && y <= b) {
				++x;
				cout << "Yes" << endl;
			}
			else cout << "No" << endl;
			++y;
		}
		else cout << "No" << endl;
	}

	return 0;
}

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

int main() {
  int N, x;
  cin >> N >> x;

  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int n = a.at(i);
    // お菓子が途中で足りなくなった場合
    if (x < n) {
      break;
    }
    // 最後の1名にお菓子を配る場合
    if (i == (N - 1)) {
      if (x == n) {
        ans++;
      }
      break;
    }

    x = x - a.at(i);
    ans++;
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;
int main(){
	string str1;
	int i, j, n = 0;
	while(getline(cin, str1)){
		bool change = false;
		for(i = 0;i < 28;i++){
			for(j = 0;j < str1.size();j++){
				if(str1[j] != ' ' && str1[j] != '.'){
					if(str1[j] == 'a'){
						str1[j] = 'z';
					}
					else str1[j] -= 1;
				}
			}
			for(j = 0;j+3 < str1.size();j++){
				if(str1[j] == 't' && str1[j+1] == 'h'){
					//if(str1[j+2] == 'e' || (str1[j+2] == 'i' && str1[j+3] == 's') || (str1[j+2] == 'a' && str1[j+3] == 't')){
						n = i + 1;
						change = true;
						break;
					//}
				}
			}
			if(change) break;
		}	
		for(i = 0;i < str1.size();i++){
			cout << str1[i];
		}
		cout << endl;
		
	}


	return 0;
}

Measured memory_bytes: 1168
a=input()
b=input()
if len(a)>len(b):
    print("GREATER")
elif len(a)<len(b):
    print("LESS")
else:
    for i,j in zip(a,b):
        if int(i)>int(j):
            print("GREATER")
            break
        elif int(i)<int(j):
            print("LESS")
            break
    else:
        print("EQUAL")

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

using namespace std;

struct P {
  int x;
  int y;
};

const int dx[4] = {-1, 0, +1, 0};
const int dy[4] = {0, -1, 0, +1};
int H, W, sy, sx, gy, gx;
vector<string> S;
vector<vector<int>> V;

int main() {
  cin >> H >> W >> sy >> sx >> gy >> gx;
  sy--;
  sx--;
  gy--;
  gx--;
  S.resize(H);
  for (int y = 0; y < H; y++) cin >> S[y];
  V = vector<vector<int>>(H, vector<int>(W, -1));

  int level = 0;
  queue<P> same;
  same.push({sx, sy});
  while (!same.empty()) {
    queue<P> jumps;
    while (!same.empty()) {
      P p = same.front();
      same.pop();

      if (V[p.y][p.x] != -1) continue;

      V[p.y][p.x] = level;
      for (int d = 0; d < 4; d++) {
        int x2 = p.x + dx[d];
        int y2 = p.y + dy[d];
        if (x2 < 0 || W <= x2 || y2 < 0 || H <= y2) continue;
        if (S[y2][x2] == '#') continue;
        same.push({x2, y2});
      }

      for (int x2 = p.x - 2; x2 <= p.x + 2; x2++) {
        for (int y2 = p.y - 2; y2 <= p.y + 2; y2++) {
          if (x2 < 0 || W <= x2 || y2 < 0 || H <= y2) continue;
          if (S[y2][x2] == '#') continue;
          jumps.push({x2, y2});
        }
      }
    }

    while (!jumps.empty()) {
      P p = jumps.front();
      jumps.pop();
      if (V[p.y][p.x] != -1) continue;
      same.push(p);
    }
    level++;
  }

  cout << V[gy][gx] << endl;

  return 0;
}


Measured memory_bytes: 10608
#include <iostream>
#include <list>
#include <valarray>
#include <cmath>
#include <cstdio>

using namespace std;

typedef double number;
typedef valarray<number> point;
const int dim = 3;

number dot(const point& a, const point& b) {
	return (a * b).sum();
}
point cross(const point& a, const point& b) {
	return a.cshift(+1)*b.cshift(-1)
		- a.cshift(-1)*b.cshift(+1);
}
number dist2(const point& a, const point& b) {
	return dot(a - b, a - b);
}

struct min_ball {
	point center;
	number radius2;
	void add(const point& p) {
		ps.push_back(p);
	}
	void compile() {
		m = 0;
		center.resize(dim, 0);
		radius2 = -1;
		make_ball(ps.end());
	}
	template <class OUT>
	void support(OUT out) {
		copy(ps.begin(), supp_end, out);
	}
	min_ball() {
		for (int i = 0; i <= dim; ++i) {
			c[i].resize(dim, 0);
			v[i].resize(dim, 0);
		}
	}
private:
	list<point> ps;
	list<point>::iterator supp_end;
	int m;
	point v[dim + 1], c[dim + 1];
	number z[dim + 1], r[dim + 1];
	void pop() { --m; }
	void push(const point& p) {
		if (m == 0) {
			c[0] = p; r[0] = 0;
		}
		else {
			number e = dist2(p, c[m - 1]) - r[m - 1];
			point delta = p - c[0];
			v[m] = p - c[0];
			for (int i = 1; i < m; ++i)
				v[m] -= v[i] * dot(v[i], delta) / z[i];
			z[m] = dot(v[m], v[m]);
			c[m] = c[m - 1] + e * v[m] / z[m] / 2.0;
			r[m] = r[m - 1] + e * e / z[m] / 4;
		}
		center = c[m];
		radius2 = r[m]; ++m;
	}
	void make_ball(list<point>::iterator i) {
		supp_end = ps.begin();
		if (m == dim + 1) return;
		for (list<point>::iterator k = ps.begin(); k != i; ) {
			list<point>::iterator j = k++;
			if (dist2(*j, center) > radius2) {
				push(*j); make_ball(j); pop();
				move_to_front(j);
			}
		}
	}
	void move_to_front(list<point>::iterator j) {
		if (supp_end == j) ++supp_end;
		ps.splice(ps.begin(), ps, j);
	}
};

int main()
{
	int N;
	cin >> N;
	min_ball ans;
	for (int i = 0; i < N; ++i) {
		double x, y, z = 0;
		cin >> x >> y;
		point p = { x, y, z };
		ans.add(p);
	}
	ans.compile();
	printf("%.10f\n", sqrt(ans.radius2));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main () {
  for(int i = 1 ; i < 110000 ; i++ ) {
    int x , y;
    cin >> x >> y;
    if(x == 0 && y== 0) break ;
    cout << min(x,y)<<' '<< max(x,y)<< endl ;
  }
}


Measured memory_bytes: 3000
/**
 * Created by hiramekun at 15:11 on 2019-09-02.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}


template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;

    vector<queue<ll>> v(n);
    rep(i, n) {
        rep(j, n - 1) {
            ll a;
            cin >> a;
            v[i].push(--a);
        }
    }

    queue<ll> next;
    ll res = n * (n - 1);
    ll ans = 0;
    bool flag = false;
    vector<bool> seen(n);

    auto solve = [&](ll now, queue<ll> &que, vector<bool> &seen, bool &flag) {
        if (v[now].empty()) return;
        ll j = v[now].front();
        if (v[j].empty()) return;

        if (!seen[j] && !seen[now] && v[j].front() == now) {
            seen[now] = seen[j] = true;
            v[now].pop(), v[j].pop();
            que.push(now), que.push(j);
            res -= 2;
            flag = true;
        }
    };
    auto validate_and_cnt = [&](bool flag) {
        if (flag) ans++;
        else {
            cout << -1 << '\n';
            exit(0);
        }
    };

    // initialize
    rep(i, n) {
        solve(i, next, seen, flag);
    }
    validate_and_cnt(flag);

    while (res > 0) {
        flag = false;
        fill(all(seen), false);
        queue<ll> tmp;
        while (!next.empty()) {
            ll now = next.front();
            next.pop();
            solve(now, tmp, seen, flag);
        }
        validate_and_cnt(flag);
        next = tmp;
    }

    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}



Measured memory_bytes: 8960
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;

int main(){
    int n,s[1000];
    double m,sum,a;
    while(true){
        cin>>n;
        if(n==0)break;
        sum=0;
        for(int i=0;i<n;i++){
            cin>>s[i];
            sum+=s[i];
        }
        m=sum/n;
        sum=0;
        for(int j=0;j<n;j++){
            sum+=(s[j]-m)*(s[j]-m);
        }
        a=sqrt(sum/n);
        printf("%f\n",a);
    }

    return 0;
}


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

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int q = Integer.parseInt(br.readLine());
      StringBuilder buf  = new StringBuilder();

      for(int i=0; i<q; i++) {
        buf.append( deriveLcs(br.readLine(), br.readLine()) )
           .append("\n");
      }

      System.out.print(buf);
    }
    catch (IOException e) {
      System.out.println("IOException!");
    }
  }

  private int deriveLcs(String seqX, String seqY) {
    int m = seqX.length();
    int n = seqY.length();
    int size = m > n ? m+1 : n+1;
    int[][] subSeq = new int[size][size];
    int maxSubSeq = 0;

    for(int i=1; i<=m; i++) subSeq[i][0] = 0;
    for(int j=1; j<=n; j++) subSeq[0][j] = 0;

    for(int i=1; i<=m; i++) {
      for(int j=1; j<=n; j++) {
        if(seqX.charAt(i-1) == seqY.charAt(j-1))
          subSeq[i][j] = subSeq[i-1][j-1] + 1;
        else
          subSeq[i][j] = Math.max(subSeq[i-1][j], subSeq[i][j-1]);

        maxSubSeq = Math.max(maxSubSeq, subSeq[i][j]);
      }
    }

    return maxSubSeq;
  }
}


Measured memory_bytes: 64444
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

class MinCostSort
{
public:
  int solve();
};

int MinCostSort::solve()
{
  int cost = 0;
  int n;
  cin >> n;
  
  vector<int> w(n);
  vector<int> sw(n);
  
  for ( int i = 0; i < n; ++i )
    {
      cin >> w[i];
      sw[i] = w[i];
    }

  sort( sw.begin(), sw.end() );

  int mw = sw[0];
  
  for ( auto i = 0; i < n; ++i )
    {
      if ( w[i] < 0 ) continue;
      
      if ( w[i] == sw[i] )
        {
          w[i] = -1;
          sw[i] = -1;
          continue;
        }
      
      int mlw = 20000;
      int ii = i;
      int j;
      int sm = 0;
      int ct = 0;
      
      while ( true )
        {
          for ( j = 0; j < n; ++j )
            {
              if ( sw[j] == w[ii] ) break;
            }
          if ( mlw > w[ii] ) mlw = w[ii];
          sm += w[ii];
          ++ct;
          w[ii] = -1;
          sw[j] = -1;
          ii = j;
          if ( ii == i ) break;
        }
      cost += min( sm + (ct - 2) * mlw, sm + (ct + 1) * mw + mlw );
    }
  
  cout << cost << endl;
  
  return 0;
}

int main()
{

  MinCostSort mcs;

  mcs.solve();

  return 0;
}

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

typedef long long ll;

int N;
bool a = 0;

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		int v;
		scanf("%d", &v);
		a |= v % 2;
	}
	if (a) printf("first\n");
	else printf("second\n");
}

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

typedef long long ll;
typedef unsigned long long ull;

const int MAX_BITS = 42;
const int N = 100005;

ll bits[MAX_BITS][2], n, k, in[N], fit[MAX_BITS];

int main () {
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> in[i];

	for (int i = 0; i < n; i++) 
		for (int j = 0; j < MAX_BITS; j++) 
			bits[j][(in[i]&(1LL<<j)) > 0]++;

	for (int i = 0; i < MAX_BITS; i++)
		fit[i] = (bits[i][0] > bits[i][1] ? 1 : 0);

	ll best = 0;
	for (int i = MAX_BITS-1; i >= 0; i--)
		if (best + fit[i]*(1LL<<i) <= k)
			best += fit[i]*(1LL<<i);
	
	ll ans = 0;
	for (int i = 0; i < n; i++)
		ans += best^in[i];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
using namespace std;
int main(int argc,char** argv){
  int N,K;
  cin>>N>>K;
  vector<int> h(N);
  for(int i=0;i<N;i++){
    cin>>h[i];
  }
  sort(h.begin(),h.end());
  int diff=INT_MAX;
  K--;
  N-=K;
  for(int i=0;i<N;i++){
    diff=min(diff,h[i+K]-h[i]);
  }
  cout<<diff<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
using namespace std;
int blo[55];
int sim[97];
int n;
int main(){
	for(int i=0;i<55;i++){
		blo[i]=i*i*i;
	}
	for(int j=0;j<97;j++){
		sim[j]=j*(j+1)*(j+2)/6;
	}
	while(1){
		scanf("%d",&n);
		if(!n)break;
		int ans=0;
		for(int i=0;i<55;i++){
			if(blo[i]>n){
				break;
			}else{
				int ryp=n-blo[i];
				int rp=upper_bound(sim,sim+97,ryp)-sim;
				if(rp){
					rp--;
				}
				ans=max(ans,blo[i]+sim[rp]);
			}
		}
		printf("%d\n",ans);
	}
}

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

int main (){
    int n;
    cin >> n;
    if(n%2 == 0){
        printf("%.10f", 0.5);
    } else {
        printf("%.10f", float (n / 2 + 1 ) /n);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    ll a, b, ans;
    char op;
    cin >> a >> op >> b;
    if(op == '+') ans = a+b;
    else ans = a-b;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
using namespace std;

void replaceAll(string &s, string a, string b){
  int pos = 0;
  while((pos=s.find(a))!=string::npos)s.replace(pos,a.size(),b);
}

string add(string a,string b){
  if(a.size() < b.size())return add(b,a);

  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());

  int carry = 0;
  for(int i=0;i<a.size();i++){
    a[i] += carry;
    if(i<b.size())a[i] += b[i] - '0';
    if(a[i] > '9'){
      carry = 1;
      a[i] -= 10;
    }else carry = 0;
  }
  
  if(carry)a += "1";
  reverse(a.begin(),a.end());
  return a;
}

int main(){
  int i;
  string s;
  while(cin >> s){
    s.replace(s.find("+"),1," "); s.replace(s.find("="),1," ");

    string t[3];
    stringstream ss(s);
    for(i=0;i<3;i++)ss >> t[i];

    for(i=0;i<10;i++){
      if(i==0){
	bool f = false;
	for(int j=0;j<3;j++)
	  if(t[j][0] == 'X' && t[j].size()>1)f = true;
	if(f)continue;
      }

      string tmp[3];
      for(int j=0;j<3;j++)tmp[j] = t[j];

      string digit = "";
      digit += '0'+i;
      for(int j=0;j<3;j++)replaceAll(tmp[j],"X",digit);
 
      if(add(tmp[0],tmp[1])==tmp[2]){
	cout << i << endl;
	break;
      }
    }
    if(i==10)cout << "NA\n";
  } 
}

Measured memory_bytes: 1212
#include<stdio.h>
#include<string.h>
#include<ctype.h>
main(){
  char w[10],t[1000];
  int i,counter=0;
  scanf("%s",w);
  while(1){
    scanf("%s",t);
    if(strcmp(t,"END_OF_TEXT")==0)
      break;
    for(i=0;t[i]!='\0';i++)
      t[i]=tolower(t[i]);
    if(strcmp(w,t)==0)
      counter++;
  }
  printf("%d\n",counter);
  return 0;
}


Measured memory_bytes: 2088
#include <cstdint>
#include <iostream>

using namespace std;

static int64_t split_same_height(int64_t H, int64_t W)
{
  int64_t min_diff = UINT32_MAX;
  for (int64_t i = 0; i <= H; i++) {
    int64_t w1 = i * W;
    int64_t w2 = (H - i) / 2 * W;
    int64_t w3 = (H - i - (H - i) / 2) * W;
    int64_t max_area = max(w1, max(w2, w3));
    int64_t min_area = min(w1, min(w2, w3));
    min_diff = min(min_diff, max_area - min_area);
  }
  return min_diff;
}

static int64_t split_bottom_two(int64_t H, int64_t W)
{
  int64_t min_diff = UINT32_MAX;
  for (int64_t i = 0; i <= H; i++) {
    int64_t w1 = i * W;
    int64_t w2 = (H - i) * (W / 2);
    int64_t w3 = (H - i) * (W - W / 2);
    int64_t max_area = max(w1, max(w2, w3));
    int64_t min_area = min(w1, min(w2, w3));
    min_diff = min(min_diff, max_area - min_area);
  }
  return min_diff;
}

int32_t main()
{
  int64_t H, W;
  cin >> H >> W;

  cout << min(split_same_height(H, W), min(split_same_height(W, H), min(split_bottom_two(W, H), split_bottom_two(H, W)))) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a[999];
int main(){
	ll n,y;
	scanf("%lld%lld",&n,&y);
	rep(i,0,n+1)rep(j,0,n+1){
		ll k=(y-10000*i-5000*j)/1000;
		if(k>=0&&i+j+k==n){
			printf("%lld %lld %lld\n",i,j,k);
			return 0;
		}
	}
	puts("-1 -1 -1");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
 
 
 
int main() {
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
     
    string s;
    cin>>s;
   cout<<s[0]<<s[1]<<s[2];
  
    
   
	return 0;
	
} 

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,cn;
  cin >> n >> cn;
  mat d(cn,vec(cn));
  for(ll i=0;i<cn;i++) {
    for(ll j=0;j<cn;j++) {
      ll t;
      cin >> t;
      d[i][j]=t;
    }
  }
  mat c(n,vec(n));
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<n;j++) {
      cin >> c[i][j];
      c[i][j]--;
    }
  }
  vector<map<ll,ll>> count(3);
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<n;j++) {
      count[(i+j+2)%3][c[i][j]]++;
    }
  }
  ll ans=inf;
  for(ll i=0;i<cn;i++) {
    for(ll j=0;j<cn;j++) {
      if(i==j) continue;
      for(ll k=0;k<cn;k++) {
        if(i==k||j==k) continue;
        ll tans=0;
        for(auto p:count[0]) {
          tans+=d[p.first][i]*p.second;
        }
        for(auto p:count[1]) {
          tans+=d[p.first][j]*p.second;
        }
        for(auto p:count[2]) {
          tans+=d[p.first][k]*p.second;
        }
        ans=min(ans,tans);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;
int main() {
	
	int x;
	cin >> x;
	string s;
	int sum = 0;
	cin >> s;
	for (int i = 0; i < x-1; i++) {
		if (s[i] != s[i + 1])sum++;
	}
	cout << sum + 1;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int h,w;
vs a;

void f(){
	for(int i=0;i<w+2;i++) cout<<'#';
	cout<<endl;
}

int main(){
	cin>>h>>w;
	a=vs(h);
	for(int i=0;i<h;i++) cin>>a[i];
	f();
	for(int i=0;i<h;i++){
		cout<<'#';
		for(int j=0;j<w;j++) cout<<a[i][j];
		cout<<'#'<<endl;
	}
	f();
}

Measured memory_bytes: 256
/*input
3
2 5

6
0 153 10 10 23
*/

#include <bits/stdc++.h>
using namespace std;
#define int long long int
// int dp[5003][5003];
#define maxl( X, Y) ((X) > (Y))? X : Y
// const int nax =100;
const int maxn = 1e5 +5;
#define debug(x) cout << #x << " " << x << "\n";

int exp(int a, int n)
{
	if ( n==0)
		return 1;
	if ( n==1 )
		return a;
	if ( n & 1)
		return (a * exp((a*a), n/2));
	else
		return exp((a*a), n/2);
}
const int nax =102;
int b[nax];
signed main()
{
	int n; 
	cin >> n;
	for ( int i =0; i < n-1; i++)
		cin >> b[i];
	b[n-1] = INT_MAX;
	int sum = b[0];
	for ( int i =1; i < n; i++)
	{
		sum += min(b[i] , b[i-1]);
	}
	cout << sum;
}


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

char S[112345];
int rec = 0;
bool ans = true;

int main(void) {
	scanf("%s", &S);

	rec = strlen(S) - 1;
	while (true) {
		if (rec <= 0) { break; }
		if (S[rec - 4] == 'd'&&
			S[rec - 3] == 'r'&&
			S[rec - 2] == 'e'&&
			S[rec - 1] == 'a'&&
			S[rec] == 'm') {
			rec -= 5;
		}
		else if (S[rec - 6] == 'd'&&
			S[rec - 5] == 'r'&&
			S[rec - 4] == 'e'&&
			S[rec - 3] == 'a'&&
			S[rec - 2] == 'm'&&
			S[rec - 1] == 'e'&&
			S[rec] == 'r') {
			rec -= 7;
		}
		else if (S[rec - 4] == 'e'&&
			S[rec - 3] == 'r'&&
			S[rec - 2] == 'a'&&
			S[rec - 1] == 's'&&
			S[rec] == 'e') {
			rec -= 5;
		}
		else if (S[rec - 5] == 'e'&&
			S[rec - 4] == 'r'&&
			S[rec - 3] == 'a'&&
			S[rec - 2] == 's'&&
			S[rec - 1] == 'e'&&
			S[rec] == 'r') {
			rec -= 6;
		}
		else {
			ans = false;
			break;
		}
	}

	if (ans == true) { printf("YES\n"); }
	else { printf("NO\n"); }
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int ans = 0;
  ans += min(a,k);
  k -= min(a,k);
  k -= min(b,k);
  ans -= min(c,k);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    
    string s;
    cin >> s;
    if (s.back() == 's') {
        s += "es";
    } else {
        s += "s";
    }
    cout << s << endl;

}






Measured memory_bytes: 3628
import math
import itertools
 
N=int(input())
P=[]
all_dist=[]
 
def Len(X,Y):
    return math.sqrt((X[0]-Y[0])**2+(X[1]-Y[1])**2)

for _ in range(N):
    a,b=map(int,input().split())
    P.append([a,b])
#print('townmap_is',P)
 
route=list(itertools.permutations(P))
#print(route)
 
for k in range(math.factorial(N)):
    B=0
    A=list(route[k])
    for i in range(len(A)-1):
        B+=Len(A[i],A[i+1])
    all_dist.append(B)
ans=sum(all_dist)/len(all_dist)
 
print(str(ans))

Measured memory_bytes: 9332
X, K, D = map(int, input().split())
x = abs(X)

if x - D*K >= 0 :
    print(x - D*K)
    exit()

k = x//D
if (K - k)%2 == 0:
    print(x - D*k)
    exit()
if x - D*(k-1) < abs(x - D*(k+1)):
    print(x - D*(k-1))
    exit()
else:
    print(abs(x - D*(k+1)))

Measured memory_bytes: 9192
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n = inn()
x = 0
for i in range(n):
    d,e = inm()
    if d==e:
        x += 1
        if x==3:
            print('Yes')
            exit()
    else:
        x = 0
print('No')


Measured memory_bytes: 62488
#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
int a[N];
vector<int> b;
int main(){
    ios::sync_with_stdio(0);
    int n; cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n);
    for(int i=1;i<=n/3;i++){
        b.push_back(a[i]);
        if(i+n/3<=n) b.push_back(a[i+n/3]);
        if(i+n/3+n/3<=n) b.push_back(a[i+n/3+n/3]);
    }
    int ok = 1;
    for(int i=0;i<n;i++){
        if((b[i]^b[(i+1)%n])!=b[(i+2)%n]) ok = 0;
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 1276
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

int main(){
    string s;
    cin>>s;
    int l=0,r=s.size()-1;
    int ans=0;
    while(l<=r){
        if(s[l]!=s[r]){
            if(s[l]=='x'){
                l++;
                ans++;
            }
            else if(s[r]=='x'){
                r--;
                ans++;
            }
            else{
                cout<<"-1"<<endl;
                return 0;
            }
        }
        else{
            l++;
            r--;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
h, w = map(int, input().split())
s = ["a"*(w+2)] + ["a" + input() + "a" for i in range(h)] + ["a"*(w+2)]

ans = []
for i in range(1, h+1):
  for j in range(1, w+1):
    if s[i][j] == "#":
      ans.append("#")
    else:
      c = [s[i-1][j-1], s[i-1][j], s[i-1][j+1], s[i][j-1], s[i][j+1], s[i+1][j-1], s[i+1][j], s[i+1][j+1]]
      ans.append(c.count("#"))
      
for i in range(h):
  print("".join(list(map(str, ans[i*w:(i+1)*w]))))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int dp[100101];
int h[100001];

int main() {
    int n; cin >> n;
    rep(i,n) cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    REP(i,2,n){
        dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int num1 = scan.nextInt();
		int[] array1 = new int[num1+1];
		 //配列1個目
		for(int i = 0; i < num1; i++) {
			array1[i] = scan.nextInt();
		}
		//配列2個目
		int num2 = scan.nextInt();
		int[] array2 = new int[num2];
		for(int i = 0; i < num2; i++) {
			array2[i] = scan.nextInt();
		}
		
		int count = 0; //2つの配列の共通の個数
		
		for(int i = 0; i < num2; i++) {
		count += linearSearch(num1, array1, array2[i]);
		}
		
		System.out.println(count);

}
	public static int linearSearch(int num1, int[] S, int x) {
		int i = 0;
		S[num1] = x;
		while(S[i] != x) {
			i++;
			if(i == num1) {
				return 0;
			}
		}
		return 1;
	}
}


Measured memory_bytes: 39880
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        
        UnionFind uf = new UnionFind(n);
        
        List<Integer>[] to = new List[n];
        for (int i = 0; i < n; i++) {
            to[i] = new ArrayList<Integer>();
        }
        
        for (int i = 0; i < m; i++) {
            int p = sc.nextInt() - 1;
            int q = sc.nextInt() - 1;
            if (p > q) {
                int tmp = p;
                p = q;
                q = tmp;
            }
            uf.unite(p, q);
            
            to[p].add(q);
            to[q].add(p);
        }
        
        List<Integer>[] to2 = new List[n];
        for (int i = 0; i < n; i++) {
            to2[i] = new ArrayList<Integer>();
        }
        
        for (int i = 0; i < k; i++) {
            int p = sc.nextInt() - 1;
            int q = sc.nextInt() - 1;
            
            to2[p].add(q);
            to2[q].add(p);
        }
        
        for (int i = 0; i < n; i++) {
            int count = uf.size[uf.root(i)];
            count--;
            count -= to[i].size();
            // System.out.println(count + "a");
            
            
            for (Integer x : to2[i]) {
                if (uf.same(x, i)) {
                    count--;
                }
            }
            
            System.out.print(count);
            if (i != n - 1) {
                System.out.print(" ");
            } else {
                System.out.println();
            }
        }
    }
}

class UnionFind {
    int[] par;  // 自身の親
    int[] size; // 自身の属するグループの要素数
    int connectedComponent;

    UnionFind(int n) {
        par = new int[n];
        for (int i = 0; i < n; i++) {
            par[i] = i;
        }
        
        size = new int[n];
        Arrays.fill(size, 1);
        connectedComponent = n;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
        // 1-2-4の場合、4の親=2を4の根=1に繋ぎ変えた上で親を返す
        // ↑根まで辿る深さを減らす為
        // return a = b;とは、aにbを代入し、aを返すという意味
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx != ry) {
            par[ry] = rx;
            
            int resize = size[rx] + size[ry];
            size[rx] = resize;
            size[ry] = resize;
            connectedComponent--;
        }
    }

    boolean same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
}

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | ";
    __f(comma + 1, args...);
}

int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);
    ll ans = 0;
    ll x, k, d;
    cin >> x >> k >> d;
    if (x < 0)
        x *= -1;
    ll y = x / d;
    if (y > k)
    {
        ans = x - (k * d);
    }
    else
    {
        k -= y;
        if (x == 0)
        {
            if (k & 1)
                ans = d;
        }
        else
        {
            ll u = x - (y * d) - d;
            u *= -1;
            if (k & 1)
                ans = u;
            else
                ans = x - (y * d);
        }
    }

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


Measured memory_bytes: 3640
from collections import defaultdict


def factorize2(n):
    """
    nの値を素因数分解し、素因数とその指数をtupleにまとめたリストを返す
    e.g.
    [(2, 2), (5, 1)]
    """
    b = 2
    fct = []
    while b * b <= n:
        cnt = 0
        while n % b == 0:
            cnt += 1
            n //= b
        if cnt > 0:
            fct.append((b, cnt))
        b += 1
    if n > 1:
        fct.append((n, 1))
    return fct


# 75 = 5 * 5 * 3
# p^74 / p^24 * q^2 / p^14 * q^4 / p^4 * q^4 * r^2 の形しか七五数になりえない

N = int(input())
pf = defaultdict(int)
for i in range(1, N + 1):
    for p, n in factorize2(i):
        pf[p] += n

c74, c24, c14, c4, c2 = 0, 0, 0, 0, 0
for p, n in pf.items():
    if n >= 74:
        c74 += 1
    if n >= 24:
        c24 += 1
    if n >= 14:
        c14 += 1
    if n >= 4:
        c4 += 1
    if n >= 2:
        c2 += 1

ans = c74
ans += c24 * max(0, c2 - 1)
ans += c14 * max(0, c4 - 1)
ans += (c4 * max(0, c4 - 1) // 2) * max(0, c2 - 2)
print(ans)

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

int main() {
  ll n; cin>>n;
  vector<ll> v(n);
  ll sum=0, cm=0, m;
  rep(i,n){
    cin>>v[i];
    if(i==0){m=abs(v[0]);}
    sum+=abs(v[i]);
    if(v[i]<0){cm++;}
    m=min(m,abs(v[i]));
  }
  if(cm %2==0 || m==0){cout<<sum;}
  else{cout<<sum-2*m;}
}



Measured memory_bytes: 4044
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define ull unsigned long long

int main (){
  ull H;
  cin >> H;

  ull cnt = 0;
  do {
    ++cnt;
  } while ((H = H / 2) > 0);

  ull ans = pow(2, cnt) - 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
import sys
import numpy as np


def solve(S: str):
    print(S[:3])
    return


# 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
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27112
# include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int main(){

  int a, b, c, d, e, k;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cin >> e;
  cin >> k;
  if(e-a > k){
    cout << ":(" << endl;
  } else{
    cout << "Yay!" << endl;
  }
}

Measured memory_bytes: 256
A, B = map(int, input().split())


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


a = set(prime_decomposition(A))
b = set(prime_decomposition(B))

print(len(a & b) + 1)

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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    while(1) {
        ll n;
        cin >> n;
        if(!n) break;
        vector<tuple<ll,ll,ll,ll>> v(2*n);
        for(ll i=0; i<n; i++) {
            string s;

            cin >> s;
            s[2] = s[5] = '\0';
            ll x, y, z;
            tie(x, y, z) = make_tuple(atoll(s.c_str()), atoll(s.c_str()+3), atoll(s.c_str()+6));
            v[2*i+0] = make_tuple(x,y,z,1);

            cin >> s;
            s[2] = s[5] = '\0';
            tie(x, y, z) = make_tuple(atoll(s.c_str()), atoll(s.c_str()+3), atoll(s.c_str()+6));
            v[2*i+1] = make_tuple(x,y,z,-1);
        }

        sort(v.begin(), v.end());

        ll res = 0, s = 0;
        for(auto &t: v) {
            ll x, y, z, w;
            tie(x, y, z, w) = t;
            s += w;
            res = max(res, s);
        }
        cout << res << endl;
    }
}



Measured memory_bytes: 3820
from bisect import bisect_left
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
ans = 0
for ele in t:
  i = bisect_left(s, ele)
  if s[i]==ele:
    ans += 1
print(ans)


Measured memory_bytes: 16740
package main

import (
	"fmt"
)

func main(){
	var w, h, x, y int64
	fmt.Scanf("%d%d%d%d",&w,&h,&x,&y)
	ans1 := float64(w) * float64(h) / 2
	
	if x + x == w && y + y == h {
		fmt.Printf("%f %d\n",ans1,1)
	} else {
		fmt.Printf("%f %d\n",ans1,0)
	}

}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;

int main()
{
	string s;
	cin >> s;
	if (s == "keyence")
	{
		co("YES");
		return 0;
	}
	int n = s.size();
	rep(i, n)
	{
		for (int j = i; j < n; j++)
		{
			string s1 = s;
			s1.erase(i, j - i + 1);
			if (s1=="keyence")
			{
				co("YES");
				return 0;
			}
		}
	}
	co("NO");
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
    public static void main(String [] args)
    {
        Scanner scan = new Scanner(System.in);
       
        int a = scan.nextInt();

        int b = scan.nextInt();
        

        System.out.print(a * b);
        
        System.out.print(" ");

        System.out.println((a * 2) + (b * 2));
    }  
}



Measured memory_bytes: 26092
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll dp[100005];

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

    for(int i=0;i<100005;i++) dp[i] = LINF;
    dp[0] = 0;
    for(int i=0;i<N;i++){
        dp[i+1] = min(dp[i+1],dp[i] + abs(h[i+1] - h[i]));
        dp[i+2] = min(dp[i+2],dp[i] + abs(h[i+2] - h[i]));
    }
    cout << dp[N-1] << endl;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<string> S(N, "");
    char initial[5] = {'M', 'A', 'R', 'C', 'H'};
    map<char, ll> countInital;
    REP(i, 5)
    {
        countInital[initial[i]] = 0;
    }
    REP(i, N)
    {
        cin >> S[i];
        REP(j, 5)
        {
            if (S[i][0] == initial[j])
                countInital[initial[j]]++;
        }
    }

    ll ans = 0;
    REP(i, 5)
    {
        char c1 = initial[i];
        REP(j, 5)
        {
            if (initial[j] != c1)
            {
                char c2 = initial[j];
                REP(k, 5)
                {
                    if (initial[k] != c1 && initial[k] != c2)
                    {
                        char c3 = initial[k];
                        ans += countInital[c1] * countInital[c2] * countInital[c3];
                    }
                }
            }
        }
    }
    // 順列で組み合わせを足しているので3!=6 で答えをわる
    ans /= 6;

    cout << ans << endl;
}


Measured memory_bytes: 6144
import sys

def increment(asc, N):
    new_int = asc + N
    if new_int > ord('Z'):
        new_int = new_int - ord('Z') + ord('A') - 1
    return new_int

N = int(input())
S = input()

out = ''
for c in list(S):
    asc = ord(c)
    new_c = chr(increment(asc, N))
    out += new_c

print(out)

Measured memory_bytes: 41180
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

const int MOD = INF+7;

int main(){
    int n;cin>>n;
    string s;cin>>s;
    vector<int>r(n,0),g(n,0),b(n,0);
    rep(i,n){
        r[i] += r[i-1];
        g[i] += g[i-1];
        b[i] += b[i-1];
        if(s[i]=='R')r[i]++;
        if(s[i]=='G')g[i]++;
        if(s[i]=='B')b[i]++;
    }
    ll res = 0;
    rep(i,n){
        REP(j,i+1,n-1){
            if(s[i]!=s[j]){
              //cout<<i<<" "<<j<<" "<<j+j-i<<endl;
                if(s[i]!='R' && s[j]!='R'){
                    if(j+j-i>=n)res += (r[n-1]-r[j]);
                    else res += ((r[j+j-i-1]-r[j])+(r[n-1]-r[j+j-i]));
                }
                if(s[i]!='G' && s[j]!='G'){
                    if(j+j-i>=n)res += (g[n-1]-g[j]);
                    else res += ((g[j+j-i-1]-g[j])+(g[n-1]-g[j+j-i]));
                }
                if(s[i]!='B' && s[j]!='B'){
                    if(j+j-i>=n)res += (b[n-1]-b[j]);
                    else res += ((b[j+j-i-1]-b[j])+(b[n-1]-b[j+j-i]));
                  //if(i==0 && j==2)cout<<((b[j+j-i-1]-b[j])+(b[n-1]-b[j+j-i]));
                }
            }
        }
    }
    cout<<res<<endl;
    //rep(i,n)cout<<r[i]<<" "<<g[i]<<" "<<b[i]<<endl;
}

Measured memory_bytes: 3660
n = gets.to_i
a = gets.split.map(&:to_i)
class Array
  def gcd
    inject(:gcd)
  end
end
sc = a.gcd

pc = true
x = []
N = a.max

#####2以上N以下の整数　高速素因数分解
#前処理エラトステネスの篩 O(NloglogN)
$spf = Array.new(N-1){|index|index+2}
min = 2
for i in 2..(Math.sqrt(N).to_i)
  if $spf[i-2] == i
    for j in 1..(N/i)
      $spf[i*j-2] = i
    end
  end
end

#クエリ 素因数分解する整数Aに対してO(logA)
def pdiv(sub)
  x = sub
  y = []
  while x != 1
    y << $spf[x-2]
    x /= $spf[x-2]
  end
  y.tally.to_a
end

h = Hash.new(0)
a.each do |i|
  y = pdiv(i)
  y.each do |j|
    if h[j[0]] == 0
      h[j[0]] = 1
    else
      pc = false
      break
    end
  end
  break if pc == false
end

if pc == true
  puts "pairwise coprime"
elsif sc == 1
  puts "setwise coprime"
else
  puts "not coprime"
end

Measured memory_bytes: 108208
N = int(input())
Na = []
T = []
for i in range(N):
    na, t = input().split()
    t = int(t)
    T.append(t)
    Na.append(na)

X = input()

re = 0
for i in range(N):
    if Na[i]==X:
        re += T[i]
        break
    re += T[i]

print(sum(T)-re)

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

using namespace std;

int n;
long double tmp;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		tmp += (long double)(1)/x;
	}
	cout.precision(20);
	cout << fixed << 1/tmp << '\n';
	return 0;
}


Measured memory_bytes: 256