akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.IntStream;

public class Main{
	public static void main(String[]$) throws IOException{
		new Main().solve();
	}
	static FastScanner s=new FastScanner(System.in);
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static int gInt() throws IOException{return s.nextInt();}
	static long gLong() throws IOException{return s.nextLong();}
	static long gDouble() throws IOException{return s.nextLong();}

	private void solve() throws IOException{
		yesno(s.next().contains("AC"),"Yes","No");
	}

	static void yesno(boolean f) {
		yesno(f,"YES","NO");
	}
	static void yesno(boolean f,String yes,String no) {
		System.out.println(f?yes:no);
	}
}
class FastScanner{
	private final BufferedInputStream	in;
	private static final int			bufSize	=1<<16;
	private final byte					buf[]	=new byte[bufSize];
	private int							i		=bufSize;
	private int							k		=bufSize;
	private final StringBuilder			str		=new StringBuilder();

	FastScanner(InputStream in){
		this.in=new BufferedInputStream(in,bufSize);
	}
	int nextInt() throws IOException{
		return (int)nextLong();
	}
	long nextLong() throws IOException{
		int c;
		long x=0;
		boolean sign=true;
		while((c=nextChar())<=32)
			;
		if(c=='-'){
			sign=false;
			c=nextChar();
		}
		if(c=='+'){
			c=nextChar();
		}
		while(c>='0'){
			x=x*10+(c-'0');
			c=nextChar();
		}
		return sign?x:-x;
	}
	int nextChar() throws IOException{
		if(i==k){
			k=in.read(buf,0,bufSize);
			i=0;
		}
		return i>=k?-1:buf[i++];
	}
	String next() throws IOException{
		int c;
		str.setLength(0);
		while((c=nextChar())<=32&&c!=-1)
			;
		if(c==-1){
			return null;
		}
		while(c>32){
			str.append((char)c);
			c=nextChar();
		}
		return str.toString();
	}
	String nextLine() throws IOException{
		int c;
		str.setLength(0);
		while((c=nextChar())<=32&&c!=-1)
			;
		if(c==-1){
			return null;
		}
		while(c!='\n'){
			str.append((char)c);
			c=nextChar();
		}
		return str.toString();
	}
}

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

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> h(n, 0);
    rep(i, n)
    {
        cin >> h[i];
    }
    vector<vector<int>> mat(n);
    int a, b;
    rep(i, m)
    {
        cin >> a >> b;
        mat[a - 1].push_back(b - 1);
        mat[b - 1].push_back(a - 1);
    }
    int cnt = 0;
    bool flag;
    rep(i, n)
    {
        flag = true;
        rep(j, mat[i].size())
        {
            if (h[i] <= h[mat[i][j]])
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 8740
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n;
    string t, h;
    cin >> n;
    int st = 0, sh = 0;
    for(int i = 0; i < n; i ++){
        cin >> t >> h;
        if (t < h) sh += 3;
        else if (t > h) st += 3;
        else{
            st += 1;
            sh += 1;
        }
    }
    printf("%d %d\n", st, sh);
    return 0;
}


Measured memory_bytes: 3284
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
using mint = modint998244353;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string S;
  cin >> S;
  vector<int> sa = suffix_array(S);
  lint ans = (lint)S.size() * (S.size() + 1) / 2;
  vector<int> lcp = lcp_array(S, sa);
  REP(i, lcp.size()) ans -= lcp[i];
  cout << ans << endl;
}

Measured memory_bytes: 15612
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2") 
#pragma GCC optimization ("unroll-loops")


using namespace std;
using ll = long long;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ff first
#define ss second
#define Ceil(x, y) ((x+y-1)/y)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x);
const int mod = (int) 1e9 + 7;


void solve()
{
	string str;
	cin>>str;
	if(str.back() == 's')
		cout<<str<<"es";
	else
		cout<<str<<'s';
}

int main(int argc, char *argv[])
{
	clock_t clk_start = clock();
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
 
	int cases = 1;
	// cin>>cases;
	for(int i=1; i<=cases; i++)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	cerr<<"Execution Time: "<<fixed<<double(clock() - clk_start)/double(CLOCKS_PER_SEC)<<setprecision(6)<<" sec\n"; 
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main(){
	int h,w;
	cin>>h>>w;
	char grid[h+1][w+1];
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>grid[i][j];
		}
	}
	int dp[h+1][w+1];
	for(int i=0;i<=h;i++){
		for(int j=0;j<=w;j++){
			dp[i][j]=0;
		}
	}
	dp[1][1]=1;
	for(int i=0;i<=h;i++){
		for(int j=0;j<=w;j++){
			if(i==0||j==0){
				dp[i][j]==0;
				continue;
			}
			if(i==1&&j==1)
				continue;
			if(grid[i][j]!='#'){
				//cout<<"i="<<i<<"j="<<j<<endl;
				dp[i][j]=dp[i][j-1]+dp[i-1][j];
				dp[i][j]%=MOD;
			}

		}
	}
	// for(int i=0;i<=h;i++){
	// 	for(int j=0;j<=w;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	cout<<dp[h][w]<<endl;
}

Measured memory_bytes: 5120
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int a,b;cin>>a>>b;
	if(a>=13)cout<<b<<endl;
	else if(a<=12&&a>5)cout<<b/2<<endl;
	else cout<<"0"<<endl;
}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N;
    cin>>N;
    vi A(N,0);
    REP(i, 0, N) cin >> A[i];
    int all_xor = 0;
    REP(i, 0, N) all_xor = all_xor^A[i];
    REP(i, 0, N) cout << (all_xor^A[i]) << endl;
}

Measured memory_bytes: 3960
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
    tmp = input()
    a.append(tmp)
    
for i in range(m):
    tmp = input()
    b.append(tmp)
    
ans = False
for w in range(0 , n-m+1):
    for h in range(0,n-m+1):
        if ans == True:
            break
        flag = True
        for i in range(m):
            if a[h+i][w:w+m] == b[i]:
                pass
            else:
                flag = False
                break
        if flag == True:
            ans = True
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
def main():
    n = input()
    array = list(map(int, input().split(" ")))
    minX = min(array)
    maxX = max(array)
    p_sum = 0
    power_list = []
    for p in range(minX, maxX + 1):
        for x in array:
            p_sum += power(x, p)
        power_list.append(p_sum)
        p_sum = 0        
    print(min(power_list))

def power(x, p):
    return (x - p)**2

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import math
a_list = []
n, m = map(int, input().split())
for i in range(math.ceil(m**(1/2)), 0, -1):
    if m % i == 0:
        a_list.append(i)
        a_list.append(m//i)
border = math.floor(m / n)
a_list = list(reversed(sorted(a_list)))
for aa in a_list:
    if border >= aa:
        ans = aa
        break
print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"sort"
)

type Restaurant struct {
	Index int
	City  string
	Point int
}

type Restaurants []Restaurant

func (r Restaurants) Len() int {
	return len(r)
}

func (r Restaurants) Less(i, j int) bool {
	if r[i].City < r[j].City {
		return true
	} else if r[i].City == r[j].City {
		return r[i].Point > r[j].Point
	}
	return false
}

func (r Restaurants) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func main() {
	var n int
	fmt.Scan(&n)

	restaurants := make([]Restaurant, n)

	for i := 0; i < n; i++ {
		restaurant := Restaurant{}
		restaurant.Index = i + 1
		fmt.Scan(&restaurant.City, &restaurant.Point)
		restaurants[i] = restaurant
	}

	sort.Sort(Restaurants(restaurants))

	for _, restaurant := range restaurants {
		fmt.Println(restaurant.Index)
	}
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
class graph
{
    int V;
    list<int> *l;
    public:
        graph(int v)
        {
            V=v;
            l=new list<int>[V];
        }
        void add_edge(int u ,int v)
        {
            l[u].push_back(v);
            l[v].push_back(u);
        }
void com_helper(int i,map<int,bool>&vis, int &c)
{
    vis[i]=true;
  // cout<<i<<" ";
   c++;
    list<int>::iterator it;
    
    for(it=l[i].begin();it!=l[i].end();++it)
    {
        if(!vis[*it])
        {
            com_helper(*it,vis,c);
        }
    }
    return ;
}
void noofcon_com()
{  int maxi=-99;
    map<int,bool>vis;
    for(int i=0;i<V;i++)
  
    vis[i]=false;
    int c=0;
    for(int i=0;i<V;i++)
    {
         int c=0;
        if(!vis[i])
        {
           
            com_helper(i,vis,c);
            maxi=max(maxi,c);
        }
    }
    cout<<maxi<<endl;
  
}};
int main()
{
    int n,m;
    cin>>n>>m;
    graph g(n+1);
    
    while(m--)
    {
            int x,y;
            cin>>x>>y;
            g.add_edge(x,y);
    }
g.noofcon_com();
}

Measured memory_bytes: 51964
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N;
	cin >> N;
	ll A[N];
	for (ll i = 0; i < N; ++i) cin >> A[i];
 
	// 
	ll ans = 0;
	if (A[0]!=0) ans = -1;
	else{
		REP(i,N-1){
			if (A[i+1]>=A[i]+2){
				ans = -1;
				break;
			}
			else if (A[i+1]>=A[i]+1){
				ans++;
			}
			else if (A[i+1]<=A[i]+1){
				ans += A[i+1];
			}
		}
	}
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n;
	while(cin>>n,n){
		vvi in(n,vi(n));
		rep(i,n)rep(j,n)cin>>in[i][j];
		int out=0;
		rep(i,n){
			int ma=in[i][0];
			rep(j,n)ma=min(ma,in[i][j]);
			rep(j,n)if(ma==in[i][j]){
				int tmp=ma;
				rep(k,n)tmp=max(tmp,in[k][j]);
				if(tmp==ma)out=max(out,ma);
			}
		}
		cout<<out<<endl;
	}
}

Measured memory_bytes: 1212
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
A = list(map(int, input().split()))
s = set(A)
flag = [False]*(10**6+100)

for i in range(10**6+100):
    if i in s:
        flag[i] = True
        
for i in range(10**6+100):
    if i in s:
        for j in range(2*i, 10**6+100, i):
            flag[j] = False

cnt = Counter(A)
ans = 0

for i in range(10**6+100):
    if flag[i] and cnt[i]==1:
        ans += 1

print(ans)

Measured memory_bytes: 159384
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;


class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int
          a = int.Parse(Reader.ReadLine());
        int b = int.Parse(Reader.ReadLine());
        int h = int.Parse(Reader.ReadLine());

        int ans = (a + b) * h / 2;
        Console.WriteLine(ans);

    }


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"
3
4
2




";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 2776
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define a first
#define b second

// Efficient program to print all prime factors of a given number
// https://www.geeksforgeeks.org/print-all-prime-factors-of-a-given-number/
// 与えられた正整数についての素因数分解を計算.
// @param X: 素因数分解を行う整数.
// @return ret: 素因数分解 の 結果 を 返却.
map<LL, LL> div(LL X){
    
    // 1. X を 2で割り切れなくなるまで割っていく.
    map<LL, LL> ret;
    while(X % 2 == 0) ret[2]++, X >>= 1;
    
    // 2. X を 3以上の奇数で, 割り切れなくなるまで順次割っていく.
    repex(i, 3, sqrt(X) + 1, 2){
        while(X % i == 0){
            ret[i]++;
            X /= i;
        }
    }
    
    // 3. X が 2 より 大きな素数であれば, 追加.
    if(X > 2) ret[X]++;
    
    // 4. 出力.
    return ret;
}

int main(){
    
    // 1. 入力情報.
    LL N, P;
    scanf("%lld %lld", &N, &P);
    
    // 2. 素因数分解.
    map<LL, LL> m = div(P);
    // for(auto &p : m) printf("%lld %lld\n", p.a, p.b);
    
    // 3. 最大公約数は？
    LL ans = 1;
    for(auto &p : m){
        int l = p.b / N;
        rep(i, l) ans *= p.a;
    }
    
    // 4. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 256
def V_dijkstra(V,AL,S):
    INF=float('inf')
    ans=[INF]*V
    ans[S]=0
    used=[0]*V # 0:未確定
    used[S]=1
    que=[i for i in range(V)]
    while que:
        u=min(que,key=lambda x: ans[x])
        que.pop(que.index(u))
        used[u]=1
        for v,w in AL[u]:
            if not used[v] and ans[v]>ans[u]+w:
                ans[v]=ans[u]+w
    return ans

# verified: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_12_B
N=int(input())
AL=[[] for _ in range(N)]
for _ in range(N):
    for i,x in enumerate(input().split()):
        x=int(x)
        if i==0:
            j=x
        elif i==1:
            pass
        else:
            if i%2==0:
                tmp=[x]
            else:
                tmp.append(x)
                AL[j].append(tmp)
for ans in enumerate(V_dijkstra(N,AL,0)):
    print(*ans)



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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	for(int i = 0; i < n; i++) {
		a[i] = 25000*(i+1);
		b[i] = 25000*(n-i);
	}
	for(int i = 0; i < n; i++) {
		int p;
		cin >> p;
		b[p-1] += i;
	}
	cout << a[0];
	for(int i = 1; i < n; i++) {
		cout << " " << a[i];
	}
	cout << endl;
	cout << b[0];
	for(int i = 1; i < n; i++) {
		cout << " " << b[i];
	}
	cout << endl;
}


Measured memory_bytes: 768
def f(a, b):
    an = len(str(a))
    bn = len(str(b))
    return max(an, bn)


def make_divisors(n):
    ans = float('inf')
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            ans = min(ans, f(i, n // i))
    return ans


n = int(input())
print(make_divisors(n))

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

if N >= K:
    print(min(N % K,abs(N % K - K)))
else :
    A = [N]
    M = N 
    N = abs(N-K)
    A.append(N)
    while N != M:
        N = abs(N-K)
        A.append(N)
    print(min(A))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int K = 0;
  cin >> K ;
  int A,B;
  cin >> A >> B;
  int a = A % K;
  int range = B - A;
  string ans = "NG";
  if(a == 0)
    ans = "OK";
  else if(a + range >= K)
    ans = "OK";
  cout << ans <<endl;
}

Measured memory_bytes: 3588
fun main(args: Array<String>) {
    val (N, M, C) = readLine()!!.split(" ").map(String::toInt)
    val B = readLine()!!.split(" ").map(String::toInt)
    val A = Array(N) { readLine()!!.split(" ").map(String::toInt) }

    A.fold(0) { acc, elm ->
        if (elm.zip(B).map { it.first * it.second }.sum() + C > 0) {
            acc + 1
        } else {
            acc
        }
    }.let(::println)
}

Measured memory_bytes: 38076
#include<bits/stdc++.h>
using namespace std;
long long vis[100001]={0};
void bfs(vector<long long > adj[],long long ele){
	if(vis[ele]==0){
		vis[ele]=1;
		for(long long i=0;i<adj[ele].size();i++){
			if(vis[adj[ele][i]]==0){
				bfs(adj,adj[ele][i]);
			}
		}
	}
}
int main(){
	long long n,m;
	cin>>n>>m;
	vector<long long > adj[n];
	for(long long i=0;i<m;i++){
		long long a,b;
		cin>>a>>b;
		adj[a-1].push_back(b-1);
		adj[b-1].push_back(a-1);
	}
	long long count=0;
	for(long long i=0;i<n;i++){
		if(vis[i]==0){
			count++;
			bfs(adj,i);
		}
	}
	cout<<count-1<<endl;
	return 0;
}

Measured memory_bytes: 11496
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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


        if (s.startsWith("k") && s.endsWith("eyence")) {
            System.out.println("YES");
        } else if (s.startsWith("ke") && s.endsWith("yence")) {
            System.out.println("YES");
        } else if (s.startsWith("key") && s.endsWith("ence")) {
            System.out.println("YES");
        } else if (s.startsWith("keye") && s.endsWith("nce")) {
            System.out.println("YES");
        } else if (s.startsWith("keyen") && s.endsWith("ce")) {
            System.out.println("YES");
        } else if (s.startsWith("keyenc") && s.endsWith("e")) {
            System.out.println("YES");
        } else if (s.startsWith("keyence") && s.endsWith("keyence")) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }
}












Measured memory_bytes: 22996
use std::io::stdin;
use std::collections::HashMap;

fn digits(mut n: i64) -> Vec<i64> {
    let mut ans = Vec::<i64>::new();
    while n > 0 {
        ans.push(n % 10);
        n /= 10;
    }
    ans.reverse();
    return ans;
}

fn main() {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    let words: Vec<i64> = line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let n = words[0];
    let m = words[1];

    let mut value = HashMap::new();
    let mut impossible = false;

    for _ in 0..m {
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();

        let words: Vec<i64> = line
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect();
        
        let s = words[0];
        let c = words[1];

        if value.contains_key(&s) && value.get(&s).unwrap() != &c {
            impossible = true;
        } else {
            value.insert(s, c);
        }
    }
    if value.contains_key(&1) && value.get(&1).unwrap() == &0 && n < 1 {
        impossible = true;
    }

    if impossible {
        println!("-1");
        return;
    }

    if n == 1 && m == 0 {
        println!("0");
        return;
    }
    
    if n == 1 && m == 1 && value.contains_key(&1) && value.get(&1).unwrap() == &0 {
        println!("0");
        return;
    }

    let base: i64 = 10;
    for num in base.pow((n-1) as u32)..base.pow(n as u32) {
        let mut digit = vec![0];
        digit.append(&mut digits(num));
        let mut valid = true;
        for i in 1..(n+1) {
            if value.contains_key(&i) && value.get(&i).unwrap() != &digit[i as usize] {
                valid = false;
            }
        }
        if valid {
            println!("{}", num);
            return;
        }
    }
    println!("-1");
}


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

const ll INF = 1LL << 60;

vector< vector< pair<int,int> > > to(100005);
ll dist[100005];

int main() {
  int N,M;
  cin >> N >> M;
  REP(i,M) {
    int l,r,c;
    cin >> l >> r >> c;
    l--; r--;
    to[l].emplace_back(r,c);
  }
  REP(i,N-1)
    to[i+1].emplace_back(i,0);

  REP(i,N)
    dist[i] =INF;
  dist[0] = 0;
  // ダイクストラ
  priority_queue< pair<ll, int>, vector< pair<ll,int> >, greater<pair<ll,int> > > q;
  q.push( make_pair(0, 0) );
  while( !q.empty() ) {
    auto v = q.top(); q.pop();
    if ( v.first > dist[v.second] ) continue;
    for ( auto nv: to[v.second] ) {
      if ( dist[nv.first] > dist[v.second] + nv.second ) {
        dist[nv.first] = dist[v.second] + nv.second;
        q.push( make_pair(dist[nv.first], nv.first) );
      }
    }
  }
  ll ans = (dist[N-1] == INF) ? -1 : dist[N-1];
  cout << ans << endl;
}


Measured memory_bytes: 8056
a,p,q,o,x,b;
main(){
  for(scanf("%d",&p);~scanf("%s",&a);o=o==3?b=x=!printf("%d\n",x):o){
    //printf("%d\n",a%9);
    ///*
    //printf("bef x:%d b:%d o:%d\n",x,b,o);
    if(a%9==7)b=b*2+1,x+=b>>3&1;
    if(a%9==8)o++;
    if(a%9==6)for(x++,b&=7;b;b/=2)x+=b&1;
    //printf("x:%d b:%d o:%d\n",x,b,o);
     //*/
  }
}

Measured memory_bytes: 0
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int N=2e6+10;
	
	
	void main()
	{
		int n=qread();while(n--){ int num=qread();if(num%2==0 and (num%3 and num%5)) {puts("DENIED");return;} }puts("APPROVED");
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	#endif
	srand(time(0));
	mine::main();
	if(DD) cerr<<"Time: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# 動画解説を見る
#
# 110101以下の数は、以下のいずれかである
#
# 110101
# 110100 (1を一つ選んで0にする、それ以下の桁はなんでもよいので?とする)
# 1100??
# 10????
# 0?????
#
# 上の各パターンについて条件を満たすものをそれぞれ探し、maxをとる
# 各パターンでは、0になるべき桁が必ず0になるようにする
#
# 実装上は、?をすべて1で置換。orをとった結果、0の箇所に1が来ないようにする
#
# 110101
# 110011
# 101111
# 011111



import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import re
import string

N, K = map(int, input().split())
A = []
B = []
for n in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

ret = 0

# orをとって 110101 以下になるもののみretに足す
for n in range(N):
    if K | A[n] == K:
        ret += B[n]

# Kの下位ビットから順に見ていき、もし1があれば、その桁を0にして、その桁より下位をすべて1にする
for i in range(31):
    # n番目の桁が0なら、1にする
    if (K >> i) & 1 == 0:
        K |= (1 << i)
    else:
        # n番目の桁が1なら、0にする
        K ^= (1 << i)

        local_ret = 0
        for n in range(N):
            if K | A[n] == K:
                local_ret += B[n]
        ret = max(ret, local_ret)

        # また1に戻す
        K |= (1 << i)


print(ret)


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

typedef long long int ll;

//classic dp problem
#define pb push_back
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
const ll MAX=3003;
const ll INF=1e15+7;

double dp[MAX][MAX];
double a[MAX];
ll n;

int main()
{
    cin>>n;
    
    for(int i=1;i<=n;i++)
        cin>>a[i];
        
    dp[0][0]=1.0;    //base condition
    for(int i=1;i<=n;i++)//for position
    {
        for(int j=0;j<=i;j++)//cnt of heads occur
        {
            if(j==0)
            {
                dp[i][j]=dp[i-1][j]*(1-a[i]);
            }
            else
            {
                dp[i][j]=dp[i-1][j]*(1-a[i])+dp[i-1][j-1]*a[i];
            }
        }
    }
    double res=0;
    for(int i=n/2+1;i<=n;i++)
    {
        res+=dp[n][i];
    }
    cout<<setprecision(10)<<res<<endl;
}

Measured memory_bytes: 68992
import java.util.*;
import java.math.*;

public class Main {

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

    if (s.substring(2,3).equals(s.substring(3,4)) && s.substring(4,5).equals(s.substring(5,6))) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }

}


Measured memory_bytes: 22608
#include<iostream>
#include<vector>
#include<algorithm>

int main() {
	int a,b,n,m,x,y;

	std::cin >> n>>m;

	//std::vector<std::vector<int>> v;
	//v = std::vector<std::vector<int>>(m, std::vector<int>(2, 0));
	
	std::cin >> x >> y;

	for (int i = 0; i < m-1; i++) {
		std::cin >> a >> b;
		x = std::max(x, a);
		y = std::min(y, b);
	}

	//std::cout << y<<x << std::endl;

	if (x == y) {
		std::cout <<1<< std::endl;
		return 0;
	}

	if (y-x<0) {
		std::cout << 0 << std::endl;
		return 0;
	}


	/*
	for (int& x : v) {
		std::cin >> x;
	}
	*/




	std::cout << y-x+1 << std::endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

using ull = unsigned long long;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"Yes":"No")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {
    
    int can=0;
    string S,T,SS;
    cin >>S>>T;
    SS=S;
    int len=S.size();

    FOR(i,0,len-1) {
        FOR(j,0,len-1) {
            SS[j]=S[(j+i)%len];
        }
        if(SS==T) {
            can=1;
            break;
        }
    }
    
    yn(can);
    
    return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

import numpy as np
from scipy.sparse.csgraph import floyd_warshall

n = ni()
g = np.zeros((n,n))
for i in range(n):
    g[i,:] = np.array(list(li()))
    
    
dist = floyd_warshall(g, directed=False)

consis = True
for i in range(n):
    for j in range(n):
        if g[i,j] != dist[i,j]:
            consis = False
            break
        
if not consis:
    print(-1)
    
else:
    total = 0
    INF = float("inf")
    
    for i in range(n):
        dist[i,i] = INF
        
    for i in range(n):
        for j in range(i+1,n):
            via_k = np.min(dist[i] + dist[j])
            
            if via_k > dist[i,j]:
                total += dist[i,j]
                
    print(int(total))

Measured memory_bytes: 27204
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int A, B;

int main() {

    while (cin >> A >> B) {
        if (13 <= A) {
            cout << B << endl;
        } else if (6 <= A && A <= 12) {
            cout << (B / 2) << endl;
        } else {
            cout << 0 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        BigDecimal a = new BigDecimal(scan.next());
        BigDecimal b = new BigDecimal(scan.next());
        scan.close();

        BigDecimal eight = new BigDecimal("0.08");
        BigDecimal ten = new BigDecimal("0.1");

        int aPriceMin = a.divide(eight, 0, RoundingMode.UP).intValue();
        int aPriceMax = a.add(new BigDecimal("1")).divide(eight, 0, RoundingMode.UP).intValue() - 1;

        int bPriceMin = b.divide(ten, 0, RoundingMode.UP).intValue();
        int bPriceMax = b.add(new BigDecimal("1")).divide(ten, 0, RoundingMode.UP).intValue() - 1;

        if (aPriceMax < bPriceMin) {
            System.out.println(-1);
        } else if (aPriceMin < bPriceMin && bPriceMin <= aPriceMax) {
            System.out.println(bPriceMin);
        } else if (aPriceMin <= bPriceMax && bPriceMax < aPriceMax) {
            System.out.println(aPriceMin);
        } else {
            System.out.println(-1);
        }
    }

}


Measured memory_bytes: 23380
import java.io.BufferedReader
import java.io.InputStreamReader

var cnt = 0

fun insertionSort(a: IntArray, g: Int) {
    for (i in g until a.size) {
        val pivotVal = a[i]
        var pivotIdx = i-g
        while (pivotIdx >= 0 && a[pivotIdx] > pivotVal) {
            a[pivotIdx+g] = a[pivotIdx]
            pivotIdx -= g
            cnt++
        }
        a[pivotIdx+g] = pivotVal
    }
}

fun shellSort(a: IntArray): List<Int> {
    val gs = generateSequence(seed = 1, nextFunction = { 3 * it + 1 })
            .takeWhile { it <= a.size }
            .toList()

    for (i in gs.size-1 downTo 0) {
        insertionSort(a, gs[i])
    }

    return gs
}

fun main(args: Array<String>) {
    val a = BufferedReader(InputStreamReader(System.`in`))
            .readText()
            .trim()
            .split(regex = """\s+""".toRegex())
            .drop(n = 1)
            .map { it.toInt() }
            .toIntArray()

    val gs = shellSort(a)
    println(gs.size)
    println(gs.reversed().joinToString(" "))
    println(cnt)
    println(a.joinToString("\n"))
}


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

int s[100005];

int main(){
    long long  N, a, ans=0;

    cin >>N;
    for(int i =0; i < N; i++){
        cin >> a;
        if(a > 100002){
            ans++;
        }
        else{
            s[a]++;
        }
    }
    
    for(int i =1; i < 100003 ;i++){
        if(s[i] < i){
            ans += s[i];
        }
        else{
            ans += s[i] -i;
        }
    
    }


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
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 (b<a) { a = b; return 1; } return 0; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};
int n;
int dp[100005];

int rec(int p) {
  if (p == 0) return 0;
  if (dp[p] != -1) return dp[p];
  int res = inf;
  for (int i = 1; i <= p; i *= 6) res = min(res, rec(p - i) + 1);
  for (int i = 1; i <= p; i *= 9) res = min(res, rec(p - i) + 1);
  return dp[p] = res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    memset(dp, -1, sizeof(dp));
    cout << rec(n) << endl;
    return 0;
}



Measured memory_bytes: 3712
n,$a,$b=gets.split.map(&:to_i)
$h=(1..n).map{gets.to_i}
def calc(x)
  $h.select{|h|h>$b*x}
    .inject(0){|s,h|((h.to_f-$b*x)/($a-$b)).ceil+s}<=x
end
p (0..10**9).bsearch{|i|calc(i)}


Measured memory_bytes: 26548
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a[];
		a = new int[3];
		for(int i = 0; i < 3; ++i)a[i] = sc.nextInt();
		
		sc.close();
		
		Arrays.sort(a);
		System.out.println(a[0] + a[1]);
	}

}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    int N;
    cin >> N;
    int h,m,s;
    h = N/3600;
    N = N%3600;
    m = N/60;
    N = N%60;
    s = N;
    cout << h << ":" << m << ":" << s << endl;

}


Measured memory_bytes: 3112
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var n,s,e,a;

console.log(main());
function main(){
  n = o.a();
  s = o.a(1);
  e = xArray("[]",n);
  for(var i = 1; i < n; i++){
    var t = o.l(); t[0]--, t[1]--;
    e[t[0]].push(t[1]);
    e[t[1]].push(t[0]);
  }
  var ans = 1e9;
  for(var i = 0; i < n; i++){
    var t = tree(i);
    if(t < ans)ans = t;
  }
  return ans===1e9?-1:ans;
}

function tree(r){
  a = Array(n);
  dfs(r,-1);
  if(a[r][1]&1 || a[r][0])return 1e9;
  return a[r][1] >> 1;
}

function dfs(v,p){
  var u = a[v] = [0,0,0], mx = 0, sum = 0, mn = 0;
  for(var i of e[v]){
    if(i === p)continue;
    dfs(i,v);
    u[1] += a[i][1];
    u[2] += a[i][2];
    sum += a[i][1]+a[i][2];
    if(mn <= a[i][0] + a[i][2]){
      if(mn < a[i][0] + a[i][2]){
        mx = a[i][1] + a[i][2];
        mn = a[i][0] + a[i][2];
      }
      else mx = Math.max(mx, a[i][1] + a[i][2]);
    }
  }
  u[1] += u[2];
  if(s[v] === "1")u[2]++;
  u[0] = Math.max(0,mn-sum+mx);
}

Measured memory_bytes: 41828
N, K = map(int,input().split())
x = list(map(int,input().split()))

MIN = float("inf")
for i in range(N-K+1):
	l = i
	r = i + K - 1
	cur1 = abs(x[l]) + abs(x[r]-x[l])
	cur2 = abs(x[r]) + abs(x[r]-x[l])
#	print([l,r,cur1,cur2])
	if cur1 < MIN:
		MIN = cur1
	if cur2 < MIN:
		MIN = cur2
print(MIN)


Measured memory_bytes: 14384
#include <iostream>
#include <sstream>

int main() {

	int a, b, c, d;
	int n;
	std::cin >> n;

	a = n / 1000;
	n = n - a * 1000;
	b = n / 100;
	n = n - b * 100;
	c = n / 10;
	n = n - c * 10;
	d = n;

	if (a == b && b == c) { std::cout << "Yes"; }
	else if (b == c && c == d) { std::cout << "Yes"; }
	else { std::cout << "No"; }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void){
    double x,y;
    while(true){
        cin >> x >> y;
        if(x==0 && y==0)break;
        printf("%.6lf\n",x*x+2*x*sqrt(y*y+(x/2)*(x/2)));
    }
    return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,a,b) for(register int i = a;i <= b; ++i)
const int N = 2e5+5, mod=1e9+7;
ll n,k,pri[N],g[N],s[N];
bool is[N];ll ans;
ll qpow(ll a,int b) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		a=a*a%mod;
		b>>=1;
	} return c;
}
int main() {
	scanf("%d%d",&n,&k);
	f(i,1,k) s[i]=i-1;
	s[1]=1;
	f(i,2,k) for(int j=i+i;j<=k;j+=i)  s[j]-=s[i];
	f(i,1,k) (ans+=qpow(1ll*k/i,n)*s[i])%=mod;
	printf("%lld",ans);
}

Measured memory_bytes: 4508
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  ll a[n+1]={};
  for(int i=0;i<n;i++){
    cin>>a[i];
  }

  sort(a,a+n);
  ll s[n+1]={};
  s[0]=a[0];
  for(int i=1;i<n;i++){
    s[i]=s[i-1]+a[i];
  }

  ll ans=1;
  for(int i=0;i<n-1;i++){
    ll tmp=s[i];
    ll p=0ll,q=0ll;
    for(;;){
      p=lower_bound(a,a+n,2*tmp+1)-a;
      //cout<<a[i]<<" "<<p<<endl;
      if(p==n){
        ans++;
        break;
      }else if(p==q) break;
      tmp=s[p-1];
      q=p;
    }
  }

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


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
namespace WoZhenTaMaShiGeLaJi
{
	const int N=2050,M=200100,MOD=1000000007;
	template<typename T>inline void check_max(T a,T &b){if(a>b)b=a;}
	template<typename T>inline void inc(T a,T &b){b=((b+a)%MOD+MOD)%MOD;}
	typedef long long ll;
	ll qpow(ll a,ll b){ll c=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)c=c*a%MOD;return c;}
	ll inv(ll x){return qpow(x,MOD-2);}
	ll t1[N*2][N*2],*t2[N*2],**f;
	ll fact[N*4];
	int A[M],B[M];
	int n,mx,my;
	ll ans;
	ll C(int a,int b){return fact[a]*inv(fact[b])%MOD*inv(fact[a-b])%MOD;}
	void initialize()
	{
		for(int i=0;i<N*2;i++)t2[i]=t1[i]+N;f=t2+N;
		fact[0]=1;for(int i=1;i<N*4;i++)fact[i]=fact[i-1]*i%MOD;
		
		scanf("%d",&n);
		mx=my=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",A+i,B+i);
			f[-A[i]][-B[i]]++;
			check_max(A[i],mx);
			check_max(B[i],my);
		}
	}
	void solve()
	{
		initialize();
		for(int i=-mx;i<=mx;i++)
			for(int j=-my;j<=my;j++)
			{
//				printf("f[%d][%d] = %lld\n",i,j,f[i][j]);
				inc(f[i][j],f[i+1][j]);
				inc(f[i][j],f[i][j+1]);
			}
		ans=0;
		for(int i=1;i<=n;i++)
			inc(f[A[i]][B[i]],ans);
		for(int i=1;i<=n;i++)
			inc(-C(A[i]+B[i]+A[i]+B[i],A[i]+A[i]),ans);
		ans=(ans*inv(2)%MOD+MOD)%MOD;
		printf("%lld\n",ans);
	}
}
int main()
{
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	WoZhenTaMaShiGeLaJi::solve();
	return 0;
}


Measured memory_bytes: 131328
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    vector<pair<int,int>> cb(m);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<m; i++){
        cin >> cb[i].second >> cb[i].first;
    }
    sort(cb.begin(),cb.end(),greater<pair<int,int>>());
    sort(a.begin(),a.end());
    int next = 0;
    for(int i=0; i<m; i++){
        if(next >= n) break;
        auto p = upper_bound(a.begin()+next,a.end(),cb[i].first);
        int index = min(cb[i].second,(int)distance(a.begin()+next,p));
        for(int j=0; j < index; j++){
            a[next+j] = cb[i].first;
        }
        next += index;
    }
    cout << accumulate(a.begin(),a.end(),0ll) << endl;
    return 0;
}


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

int main(){
  int n,a,b,c,x,sum;
  int stop[101];
  while(cin>>n>>a>>b>>c>>x,n||a||b||c||x){
    sum = 0;
    for(int i=0;i<n;i++) cin >> stop[i];
    
    for(int i=0,j=0;i<n;i++){
      while(true){
	if(stop[i] == x) break;
	j++;
	x = (a * x + b) % c;
	if(sum + j > 10000){ sum = -1; goto exit; }
      }
      sum += j;
      x = (a * x + b) % c; j=1;
    }
    
  exit:
    cout << sum << endl;
  }
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(void){
int N, ch=0;
char S[100];
scanf("%d%s", &N, S);
for(int i=0; i<=N; i++){
    if(S[i]=='A' && S[i+1]=='B' &&S[i+2]=='C'){
  ch+=1;
  }
}
 printf("%d",ch);
return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())
import numpy as np
#対称性を利用して点を単位格子K*2Kに圧縮
_2K, _4K = 2*K, 4*K
shape = (_2K,_4K) #後でK*2Kに圧縮
Grd = np.zeros(shape, dtype='int64')
for _ in range(N):
    x, y, c = input().split()
    x, y = int(x), int(y)
    if c == 'B':
        x, y = x%_2K, y%_2K
    else: 
        x, y = (x+K)%_2K, y%_2K
    #点について、2K*2K -> K*2Kの調整。次は等価、(K+i,K+j)と(i,j),(i,K+j)と(i+K,j)
    if x >= K and y >= K: x -= K; y -= K
    if x < K and y >= K: x += K; y -= K
    #この点がK*Kの黒色正方形内に入る。正方形を特徴づけるには頂点の座標１つだけで十分。
    #⇒１つの点はK*K個の塗り方に+1の影響を与える。
    #毎回K**2のマスにアクセスするとTLEするため、後で累積和(計算量O(K**2))を取った時に+1される範囲が等しくなるように調整する(隣接差分を取る)。
    #K=3の場合
    #[[1 1 1 0 0 0]    [[ 1 0 0 -1 0 0 0]
    # [1 1 1 0 0 0]     [ 0 0 0  0 0 0 0]
    # [1 1 1 0 0 0]  => [ 0 0 0  0 0 0 0]
    # [0 0 0 0 0 0]     [-1 0 0  1 0 0 0]
    # [0 0 0 0 0 0]     [ 0 0 0  0 0 0 0]
    # [0 0 0 0 0 0]]    [ 0 0 0  0 0 0 0]
    #                   [ 0 0 0  0 0 0 0]
    
    Grd[y, x] += 1
    Grd[y+K, x+K] += 1
    Grd[y+K, x] += -1
    Grd[y, x+K] += -1
del x, y, c

#2重累積和計算
Grd = Grd.cumsum(axis=1).cumsum(axis=0)
#2K*4K -> K*2Kへ圧縮
Grd = Grd[:,:_2K] +Grd[:,_2K:_4K]
Grd = Grd[:K,:] +np.concatenate((Grd[K:_2K,K:_2K],Grd[K:_2K,:K]),axis=1) 

ans = Grd.max()
print(ans)

Measured memory_bytes: 205804
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	string s;
	cin>>s;
	REP(i,s.size()){
		if(s[i]=='7'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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 (b<a) { a=b; return 1; } return 0; }



i64 a,b,c;
void solve(){
	cin >> a >> b >> c;
	
	if(c >= b-1) cout << a*(b-1)/b << endl;
	else{
		cout << a*c/b << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N;
  cin >> N;

  vector<long long>A(N);
  long long sum = 0,ans = 0;
  for(int i = 0;i < N;i++) {
    cin >> A[i];
    sum += A[i];
  }

  for(int i = 0;i < N-1;i++) {
    sum -= A[i];
    ans += A[i]*(sum % MOD);
    ans %= MOD;
  }

  cout << ans << endl;



}


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

signed main() {

  string a, b; cin >> a >> b;

  if(a == b) {
    cout << "EQUAL" << endl;
    return 0;
  }

  if(a.size() > b.size()) {
    cout << "GREATER" << endl;
  } else if(a.size() < b.size()) {
    cout << "LESS" << endl;
  } else {
    string l[2] = {a, b};
    // 文字列で昇順ソート
    sort(l, l+2);
    cout << (l[0]==a ? "LESS" : "GREATER") << endl;
  }
  return 0;
}


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

#define double long double
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define eb emplace_back
//#define ll long long
#define int long long
using namespace std;

const int INF = 2e9;
const int MOD = 1e9 + 7;
const int MB = 20;

int bin_pow(int a, int b) {
	if (!b) return 1LL;
	if (b % 2) return a * bin_pow(a, b - 1) % MOD;
	int q = bin_pow(a, b / 2);
	return q * q % MOD;
}

int fact(int n) {
	int res = 1;
	for (int i = 1; i <= n; i++) {
		res *= i;
		res %= MOD;
	}
	return res;
}

int get(int n, int k) {
	int res = 1;
	for (int i = 0; i < k; i++) {
		res *= (n - i);
		res %= MOD;
	}
	res = res * bin_pow(fact(k), MOD - 2) % MOD;
	return res;
}

void solve() {
	int n, a, b;
	cin >> n >> a >> b;

	int ans = bin_pow(2, n);
	ans = (ans - get(n, a) + MOD) % MOD;
	ans = (ans - get(n, b) + MOD) % MOD;
	ans = (ans - 1 + MOD) % MOD;
	cout << ans;
}

signed main() {
	/*
	freopen("caves.in", "r", stdin);
	freopen("caves.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(12);
	solve();
}

Measured memory_bytes: 256