akhauriyash/Code-Regression huggingface dataset:
S = input()

ans = False
if S == 'keyence':
    ans = True
elif S.startswith('keyence') or S.endswith('keyence'):
    ans = True
else:
    for i in range(len(S)):
        for j in range(i, len(S)):
            p1 = S[:i]
            b = S[i:j+1]
            p2 = S[j+1:]
            # print(p1, b, p2)
            if p1 + p2 == 'keyence':
                ans = True

if ans:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int mod=1e9+7;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,K; cin>>N>>K;
	ll i=0, j=N, pre=0, suf=0;
	for (int t=0; t<K; t++)
		pre+=i, suf+=j, i++, j--;
	ll ret=0;
	for (int t=K; t<=N+1; t++) {
		ret=(ret+(suf-pre+1))%mod,
		pre+=i, suf+=j, i++, j--;
	}
	cout<<ret<<"\n";
	return 0;
}

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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
    fio();
    int n;
    cin >> n;
    vl a(n);
    rep (i, n) cin >> a[i];

    vl dp(n + 1);
    dp[0] = 1000;
    rep (i, n) {
        chmax(dp[i + 1], dp[i]);
        ll kabu = dp[i] / a[i];
        for (int j = i + 1; j < n; j++) {
            if (a[j] > a[i]) {
                chmax(dp[j + 1], dp[i] % a[i] + kabu * a[j]);
            }
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int c = 0;
  int max = 0;
  cin >> s;
  for(int i = 0;i < s.size();i++){
    if(s[i] == 'R')c++;
    else{
        if(max < c)max = c;
        c = 0;
    }
  }
  if(max < c)max = c;
  cout << max << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const long MAX = 12000000;
const long MOD = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (long i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(long n, long k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long powmod(long x,long p){
  if(p==0)return 1;
  if(p%2)return powmod(x,p-1)*x%MOD;
  long long a=powmod(x,p/2);return a*a%MOD;
}
int main() {
  COMinit();
  long N;cin>>N;
  long X=0;
  for(long k=N/2+1;k<=N;k++){
    X=(X+COM(N,k)*powmod(2,N-k))%MOD;
  }
  long ans=(powmod(3,N)-2*X+2*MOD)%MOD;
  cout<<ans<<endl;
}



/*
消去によって偶奇は変化しない
偶A or 奇B -> X
偶B or 奇A -> Y
と変換すると
XXとYYが消せないものになる
どのような消し方をしてもXXが余ってしまうのは, X>N/2の時

Xがk個になる場合の数は
nCk * 2^(N-k)


*/

Measured memory_bytes: 281472
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		sc.close();

		int count = 0;
		for(int i = 0; i < list.size(); i++) {
			int high = list.get(i);
			if(high >= K) {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 49512
N = int(input()) #入力値
A = sorted(map(int, input().split()), reverse = True)
Bob=0
Alice=0
for i in range(0,N):
      if i % 2 == 0: # Bobが偶数なら実行
         Alice=Alice+int(A[i])
      else:
         Bob=Bob+int(A[i])
print(Alice-Bob)


Measured memory_bytes: 2940
#include <stdio.h>

int main()
{
	int N,c=0; scanf ("%d", &N);
	bool f[101][101] = { 0, };
	for (int i = 1; i <= N; i++) for (int j = i + 1; j <= N; j++) f[i][j] = 1, c++;
	if (N % 2) for (int i = 1, j = N - 1; i < j; i++, j--) f[i][j] = 0, c--;
	else for (int i = 1, j = N; i < j; i++, j--) f[i][j] = 0, c--;

	printf ("%d\n", c);
	for (int i = 1; i <= N; i++) for (int j = i + 1; j <= N; j++) if (f[i][j]) printf ("%d %d\n", i, j);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string s;
int k=1;
int main(void){
	cin>>s;
	string last="",n="";
	last+=s[0];
	for(int i=1;i<s.size();i++){
		n+=s[i];
		if(n!=last){k++;last=n;n="";}
	}
	cout<<k;
	return 0;
} 

Measured memory_bytes: 1152
package main

import (
	"fmt"
	"strings"
)

func main() {
	_, b, c := SingleInt(), SingleStr(), SingleInt()
	strs := strings.Split(b, "")
	k := strs[c-1]

	for _, v := range strs {
		if k == v {
			fmt.Printf("%v", v)
		} else {
			fmt.Printf("%v", "*")
		}

	}
	fmt.Println()
}

func SingleInt() int {
	var n int
	fmt.Scan(&n)
	return n
}

func SingleStr() string {
	var s string
	fmt.Scan(&s)
	return s
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int a,b,c; cin >> a >> b >> c;
	if (a + b + c >= 22)cout << "bust" << endl;
	else cout << "win" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int mat_e[100][100];
vector<pair<ll,ll>> v;
ll N,M;
ll c[51];

int dfs(int x){
  REP(i,N+1){
    if(mat_e[x][i]==1){
      if(c[i]==0){
        c[i]=1;
        dfs(i);
      }
    }
  }
  return 0;
}

bool connect(){
  INIT(c,N+1,0);
  c[1] = 1;
  dfs(1);
  return (sum(c,N+1)==N );  
}


ll solve(){
  // 初期化
  INIT2(mat_e,50,50,0);
  //入力
  cin>>N>>M;
  REP(i,M){
    ll a,b; cin>>a>>b;
    v.push_back( make_pair(a,b) );
    mat_e[a][b] = 1;
    mat_e[b][a] = 1;
  }
  //数え上げ
  ll ans = 0;
  for(pair<ll,ll> p:v){
    ll a = p.first;
    ll b = p.second;
    mat_e[a][b] = 0;
    mat_e[b][a] = 0;
    ans += !(connect()); 
    mat_e[a][b] = 1;
    mat_e[b][a] = 1;
  }
  return ans;
}

int main(){
  cout << solve()<<"\n";
}

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

int main() {
	// your code goes here
	int x;
	cin >> x;
	int k = 0;
	if(x <= 599){
		k = 8;
	}
	else if(x <= 799){
		k = 7;
	}
	else if(x <= 999){
		k = 6;
	}
	else if(x <= 1199){
		k = 5;
	}
	else if(x<= 1399){
		k = 4;
	}
	else if(x <= 1599){
		k = 3;
	}
	else if(x <= 1799){
		k = 2;
	}
	else{
		k = 1;
	}
	
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 3628
//#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int N;
int Z[5005];
string s;
int main(){
    cin >> N >> s;
    int l, r, k;
    int ans = 0;
    for (int idx = 0; idx < N; idx++) {
        l = r = idx;
        for (int i = idx+1; i < N; i++) {
            if (i > r) {
                l = r = i;
                while (r < N && s[r] == s[r - l + idx]) r++;
                Z[i] = r - l;
                r--;
            } else {
                k = i - l + idx;
                if (Z[k] < r - i + 1) Z[i] = Z[k];
                else {
                    l = i;
                    while (r < N && s[r] == s[r - l + idx]) r++;
                    Z[i] = r - l;
                    r--;
                }
            }
        }
        for (int i=idx+1; i<N; i++) {
            ans = max(ans, min(Z[i], i-idx));
            Z[i] = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
const ll INF=1e15;
void input(ll *a,ll n){
    for(ll i=0;i<n;i++)
        cin>>a[i];
}
ll lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}
bool isprime(ll n){
    if(n==1){
        return false;
    }
    if(n==2 || n==3){
        return true;
    }
    for(ll i=2;i<=sqrt(n);i++){
        if(n%i==0)
            return false;
    }
    return true;
}

//ll x[100001]={0};
//ll h[100001]={0};
//ll a[200001]={0};
//ll b[200001]={0};
//bool c[100001]={0};
//bool prime[100001]={0};
//ll prec[100011]={0};

void sieve(ll n,bool *a)
{
    for (ll p=2; p*p<=n; p++){
        if (!a[p]){
            for (ll i=p*p;i<=n;i+=p)
                a[i]=true;
        }
    }
}

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

ll distance(ll x1,ll y1,ll x2,ll y2){
    return (ll)ceil(sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
}

void solve(){
    ll x;
    cin>>x;
    double p=100;
    ll i=0;
    while(p<x){
        p+=((ll)p/100);
        i++;
    }
    cout<<i;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //sieve(100001,c);
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++){
        solve();
    }
}


Measured memory_bytes: 3672
import java.util.*;

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

        double pi = 3.1415926535897;
        
        String area = String.format("%.5f", pi * r * r);
        String arc = String.format("%.5f", 2.0 * pi * r);

        System.out.println(area + " " + arc);
    }
}
        

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

const int MaxN = 1e5 + 15;
const int MOD = 1e9 + 7;

int dp[22];
int c[22][22];

void dfs(int x, int sum)
{
    if(dp[x] <= sum)
        return;
    dp[x] = sum;
    for(int i = 0; i <= 9; ++i)
        dfs(i, sum + c[i][x]);
}

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdou);

    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    int n, m;
    cin >> n >> m;

    for(int i = 0; i <= 9; ++i)
        for(int j = 0; j <= 9; ++j)
            cin >> c[i][j];

    for(int i = 0; i <= 9; ++i)
        dp[i] = MOD;

    dfs(1, 0);

    long long ans = 0;

    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
        {
            int x;
            cin >> x;
            if(x >= 0)
                ans += dp[x];
        }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
// Template by [thunder_blade]
// IIIT ALLAHABAD
// includes :)

#include<bits/stdc++.h>
using namespace std;
#define TEST  int test_case; cin>>test_case; while(test_case--)
#define all(v) (v).begin(),(v).end()
#define fi  first
#define se  second
#define pb push_back
#define mp make_pair
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);  cin.tie(0);  cout.tie(0);
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define pf(x) printf("%f\n",x)
#define ps(x) printf("%s\n",x)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sf(x) scanf("%f",&x)
#define ss(x) scanf("%s",x)
#define pis(x) printf("%d ",x)
#define pls(x) printf("%lld ",x)
#define pfs(x) printf("%f ",x)
#define pss(x) printf("%s ",x)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007

map<int,int>ma;
int main()
{
	int n,m,u,v;
	si(n), si(m);
	for(int i=0;i<m;i++){
		si(u), si(v);
		ma[u]++;
		ma[v]++;
	}
	for(auto it : ma){
		if(it.se % 2){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,x;
    cin>>n>>x;
    vector<int> v(n);
    rep(i,n) cin>>v[i];
    ll ans = 0;
    //前処理
    if(v[0]>x){
        ans+=v[0]-x;
        v[0]=x;
    }
    if(v[v.size()-1]>x){
        ans+=v[v.size()-1]-x;
        v[v.size()-1]=x;
    }
    vector<pair<int,int>> pii;
    rep(i,n){
        if(i==0){
            pii.push_back({0,v[0]+v[1]});
        }else if(i==n-1){
            pii.push_back({v[i]+v[i-1],0});
        }else{
            pii.push_back({v[i]+v[i-1],v[i]+v[i+1]});
        }
    }
    rep(i,n){
        if(pii[i].first>x){
            ans+=pii[i].first-x;
            pii[i+1].first-=pii[i].first-x;
            pii[i].second-=pii[i].first-=x;
        }
        if(pii[i].second>x){
            ans+=pii[i].second-x;
            pii[i+1].first-=pii[i].second-x;
            pii[i+1].second-=pii[i].second-x;
            pii[i+2].first-=pii[i].second-x;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1784
N = int(input())
b = list(map(int, input().split()))
b = [0] + b
answer = []

for i in range(N, 0, -1):
    for j in range(len(b) - 1, 0, -1):
        if j == b[j]:
            answer.append(j)
            b.remove(j)
            break
    else:
        print(-1)
        exit()
else:
    print('\n'.join(map(str, reversed(answer))))

Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int A, B;
    cin >> A >> B;
    cout << (A - 1) * (B - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
lis = [13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
A, B = map(lambda x: int(x) - 1, input().split())
if lis[A] == lis[B]:
    print("Draw")
elif lis[A] > lis[B]:
    print("Alice")
else:
    print("Bob")


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
n,k = map(int, input().split())

# 空白区切りの数列をリストに代入
x = [int(i) for i in input().split()]
c = 0
for a in range(0,n):
    if x[a]==0:
        b=a
        c=1
        break
    if x[a]>0:
        b=a
        break

answer = 1000000000

if x[0] >= 0:
    answer = x[k-1]
elif x[n-1] <= 0:
    answer = -x[n-k]        
else:
    if n-b+c > k:
        answer = min(answer, x[b+k-1-c])
    if b+c > k:
        answer = min(answer, -x[b-k+c])
    for i in range(0,n):
        if i<b:
            if (b-i) < (k-c) and (i+k-1)<n:
                l=-x[i]+(x[i+k-1]-x[i])
                answer = min(answer,l)
        elif i==b:
            continue
        else:
            if (i-b) < (k-c+1) and i > (k-2):
                l=x[i] + (x[i]-x[i-k+1])
                answer = min(answer,l)




print(answer)



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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


signed main() {
    string s; cin >> s;
    int shalf = (s.length()-1)/2;
    for(int i = 0; i < s.length()/2; i++) {
        if(s[i] != s[s.length()-i-1]) {
            print("No");
            return 0;
        }
    }
    for(int i = 0; i <= shalf/2; i++) {
        if(s[i] != s[shalf-i-1]) {
            print("No");
            return 0;
        }
    }

    print("Yes");

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using ll = long long;
using namespace std;

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> as(n);
  rep(i, n) { cin >> as[i]; }

  vector<int> s;
  vector<int> ord(n + 1, -1);
  int c = 1, l = 0;
  int v = 1;
  while (ord[v] == -1) {
    ord[v] = s.size();
    s.push_back(v);
    v = as[v - 1];
  }
  c = s.size() - ord[v];
  l = ord[v];
  if (k < l) {
    cout << s[k] << endl;
  } else {
    k -= l;
    k %= c;
    cout << s[l + k] << endl;
  }
  return 0;
}

Measured memory_bytes: 5808
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


signed main(){
  int k,a,b,ans;
  init();
  cin>>k>>a>>b;
  if(a>k-1||a>b-2){
    cout<<k+1<<endl;
    return 0;
  }

  ans=a+((k-a+1)/2)*(b-a)+(k-a+1)%2;

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;


//插入节点
void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = (Node *) malloc(sizeof(Node));

    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;

    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }

}

void inorder(Node *u) {
    if (u == NIL) {
        return;
    }
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) {
        return;
    }
    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
}

//找到以某个节点为根节点的的所有节点的最小值
Node *findMin(Node *node) {
    while (node->left != NIL)
        node = node->left;
    return node;
}



void deleteNode(Node *z){
    Node *y;//要删除的对象
    Node *x;
    if(z->left==NIL||z->right==NIL)
        y=z;
    else{
        y=findMin(z->right);
    }

    if(y->left!=NIL){
        x=y->left;
    }else{
        x=y->right;
    }

    if(x!=NIL){
        x->parent=y->parent;
    }

    if(y->parent==NIL){
        root=x;
    }else{
        if(y==y->parent->left){
            y->parent->left=x;
        }else{
            y->parent->right=x;
        }
    }

    if(y!=z){
        z->key=y->key;
    }

    free(y);


}


Node *find(int k) {
    Node *x = root;
    while (x != NIL && k != x->key) {
        if (k < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    return x;
}

int main() {
    int n, x;
    string com;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> com;
        if (com == "insert") {
            cin >> x;
            insert(x);
        } else if (com == "print") {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        } else if(com=="find"){
            cin >> x;
            Node *t = find(x);
            if (t != NIL) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        }else{
            cin>>x;
            deleteNode(find(x));
        }
    }
    return 0;
}


Measured memory_bytes: 21740
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int count = 1;
		for (int i=0;i<M;i++) {
			count *=2;
		}
		int oneTime = (N-M)*100+1900*M;
		System.out.println(count*oneTime);
	}

}

Measured memory_bytes: 21844
// https://atcoder.jp/contests/abc059/tasks/abc059_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  string a, b, r;

  cin >> a >> b;

  if (a == b)
    r = "EQUAL";
  else if (b.length() < a.length())
    r = "GREATER";
  else if (a.length() < b.length())
    r = "LESS";
  else
    r = a[0] < b[0] ? "LESS" : "GREATER";

  cout << r << '\n';

  return 0;
}


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

# a = pb + r 
# N = 10, b = 4
# a (0...10)
# r 0,1,2,3,0,1,2,3,0,1,2
ans = 0

for b in range(1,N+1):
  if b<=K:
    continue
  ans += ((N+1)//b) * (b-K)
  ans += max((N+1)%b-K, 0)
  if K == 0:
    ans -= 1
print(ans)

Measured memory_bytes: 9176
n = int(input())
h = list(map(int, input().split()))

dp = [0]*n

dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2,n):
    dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]),dp[i-1] + abs(h[i]-h[i-1]))

print(dp[n-1])

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

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

    char a, b;
    cin >> a >> b;
    if (a < b)
        cout << "<\n";
    else if (a > b)
        cout << ">\n";
    else
        cout << "=\n";

    return 0;
}



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

using namespace std;
typedef long long ll;

int A[101010];
int K;

int main() {
	ll l, r;
	scanf("%d", &K);
	for(int i = 1; i <= K; i++) scanf("%d", &A[i]);
	l = r = 2;
	for(int i = K; i >= 1; i--) {
		if(l % A[i]) l += (A[i] - l % A[i]);
		r -= (r % A[i]);
		if(r < l) { puts("-1"); return 0; }
		r += (A[i] - 1);
	}
	printf("%lld %lld\n", l, r);
	return 0;
}

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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll i, j, n;
	string s;
	cin >> n >> s;
	ll ans = 0;
	for (i = 0, j = n - 1; i < j; )
		if (s[i] == 'W')
			if (s[j] == 'R')
				swap (s[i], s[j]),
				++ans, ++i, --j;
			else --j;
		else
			++i, j -= (s[j] == 'W');
	cout << ans << '\n';

	return 0;
}



Measured memory_bytes: 3760
import sys
input = sys.stdin.readline
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


i = j = 0
t = 0
while i < N and t + A[i] <= K:
	t += A[i]
	i += 1

best = i

while True:
	while j < M and t + B[j] <= K:
		t += B[j]
		j += 1

	best = max(best, i + j)

	if not i: break

	i -= 1
	t -= A[i]

print(best)


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

int main(){
    long double n,k;
    long double ans=0;
    cin>>n>>k;
    
    for(int i=1;i<=n;i++){
        long int tokuten=i;
        long double pal=1/n;
        while(tokuten<=k-1){
            tokuten*=2;
            pal*=0.5;

        }
        ans+=pal;
    }
    cout<<fixed<<setprecision(15)<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

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

	return 0;
}

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

using namespace std;
using ll = long long;

ll c(const vector<ll> &p, const vector<bool> &b) {
    ll h = p[0];
    ll res = 0;
    for (int i = 1; i < p.size(); i++)
    {
        if (b[i] == true)
        {
            if (p[i] <= h)
            {
                res += h - p[i] + 1;
                h++;
            }
        }
        h = max(h, p[i]);
    }
    return res;
}

ll calc(int n, int k, const vector<ll> &p) {
    vector<bool> b(n);
    for(int i = 0; i < k; i++) b[n - 1 - i] = true;
    ll m = LLONG_MAX;
    do {
        m = min(m, c(p, b));
    } while(next_permutation(b.begin(), b.end()));
    return m;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for(auto &x: A) cin >> x;
    cout << calc(N, K, A) << endl;
}

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

#define int long long
#define INF 1000000007
 const int n1=500;

 
int32_t main() 
{
    int n,k;
    cin>>k>>n;
    //vector<int> v;
    int x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        k-=x;
    }
    if(k>0)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 int n, m;
 cin >> n >> m;
 if (n==m) cout << "Yes";
 else cout<< "No";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>  
#include<set>
#include<iterator>
#include<list>
#include<utility>
#include<cstdlib>
#include<queue>
#include<stack>
#include<bitset>
//#include<bits/stdc++.h>
#define PI  2*acos(0.0)
#define pb push_back

       
using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;



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


ll n,m;
cin>>n>>m;
if(500*n >= m) cout<<"Yes"<<endl;
else cout<<"No"<<endl;



	
	
	return 0;
	
	
	       /***Israil Hosen
	            Computer Science & Engineering
	         University Of Rajshahi.
	         ***/
	
	
	
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
//for(int i = 0; i < n; i++)

int main() {
  int n, d;
  cin >> n >> d;
  
  cout << (n % (d * 2 + 1) == 0? n / (d * 2 + 1): n / (d * 2 + 1) + 1) << endl;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int x = Integer.parseInt(chr[0]);
			int y = Integer.parseInt(chr[1]);
			if (x == y) {
				System.out.println("Yes");
			}else if((x==2&&y!=2)||(x!=2&&y==2)){
				System.out.println("No");

			}else {
				String ansx = (x == 4 || x == 6 || x == 9 || x == 11 ? "B" : "C");
				String ansy = (y == 4 || y == 6 || y == 9 || y == 11 ? "B" : "C");
				System.out.println(ansx.equals(ansy) ? "Yes" : "No");
			}
		}
	}
}


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

using namespace std;

const int N = 1e5+15,M = 2e5+15;

#define ll long long


int a[M],b[M],w[M];


vector<int> adj[N];

bool is[N];


ll dist[N];

int par[N];

int find(int x){
	if(x==par[x])return x;
	return par[x]= find(par[x]);
}

void merge(int x,int y){
	x= find(x),y = find(y);
	if(x==y)return;
	par[y]= x;
}
int L[N],R[N];


void sp(int n){
	priority_queue< pair<ll,int>,vector<pair<ll,int> >,greater<pair<ll,int> > >pq;
	for(int i=1;i<=n;++i){
		dist[i]= 4e18;
		if(is[i])dist[i]= 0,pq.push(make_pair(0,i));
	}
	int fr;ll d,dd;
	while(!pq.empty()){
		fr = pq.top().second;
		d = pq.top().first;
		pq.pop();
		if(dist[fr]!=d)continue;

		for(int i=0;i<adj[fr].size();++i){
			int id= adj[fr][i];
			int u = a[id]^b[id]^fr;

			if(dist[u]> w[id]+ d){
				dist[u] = w[id]+d;
				pq.push(make_pair(dist[u],u));
			}	
		}
	}
}

int s[N],t[N];

vector<int> id[N];

ll D[N];

vector<int> check[N];

int main(){
	//freopen("input.txt","r",stdin);

	int n,m,i,k,q,x,y;
	scanf("%d%d%d%d",&n,&m,&k,&q);

	for(i=0;i<m;++i){
		scanf("%d%d%d",&a[i],&b[i],&w[i]);
        adj[a[i]].push_back(i);
        adj[b[i]].push_back(i);
	}
	for(i=0;i<k;++i){
		scanf("%d",&x);
		is[x]= 1;
	}

	sp(n);
	map<ll,int> Hash;
	int pos=0;
	for(i=1;i<=n;++i){
		Hash[dist[i]];

        //cout<<dist[i]<<endl;
	}
	map<ll,int>::iterator it;

	for(it= Hash.begin();it!= Hash.end();++it){
		D[pos] = it->first;
		it->second = pos++;
	}
	for(i=1;i<=n;++i){
		id[Hash[dist[i]]].push_back(i);
	}

	for(i=0;i<q;++i){
		scanf("%d%d",&s[i],&t[i]);
		L[i]= 0,R[i]= pos-1;
	}

    
	bool is=1;
	int ii,mid,u,j;
	while(is){

		
		is = 0;

		for(i=0;i<q;++i){

			if(L[i]==R[i])continue;

			is= 1;
			mid = (L[i]+R[i]+1)/2;
			check[mid].push_back(i);
		}

		for(i=1;i<=n;++i)par[i]= i;
		for(i=pos-1;i>=0;--i){

			for(ii=0;ii<id[i].size();++ii){
				u= id[i][ii];
				
				for(j=0;j<adj[u].size();++j){
					x= adj[u][j];

					y= a[x]^b[x]^u;

					if(dist[y]>=dist[u]){
						merge(u,y);
					}
				}
			}
			for(j=0;j<check[i].size();++j){
				u = check[i][j];
               
                if(find(s[u])!= find(t[u])){
					R[u] = i-1;
				}
				else
					L[u]= i;
			}
			check[i].clear();
		}
	}
	for(i=0;i<q;++i)
		printf("%lld\n",D[L[i]]);

}



Measured memory_bytes: 28332
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc082/tasks/abc082_b
s = input()
t = input()
# sのほうが小さくできる→sの一番小さな文字<tの一番大きい文字よりも小さくできれば良い

# ただし同一文字が存在する場合はどんどん次を見ていく
s = sorted(list(s))
t = sorted(list(t), reverse=True)

print('Yes' if s < t else 'No')


Measured memory_bytes: 3316
#include <cstdio>
#define IL inline
#define lt p<<1
#define rt p<<1|1
#define N 100003
#define REP(a,b,c) for(a=b;a<=c;a++)
using namespace std;
typedef long long lol;
const lol inf=(~0ULL)>>1;
int n,q;
int t[N<<2];
lol tag[N<<2],h[N<<2];
IL int rd(){
	int res=0;char c;while((c=getchar())<'0'||c>'9');
	while(c>='0'&&c<='9')res=res*10+c-'0',c=getchar();return res;
}
IL lol rl(){
	lol res=0;char c;while((c=getchar())<'0'||c>'9');
	while(c>='0'&&c<='9')res=res*10+c-'0',c=getchar();return res;
}
IL void build(int p,int l,int r){
	t[p]=l;if(l==r)return;int mid=(l+r)>>1;
	build(lt,l,mid),build(rt,mid+1,r);
}
IL void pushdown(int p){
	if(tag[p])h[lt]+=tag[p],h[rt]+=tag[p],tag[lt]+=tag[p],tag[rt]+=tag[p],tag[p]=0;
}
IL void output(int p,int l,int r){
	if(l==r){printf("%lld\n",h[p]);return;}
	int mid=(l+r)>>1;pushdown(p);output(lt,l,mid),output(rt,mid+1,r);
}
int mix;lol mih;
IL void query(int p,int l,int r,int x){
	int mid;mix=0,mih=inf;
	if(!x)return;
	while(l!=r){
		if(t[p]<=x){if(h[p]<mih)mix=t[p],mih=h[p];return;}
		pushdown(p);mid=(l+r)>>1;
		(x<=mid)?(r=mid,p=lt):(h[lt]<mih?(mix=t[lt],mih=h[lt]):0,l=mid+1,p=rt);
	}
	if(h[p]<mih)mix=l,mih=h[p];
}
IL void add(int p,int l,int r,int L,int R,lol v){
	if(L<=l && R>=r){h[p]+=v,tag[p]+=v;return;}
	pushdown(p);int mid=(l+r)>>1;
	if(L<=mid)add(lt,l,mid,L,R,v);if(R>mid)add(rt,mid+1,r,L,R,v);
	h[lt]<=h[rt]?(t[p]=t[lt],h[p]=h[lt]):(t[p]=t[rt],h[p]=h[rt]);
}
int main(){
  n=rd(),q=rd();int i,x,xx;lol y,hh,dt;
	build(1,1,n);
  REP(i,1,q){
		x=rd(),y=rl();
		query(1,1,n,x);
		xx=mix,hh=mih;
		while(y){
			dt=y/(x-xx+1);
			query(1,1,n,xx-1);
			if(dt>=mih-hh){
				dt=mih-hh;add(1,1,n,xx,x,dt);y-=dt*(x-xx+1);
				xx=mix,hh=mih;
			}
			else{
				add(1,1,n,xx,x,dt);y-=dt*(x-xx+1);
				if(y)add(1,1,n,xx,xx+y-1,1),y=0;
			}
		}
	}
	output(1,1,n);
  return 0;
}

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

int main() {
  int N , dan = 0;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0 ; i < N ; i++) cin >> vec.at(i);
  //受け取る
  
  sort(vec.begin() , vec.end() );
  
  for(int i = 0 ; i < N-1 ;i++) {
    if(vec.at(i) == vec.at(i + 1)) vec.at(i) = 0;
  }
  
  for(int i = 0 ; i < N ; i++) {
    if(vec.at(i) != 0) dan++;
  }
  
  cout << dan << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int mem[N][N];
void commonSub(int n, int m , string s1 , string s2) {
    for (int i = 0; i < n; i++) {
        mem[i][0] = 0; 
    }
    for (int j = 0; j < m; j++) {
        mem[0][j] = 0;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s1[i-1] == s2[j-1]) {
                mem[i][j] = 1 + mem[i-1][j-1];
            }
            else {
                mem[i][j] = max(mem[i-1][j] , mem[i][j-1]);
            }
        }
    }
    int index = mem[n][m];
    char s[index];
    int i = n;
    int j = m;
    while (i > 0  && j > 0) {
        if (s1[i-1] == s2[j-1]) {
            s[index-1] = s1[i-1];
            index--;
            i--;
            j--; 
        }
        else if (mem[i-1][j] > mem[i][j-1]) {
            i--;
        }
        else {
            j--;
        }
    }
    for (int x = 0; x < mem[n][m]; x++) {
        cout << s[x];
    } 
}

int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s1,s2;cin >> s1 >> s2;
    int n = s1.length();    
    int m =s2.length();
    commonSub(n , m , s1 , s2);

}

Measured memory_bytes: 38788
#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<cstring>
#include<string>
#include<map>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<bitset>
#include<queue>
#include<sstream>
#include<climits>
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1e9;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b>=c){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}
 

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

using namespace std;

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

    int a, b, c, d;

    cin >> a >> b >> c >> d;

    int qtd1, qtd2;

    qtd1 = (c+b-1)/b;
    qtd2 = (a+d-1)/d;

    if(qtd1<=qtd2) cout << "Yes\n";
    else cout << "No\n";

	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  int nks[32][16][256];
  REP(i,32) REP(j,16) REP(k,256) nks[i][j][k]=0;
  REP(i,32) nks[i][0][0]=1;
  REP(n,32) FOR(i,1,n+1){
    for(int j=9;j>=0;--j)
      REP(k,160)
	nks[n][j+1][k+i]+=nks[n][j][k];
  }
  for(;;){
    int n,k,s;
    cin >> n >> k >> s;
    if(!n&&!k&&!s) return 0;
    cout << nks[n][k][s] << endl;
  }
}

Measured memory_bytes: 1668
def resolve():
  base = 10**9+7
  S = int(input())
  dp = [0] * (S+1)
  dp[0] = 1

  for i in range(1, S+1):
    for u in range(i-2):
      dp[i] += dp[u]
      dp[i] %= base
  # print(dp)
  print(dp[S]%base)

if __name__ == "__main__":
  resolve()


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

typedef long long ll;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())

typedef double D;
typedef complex<D> P;
#define X real()
#define Y imag()
const D eps=1e-8;
const D inf=1e12;
namespace std{
  bool operator<(const P& a,const P& b){
    return a.X==b.X?a.Y<b.Y:a.X<b.X;
  }
}
bool cmp_x(const P& a,const P& b){ return a.X==b.X?a.Y<b.Y:a.X<b.X; }
D cross(P a,P b){ return (conj(a)*b).Y; }
D dot(P a,P b){ return (conj(a)*b).X; }

struct L : public vector<P> { // line and segment
  L(const P& a,const P &b){
    push_back(a);
    push_back(b);
  }
};

int ccw(P a,P b,P c) {
  b=b-a;c=c-a;
  if(cross(b,c)>0) return +1;       // counter clockwise
  if(cross(b,c)<0) return -1;       // clockwise
  if(dot(b,c)<0)   return +2;       // c--a--b on line
  if(norm(b)<norm(c)) return -2;       // a--b--c on line
  return 0;
}

vector<P> convex_hull(vector<P>& ps){
  sort(ps.begin(),ps.end(),cmp_x);
  int n=ps.size();
  int k=0;
  vector<P> qs(n*2);
  for(int i=0;i<n;i++){
    while(k>1&&cross(qs[k-1]-qs[k-2],ps[i]-qs[k-1])<=0)k--;
    qs[k++]=ps[i];
  }
  for(int i=n-2,t=k;i>=0;i--){
    while(k>t&&cross(qs[k-1]-qs[k-2],ps[i]-qs[k-1])<=0)k--;
    qs[k++]=ps[i];
  }
  qs.resize(k-1);
  return qs;
}

bool judge(P p,const vector<P>& poly){
  int sz=poly.size();
  if(sz==0)return true;
  bool ok=false;
  rep(i,sz){
    int c=ccw(poly[i],p,poly[(i+1)%sz]);
    if(c==-2)return false;
    if(c!=-1)ok=true;
  }
  return ok;
}

bool intersectSS(L s,L t){
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1])<=0&&ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1])<=0;
}

int main(){
  while(1){
    int n,m;
    cin>>n>>m;
    if(n==0)break;
    vector<P> a,b;
    rep(i,n){
      int x,y;
      cin>>x>>y;
      a.push_back(P(x,y));
    }
    rep(i,m){
      int x,y;
      cin>>x>>y;
      b.push_back(P(x,y));
    }
    vector<P> pa;
    if(a.size()>=2)pa=convex_hull(a);
    vector<P> pb;
    if(b.size()>=2)pb=convex_hull(b);
    bool ok=true;
    rep(i,n){
      if(!judge(a[i],pb))ok=false;
    }
    rep(i,m){
      if(!judge(b[i],pa))ok=false;
    }
    rep(i,n)rep(j,i){
      int sz=pb.size();
      rep(k,pb.size()){
        if(intersectSS(L(pb[k],pb[(k+1)%sz]),L(a[i],a[j])))ok=false;
      }
    }
    rep(i,m)rep(j,i){
      int sz=pa.size();
      rep(k,pa.size()){
        if(intersectSS(L(pa[k],pa[(k+1)%sz]),L(b[i],b[j])))ok=false;
      }
    }
    if(ok)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3076
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

string s;
int d[30303][10];
bool ans[10][10][10];

int main(void){
	int n,i,j,k,cnt=0;
	cin >> n;
	cin >> s;
	for(i=0; i<n; ++i){
		s[i] -= '0';
		for(j=0; j<10; ++j){
			d[i+1][j] += d[i][j];
		}
		++d[i+1][s[i]];
	}
	for(i=0; i<n; ++i){
		for(j=0; j<10; ++j){
			for(k=0; k<10; ++k){
				if(d[i][j] && (d[n][k]-d[i+1][k])){
					ans[j][s[i]][k] = true;
				}
			}
		}
	}
	for(i=0; i<10; ++i){
		for(j=0; j<10; ++j){
			for(k=0; k<10; ++k){
				if(ans[i][j][k]){
					++cnt;
				}
			}
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1536
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

n=int(input())
s=input().strip()

memo={}
def getans(a,b,c):
    while a and c and a[0]==c[-1]:
        a=a[1:]
        c=c[:-1]
    if b=="":
        if a=="" and c=="": return 1
        else: return 0
    key=a+"/"+b+"/"+c
    if key in memo: return memo[key]
    # select first letter
    ans=0
    for i in range(1,len(b)):
        if b[0]==b[i]:
            ans+=getans(a,b[1:i],b[i+1:]+c)
    # don't select first letter
    ans+=getans(a+b[0],b[1:],c)
    memo[key]=ans
    #print(key,ans)
    return ans

print(getans("",s,"")*2)

#print(len(memo))


Measured memory_bytes: 155580
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

bool isPrime(int x){
  int i;
  if(x < 2)return 0;
  else if(x == 2) return 1;
  if(x%2 == 0) return 0;
  for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
  return 1;
}

int binary(vector<int> a,lint key) {
  lint left = 0;
  lint right = a.size();
  while(left<right){
    lint mid = (left+right)/2;
    if(a[mid] == key){
      return 1;
    }
    else if(key<a[mid]){
      right = mid;
    }
    else{
      left = mid+1;
    }
  }
  return 0;
}



int main(){
  int a;
  cin>>a;
  if(a<=7){
  }
  else{
    while(a>7){
      a-=7;
    }
  }
  if(a==1){
    cout<<"fri"<<endl;
  }
  else if(a==2){
    cout<<"sat"<<endl;
  }
  else if(a==3){
    cout<<"sun"<<endl;
  }
  else if(a==4){
    cout<<"mon"<<endl;
  }
  else if(a==5){
    cout<<"tue"<<endl;
  }
  else if(a==6){
    cout<<"wed"<<endl;
  }
  else if(a==7){
    cout<<"thu"<<endl;
  }
}



Measured memory_bytes: 3092
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            var s = Console.ReadLine();
            int n = int.Parse(s);
            var s2 = Console.ReadLine().Split(' ');
            var b = new int[n];
            int difcount = 0;
            for (int i = 0; i < n; i++)
            {
                b[i] = int.Parse(s2[i]);
                if (b[i] != i + 1)
                {
                    difcount++;
                }
            }
            if (difcount == 0 || difcount == 2)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }


#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}


Measured memory_bytes: 13140