akhauriyash/Code-Regression huggingface dataset:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	static void solve(){//Here is the main function
		String s = next();
		if(s.indexOf("YAKI") == 0){
			myout("Yes");
		}else{
			myout("No");
		}
	}
	//Method addition frame start



	//Method addition frame end

	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
}


Measured memory_bytes: 32864
mod = 1000000007
def add(a, b):
    return (a + b) % mod

N, M = map(int, input().split())
Broken_set = set([])
for _ in range(M):
    Broken_set.add(int(input()))

if 1 in Broken_set:    
    dp = [0]*(N+1)
    dp[0] = 1
    dp[1] = 0
    for i in range(2, N+1):
        if i in Broken_set:
            dp[i] = 0
        else:
            dp[i] = add(dp[i-1], dp[i-2])

else:
    dp = [0]*(N+1)
    dp[0] = 1
    dp[1] = 1
    for i in range(2, N+1):
        if i in Broken_set:
            dp[i] = 0
        else:
            dp[i] = add(dp[i-1], dp[i-2])

print(dp[N])

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

int main() {
  int X, Y; cin >> X >> Y;
  for(int i=0; i<=X; i++){
    if(i*2+(X-i)*4==Y) {cout << "Yes"; return 0;}
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    if(N%10==3){
        cout << "bon" << endl;
    }else if(N%10==0 || N%10==1 || N%10==6 || N%10==8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
from heapq import*;n,*a=map(int,open(0).read().split());b,h,c,p=a[:n],heappushpop,[-i for i in a[n:][::-1]],heapify;s,d=sum(b),c[:n];t=sum(d);p(b);p(d);r,l=[s],[t]
for i in range(n,n*2):s+=a[i]-h(b,a[i]);t+=c[i]-h(d,c[i]);r+=[s];l+=[t]
print(max(map(sum,zip(r,l[::-1]))))

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

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

struct info {
  string name;
  int score, order;
};

bool comp(const info& a, const info& b) {
  if (a.name != b.name) return a.name < b.name;
  return a.score > b.score;
}

int main() {
  int n;
  cin >> n;
  vector<info> infom(n);
  rep(i,n) {
    cin >> infom[i].name >> infom[i].score;
    infom[i].order = i+1;
  }
  sort(infom.begin(), infom.end(), comp);
  rep(i,n) printf("%d\n", infom[i].order);
  return 0;
}


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

//#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x, n;
    cin >> x >> n;
    set<int> s;
    for (int i = 0; i < n; i++) {
        int j;
        cin >> j;
        s.emplace(j);
    }
    for (int d = 0; true; d++) {
        if (s.count(x-d) == 0) {
            cout << x-d << '\n';
            break;
        } else if (s.count(x+d) == 0) {
            cout << x+d << '\n';
            break;
        }
    }
}
/*

 */


Measured memory_bytes: 3660
/* Author : bhavye9499 - Bhavye Anand Gupta */

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define endl "\n"
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<ll,ll>
#define showArr(A,a,n) {for(int i=a; i<a+n; i++) cout << A[i] << " "; cout << endl;}
#define showPair(A,a,n) {for(int i=a; i<a+n; i++) cout << A[i].fi << " " << A[i].se << endl;}

const ll MOD = 1e9 + 7;

ll dp[100100], A[100100], n;

ll fun(ll i);

int main() {
    ios::sync_with_stdio(false);
    memset(dp, -1, sizeof(dp));
    memset(A, 0, sizeof(dp));
    cin >> n;
    for(int i = 0; i < n; i++) {
    	cin >> A[i];
    }
    A[n] = LLONG_MAX / 2;
    A[n + 1] = LLONG_MAX / 2;
    ll ans = fun(0);
    cout << ans << endl;
}

ll fun(ll i) {
	if(i == n-1)
		return dp[i] = 0;
	if(i >= n)
		return dp[i] = LLONG_MAX / 2;
	if(dp[i] == -1)
		return dp[i] = min(abs(A[i] - A[i + 1]) + fun(i + 1), abs(A[i] - A[i + 2]) + fun(i + 2));
	return dp[i];
}

Measured memory_bytes: 3328
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a * b;
        int length = 2 * (a + b);
        System.out.println(area + " " + length);
        sc.close();
    }
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;


using Row = vector<int64>;
using Mat = vector<Row>;
vector<PLL> l[212345], r[212345]; // (match, val)

int main(void){
	int32 N;
	using T = tuple<int64, int64, int64, int64>;
	cin >> N;
	vector<T> cwsv(N); // compare, wei, solid, value
	REP(i, N){
		int64 w, s, v;
		cin >> w >> s >> v;
		cwsv[i] = T(w+s, w, s, v);
	}
	sort(all(cwsv));
	vector<int64> dp(20010, 0);
	REP(i, N){
		vector<int64> dp2(20010, 0);
		dp2 = dp;
		int64 w, s, v, _;
		tie(_, w, s, v) = cwsv[i];
		REP(j, 20010){
			if(j <= s && j+w <= 20000){
				chmax(dp2[j+w], dp[j]+v);
			}
		}
		swap(dp, dp2);
	}
	cout << *max_element(all(dp)) << endl;
}


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

int main() {
	string S;
	cin >> S;
	int A = 0, B = 0, N = S.size();
	int i;
	for (i = 0; i < N; i++) {
		switch (S.at(i)) {
		case '0':
			A++;
			break;
		case'1':
			B++;
			break;
		}
	}
	cout << N - abs(A - B);
}

Measured memory_bytes: 512
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<String>();
    let b=read::<String>();
    let c=read::<String>();
    let a=b.as_bytes().iter().map(|c|*c as char).collect::<Vec<char>>();
    println!("A{}C",a[0])
}

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

int main() {
    int n;cin>>n;
    set<int> s;
    for (int i=0;i<n;i++) {
        int a;cin>>a;
        s.insert(a);
    }
    if (s.size()==n)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  for (int i=0; i<n; i++){
  	  string s;
      cin >> s;
      if (s=="Y"){
      	  cout<<"Four"<<endl;
      	  exit(0);
      }
   }
  cout<<"Three"<<endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)


def DFS(num,pre):
    global point
    if color[num]=="white":
        ans[num]=C.pop()
        point +=min(ans[num],pre)
        color[num]="black"
        for i in T[num]:
            DFS(i,ans[num])


n=int(input())
AB=[list(map(int,input().split())) for _ in range(n-1)]
C=sorted(list(map(int,input().split())))
color=["white" for _ in range(n)]

T=[[] for _ in range(n)]
for a,b in AB:
    T[a-1].append(b-1)
    T[b-1].append(a-1)

ans=[0 for _ in range(n)]
point=0
DFS(0,0)

print(point)
print(*ans)

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

#define pb push_back
#define ff first
#define ss second

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

string s;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s;
	if (s[1] == s[0] || s[2] == s[1] || s[3] == s[2])
		cout << "Bad";
	else
		cout << "Good";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define ull unsigned long long int
#define ll long long int
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define IO freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
using namespace std;

const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

int main(){

    FAST;
    int n; cin >> n;
    int arr[n]; ll dp[n];
    for(int i=0; i<n; i++)
        cin >> arr[i];
    
    for(int i=0; i<n; i++)
        dp[i]=0;

    dp[1]=abs(arr[1]-arr[0]);

    for(int i=2; i<n; i++)
        dp[i]=min(dp[i-2]+abs(arr[i]-arr[i-2]), dp[i-1]+abs(arr[i]-arr[i-1]));

    cout << dp[n-1];
    return 0;
}

Measured memory_bytes: 1408
mod = 10 ** 9 + 7
H, W, K = map(int, input().split())

if  W == 1:
    print(1)
    exit()

base = [[0] * W for _ in range(W)]

for bit in range(2 ** (W - 1)):
    temp = [(bit & (1 << i) != 0) for i in range(W - 1)]
    before = False
    is_ok = True
    for line in temp:
        if line:
            if before:
                is_ok = False
                break
            else:
                before = True
        else:
            before = False
    
    if is_ok:
        before = False
        for i, line in enumerate(temp):
            if line:
                base[i][i + 1] += 1
                base[i + 1][i] += 1
                before = True
            else:
                if not before:
                    base[i][i] += 1

                before = False

        if not temp[-1]:
            base[-1][-1] += 1
dp = [[0] * W for _ in range(H + 1)]
dp[0][0] = 1
for i in range(1, H + 1, 1):
    for j in range(W):
        for k in range(W):
            dp[i][j] = (dp[i][j] + dp[i - 1][k] * base[k][j]) % mod

print(dp[H][K - 1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,a;
	cin>>n;
	map<ll,ll>mp;
	bool f=1;
	for(int i=0;i<n;i++){
		cin>>a;
		mp[a]++;
		if(mp[a]==2)f=0;
	}
	cout<<(f?"YES":"NO");
	return 0;
}


Measured memory_bytes: 12800
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
	ll n,p,q,c[500010];
	scanf("%lld%lld%lld",&n,&p,&q);
	for(int i = 0 ; i < n ; i ++){
		scanf("%lld",&c[i]);
	}
	ll a[500010];
	for(int i = 0 ; i < n ; i ++){
		a[i] = c[i]+i*p;
	}
	sort(a,a+n);
	ll sum = 0;
	for(int i = 0 ; i < n ; i ++){
		sum += c[i];
	}
	ll ret = sum;
	for(int i = 0 ; i < n ; i ++){
		sum += p*q+2*i*p-a[i];
		ret = max ( ret , sum );
	}
	cout << ret << endl;
}

Measured memory_bytes: 11056
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

const int MAX = 100;

int selectionSort(int A[], int n)
{
    int SwapNum{0};
    for (int i = 0; i < n; i++) //失之毫厘，谬以千里
    {
        int min = i;
        for (int j = i + 1; j < n; j++)
        {
            if (A[j] < A[min])
            {
                min = j;
            }
        }
        swap(A[i], A[min]);
        if (min != i)
        {
            SwapNum++;
        }
    }
    return SwapNum;
}

int main()
{
    int A[MAX];
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &A[i]);
    }
    int ans = selectionSort(A, n);
    for (int i = 0; i < n - 1; i++)
    {
        printf("%d ", A[i]);
    }
    printf("%d\n%d\n", A[n - 1], ans);
    return 0;
}


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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   int A, B, C, ans = 0;
   cin >> A >> B >> C;

   vector<int> input = {A, B, C};
   sort(input.begin(), input.end());

   while (A % 2 + B % 2 + C % 2 == 0) {
     ans++;
     int tmpA = A, tmpB = B;
     A = B / 2 + C / 2;
     B = C / 2 + tmpA / 2;
     C = tmpA / 2 + tmpB / 2;

     vector<int> tmp = {A, B, C};
     if (tmp == input) {
       ans = -1;
       break;
     }
   }
   cout << ans << endl;
 }


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int K; cin >> K;
    int idx = -1;
    rep(i, S.length()) {
        if(S[i] != '1') {
            idx = i;
            break;
        }
    }
    K--;
    if(idx == -1 || K < idx) {
        cout << 1 << endl;
    } else {
        cout << S[idx] << endl;
    }

    return 0;
}


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

d = {}
 
for _ in range(N):
    s = input()
    if s in d:
        d[s] = d[s] + 1
    else:
        d[s] = 1

M = int(input())

for _ in range(M):
    t = input()
    if t in d:
        d[t] = d[t] - 1
    else:
        d[t] = 0

max = 0

for key in d:
    if d[key]>max:
        max = d[key]

print(max)



Measured memory_bytes: 3064
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


def lmi():
    return list(map(int, input().split()))


def llmi(n):
    return [lmi() for _ in range(n)]


N, M = lmi()

A = lmi()

x = N - sum(A)
if x >= 0:
    print(x)
else:
    print(-1)


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << ((a <= c && c <= b) ? "Yes" : "No") << endl;
  return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 710;

int n, m;
int col[MN], cmp[MN];
bool g[MN][MN];
int cnt;
vi vs[MN];

bool dfs(int v, int k, int c) {
	col[v] = c;
	cmp[v] = k;
	vs[k].pb(v);

	rep(i, n) if (i != v && !g[v][i]) {
		if (col[i] == -1) {
			if (!dfs(i, k, c ^ 1)) {
				return false;
			}
		} else if (col[i] == c) {
			return false;
		}
	}

	return true;
}

bool dp[MN][MN];

int main() {
	cin >> n >> m;

	rep(i, m) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a][b] = g[b][a] = 1;
	}

	memset(col, -1, sizeof(col));

	int now = 0;

	rep(i, n) {
		if (col[i] == -1) {
			if (!dfs(i, now++, 0)) {
				puts("-1");
				return 0;
			}
		}
	}

	dp[0][0] = 1;

	rep(i, now) {
		int c[2] = {};
		for (int v : vs[i]) {
			++c[col[v]];
		}

		rep(j, MN) {
			if (dp[i][j]) {
				if (j + c[0] <= n) {
					dp[i+1][j + c[0]] = 1;
				}
				if (j + c[1] <= n) {
					dp[i+1][j + c[1]] = 1;
				}
			}
		}
	}

	int ret = 0;

	rep(i, MN) {
		if (dp[now][i]) {
			ret = max(ret, i * (n - i));
		}
	}

	cout << n * (n-1) / 2 - ret << endl;

	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
int solve(int, int, int);
int A[2001];
int n;
 
int main(){
  int j, q, i;
  int M[2001];
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&M[i]);
  }
   
  for(i=0; i<q; i++){
    if(solve(0, 0, M[i])) printf("yes\n");
    else printf("no\n");
  }
 
  return 0;
}
 
 
 
int solve(int p, int t, int k){
  if(t == k) return 1;
  if(p >= n) return 0;
  if(solve(p+1, t, k)) return 1;
  if(solve(p+1, t+A[p], k)) return 1;
  return 0;
}

Measured memory_bytes: 1804
#include<stdio.h>
#include<string.h>
#define LEN 100005
#define MAX 100005

typedef struct pp{
char name[100];
int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail]=x;
  if(tail+1==MAX)
    tail=0;
  else
    tail++;
}

P dequeue(void){
  P x;
  x=Q[head];
  if(head+1==MAX)
    head=0;
  else head++;
  return x;

}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head=0;
  tail=n;
  while(head!=tail){
    u=dequeue();
    if(q>u.t){
      c=u.t;
    }
    else{
      c=q;
    }
    u.t-=c;
    elaps+=c;
    if(u.t>0){
      enqueue(u);
    }
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}

Measured memory_bytes: 10756
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    ll a, b;
    cin>>n>>a>>b;
    vector<ll> v(n);
    rep(i, n) cin>>v[i];
    ll ans=0;
    rep(i, n-1){
        ans+=min(b, a*(v[i+1]-v[i]));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
typedef long long LL;
const int MaxN = 505;

int vis[105];

int main() {
	int n, m, x;
	scanf("%d %d %d", &n, &m, &x);
	for(int i = 1; i <= m; i++) {
		int a;
		scanf("%d", &a);
		vis[a] = 1;
	}
	int ans1 = 0, ans2 = 0;
	for(int i = x; i <= n; i++) 
		if(vis[i]) ans1++;
	for(int i = x; i >= 0; i--)
		if(vis[i]) ans2++;
	printf("%d\n", min(ans1, ans2));
	return 0;
}


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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e5+5;

int n,m;
vector<vector<int>> adj;
vector<int> vis(N);

int dp[N];

int dfs(int x) {
    if(vis[x])
        return dp[x];
    vis[x]=1;
    int m = 0;
    for(int i: adj[x]) {
        int a = dfs(i);
        m=max(a,m);
    }
    dp[x]=(m+1);
    return dp[x];
}

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

    cin>>n>>m;
    adj.resize(n+1);
    int u,v;
    for(int i=0;i<m;i++) {
        cin>>u>>v;
        adj[u].pb(v);
    }
    int ans = 0;
    for(int i=1;i<=n;i++) {
        if(!vis[i]) {
            ans=max(ans,dfs(i));
        }
    }

    cout<<ans-1;

    return 0;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    map<char, ll> mp;
    vector<ll> a(3,0);
    string s;
    cin >> s;
    for(ll i = 0; i < s.size(); i++){
        mp[s[i]]++;
        a[s[i] - 97]++;
    }
    sort(a.begin(),a.end());
    if(a[2] - a[0] <= 1)
    cout << "YES" << endl;
    else 
    cout <<"NO" << endl;
}

Measured memory_bytes: 512
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
typedef pair<int,int> pii;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

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

void solve(){

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

    priority_queue<int> q;

    for(int i = 0;i<n;i++){
        int a;
        cin >> a;

        q.push(a);
    }

    while(!q.empty() && m){
        int temp = q.top();
        q.pop();

        int temp2;
        if(!q.empty())temp2 = 0;
        temp2 = q.top();

        while(temp>=temp2&& m){
            temp/=2;
            m--;
        }
        q.push(temp);

    }

    int ans = 0;

    while(!q.empty()){
        int temp = q.top();
        q.pop();
        ans+=temp;
    }

    cout << ans << endl;
} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 1400
use proconio::*;
use std::collections::HashMap;

fn main() {
    input! {
        n:i64,
        mut x:i64,
        m:i64,
    }

    let mut amari = HashMap::new();
    // 0番目はあまりが0(Key: あまり, Value 順番)
    amari.insert(-1i64, 0i64);
    let mut res = 0i64;
    let mut ruiseki = vec![0i64; 100005];

    let mut ikkai = 0i64;
    let mut start = -1i64;
    let mut junban = 0i64;
    let mut syuuki = -1i64;
    loop {
        junban += 1;
        ruiseki[junban as usize] = ruiseki[(junban - 1) as usize] + x;

        if amari.contains_key(&x) {
            syuuki = junban - amari.get(&x).unwrap();
            ikkai = ruiseki[junban as usize] - ruiseki[(junban - syuuki) as usize];
            start = *amari.get(&x).unwrap();
            break;
        } else {
            amari.insert(x, junban);
            x = (x * x) % m;

            if junban == n {
                println!("{}", ruiseki[n as usize]);
                return;
            }
        }
    }

    res = ruiseki[(start - 1) as usize];
    // m/周期と余りで良いので
    res += (n - start + 1) / syuuki * ikkai;

    for _ in 0..((n - start + 1) % syuuki) {
        res += x;
        x = (x * x) % m;
    }

    /*println!(
        "ruiseki: {:?}, syuuki : {}, ikkai : {}, nokori : {}",
        ruiseki,
        syuuki,
        ikkai,
        n % syuuki
    );
    */
    println!("{}", res);
}


Measured memory_bytes: 3940
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (100000)
#define MOD (1000000007)

ll a[MAXN];
ll ans[MAXN];
int main(void)
{
    ll n;
    scanf("%ld",&n);
    ll oddsum=0;
    ll evensum=0;
    for(int i=0;i<n;i++)
    {
        scanf("%ld",&(a[i]));
        if(i%2==0) evensum+=a[i];
        else oddsum += a[i];
    }
    ans[0] = evensum - oddsum;
    for(int i=n-1;i>=1;i--)
    {
        ans[i] = (a[i]-(ans[(i+1)%n]/2))*2;
    }

    for(int i=0;i<n;i++)
    {
        printf("%ld%c",ans[i],i==n-1?'\n':' ');
        
    }
    return 0;
}


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

int main(){
    int D; cin >> D;
    vector<int> c(27,0);
    for(int i = 1; i < 27; i++) cin >> c[i];
    vector<vector<int>> s(D+1,vector<int>(27,0));
    for(int d = 1; d < D+1; d++){
        for(int i = 1; i < 27; i++) cin >> s[d][i];
    }
    
    vector<int> t(D+1);
    for(int i = 1; i < D+1; i++){
        cin >> t[i];
    }
    
    map<int,int> mp;
    
    int ans  = 0;
    for(int d = 1; d < D+1 ; d++){
        ans += s[d][t[d]];
        //cout << ans << endl;
        mp[t[d]] = d;
        for(int i = 1; i < 27; i++)ans -= c[i]*(d -mp[i]);
        cout << ans << endl;
        
    }
    
    
    
}

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

int main(){
    string str;
    bool flag = false;
    cin >> str;

    if(str[2] == str[3] && str[4] == str[5]){
        flag = true;
    }
    if(flag){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  int p=0;
  int n=A;
  while(n<B+1){
    int x=n/10;
    int y=n/1000;
    if(x%10==y%10 && n%10==n/10000){
      p++;
    }
    n++;
  }
  cout<<p<<endl;
}
    

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

using namespace std;
typedef long long ll;





int main()
{
    
    double a,b,x;
    cin >> a >> b >> x;
    double ans;
    
    if(a*a*b/2 >= x){
        cout << fixed << setprecision(10);
        cout << atan(a*b*b/2/x)/M_PI*180.0 << endl;
    }else{
        cout << fixed << setprecision(10);
        cout << atan((2*b-(2*x/a/a))/a)/M_PI*180.0 << endl;
    }
    
    
    return 0;
}



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

int main(){
	int n,q,k;
	cin >> n >> k >> q;
	int* a = new int[q];

	int* score = new int[n];
	for(int i=0;i<n;i++){
		score[i]=k-q;
	}

	for(int i=0;i<q;i++){
		cin >> a[i];
		score[a[i]-1] += 1;
	}

	for(int i=0;i<n;i++){
		if(score[i]>0){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}

	return 0;
}

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

int main() {
  int a,b;cin>>a>>b;
  int ans=max(a+b,a-b);
  ans=max(ans,a*b);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
using System;
class Program{
	static void Main(){
		long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		long a=0,b=0,ans=0;
		long[,,] dp=new long[s[0]+1,s[0]+1,s[0]*4+1];
		for(long i=1;i<=s[0];i++){
			long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
			if(i==1){a=q[0]-1;}
			q[0]-=a;
			b+=q[0];
			for(long j=1;j<=i;j++){
				for(long k=1;k<=b;k++){
					if(k>=q[0]&&j*a+k<=s[1]){dp[i,j,k]=Math.Max(dp[i-1,j-1,k-q[0]]+q[1],Math.Max(dp[i-1,j,k],dp[i,j-1,k]));}
					else{dp[i,j,k]=Math.Max(dp[i-1,j,k],dp[i,j-1,k]);}
				}
			}
		}
		for(long i=1;i<=b;i++){ans=Math.Max(ans,dp[s[0],s[0],i]);}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 41952
import copy
inf = 10**9
n, m = map(int, input().split())
graph = [[] for _ in range(n)]
bridge_list = []
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
    bridge_list.append([a, b])
ans = 0
for a, b in bridge_list:
    graph_copy = copy.deepcopy(graph)
    graph_copy[b].remove(a)
    graph_copy[a].remove(b)
    distance_list = [inf] * n
    distance_list[0] = 0
    visited = set([])
    point = set([0])
    while len(point - visited) > 0:
        vvv = [[vv, i] for i, vv in enumerate(distance_list) if i in (point - visited)]
        u = min(vvv)[1]
        for v in graph_copy[u]:
            if distance_list[u] + 1 < distance_list[v]:
                distance_list[v] = distance_list[u] + 1
                point.add(v)
        visited.add(u)
    if distance_list.count(inf) > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE


void solve (void)
{
  int R,G,B; cin>>R; cin>>G;cin>>B;
  if((R*100 + G*10 +B)%4 == 0)
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

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

  for(int i = 0; i < N; i++){
    cin >> c;
    
    if(c == "Y"){
      cout << "Four" << endl;
      return 0;
    }
  }
    cout << "Three" << endl;
    return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 200005;

int n;
string s;
int pre[N];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (i > 0)
			pre[i] = pre[i - 1];
		if (s[i] == '#')
			pre[i]++;
	}
	int res = OO;
	int c = 0;
	for (int i = n - 1; i >= 0; i--) {
		res = min(res, pre[i] + c);
		if (s[i] == '.')
			c++;
	}
	res = min(res, c);
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1300
# coding: utf-8

def era(n)
    $primes = Array.new(n, true)
    $primes[0], $primes[1] = false, false
    (2..Math.sqrt(n)).each do |i|
        if $primes[i]
            (i * i).step(n, i).each do |j|
                $primes[j] = false
            end
        end
    end
end

max = 1000001
era(max)

$niteru2017 = Array.new(1000001, 0)

tmp = 0
1.step(100001) {|i|
    if i % 2 == 0
        $niteru2017[i] = $niteru2017[i-1]
    elsif $primes[i] && $primes[(i+1)/2]
        tmp += 1
        $niteru2017[i] = tmp
    else
        $niteru2017[i] = $niteru2017[i-1]
    end
}

q = gets.to_i

for i in 1..q do
    l, r = gets.chomp.split(" ").map(&:to_i);
    puts $niteru2017[r] - $niteru2017[l-1]
end

Measured memory_bytes: 19580
#include<stdio.h>
int main(){
  char s[11]={},a[11]={};
  int j=0;
  scanf("%s",s);
  for(int i=0;s[i]!='\0';i++){
    switch(s[i]){
      case '0':
      case '1':
        a[j]=s[i];
        j++;
        break;
      case 'B':
        if(--j<0) j=0;
        break;
      default:
        break;
    }
    a[j]='\0';
  }
  printf("%s\n",a);
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long mod(long long a, long long b) { return (a%b+b)%b; }
long long gcd(long long x, long long y) { return __gcd(x, y); }
long long lcm(long long x, long long y) { return x * 1ll * y / gcd(x, y); }
 
 
const long long MAXN = 1e9 + 9;
const long long SIZE = 2e5 + 5;
const long long MOD = 1e9 + 7;


int N, arr[SIZE];
long long sum, res;

int main() { speedhack()

	cin >> N;

	forn (i, N) {
		cin >> arr[i];
		sum = mod (sum + arr[i], MOD);
	}

	forn (i, N) {
		sum = mod (sum - arr[i], MOD);
		res = mod (res + sum * arr[i], MOD);
	}

	cout << res;

	return 0;
}

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

int main(){
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;
	tx=tx-sx;
	ty=ty-sy;
	sx=sy=0;
	for(int i=0;i<ty;i++)
		cout<<'U';
	for(int i=0;i<tx;i++)
		cout<<'R';
	for (int i = 0; i < ty; ++i)
	{
		cout<<'D';
	}
	for(int i=0;i<=tx;i++)
		cout<<'L';
	for(int i=0;i<=ty;i++)
		cout<<'U';
	for(int i=0;i<=tx;i++)
		cout<<'R';
	cout<<'D';
	cout<<'R';
	for (int i = 0; i <= ty; ++i)
	{
		cout<<'D';
	}
	for(int i=0;i<=tx;i++)
		cout<<'L';
	cout<<'U';
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int red_cnt = 0;
    rep(i, s.length()) if (s[i] == 'R') red_cnt++;

    int ans = 0;
    rep(i, red_cnt) {
        if (s[i] == 'W') ans++;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define DIM 200009
#define INF ((long long)1e18+9ll)
#define pairll pair<long long,long long>
#define fi first
#define se second
#define ld long double
#define endl '\n'
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define amen exit(0)

long long i,j,k,l,n,m,sz,C;

struct line{
    long long k,b;
};

line ls[DIM];

long long a[DIM],dp[DIM];

bool check(line a1,line a2,line a3){
    return (ld)(a1.b-a2.b)/(ld)(a1.k-a2.k)>=(ld)(a1.b-a3.b)/(ld)(a1.k-a3.k);
}

void add(long long k,long long b){
    line a={k,b};
    while(sz>1 && check(ls[sz-1],a,ls[sz]))sz--;
    ls[++sz]=a;
}

long long get(long long num,long long x){
    return ls[num].k*x+ls[num].b;
}

long long bs(long long x){
    long long l=0,r=sz;
    while(r-l>1){
        long long mid=(l+r)/2;
        if(get(mid,x)<get(mid+1,x))r=mid;
        else l=mid;
    }
    return get(r,x);
}

int main()
{
    fast;

    cin>>n>>C;
    for(i=1;i<=n;i++)cin>>a[i];

    dp[1]=0;
    add(-2*a[1],a[1]*a[1]);
    for(i=2;i<=n;i++){
        dp[i]=bs(a[i])+C+a[i]*a[i];
        add(-2*a[i],dp[i]+a[i]*a[i]);
    }

    cout<<dp[n]<<endl;

    amen;
}
/**
dp[i]=dp[j]+(h[i]-h[j])*(h[i]-h[j])+C
dp[i]=dp[j]+h[i]*h[i]-2*h[i]*h[j]+h[j]*h[j]+C

b=dp[j]+h[i]*h[i]+h[j]*h[j]+C
k=-2*h[i]
*/


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define F first
#define S second
//#define int long long

///My functions

//Constants
const int mxn = 3*1e5+5, inf = 1e9+7, mod = 1e9+7;
const long long infLL = 1e18+5;
const double EPS = 1e-9 , PI = acos(-1);

//Structs

//Variables
int n,m,Q,k,a,b,c,sum,ans,MAXans,MINans,sc,pos,acc[mxn],racc[mxn],ar[mxn];
vector<int>v,g[mxn];
bitset<mxn>flag;
bool sol ;
string s;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> s;
    if( s[s.size() - 1] == '?' ) s[s.size() - 1] = 'D' ;
    for( int i = 0 ; i < s.size() - 1 ; i++ ){

    	if( s[i] == '?' and i > 0 and s[i - 1] == 'P' ) s[i] = 'D' ; 
    	else if( s[i] == '?' and s[i + 1] == '?' ) s[i] = 'P';
    	else if( s[i] == '?' and s[i + 1] == 'D' ) s[i] = 'P';
    	else if( s[i] == '?' ) s[i] = 'D' ; 

    }

    cout << s ; 

    return 0;
}
























Measured memory_bytes: 10808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int N, H;
vector<int> a, b;

int main () {
  cin >> N >> H;
  a.resize(N), b.resize(N);
  rep(i,N)cin >> a[i] >> b[i];

  sort(all(a));
  sort(all(b));

  int ans = 0;
  int i = N - 1;
  while(H > 0 && b[i] > a[N-1] && i >= 0) {
    H -= b[i];
    ans++;
    i--;
  }

  if(H > 0) ans += (H + a[N-1] - 1) / a[N-1];

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


Measured memory_bytes: 1024
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    s=STR()
    s=set(s)
    if len(s)==1:
        print('No')
    else:
        print('Yes')
if __name__ == '__main__':
    do()

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

using namespace std;
int main(){
    int n,cnt=0;
    string s;
    cin >> n;
    for(int i=1; i<=n; i++){
       cin >> s;
       if(s=="Y"){
         cout << "Four" << endl;
         break;
       }
     cnt++;
    }
    if(cnt==n) cout << "Three" << endl;
    return 0;
}

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

int main() {
  int n,T;
  cin >> n >> T;
  ll ans = T;
  vector<int>t(n);
  rep(i,n) cin >> t[i];
  rep(i,n-1){
    if(t[i+1]-t[i] < T) ans += t[i+1]-t[i];
    else ans += T;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
'''
https://atcoder.jp/contests/abc145/tasks/abc145_d
'''
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    mod = 10**9 + 7

    X,Y = map(int, input().split())
    if (X+Y)%3 != 0:
        print(0)
        exit()

    a = (2*X-Y)//3
    b = (2*Y-X)//3

    if a<0 or b<0:
        print(0)
        exit()

    def extgcd(a, b):
        if b == 0:
            return a, 1, 0
        else:
            d, x, y = extgcd(b, a % b)
            x -= (a // b) * y
            return d, y, x
        
    def modinv(a, mod): 
        return extgcd(a, mod)[1] % mod

    def modcomb(n, k, mod):
        q, a = 1, 1
        for i in range(n-k+1, n+1):
            q = (q * i) % mod
        for i in range(2, k+1):
            a = (a * i) % mod
        return int(q * modinv(a, mod) % mod)

    print(modcomb(a+b, a, mod))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i < n; i++)
#define repv(i,n) for(int i = n-1; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;

char BUF[3500000];
inline void I(int&a){scanf("%d",&a);}
inline void I(int&a,int&b){scanf("%d%d",&a,&b);}
inline void I(int&a,int&b,int&c){scanf("%d%d%d",&a,&b,&c);}
inline void I(int&a,int&b,int&c,int&d){scanf("%d%d%d%d",&a,&b,&c,&d);}
inline void L(ll&a){scanf("%lld",&a);}
inline void L(ll&a,ll&b){scanf("%lld%lld",&a,&b);}
inline void L(ll&a,ll&b,ll&c){scanf("%lld%lld%lld",&a,&b,&c);}
inline void L(ll&a,ll&b,ll&c,ll&d){scanf("%lld%lld%lld%lld",&a,&b,&c,&d);}
inline void S(string&str){str.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)str.pb(BUF[i]);}
inline void SV(vector<int>&v){v.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)if('a'<=BUF[i]&&BUF[i]<='z')v.pb(BUF[i]-'a');else v.pb(BUF[i]-'A');}

const auto EPS = 1e-10;
const auto INF = 100000000;
const auto MOD = 1000000007;
typedef pair<ll,ll> P;

ll x;

int main(){
    cin >> x;
    ll ans = 1;
    for(ll i = 1; i < 200000; i++){
        if(i*(i+1)/2 >= x){
            cout << i << endl;
            return 0;
        }
        ans *= i;
    }
}
































Measured memory_bytes: 256
#include <bits/stdc++.h>
          using namespace std;
          #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
          #define M_PI 3.14159265358979323846
          #define data data_
          #define ff first
          #define ss second

          int main()
          {
          // clock_t begin = clock();
          // #ifndef ONLINE_JUDGE
          // freopen("input.txt", "r", stdin);
          // freopen("output.txt", "w", stdout);
          // #endif
          tani_nachi_ke  

          double b,h,x;
          cin >> b >> h >> x;
          // cout << (2*h*b*b - 2*x) << endl;
          cout << setprecision(9);
          cout << fixed;
          if(x*2 >=(b*b*h))
          {     double theta = atan((2*h*b*b - 2*x)/(b*b*b));
                cout << ((theta*180)/M_PI) << endl;
          }
          else
          {
               double theta = atan((b*h*h)/(2*x));
                cout << ((theta*180)/M_PI) << endl;
          }

          // #ifndef ONLINE_JUDGE 
          // clock_t end = clock();
          // cout<<endl<<double(end - begin) / CLOCKS_PER_SEC*1000<<" ms";
          // #endif 
          // return 0;
          }

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

constexpr int MAX_N = 1e5;
int s[MAX_N+1];

int main() {

  // エラトステネスのふるい
  bitset<MAX_N + 1> isPrime;
  for (int i{2}; i <= MAX_N; ++i)
    isPrime.set(i);
  for (int i{2}; i <= MAX_N; ++i) {
    if (isPrime[i]) {
      for (int j{i * 2}; j <= MAX_N; j += i) {
        isPrime.reset(j);
      }
    }
  }

  // 累積和
//  vector<int> s(MAX_N + 1, 0);
  for (int i{}; i < MAX_N; ++i) {
    s[i + 1] = s[i] + (isPrime[i] && isPrime[(i+1)/2]);
  }

  int Q; cin >> Q;
  for (int i{}; i < Q; ++i) {
    int l, r; cin >> l >> r;
    cout << s[r+1] - s[l] << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
N,M = map(int,input().split())
C = {str(i):[0,0] for i in range(1,N+1)}
for _ in range(M):
    p,s = input().split()
    if s == "AC":
        if C[p][0]==0:
            C[p][0] = 1
    else:
        if C[p][0]==0:
            C[p][1] += 1
A = [0,0]
for i in range(1,N+1):
    if C[str(i)][0]==1:
        A[0] += 1
        A[1] += C[str(i)][1]
print(*A)

Measured memory_bytes: 25380
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>

#define INT_MAX 2000000000
#define MOD 1000000007
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = uint64_t;


using namespace std;

int main() {

	int i, j, k;
	int h, w;
	cin >> h >> w;
	vector<vector<char>> a(h, vector<char> (w));
	rep(i, 0, h) {
		rep(j, 0, w) {
			cin >> a[i][j];
		}
		rep(j, 0, w) {
			cout << a[i][j];
		}
		cout << endl;
		rep(j, 0, w) {
			cout << a[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256