akhauriyash/Code-Regression huggingface dataset:
/// Swift5 -> Swift2.2

extension String {
    // split(separator:maxSplits:omittingEmptySubsequences:)
    func split(separator separator: Character) -> [String] {
        return self.characters.split(separator).map(String.init)
    }
}
extension Array {
    // init(repeating:count:)
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
  	// func lastIndex(where predicate: (Element) throws -> Bool) rethrows -> Int?
    func lastIndex(where predicate: (Element) -> Bool) -> Int? {
      	for i in stride(from: count - 1, through: 0, by: -1) {
          	if predicate(self[i]) {
              	return i
            }
        }
      	return nil
    }
}
extension Array where Element: Comparable {
    // sorted()
    func sorted() -> [Element] {
        return self.sort( { $0 < $1 } )
    }
}
// stride(from:through:by:)
func stride(from start: Int, through end: Int, by stride: Int) -> StrideThrough<Int> {
    return start.stride(through: end, by: stride)
}
// stride(from:to:by)
func stride(from start: Int, to end: Int, by stride: Int) -> StrideTo<Int> {
    return start.stride(to: end, by: stride)
}
extension Range {
    func reversed() -> [Element] {
        return self.reverse()
    }
}

/// end

let input = readLine()!.split(separator: " ").map { Int($0)! }
let N = input[0]
let W = input[1]

var dp = Array(repeating: 1_000_000_000 + 1, count: 1_000 * N + 1)
dp[0] = 0

for _ in 0 ..< N {
    let knapsack = readLine()!.split(separator: " ").map { Int($0)! }
    let weight = knapsack[0]
    let value = knapsack[1]

    for i in stride(from: 1_000 * N, through: value, by: -1) {
        dp[i] = min(dp[i], dp[i - value] + weight)
    }
}

print(dp.lastIndex { $0 <= W }!)


Measured memory_bytes: 4208
import java.util.*;
class Main{
public static void main(String[]args){
  Scanner sc=new Scanner(System.in);
  long x=Math.abs(sc.nextLong());
  long k=sc.nextLong();
  long d=sc.nextLong();
  if(k-x/d<=0){
    System.out.println(x-k*d);
  }else{
  k-=x/d;
  System.out.println(k%2==0?x-d*(x/d):Math.abs(x-d*(x/d)-d));}
}
}


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

int class_judge(int x){
    if(x == 2){
        return 3;
    }else if(x == 4 || x == 6 || x == 9 || x == 11){
        return 2;
    }else{
        return 1;
    }
}
int main(){
    int a, b;
    int aclass, bclass;
    cin >> a >> b;
    aclass = class_judge(a);
    bclass = class_judge(b);
    if(aclass == bclass){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


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

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}



void solve() {
	ll n, x;
	cin >> n >> x;
	ll y = n - x;
	ll ans = x + y * (x / y * 2);
	if (x % y == 0) {
		cout << ans << en;
		return;
	}
	ans += y + x % y * 2;
	x = x % y;
	y = y - x;
	while(true){
		if (y > x) {
			ans += y / x * x * 2;
			if (y % x == 0) {
				ans -= x;
				cout << ans << en;
				return;
			}
			y = y % x;
		}
		ans += x / y * 2 * y;
		if (x % y == 0) {
			ans -= y;
			cout << ans << en;
			return;
		}
		ans += x % y * 2;
		x = x % y;
		y = y - x;
	}
	cout << ans << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=1e6+5,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,Q,K,T;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
int kpow(int x,int k){
    int ans=1,now=x;
    while(k){
        if(k&1)ans=1ll*ans*now%mod;
        now=1ll*now*now%mod,k>>=1;
    }return ans;
}

signed main(){
    //file(a);
    n=read();
    int ans=(kpow(10,n)-kpow(8,n)+mod)%mod;//cout<<ans<<endl;
    int inv8=kpow(8,mod-2),sum=0,nowc=n,now8=kpow(8,n-1);
    rep(i,1,n){
        sum=(sum+2ll*nowc*now8%mod)%mod;
        nowc=1ll*(n-i)*kpow(i+1,mod-2)%mod*nowc%mod;
        now8=1ll*now8*inv8%mod;
    }printf("%lld\n",(ans-sum+mod)%mod);
    


    return 0;
}


Measured memory_bytes: 3680
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        boolean all2 = true;
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 != 0) {
                all2 = false;
                break;
            }
        }

        if (all2) {
            System.out.println("second");
        } else {
            System.out.println("first");
        }
    }
}


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

using namespace std;

class UnionFind {
 public:
  vector<int> parent;

  UnionFind(int n) : parent(n, -1) {}

  int root(int x) {
    if (parent[x] < 0) return x;
    return parent[x] = root(parent[x]);
  }

  bool issame(int x, int y) { return root(x) == root(y); }

  int size(int x) { return -parent[root(x)]; }

  bool unite(int x, int y) {
    int rx = root(x), ry = root(y);
    if (rx == ry) return false;
    if (parent[rx] > parent[ry]) swap(rx, ry);
    parent[rx] += parent[ry];
    parent[ry] = rx;
    return true;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind uf(N);
  vector<vector<int>> AB(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    uf.unite(a, b);
    AB[a].emplace_back(b);
    AB[b].emplace_back(a);
  }
  vector<vector<int>> CD(N);
  for (int i = 0; i < K; i++) {
    int c, d;
    cin >> c >> d;
    c--, d--;
    CD[c].emplace_back(d);
    CD[d].emplace_back(c);
  }
  for (int i = 0; i < N; i++) {
    int res = uf.size(i) - (int)AB[i].size();
    for (int x : CD[i]) {
      if (uf.issame(i, x)) res--;
    }
    cout << res - 1 << (i == N - 1 ? '\n' : ' ');
  }
  return 0;
}


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

int val[100010];


int main()
{
	int n,k,q;
	cin>>n>>k>>q;
	for(int i=1; i<=n; i++)
		val[i]=k-q;
	int x;
	for(int i=0; i<q; i++)
	{
		scanf("%d",&x);
		val[x]++;
	}
	for(int i=1; i<=n; i++)
	{
		if(val[i] <= 0)
			puts("No");
		else puts("Yes");
	}
	return 0;
}



Measured memory_bytes: 1024
import scala.io.StdIn

object Main extends App {
  val s  = StdIn.readLine()

  def solve(s: String): String = {
    s.zipWithIndex.foreach { v =>
      if ((v._2 + 1) %2 == 0) {
        if (v._1 != 'L'  &&  v._1 != 'U' && v._1 != 'D') {
          return "No"
        }
      } else {
        if (v._1 != 'R'  &&  v._1 != 'U' && v._1 != 'D') {
          return "No"
        }
      }
    }
    "Yes"
  }
  println(solve(s))
}
  



Measured memory_bytes: 25532
#include <math.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

template <typename A, typename B>
std::ostream& operator<<(std::ostream& os, std::pair<A, B>& v) {
    return os << "(" << v.first << " " << v.second << ")";
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& v) {
    os << "[ "; for (auto &i: v) os << i << " "; return os << "]";
}

template <typename T>
void eout(const char *s, T H) {
    std::cerr << s << "=" << H << "\n";
}

template <typename T1, typename... T2>
void eout(const char *s, T1 H, T2... T) {
    while (*s != ',') std::cerr << *s++;
    std::cerr << "=" << H << " | "; eout(++s, T...);
}

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(args...)      std::cerr << "DBG:"; eout(#args, args)

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define sz(v)             ((int) v.size())
#define all(v)            (v).begin(), (v).end()

#define no                std::cout << "NO\n"
#define yes               std::cout << "YES\n"

#define INF    	          2147483647
#define LNF               9223372036854775807LL

using ll  = long long int;
using vi  = std::vector<int>;
using vb  = std::vector<bool>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

int solve();
int main() {
    std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

    //inn(t); repr(tc, 1, t + 1)
    (void) solve();

    return 0;
}

int solve() {
    inn(l); inn(r);

    if (r - l + 1 >= 2019) out(0);
    else {
        int ans = 2019;
        repr(i, l, r + 1) {
            repr(j, i + 1, r + 1) {
                ans = std::min(ans, (int) ((ll) i * j % 2019));
            }
        }
        out(ans);
    }
    return 0;
}


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

using namespace std;

#define pb push_back
#define ll long long
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define bug cout << "ok" << endl

const ll INF = 1e9 + 5, N = 1e5 + 5, mod = 1e9 + 7;

int main(){
	string s;
	cin >> s;
	ll ans = 0;
	for(int i = 0; i < s.size(); i++){
		ll x = s[i] - '0';
		ans += x;
		ans %= 9;
	}
	if(ans == 0) cout << "Yes" << endl;
	else cout << "No" << endl; 
}

Measured memory_bytes: 3724
#include<iostream>
#include<algorithm>
using namespace std;
static const int Max = 200000;
int min(int a, int b)
{
	return a > b ? b : a;
}
int max(int a, int b)
{
	return a < b ? b : a;
}
int main()
{
	int n,R[Max];
	int maxv, minv;
	while (cin >> n) {
		for (int i = 0; i < n; i++)
			cin >> R[i];
		minv = R[0];
		maxv = -2000000000;
		for (int j = 1; j < n; j++)
		{
			
			maxv = max(maxv, R[j]-minv);
			minv = min(minv, R[j]);
		}
		cout << maxv  << endl;
	
	}
    return 0;
}


Measured memory_bytes: 3880
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define each(e,v) for(auto&& e:(v))
#define DEBUG(x) cout<<#x<<": "<<x<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;

int main() {
    int a, b; cin >> a >> b;
    if(a <= 0 && 0 <= b) cout << "Zero" << endl;
    else if(0 < a) cout << "Positive" << endl;
    else if((b-a) % 2 == 0) {
        cout << "Negative" << endl;
    } else {
        cout << "Positive" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long 
#define mp make_pair
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0) 
#define sz(a) (a).size()
#define triple pair<pill, ll>
#define pinode pair<node*, node*>
#define quadra pair<pill, pill>
using namespace std;

/*
 tips :
 Sqrt opt
 Binary search
 Try to find the easiest solution
 Recursiya
 FUCK YOU pishi kod akuratnee daun yobani
 sdohni v adu nahui blyat' y ub'uy tebya
 esli ti blyad' budesh pisat' kod gryaznim
 to ya tebya v rot viebu
*/

const ll N = 1e6 + 10;
const ll big = 1e18;
const ll shift = 1000;
const ll block = 500;
const long long mod = 1e9 + 7;

ll dp[N];

ll n;
vector<pill> z;

struct node {
 	node *l, *r;
 	ll z;
 	node(ll wh) {
 	 	l = r = nullptr;
 	 	z = wh;
 	}
} *rt[2] = {new node(big), new node(-big)};

void upd(ll p, ll a, ll b, node *u = rt[0], node *v = rt[1], ll tl = 0, ll tr = 1e9 + 1) {
 	if(tl == tr) {
 	    u->z = min(u->z, a + b);
 	    v->z = max(v->z, b - a);
	 	return;
 	}
 	ll m = tl + tr >> 1;
 	if(p <= m)
 		upd(p, a, b, u->l = (u->l ? u->l : new node(big)), v->l = (v->l ? v->l : new node(-big)), tl, m);
	else
		upd(p, a, b, u->r = (u->r ? u->r : new node(big)), v->r = (v->r ? v->r : new node(-big)), m + 1, tr);
	v->z = max((v->l ? v->l->z : -big), v->r ? v->r->z : -big);
	u->z = min((u->l ? u->l->z : big), u->r ? u->r->z : big);
}
                                                                                	
ll getL(ll l, ll r, node *v = rt[1], ll tl = 0, ll tr = 1e9 + 1) {
	if(l > tr || tl > r || !v)
		return  -big;
	if(l <= tl && tr <= r)	
		return v->z;
	ll m = tl + tr >> 1;
	return max(getL(l, r, v->l, tl, m), getL(l, r,  v->r, m + 1, tr));
}

ll getR(ll l, ll r, node *v = rt[0], ll tl = 0, ll tr = 1e9 + 1) {
	if(l > tr || tl > r || !v)
		return big;
	if(l <= tl && tr <= r)	
		return v->z;
	ll m = tl + tr >> 1;
	return min(getR(l, r, v->l, tl, m), getR(l, r,  v->r, m + 1, tr));
}           


int main() {
  	speed;
	cin >> n;
	for(int i = 1, a, b; i <= n; i++) {
		cin >> a >> b;
		z.pb({a, b});
	}
	sort(all(z));
	ll ans = -2 * big;
	for(auto u : z) {
	 	ll su = u.f + u.s;
	 	ll a = getR(0, u.s);
	 	ll b = getL(u.s, 1e9 + 1);
	 	if(a != big)
	 		ans = max(ans, su - a);
	 	if(b != -big)
	 		ans = max(ans, (u.f - u.s) + b);	
		upd(u.s, u.f, u.s);		 	
	}
	cout << ans;
}             

/*

*/          

Measured memory_bytes: 174224
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    while(cin >> n >> s){
        cout << (n >= 3200 ? s : "red") << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	string s;
	cin>>s;
	rep(i,s.size()-1){
		if(s[i]==s[i+1]){
			cout<<i+1<<" "<<i+2<<endl;
			return;
		}
	}
	if(s.size()>=3) rep(i,s.size()-2){
		if(s[i]==s[i+2]){
			cout<<i+1<<" "<<i+3<<endl;
			return;
		}
	}
	cout<<-1<<" "<<-1<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;

//二次元配列
//先に周囲8ますに存在する爆弾の個数を記録した配列を作成、
//次いで爆弾ならば数字を置き換える

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

    //8箇所
    int[] dx = {-1,-1,-1, 0,0, 1,1,1};
    int[] dy = {-1, 0, 1,-1,1,-1,0,1};
    int h  = sc.nextInt();
    int w  = sc.nextInt();
    // char[][] bomb = new char
    String bomb = "#";
    char[] charBomb = bomb.toCharArray();
    String[] s = new String[h];
    for (int i = 0; i < h; i++) {
      s[i] = sc.next();
    }
    int[][] board = new int[100][100];
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if(s[i].charAt(j) == charBomb[0]){
            for (int k = 0; k < 8; k++) {
              if(0 <= i+dy[k] && i+dy[k] <= h && 0 <= j+dx[k] && j+dx[k] <= w){
                board[i+dy[k]][j+dx[k]]++;
              }
            }

        }
      }
    }
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
          if(s[i].charAt(j) == charBomb[0]){
            System.out.print(charBomb[0]);
          }else{
            System.out.print(board[i][j]);
          }
      }
      System.out.println(" ");
    }

  }
}


Measured memory_bytes: 22228
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int a[100100],b[100100],c[200100],n;

int lowbit(int x)
{
    return x&(-x);
}

void add(int x,int val)
{
    x=x+(n+1);
    int i;
    for (i=x;i<=2*n+1;i+=lowbit(i)) c[i]+=val;
}

long long sum(int x)
{
    x+=(n+1);
    int i;
    long long ans=0;
    for (i=x;i>0;i-=lowbit(i)) ans+=c[i];
    return ans;
}

long long work(int num)
{
    int i,tmp=0;long long ans=0;
    for (i=1;i<=n;i++)
    {
        if (a[i]<=num) tmp++; else tmp--;
        ans+=sum(tmp-1);
        add(tmp,1);
    }
    tmp=0;
    for (i=1;i<=n;i++)
    {
        if (a[i]<=num) tmp++; else tmp--;
        add(tmp,-1);
    }
    return ans;
}

int main()
{
    int i;
    scanf("%d",&n);
    for (i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    memset(c,0,sizeof(c));
    sort(b+1,b+1+n);
    int m=unique(b+1,b+1+n)-b-1;
    int l=1,r=m,ans;
    long long target=(long long)n*(n+1)/2;target=target/2+1;
    add(0,1);
    while (l<=r)
    {
        int mid=(l+r)/2;
        if (work(b[mid])>=target) {ans=b[mid];r=mid-1;}
        else l=mid+1;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1792
import sys
from collections import Counter
from collections import deque
import math
import fractions
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
au=lmp()
ad=lmp()
u=[0]*n
d=[0]*n
u[0]=au[0]
d[0]=sum(ad)
for i in range(1,n):
    u[i]=u[i-1]+au[i]
    d[i]=d[i-1]-ad[i-1]
ans=[0]*n
for i in range(n):
    ans[i]=u[i]+d[i]
print(max(ans))

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver2 {
 public:
  int n, m;
  Solver2(LL n, LL m) : n(n), m(m){};

  void solve() {
    cout << n - m + 1 << endl;
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, k;
  std::cin >> n >> k;

  Problem::Solver2 sol(n, k);
  sol.solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
#define sort(x) sort(x.begin(), x.end())
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    if(n == m)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl
#define DOUBLE(d) cout << fixed << setprecision(15) << (d) << endl

int N;

void build(int k) {
    cout << k << endl;
    vvi ans(k);
    int x = 1;
    REP (i, k) FOR (j, i+1, k) {
        ans[i].push_back(x);
        ans[j].push_back(x);
        x++;
    }

    REP (i, k) {
        cout << k-1;
        FORE (x, ans[i]) cout << " " << x;
        cout << endl;
    }
}

void solve() {
    REP (k, N+10) {
        if (k * (k-1) / 2 == N) {
            cout << "Yes" << endl;
            build(k);
            return;
        } else if (k * (k-1) / 2 > N) {
            cout << "No" << endl;
            return;
        }
    }
}

int main() {
    cin >> N;
    solve();
}

Measured memory_bytes: 3200
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int A,B,C,D;
    cin>>A>>B>>C>>D;

    int x=C-A;
    int y=D-B;

    cout<<C-y<<" "<<D+x<<" "<<A-y<<" "<<B+x<<endl;


}




Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    int a[m];
    set<int> st;
    for (int i=0; i<m; i++) {
        int a;
        cin >> a;
        st.insert(a);
    }
    long long p[n+1]; //i段目にたどりつくまでの移動方法をp[i]通りとする
    p[0] = 1;
    if (*st.begin() == 1) {
        p[1] = 0;
        st.erase(st.begin());
    } else {
        p[1] = 1;
    }
    for (int i=2; i<n+1; i++) {
        if (*st.begin() == i) {
            p[i] = 0;
            st.erase(st.begin());
        } else {
            p[i] = (p[i-1] + p[i-2]) % 1000000007;
        }
    }
    cout << p[n] << endl;
}

Measured memory_bytes: 5760
k,x = map(int,input().split())


result = list(range(x-k+1,x)) + list(range(x,x+k))
ans_L = list(set([i for i in result if (i>=-10000) or (i<=10000)]))

ans_L.sort()
ans_L = map(str,ans_L)

print(" ".join(ans_L))

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int[] t = new int[n];
		for(int i = 0;i < n;i++){
			t[i] = saori.saori_hayami();
		}
		int m = saori.saori_hayami();
		int[] p = new int[m];
		int[] x = new int[m];
		for(int i = 0;i < m;i++){
			p[i] = saori.saori_hayami();
			x[i] = saori.saori_hayami();
		}
		int[] ans = new int[m];
		for(int i = 0;i < m;i++){
			for(int j = 0;j < n;j++){
				if(p[i]-1 == j){
					ans[i] += x[i];
				} else {
					ans[i] += t[j];
				}
			}
		}
		for(int i = 0;i < m;i++){
			System.out.println(ans[i]);
		}

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 20692
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

W,H = inpl()
Lines = []
for i in range(W):
	Lines.append([int(input()),True])
for i in range(H):
	Lines.append([int(input()),False])

Lines.sort()
X = Y = 0
ans = 0
for c,xy in Lines:
	if xy:
		ans += c*(H+1-Y)
		X += 1
	else:
		ans += c*(W+1-X)
		Y += 1

print(ans)


Measured memory_bytes: 33448
def resolve():
    n = int(input())
    c = input()
    ans = 0
    l = -1
    r = n
    while True:
        l += 1
        r -= 1
        while l < n and c[l] == "R":
            l += 1
        while r >= 0 and c[r] == "W":
            r -= 1
        if l > r:
            break
        ans += 1
    print(ans)


if __name__ == '__main__':
    resolve()


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

struct Team{
  vi wa;
  int num;
  int ac;
  int time;

  void init(int p, int i) {
    wa.resize(p, 0);
    num = i;
    ac = 0;
    time = 0;
  }

  void wrong(int p) {
    wa[p]++;
  }

  void correct(int p, int t) {
    ac++;
    time += t + 1200 * wa[p];
  }
};

bool operator>(const Team& t1, const Team& t2) {
  if(t1.ac == t2.ac) {
    if(t1.time == t2.time) {
      return t1.num < t2.num;
    } else {
      return t1.time < t2.time;
    }
  } else {
    return t1.ac > t2.ac;
  }
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int t, p, r; cin >> t >> p >> r;
    if(t == 0) break;
    vector<Team> team(t);
    REP(i, t) {
      team[i].init(p, i);
    }
    REP(i, r) {
      int t, p, time;
      string message;
      cin >> t >> p >> time >> message;
      if(message == "CORRECT") {
        team[t-1].correct(p-1, time);
      } else {
        team[t-1].wrong(p-1);
      }
    }
    sort(ALL(team), greater<Team>());

    REP(i, t) {
      cout << team[i].num+1 << " " << team[i].ac << " " << team[i].time << endl;
    }
  }
}



Measured memory_bytes: 3192
N = int(input())
A = input().split()

def b_sort(a):
	while True:
		for n in reversed(range(1, len(a))):
			if a[n][1] < a[n - 1][1]:
				a[n - 1], a[n] = a[n], a[n - 1]
				break
		else:
			return

def s_sort(a):
	for n in range(len(a)):
		min_n = n
		for m in range(n, len(a)):
			if a[m][1] < a[min_n][1]:
				min_n = m
		if n != min_n:
			a[n], a[min_n] = a[min_n], a[n]
	return

a_b = A.copy()
b_sort(a_b)
print(*a_b)
print("Stable")

a_s = A.copy()
s_sort(a_s)
print(*a_s)
print(["Stable", "Not stable"][not(a_b == a_s)])



Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for (int i = 0; i < (int)c; i++)
int main() {
    int n;
    scanf("%d", &n);
    set<int> se; //3200未満の色の種類
    int over_num = 0; //3200以上の人
    rep(i, n) {
        int a;
        scanf("%d", &a);
        if(a >= 3200) over_num++;
        else se.insert(a / 400); ///400で色の種類に変換
    }

    int max = se.size() + over_num; //色の種類に、自由に色を選べる人が全員違う色を選んだとする
    
    int min = 0;
    if (se.size() == 0) min = 1; //みんな3200以上だとみんな同じ色を選ぶ
    else min = se.size(); //自由に色を選べる人が既出の色を選ぶ

    printf("%d %d\n", min, max);
    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)
vector<int> Aback;

int binary_search(int A, int cnt){
    int left = 0; int right = cnt + 1;
    while(right - left > 1){
        int mid = (right + left) /2;
        if(Aback[mid] >= A) left = mid;
        else right = mid;
    }
    return right;
}

int main() {
    int N, A, ans, cnt;
    cin>>N;
    Aback.resize(N);
    cnt = 0;

    REP(i, 0, N){
        cin >> A;        
        int j = binary_search(A, cnt);

        Aback[j] = A;
        cnt = max(j, cnt);
    }
    cout << cnt << endl;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

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



Measured memory_bytes: 256
N, K, L = map(int, input().split())

class UnionFind():
  def __init__(self):
    self.par = [i for i in range(N)]

  def root(self, x):
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.root(self.par[x])
      return self.par[x]
  
  def unite(self, x, y):
    self.par[self.root(y)] = self.root(x)

ufRoad = UnionFind()

for i in range(K):
  p, q = map(int, input().split())
  ufRoad.unite(p-1, q-1)

ufRail = UnionFind()

for i in range(L):
  r, s = map(int, input().split())
  ufRail.unite(r-1, s-1)

d = {}

for i in range(N):
  d[(ufRoad.root(i), ufRail.root(i))] = d.get((ufRoad.root(i), ufRail.root(i)), 0) + 1

r = [0] * N

for i in range(N):
  r[i] = d.get((ufRoad.root(i), ufRail.root(i)))

print(*r)

Measured memory_bytes: 52916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;

class UnionFind{
public:
    //親の番号を格納する。親だった場合はー（その集合のサイズ）
    vector<int> parents;

    //作る時はparentsを-1で初期化する
    //こうすることで全部ばらばらになる
    UnionFind(int n){
        parents = vector<int>(n, -1);
    }

    //Aがどのグループにいるか調べる
    int root(int A){
        if(parents[A]<0) return A;
        return parents[A] = root(parents[A]);
    }

    //自分のいるグループの大きさを調べる
    int size(int A){
        return -parents[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接ではなく親同士をくっつける
        A=root(A);
        B=root(B);
        if(A==B){
            return false;
        }

        //大きい方（A)に小さい方（B)をくっつけたい
        if(size(A)<size(B)) swap(A, B);

        parents[A] += parents[B];
        parents[B] = A;

        return true;
    }
};

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

    ll n,m; cin >> n >> m;
    vector<ll> a(m), b(m);
    for(int i=0; i<m; ++i) { cin >> a[i] >> b[i]; --a[i]; --b[i]; }
    
    vector<ll> ans(m, 0);

    UnionFind uni(n);
    ll tmp = n*(n-1)/2;
    ans[m-1] = tmp;

    for(int i=m-1; i>0; --i){
        if(uni.root(a[i]) == uni.root(b[i])){
            ans[i-1] = tmp;
        }
        else{
            tmp -= uni.size(a[i]) * uni.size(b[i]);
            uni.connect(a[i], b[i]);
            ans[i-1] = tmp;
        }
    }

    for(int i=0; i<m; ++i) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 4096
#include<stdio.h>

int func(int,int);

int main(){
  int N;
  int result=0;

  while(1){
    scanf("%d",&N);
    if(N==0)break;
    if(N>=3) result=func(N,0);
    printf("%d\n",result);
  }
  
  return 0;
}

int func(int x,int i){
  int z;
  int j=1;
  int count=0;
  
  z=x;
  
  while(1){
    x-=i;
    if(x==0){
      count++;
      j++;
      i=j;
      x=z;
      continue;
    }else if(x<0){
      j++;
      i=j;
      x=z;
      continue;
    }
    i++;
    
    if(j==z/2+1)break;
  }

  return count;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define N 10010
using namespace std;
int n;
int A[2000010],B[2000010];

void Csort(){
  int cnt[N]={};
  for(int i=0;i<n;i++) cnt[A[i]]++;
  for(int i=1;i<N;i++) cnt[i]+=cnt[i-1];
  for(int i=0;i<n;i++) B[cnt[A[i]]--] = A[i];
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++) scanf("%d",&A[i]);
   Csort();
  for(int i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 18820
def main():
    S = input()
    N = len(S)
    if S == "keyence":
        print("YES")
        return
    for i in range(N):
        for j in range(i + 1, N + 1):
            cand = S[:i] + S[j:]
            if cand == "keyence":
                print("YES")
                return

    print("NO")
    return


main()


Measured memory_bytes: 3060
s=input()

def solve(s):
	if s[0]==s[-1]:
		A=1 
	else:
		A=0
	if len(s)%2==0:
		B=1
	else:
		B=0
	if A+B==1:
		return("Second")
	else:
		return("First")

print(solve(s))

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

int main() {
    // get numTown, numTeleport
    long long int numTown;
    long long int numTeleport;
    cin >> numTown >> numTeleport;

    long long int teleport[200001];
    for (long long int i = 1; i <= numTown; i++) {
        cin >> teleport[i];
    }

    // find loop
    long long int stepUntilRepeatStart;
    long long int townToContinueFrom;
    
    bool visited[200001];
    long long int now{1};
    for (long long int i = 0; i < numTeleport; i++) {
        if (i == 0) visited[now] = true;
        else {
            if (!visited[now]) visited[now] = true;
            else { //revisit
                townToContinueFrom = now;
                stepUntilRepeatStart = i;
                break;
            }
        }
        // teleport
        now = teleport[now];
    }

    long long int repeatedSteps;
    now = 1;
    // count the length of repeat
    for (long long int i = 0; i < stepUntilRepeatStart; i++) {
        if (now == townToContinueFrom) {
            repeatedSteps = stepUntilRepeatStart - i;
            break;
        }
        now = teleport[now];
    }
    
    long long int remainingSteps = (numTeleport - stepUntilRepeatStart) % repeatedSteps;
    now = townToContinueFrom;
    for (long long int i = 0; i < remainingSteps; i++) {
        now = teleport[now];
    }

    cout << now << endl;

    return 0;
}

Measured memory_bytes: 5348
//
// Created by 吉川純平 on 2019-12-01.
//

#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
//using ull = unsigned long long;
#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
struct Node{
    ll parent = -1;
    ll chl = -1;
    ll chr = -1;
};
struct Node nodes[100000];
ll root;
void print(ll num){
  cout << " " << num;
}
void child_priority(ll num){
  if(nodes[num].chl != -1){
    child_priority(nodes[num].chl);
  }
  if(nodes[num].chr != -1){
    child_priority(nodes[num].chr);
  }
  print(num);
}
void parent_priority(ll num){
  print(num);
  if(nodes[num].chl != -1){
    parent_priority(nodes[num].chl);
  }
  if(nodes[num].chr != -1){
    parent_priority(nodes[num].chr);
  }
}
void left_priority(ll num){
  if(nodes[num].chl != -1){
    left_priority(nodes[num].chl);
  }
  print(num);
  if(nodes[num].chr != -1){
    left_priority(nodes[num].chr);
  }
}
int main(){
  ll n;
  cin >> n;
  rep(i,n){
    cin >> tmp1 >> tmp2 >> tmp3;
    nodes[tmp1].chl = tmp2;
    nodes[tmp1].chr = tmp3;
    if(tmp2 != -1){
      nodes[tmp2].parent = tmp1;
    }
    if(tmp3 != -1){
      nodes[tmp3].parent = tmp1;
    }
  }
  rep(i,n){
    if(nodes[i].parent == -1){
      root = i;
    }
  }
  cout << "Preorder" << endl;
  parent_priority(root);
  cout << endl;
  cout << "Inorder" << endl;
  left_priority(root);
  cout << endl;
  cout << "Postorder" << endl;
  child_priority(root);
  cout << endl;
  return 0;
}




Measured memory_bytes: 3160
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} end
def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
s=gs


cnt=0
es=[0]
n.times do |i|
  cnt+=1 if s[i]=='E'
  es<<cnt
end

cnt=0
ws=[0]
sr=s.reverse
n.times do |i|
  cnt+=1 if sr[i]=='W'
  ws<<cnt
end

ans=[]
n.times do |i|
  c=es[i]+ws[n-i-1]
  ans<<c
end
# puts es.to_s
# puts ws.to_s
# puts ans.to_s

puts n-ans.max-1

Measured memory_bytes: 9876
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
//#define T_ int
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
//struct bit_2d{T_ a[2005][2005];int lowbit(int x){return x&(-x);}void add(int x,int y,T_ z){int i,j;for (i=x;i<=2000;i+=lowbit(i)){for (j=y;j<=2000;j+=lowbit(j)){a[i][j]+=z;}}}T_ query(int x,int y){int i,j;T_ s=0;for (i=x;i;i-=lowbit(i)){for (j=y;j;j-=lowbit(j)){s+=a[i][j];}}return s;}T_ query(int x,int y,int xx,int yy){return query(xx,yy)-query(x-1,yy)-query(xx,y-1)+query(x-1,y-1);}};
long long n,m,i,j,ans;
bool check(long long x)
{
	return x&&(n/x==(n%x));
}
int main()
{
	cin>>n;
	long long s=0,i;
	for (i=1;i*i<=n;i++){
		if (n%i==0){
			if (check(i-1)) s+=i-1;
			if (i*i!=n) if (check(n/i-1)) s+=n/i-1;
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256