akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

const inf = math.MaxInt32

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

// リストからidx番目の要素を抜かしたものを取得
func delete(idx int, L []int) (result []int) {
	result = append(result, L[:idx]...)
	result = append(result, L[idx+1:]...)
	return
}

// sliceの全組み合わせを返す
func permute(L []int) (result [][]int) {

	var inner func(LL []int)

	inner = func(LL []int) {
		if len(LL) == 0 {
			result = append(result, []int{}) //
		}
		for idx, r := range L {
			for _, t := range permute(delete(idx, L)) {
				result = append(result, append([]int{r}, t...))
			}
		}
	}
	inner(L)
	return

}

func main() {
	sc.Split(bufio.ScanWords)

	N, M, R := getInt(), getInt(), getInt()
	var D [201][201]int
	for i := 0; i <= N; i++ {
		for j := 0; j <= N; j++ {
			D[i][j] = inf
		}
		D[i][i] = 0
	}
	r := make([]int, R)
	for i := 0; i < R; i++ {
		r[i] = getInt()
	}
	for i := 0; i < M; i++ {
		from, to, cost := getInt(), getInt(), getInt()
		D[from][to] = cost
		D[to][from] = cost
	}

	for k := 1; k <= N; k++ {
		for i := 1; i <= N; i++ {
			for j := 1; j <= N; j++ {
				if D[i][k]+D[k][j] < D[i][j] {
					D[i][j] = D[i][k] + D[k][j]
				}
			}
		}
	}

	ans := inf
	for _, l := range permute(r) {
		sum := 0
		from := l[0]
		for i := 1; i < len(l); i++ {
			to := l[i]
			sum += D[from][to]
			from = to
		}
		ans = min(ans, sum)
	}
	out(ans)

}


Measured memory_bytes: 9600
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    int a,b,k;
    int ul,ll;
    cin >> a  >> b >> k;
    ll = a;
    ul = b;
    if(ul == ll){
	cout << ll << std::endl;
    }else{
    for(int i=0;i<k;i++){
      if(ul > ll){
    	cout << a+i << std::endl;
	ll = a+i;
    }else{
	    break;
    }
    }
    for(int i=0;i<k;i++){
      ul = b-(k-i-1);	    
      if(ul > ll){
   	cout << b-(k-i-1) << std::endl;
     } 	     
     }
    }

    return 0;
}


Measured memory_bytes: 256
N=int(input())
S= input()

flag=1
if N % 2 ==1:
  flag=0
  
for i in range(N//2):
  if (S[i] != S[i+N//2]):
    flag=0
    
if flag==1:
  print('Yes')
else:
  print('No')

     
  

Measured memory_bytes: 2940
import java.util.*;
//import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;
//import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		sc.close();
		char[] s2 = new char[s.length*2];
		arraycopy(s, 0, s2, 0, s.length);
		arraycopy(s, 0, s2, s.length, s.length);
		boolean f = false;
		for (i = 1; i <= s.length; i++) {
			boolean f2 = true;
			for (j = 0; j < s.length; j++) {
				if(s2[i+j] != t[j]) {
					f2 = false;
					break;
				}
			}
			if(f2) {
				f = true;
				break;
			}
		}
		out.println(f?"Yes":"No");
	}
}


Measured memory_bytes: 24916
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, d float64
	fmt.Scan(&a, &b, &c, &d)
	ad := math.Ceil(a / d)
	cb := math.Ceil(c / b)
	if ad >= cb {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1816
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
#define PREFIX "#" TOSTRING(__LINE__) "| "
#define debug(x) \
{ \
  std::cout << PREFIX << #x << " = " << x << std::endl; \
}

std::ostream& output_indent(std::ostream& os, int ind) {
  for(int i = 0; i < ind; i++) os << " ";
  return os;
}

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p) {
  return (os << "(" << p.first << ", " << p.second << ")");
}
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
  os << "[";
  for(int i = 0;i < v.size();i++) os << v[i] << ", ";
  return (os << "]");
}

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  vector<i64> ans((i64)(1e4 + 1));
  for(int i = 1; i * i < ans.size(); i++) {
    i64 now = i * i;
    for(int j = 1; now + j * j + i * j < ans.size(); j++) {
      i64 now2 = now + j * j + i * j;
      for(int z = 1; now2 + z * z + i * z + j * z < ans.size(); z++) {
        i64 now3 = now2 + z * z + i * z + j * z;
        ans[now3]++;
      }
    }
  }
  i64 N;
  cin >> N;
  rep(i,1,N + 1) {
    cout << ans[i] << "\n";
  }
}


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

using namespace std;

const int mod = 1e9 + 7;
const int eps = 1e-4;

long long alph[26];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    int k;
    cin >> s >> k;

    set<string> ans;
    for(int i = 0; i < s.size(); ++i)
    {
        string to_push = "";

        for(int j = 0; j <= 4; ++j)
        {
            if(i + j < s.size())
            {
                to_push += s[i + j];
               // cout << to_push << '\n';
                ans.insert(to_push);
            }
            else
                break;
        }
    }

    int j = 1;
    for(auto i : ans)
    {
     //   cout << i << '\n';
        if(j == k)
            return cout << i << '\n', 0;
        ++j;
    }
}


Measured memory_bytes: 1664
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int sum;
int H, W, S;
int tab[40][40];
PII memo[40][40][40][40];
PII dfs(int x1, int y1, int x2, int y2){
  if(memo[x1][y1][x2][y2].first >= 0) return memo[x1][y1][x2][y2];
  
  int tot = 0;
  for(int y=y1;y<y2;++y)
	for(int x=x1;x<x2;++x)
	  tot += tab[y][x];
  if(sum - tot > S) return memo[x1][y1][x2][y2] = MP(0,0);

  PII& res = memo[x1][y1][x2][y2];
  res = MP(1,tot);
  for(int x=x1+1;x<x2;++x){
	PII p1 = dfs(x1,y1,x,y2);
	PII p2 = dfs(x,y1,x2,y2);
	if(p1.first <= 0 || p2.first <= 0) continue;
	res = max(res, MP(p1.first+p2.first, min(p1.second, p2.second)));
  }

  for(int y=y1+1;y<y2;++y){
	PII p1 = dfs(x1,y1,x2,y);
	PII p2 = dfs(x1,y,x2,y2);
	if(p1.first <= 0 || p2.first <= 0) continue;
	res = max(res, MP(p1.first+p2.first, min(p1.second, p2.second)));
  }

  return res;
}

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

  while(cin>>H>>W>>S,H){
	REP(y,H) REP(x,W) cin >> tab[y][x];
	sum = 0;
	REP(y,H) REP(x,W) sum += tab[y][x];
	fill((PII*)memo, (PII*)memo+40*40*40*40, MP(-1,0));

	
	PII pii = dfs(0,0,W,H);
	cout << pii.first << " " << S + pii.second - sum << endl;
  }
  
  return 0;
}

Measured memory_bytes: 21208
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N, C, K;
  cin >> N >> C >> K;
  vector<int> T(N);
  for (int i=0; i<N; i++) cin >> T[i];
  sort(T.begin(), T.end());
  int i = 0, res = 0;
  while (i<N) {
    res++;
    int start = i; // バスの乗客のうち最も早く着いた客
    while (i<N&&T[i]-T[start]<=K&&i-start<C) i++;
  }
  cout << res << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n,a,b;
int main(){
  cin>>n>>a>>b;
  int x,k;
  int ans=0;
  for(int i=1;i<=n;i++){
    k=0; x=i;
    while(x){
      k+=x%10;
      x/=10;
    }
    if(a<=k&&k<=b) ans+=i;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int INF = 114514810;
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
  }
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A,B;
	cin >> A >> B;
	cout << (A-1)*(B-1) << endl;
}

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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MOD 1000000007

ll powmod(ll x, ll y, ll mod)
{
    if (y == 0)
        return 1;

    if (y & 1) {
        return powmod(x*x % mod, y/2, mod) * x % mod;
    } else {
        return powmod(x*x % mod, y/2, mod);
    }
}

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

    ll ans = powmod(m, n, MOD);

    printf("%lld\n", ans);
}



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

using namespace std;

typedef long long ll;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 * 3, INF = 1e9;
vector<vector<pair<ll, ll>>> gr;

ll used[SIZE], usedEdge[SIZE], pr[SIZE], col[SIZE];
vector<ll> vec;
vector<pair<ll, ll>> edges, vec2;

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

    gr.resize(n);
    vec.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> vec[i];
        vec2.push_back({vec[i], i});
    }

    sort(vec2.begin(), vec2.end());
    for (int i = 0; i < m; i++) {
        pr[i] = INF;
        ll u, v;
        cin >> u >> v;
        u--; v--;
        gr[u].push_back({v, i});
        gr[v].push_back({u, i});
        edges.push_back({u, v});
    }
    
    for (int i = 0; i < vec2.size(); i++) {
        ll v = vec2[i].second, val = vec2[i].first;
        if (used[v]) continue;
        
        bool fl = true;
        used[v] = 1;

        for (auto to : gr[v]) {
            if (fl && vec[to.first] == vec[v]) {
                if (col[to.first] == 0) {
                    pr[to.second] = vec[v];
                    col[v] = 1;
                    col[to.first] = 2;
                    used[to.first] = 1;
                    fl = false;
                } else {
                    pr[to.second] = vec[v];
                    col[v] = (!(col[to.first] - 1)) + 1;
                    used[to.first] = 1;
                    fl = false;
                }
            }
        }
        if (fl) {
            for (auto to : gr[v]) {
                if (fl && used[to.first]) {
                    ll dist = vec[v] - vec[to.first];
                    col[v] = col[to.first];
                    pr[to.second] = dist;
                    fl = false;
                }
            }
        }
        if (fl) {
            cout << "-1";
            return 0;
        }
    }

    for (int i = 0; i < n; i++) {
        if (col[i] == 1) {
            cout << "B";
        } else {
            cout << "W";
        }
    }
    cout << "\n";
    for (int i = 0; i < m; i++) {
        cout << pr[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 23824
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int n,x[200005],y[200005],p,v[200005],f,t,m,dp[200005][25],nibab[25];

vector <int> g[200005],h[200005],q,s;

void DFS(int nod){
    s.push_back(nod);
    if(v[nod]){
        f=1;
        return;
    }
    v[nod]=1;
    for(int i : h[nod]){
        if(!f) DFS(i);
    }
    if(!f) s.pop_back();
}

int Find(int nod){
    int x=1;
    vector <int> p;
    for(int i : g[nod]){
        p.push_back(Find(i));
    }
    p.push_back(-1);
    sort(p.begin(),p.end());
    for(int i=1;i<p.size();i++){
        if(p[i]-p[i-1]>1) return p[i-1]+1;
    }
    return p[p.size()-1]+1;
}

int32_t main(){
    ios_base :: sync_with_stdio(0);
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> p;
        g[p].push_back(i);
        h[i].push_back(p);
    }
    DFS(1);
    for(int i=s.size()-2;i>=0;i--){
        q.push_back(s[i]);
        if(s[i]==s[s.size()-1]) break;
    }
    m=q.size();
    for(int i=0;i<m;i++){
        for(int j=0;j<25;j++) nibab[j]=0;
        for(int j : g[q[i]]){
            if((i!=m-1 && j!=q[i+1]) || (i==m-1 && j!=q[0])){
                nibab[Find(j)]=1;
            }
        }
        while(nibab[x[i+1]]) x[i+1]++;
        y[i+1]=x[i+1]+1;
        while(nibab[y[i+1]]) y[i+1]++;
    }
    for(int k=0;k<25;k++){
        for(int i=1;i<=m+1;i++){
            for(int j=0;j<25;j++) dp[i][j]=0;
        }
        dp[m+1][k]=1;

        for(int i=m;i;i--){
            for(int j=0;j<25;j++){
                if(j!=x[i]) dp[i][x[i]]=max(dp[i][x[i]],dp[i+1][j]);
            }
            dp[i][y[i]]=dp[i+1][x[i]];
        }

        if(dp[1][k]){
            cout << "POSSIBLE";
            return 0;
        }
    }
    cout << "IMPOSSIBLE";
}


Measured memory_bytes: 50040
k = int(input())
n = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(n[k-1])

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
	int m,n;cin>>m>>n;
	int a[m][n];
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	int b[n];
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	int c[m]={0};
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			c[i]+=a[i][j]*b[j];
		}
	}
	for(int i=0;i<m;i++){
		cout<<c[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	ll ans = 1;
	for(ll i = 1; i * i <= m; i++)
	{
		if(m % i != 0)
			continue;
		ll b = m / i;
		if(i * n <= m)
			ans = max(ans, i);
		if(b * n <= m) 
			ans = max(ans, b);
	}
	cout << ans << endl;
	return 0;
}



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

using namespace std;

int main(int argc, char **argv)
{
	int n, k;
	cin >> n >> k;
	int record[n] = {};
	for(int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		a--;
		record[a]++;
	}
	vector<int> result;
	for(int i = 0; i < n; i++) if(record[i]) result.push_back(record[i]);
	if(result.size() <= k)
	{
		cout << 0;
		return 0;
	}
	sort(result.begin(), result.end());
	int count = 0;
	for(int i = 0; i < result.size() - k; i++) count += result[i];
	cout << count;	
	return 0;
}

Measured memory_bytes: 2168
#include <cstdio>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main(void) {
  int n;
  cin >> n;
  puts(n < 1000 ? "ABC" : "ABD");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
int main()
{
	ll m,st=100;
	int len=0;
	cin >> m;
	while (st < m)
	{
		st = st*1.01;
		len++;
	}
	cout << len << endl;
	return 0;
}

Measured memory_bytes: 3184
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int A[3];

int main() {
  cin >> A[0] >> A[1] >> A[2];

  sort(A, A + 3);

  cout << A[0] + A[1] + 10 * A[2] << endl;

  return 0;
}


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

int main() {
  
  int n;
  cin >> n;
  
  string a,b,s,p,q;
  
  for ( int i = 1; i <= n; i++){
    cin >> s;
    p += s;
  }
  
  for ( int i = 1; i <= n; i++){
    cin >> s;
    q += s;
  }
  
  a = p;
  
  sort(a.begin(),a.end());
  
  b = a;  
  
  int count1 = 1,count2 = 1;
  
  while(true){
    if ( a == p ){
      break;
    }
    next_permutation(a.begin(),a.end());
    count1++;
  }
  
  while(true){
    if ( b == q ){
      break;
    }
    next_permutation(b.begin(),b.end());
    count2++;
  }
  
  cout << abs(count1-count2) << endl;  
  
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(N * A, B) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	//ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		VI w(N);
		REP(i, N) cin>>w[i];

		ll mx = 101*N;
		vector<bool> dp(mx);
		dp[0] = true;
		REP(i, N) {
			for(int j=mx-1;j>=0;j--) {
				ll nv = j+w[i];
				if(dp[j] && nv<mx) dp[nv] = true;
			}
		}
//		DD(dp);
		ll ans = 0;
		REP(j, mx) {
			if(dp[j] && j%10) ans = max(ans, (ll)j);
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647

int N;

void dfs(string s, char mx) {
	if (s.length() == N) {
		cout << s << endl;
	}
	else {
		for (char c = 'a'; c <= mx; ++c) {
			if (c == mx) {
				dfs(s + c, (char)(mx + 1));
			}
			else {
				dfs(s + c, mx);
			}
		}
	}
}

int main() {
	cin >> N;
	dfs("", 'a');

	return 0;
}

Measured memory_bytes: 1536
H,W=map(int,input().split())
gy,gx=H-1,W-1
grid=["" for i in range(H)]
touched=0
for i in range(H):
  grid[i]=input()
  touched+=grid[i].count("#")

if touched!=(H+W-1):
  print("Impossible")
  exit(0)

stack=[]
stack.append([0,0])
goal=False
while stack:
  v=stack.pop()
  y=v[0]
  x=v[1]
  if y==gy and x==gx:
    goal=True
    break
  if grid[y][x]==".":
    continue
  if y+1<H:
    stack.append([y+1,x])
  if x+1<W:
    stack.append([y,x+1])
    
print(("Impossible","Possible")[goal])

Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int min = x - k + 1;
		int max = x + k - 1;
		for (int i = min; i < max; i++) {
			System.out.print(i + " ");
		}
		System.out.println(max);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22868
Q, H, S, D = map(int, input().split())
N = int(input())

H = min(H, 2 * Q)
S = min(S, 2 * H)

res = 0
if 2 * S <= D:
	res = N * S
elif 2 * S > D:
	if N % 2 == 0:
		res = D * (N // 2)
	else:
		res = D * (N // 2) + S

print(res)

Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;

int main()

{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    ll ans = 0;
    vector<int> res;
    res.push_back(a[0]);
    for (int i = 1; i < n; ++i)
        res.push_back(a[i]), res.push_back(a[i]);
    for (int i = 0; i < n - 1; ++i)
        ans += res[i];
    cout << ans << endl;
}


Measured memory_bytes: 6160
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

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

long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

map< long long int, long long int > prime_factor(long long int n) {//素因数分解
    map< long long int, long long int > ret;
    for(long long int i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}



int main() {

    int N;
    cin >> N;
    long long int a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }

    long long int result=0;

    for(int i=0;i<N;i++){
        if(a[i]==0){
            continue;
        }else{
            result+=(a[i]/2);
            a[i]-=2*(a[i]/2);
            if(i!=N-1&&a[i]==1&&a[i+1]!=0){
                result+=1;
                a[i+1]--;
            }
        }
    }

    cout << result << endl;
}











Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

vector<int> G[N];
char s[N];
int mx[N],sub[N],mn[N],lw[N];
void dfs(int v,int p){
  sub[v]=0;
  if(s[v]=='1') lw[v]=1;
  REP(i,G[v].size()) if(G[v][i]!=p) {
    dfs(G[v][i],v);
    lw[v]|=lw[G[v][i]];
    sub[v]=max(sub[v],sub[G[v][i]]+1);
  } 
}
void dfs1(int v,int p,int l,int ik){
  pii arr[2]; FILL(arr,0);
  mn[v]=mod;
  if(ik) mn[v]=l;
  arr[0]=mp(l,p);

  REP(i,G[v].size()) if(G[v][i]!=p) {
    pii z = mp(sub[G[v][i]]+1,G[v][i]);
    if(lw[G[v][i]]) mn[v]=min(mn[v],sub[G[v][i]]+1);
    ik+=lw[G[v][i]];
    if(z>arr[0]) arr[1]=arr[0],arr[0]=z;
    else arr[1]=max(arr[1],z);
  }
  if(s[v]=='1') mn[v]=0,ik++;
  mx[v]=min(arr[0].X-1,arr[1].X+1);
 // printf("%d %d\n",v+1,mx[v]+1);
  REP(i,G[v].size()) if(G[v][i]!=p){
    int p = (ik>lw[G[v][i]]);
    if(G[v][i]!=arr[0].Y) dfs1(G[v][i],v,arr[0].X+1,p);
    else dfs1(G[v][i],v,arr[1].X+1,p);
  }
}
int main(){
  int n; scanf("%d",&n);
  REP(i,n-1){
    int x,y; scanf("%d%d",&x,&y); x--;y--;
    G[x].pb(y); G[y].pb(x);
  }
  scanf("%s",s);
  dfs(0,-1);
  dfs1(0,-1,0,0);
  ll ans=1;
  REP(i,n) if(mn[i]<=mx[i]) ans+=mx[i]-mn[i]+1;
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 49920
#include <bits/stdc++.h>
	#define endl '\n'
	#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
	#define ll long long 
	using namespace std;
	const int N = 1e5+10;
	const int M = 1e9+7;

	int main(){
		FIO;
		int n , we;
		cin >> n >> we;
		int w[n+1],val[n+1];
		for (int i = 1; i <= n; ++i)
		{
			cin >> w[i] >> val[i];
		}
		long long  dp[n+1][100001];
		for (int i = 0; i <= n; ++i)
		{
			for (int j = 0; j <= 100000; ++j)
			{
				dp[i][j] = 1000000001;
			}
		}
		dp[0][0] = 0;
		for (int i = 1; i <= n; ++i)
		{
			for (int j = 0; j <= 100000; ++j)
			{
				if(j == 0)
					dp[i][j] = 0;
				else if(j >= val[i])
					dp[i][j] = min(dp[i-1][j],w[i] + dp[i-1][j-val[i]]);
				else
					dp[i][j] = dp[i-1][j];
			}
		}
		// for (int i = 1; i <= n; ++i)
		// {
		// 	for (int j = 1; j <= 22; ++j)
		// 	{
		// 		cout << dp[i][j] << " ";  
		// 	}
		// 	cout << "\n";
		// }
		long long ans=-1;
		for (int i = 100000; i >= 0; --i)
		{
			if(dp[n][i] <= we)
			{
				// cout << dp[n][i] << " " << i << " "; 
				ans = i;
				break;
			}
		}
		cout << ans << " ";
	}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int N;
string S[200000];

int main(void){
	map<string, int> m;
	cin >> N;
	for(int i = 0; i < N; i++){
		string s;
		cin >> s;
		m[s]++;
	}

	int M = 0;
	for(auto x: m){
		M = max(M, x.second);
	}
	for(auto x: m){
		if(x.second == M) cout << x.first << '\n';
	}

	return 0;
}

Measured memory_bytes: 26752
n, m = gets.split.map(&:to_i)
h = gets.split.map(&:to_i).tally
m.times do
  b, c = gets.split.map(&:to_i)
  if h.key?(c)
    h[c] += b
  else
    h[c] = b
  end
end
ans = 0
cnt = 0
h.sort_by{|k, v| -k}.each do |k, v|
  if cnt + v < n
    ans += k * v
    cnt += v
  else
    ans += k * (n - cnt)
    break
  end
end
puts ans

Measured memory_bytes: 39236
#include<stdio.h>
int main(){
    char a[4];
    for(int i=0;i<4;i++)
    scanf("%c",&a[i]);
    if(a[0]==a[1]||a[1]==a[2]||a[2]==a[3])
    printf("Bad");
    else
    printf("Good");
    return 0;
}

Measured memory_bytes: 128
n,p=map(int,input().split())
a=[int(x)%2 for x in input().split()]
even=0
for aa in a:
    if aa%2==0:
        even+=1

if even==n:
    if p==0:
        print(2**n)
    else:
        print(0)
else:
    dp=[[0]*3 for i in range(n+1)]
    if a[0]%2==0:
        dp[0][0]=1
        dp[0][1]=0
    else:
        dp[0][0]=0
        dp[0][1]=1    
    for i in range(n):
        for j in range(2):
            j%=2
            if a[i]%2==0:
                dp[i+1][j]=2*dp[i][j]
                dp[i+1][(j+1)%2]=2*dp[i][(j+1)%2]
            elif a[i]%2==1:
                dp[i+1][j]=dp[i][j]+dp[i][(j+1)%2]
                dp[i+1][(j+1)%2]=dp[i][j]+dp[i][(j+1)%2]
    
    print(dp[n][p])


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

using namespace std;

int n,a[110];
inline int ab(int x)
{
    return x<0?-x:x;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int i,j;
    cin>>n;
    for(i=1,a[0]=0;i<=n;i++)
    {
        cin>>a[i];
        a[i]+=a[i-1];
    }
    int minn=1e7;
    for(i=1;i<=n;i++)
        minn=min(minn,ab(a[n]-2*a[i]));
    cout<<minn<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a;
int _gcd(int x,int y){
	if(x<y) swap(x,y);
	return !y?x:_gcd(y,x%y);
}
int main(){
  int n,tmp;
  cin>>n;
	cin>>tmp;
  for(int i=0;i<n-1;i++){
		cin>>a;
		tmp=_gcd(tmp,a);
	}
	cout<<tmp<<'\n';
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
ll power(ll a,ll x){
    if(x<0)return 1;
    ll r=1;
    while(x!=0){
        if(x%2==1){
            r=r*a;r%=p;
        }
        a=a*a;a%=p;
        x=x/2;
    }
    return r;
}
ll mul(ll a,ll b){
    ll t=(a*b);
    if(t>=p)t%=p;
    return t;
}
int main() {
   
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        ll n;cin>>n;ll c[n];
        rep(i,n)cin>>c[i];sort(c,c+n);
        ll ans=0;
        rep(i,n){
            ll temp=0;
            temp=mul(n-i-1,power(2,(2*n-2)));
            temp=mul(temp,c[i]);
            temp=temp+mul(c[i],power(2,2*n-1));
            ans=ans+temp;ans%=p;
        }
        // ans=ans+2*(c[n-1]);ans%=p;
        cout<<ans;
    }   
    timecalculater();
    return 0;   
} 

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int mod = 998244353;
const int N = 3e3+23;

int a, b, c, d;
long long dp[N][N][2];

void solve() {
  scanf("%d%d%d%d", &a, &b, &c, &d);
  dp[a][b][0] = 1;
  for (int i = 1; i <= c; ++i) {
    for (int j = 1; j <= d; ++j) {
      for (int f = 0; f < 2; ++f) {
	if (j < d)
	  dp[i][j+1][1] = (dp[i][j+1][1] + dp[i][j][f]*i%mod)%mod;
	if (i == c) continue;
	if (f)
	  dp[i+1][j][0] = (dp[i+1][j][0] + dp[i][j][f])%mod;
	else
	  dp[i+1][j][0] = (dp[i+1][j][0] + dp[i][j][f]*j%mod)%mod;
      }
    }
  }
  printf("%lld", (dp[c][d][0]+dp[c][d][1])%mod);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 145420
#include <bits/stdc++.h>
using namespace std;
 
const int INF = 1145141919;
const long long INFL = 1LL<<60;
 
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;
}
 
int main()
{
	long long int N;
	cin >> N;
	long long int A[110000];
	for (long long int i = 0; i < N; ++i)
	{
		cin >> A[i];
	}
	sort(A, A + N);
	long long int ans = 0;
	long long int ans2 = 0;
	long long int ansA[110000];
	long long int ansB[110000];
	for (long long int i = 0; i < (N/2)*2; ++i)
	{
		ansA[i] = (i % 2 == 0?A[N-1-i/2]:A[i/2]);
		ansB[i] = (i % 2 == 1?A[N-1-i/2]:A[i/2]);
	}
	for (long long int i = 0; i < (N/2)*2-1; ++i)
	{
		ans += abs(ansA[i]-ansA[i+1]);
		ans2 += abs(ansB[i]-ansB[i+1]);
	}
	if(N % 2 != 0)
	{
		// cout << max(abs(ansA[0] - A[N/2]), abs(ansA[N-1] - A[N/2])) << endl;
		ans += max(abs(ansA[0] - A[N/2]), abs(ansA[N-2] - A[N/2]));
		ans2 += max(abs(ansB[0] - A[N/2]), abs(ansB[N-2] - A[N/2]));
	}
	else
	{
		ans -= abs(ansA[N-2]-ansA[N-1]);
		ans += max(abs(ansA[N-2]-ansA[N-1]),abs(ansA[0]-ansA[N-1]));
		ans2 -= abs(ansB[N-2]-ansB[N-1]);
		ans2 += max(abs(ansB[N-2]-ansB[N-1]),abs(ansB[0]-ansB[N-1]));
	}
	cout << max(ans, ans2) << endl;
}

Measured memory_bytes: 2816
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	string S;
	cin >> S;
#if 0
	for(int i=0;i<S.size();i++){
		for(int j=1;j<=7;j++){
			for(int k=i+j;k<S.size();k++){
				if(S.substr(i,j)+S.substr(k,7-j)=="keyence"){
					cout << "YES" << endl;
					return 0;
				}
			}
		}
	}
#endif
	for(int i=0;i<=7;i++){
		if(S.substr(0,i)+S.substr(S.size()-(7-i))=="keyence"){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;

	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var HW = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            var H = HW[0];
            var W = HW[1];
            var map = new char[H][];
            for(var i=0;i<H;i++)
            {
                map[i] = Console.ReadLine().ToCharArray();
            }
            var ans = map.Select(x => x.ToArray()).ToArray();
            for(var i=0;i<H;i++)
            {
                for(var j=0;j<W;j++)
                {
                    if(map[i][j]!='#')
                    {
                        ans[i][j] = GetNum(map, i, j,H,W).ToString()[0];
                    }
                }
            }
            for(var i=0;i<H;i++)
            {
                Console.WriteLine(ans[i]);
            }
        }

        static int GetNum(char[][] map,int i,int j,int H,int W)
        {
            var ans = 0;
            Func<int, int, bool> Check = (y, x) =>
             {
                 if (y < 0 || H <= y || x < 0 || W <= x) return false;
                 return map[y][x]=='#';
             };
            if (Check(i - 1, j - 1)) ans++;
            if (Check(i - 1, j)) ans++;
            if (Check(i - 1, j + 1)) ans++;
            if (Check(i, j - 1)) ans++;
            if (Check(i, j + 1)) ans++;
            if (Check(i + 1, j - 1)) ans++;
            if (Check(i + 1, j)) ans++;
            if (Check(i + 1, j + 1)) ans++;
            return ans;
        }
    }
}

Measured memory_bytes: 13524
#include <iostream>
#include <vector>
#include <deque>
#include <numeric>
#include <algorithm>
#include <iomanip>
using namespace std;

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

	double bunsi = 1;
	vector<double> A(N);
	for(double i=0;i<N; i++) {
		cin >> A.at(i);
		bunsi *= A.at(i);
	}

	double bunbo = 0;
	for(double i=0; i<N; i++) {
		bunbo += bunsi / A.at(i);
	}

	double ans = (double)bunsi/(double)bunbo;
	// cout <<  << ans << endl;
	printf("%.20f\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5;
vector <vector <int> > edge(MAX_N);
vector <int> ans(MAX_N - 1, 0);
vector <bool> flag(MAX_N, false);
map <pair <int, int>, int> m;

void dfs(int n, int cb) {
  flag[n] = true;
  int c = 1;
  for (auto itr = edge[n].begin(); itr != edge[n].end(); itr++) {
	  if (c == cb) {
		  c++;
		}
	  if (!flag[*itr]) {
		  ans[m.at(make_pair(n, *itr))] = c;
		  dfs(*itr, c);
		  c++;
		}
	}
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
	  int a, b;
	  cin >> a >> b;
	  a--;
	  b--;
	  edge[a].push_back(b);
	  edge[b].push_back(a);
	  m.insert(make_pair(make_pair(a, b), i));
	  m.insert(make_pair(make_pair(b, a), i));
	}
  ans[0] = 1;
  dfs(0, 0);
  cout << *max_element(ans.begin(), ans.end()) << endl;
  for (int i = 0; i < n - 1; i++) {
	  cout << ans[i] << endl;
	}
  return 0;
}


Measured memory_bytes: 18944
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
sys.setrecursionlimit(10**7)
F = sys.stdin

N,K = map(int,F.readline().split())
H_list = list(map(int,F.readline().rstrip().split()))
attack = 0

if K >= N:
    print(0)
    sys.exit()

H_list.sort(reverse=True)

for i in range(N):
    if i >= K:
        attack += H_list[i]


print(attack)


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

#define ff               first
#define ss               second
#define mp               make_pair
#define pb               push_back
#define pii              pair<int,int>
#define vi               vector<int> 
#define mii              map<int,int>
#define setbits(x)       __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod              1000000007
#define inf              1e18
#define endl             "\n"

void h_code()
{
 #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
 #endif
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

void l_code()
{
 #ifndef ONLINE_JUDGE
     cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
 #endif
}
const int N=100005;

int main() {
  //  h_code();
    int t=1;
    
    while(t--)
    {
        int h,a,cnt=0;
        cin>>h>>a;
        while(h>a)
        {
            h-=a;
            cnt++;
        }
            cout<<cnt+1;
        
    }
    //l_code();
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<string>
#define dd double
#define ll long long
dd PI = acos(-1);
//ios::sync_with_stdio(false);
using namespace std;
const ll MAXN = 5e6 + 5;
const ll INF = 0xffffffff;

int main() {
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	for (ll i = m - n + 1; i < m + n; i++) {
		cout << i;
		if (i == m + n - 1) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}
}
	

Measured memory_bytes: 256
N,x=map(int,input().split())
if x==1 or x==2*N-1:
    print("No")
    exit()
if N==2:
    print('Yes')
    print(*[1,2,3],sep='\n')
    exit()
s=set(range(1,2*N))
s.remove(x)
ans=[0]*(2*N-1)
ans[N-1]=x
min1=min(s)
max1=max(s)
s.remove(min1);s.remove(max1)
if x==2*N-2:
    min2=min(s)
    s.remove(min2)
    ans[N-2]=min1;ans[N]=max1;ans[N+1]=min2
else:
    max2=max(s)
    s.remove(max2)
    ans[N-2]=max1;ans[N]=min1;ans[N+1]=max2
li=list(s)
for i in range(2*N-1):
    if ans[i]==0:
        ans[i]=li.pop()
print("Yes")
print(*ans,sep='\n')

Measured memory_bytes: 28028
N = int(input())
day = [list(map(int, input().split())) for i in range(N)]

happiness = [[0,0,0] for i in range(N)]

happiness[0] = day[0]

for i in range(1, N):
  happiness[i][0] = day[i][0] + max(happiness[i-1][1], happiness[i-1][2])
  happiness[i][1] = day[i][1] + max(happiness[i-1][0], happiness[i-1][2])
  happiness[i][2] = day[i][2] + max(happiness[i-1][0], happiness[i-1][1])

print(max(happiness[N-1][0], happiness[N-1][1], happiness[N-1][2]))


Measured memory_bytes: 104544
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cout << a[i] << " "; cout << "\n"; }
template<class T> void verr(const vector<T>& v){ for(auto& a : v) cout << a << " "; cout << "\n"; }
ll dbgt = 1; void err() { cout << "passed " << dbgt++ << "\n"; }
template<class H, class... T> void err(H&& h,T&&... t){ cout<< h << (sizeof...(t)?" ":"\n"); if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
bool used[100005];
int main() {
    init();
    ll N;
    cin >> N;
    vvc<ll> G(N);
    rep(i,N-1){
        ll a, b;
        cin >> a >> b;
        a--,b--;
        G[a].eb(b);
        G[b].eb(a);
    }

    ll cnt[2] = {};
    queue<pair<ll, ll>> q;
    q.emplace(0, 0), q.emplace(N - 1, 1);
    
    while(!q.empty()){
        ll now, p;
        tie(now, p) = q.front(), q.pop();
        if (used[now]) continue;
        used[now] = true;
        cnt[p]++;
        for(auto& to:G[now]){
            q.emplace(to, p);
        }
    }

    cout << (cnt[0] > cnt[1] ? "Fennec" : "Snuke") << endl;
}

Measured memory_bytes: 7040
def main():
    N,K = map(int, input().split())
    P = list(map(int, input().split()))
    S = [0]*(N)

    for i in range(N):
        P[i] = P[i]+1

    S[0]=P[0]
    for i in range(1,N):
        S[i] = S[i-1] + P[i]

    m = S[K-1]

    for i in range(N-K):
        m = max(m,S[i+K]-S[i])

    print(m/2)


if __name__ == '__main__':
    main()



Measured memory_bytes: 71792