akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v.at(i);
    }
    
    int ans = 0;
    int sum;
    for (int left = 0; left <= n; left++)
    {
        for (int right = left; right <= n; right++)
        {
            if (left + n - right > k) continue;

            vector<int> having;
            for (int l = 0; l < left; l++)
            {
                having.push_back(v.at(l));
            }
            for (int r = 0; r < n - right; r++)
            {
                having.push_back(v.at(n - r - 1));
            }

            sort(having.begin(), having.end());

            sum = 0;
            for (int i = 0; i < (int)having.size(); i++)
            {
                sum += having.at(i);
            }
            
            for (int i = 0; i < min((int)having.size(), k - (left + n - right)); i++)
            {
                if (having.at(i) >= 0) break;

                sum -= having.at(i);
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
 
public class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);

        int cnt = 0;
        String str = "";


        String a = sc.next();
        String b = sc.next();

        if( a.equals( b ) ) System.out.println("H");
        if( !a.equals( b ) ) System.out.println("D");


        System.out.println();
    }

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int main(){
	fastio();
	int a,b;
	cin>>a>>b;
	int l = 1;
	 int r = 1000000;

	 bool ok = false;
	 int ans;

	 for(int i=1;i<=1000000;i++){
	 	l = i*8, r = i*10;
	 	l = l/100, r = r/100;
	 	if(l==a && r==b){
	 		ans = i;
	 		ok = true;
	 		break;
	 	}
	 }
	 if(!ok){
	 	cout<<"-1";
	 }else{
	 	cout<<ans;
	 }
}

Measured memory_bytes: 256
/*input

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}

void solve(){
	ll i,j,k;
	ll a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	return 0;
}




Measured memory_bytes: 3652
import numpy as np
n, x, y =  list(map(int, input().split()))

# n, x, y = 6, 1, 6

r = y - x - 1
left = x
right = n - y + 1
base = left + right
arr = np.array([0] * (n - 1))
for k in range(base):
    arr[k] += base - k - 1
    
r += 2
if r % 2 == 0:
    arr_r = [r] * ((r // 2) - 1) + [r // 2]
else:
    arr_r = [r] * (r // 2)
    
r -= 2
for k in range(len(arr_r)):
    arr[k] += arr_r[k]

#print(arr_r)
# for k in range(r):
#     arr[k] += r - k - 1

if r % 2 == 0:
    arr_r = [1] + [2] * ((r // 2) - 1)  + [1]
else:
    arr_r = [1] + [2] *(r // 2)
    
#print(arr_r)

arr = np.array(arr)
if right > 1:
    for k in range(1, right):
        arr[k : k + len(arr_r)] += arr_r
if left > 1:
    for k in range(1, left):
        arr[k : k + len(arr_r)] += arr_r
arr[0] -= 1
for a in arr:
    print(a)

Measured memory_bytes: 12764
#include <stdio.h>
#include <math.h>
int main(){
	double ans,x,h;
	while(1){
	scanf("%lf %lf",&x,&h);
	if(x==0&&h==0)break;
	ans=x*sqrt(4*h*h+x*x)+x*x;
	printf("%lf\n",ans);
	}
return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

int main() {
    int a,b,n,plan1,plan2,minm;
    cin>>n>>a>>b;
    plan1=(a*n);
    plan2=b;
    minm=min(plan1,plan2);
    cout<<minm;
    return 0;
}


Measured memory_bytes: 256
x1,y1,x2,y2 = list(map(int,input().split()))

x3 = x2 -(y2-y1)
y3 = y2 +(x2-x1)
x4 = x3-(x2-x1)
y4 = y3 -(y2-y1)
print(x3,y3,x4,y4)

Measured memory_bytes: 2940
#include<cstdio>
#include<cmath>
int a[110];
int main() {
	int n;
	int kase;
		scanf("%d", &n);
		int flag = -1;
		a[0] = 0;
		while(n) {
			a[++flag] = n%(-2);
			n /= (-2);
			if(a[flag] == -1) {
				a[flag] = 1;
				n++;
			}
		}
		while(flag>0) printf("%d", a[flag--]);
		printf("%d", a[0]);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

const string word[] = {
  string("dream"),
  string("dreamer"),
  string("erase"),
  string("eraser")
};

int main() {
  string s;
  cin >> s;

  auto len = static_cast<int>(s.size());
  vector<bool> reach(len + 1);
  reach[0] = true;
  int ridx = 0;

  for (int i = 0; i < len; ++i) {
    if (ridx < i) {
      break;
    }
    for (auto&& w : word) {
      if (len < i + w.size()) continue;
      if (0 == s.compare(i, w.size(), w)) {
        int tmp = i + w.size();
        reach[tmp] = true;
        if (ridx < tmp) ridx = tmp;
        if (len == ridx) break;
      }
    }
  }

  cout << (reach[len] ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
	int x1, y1, x2, y2;
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	int dx = x2 - x1, dy = y2 - y1;
	printf("%d %d %d %d\n", x2 - dy, y2 + dx, x1 - dy, y1 + dx);
	return 0;
}


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

typedef long long ll;
typedef long double ld;

const int MOD = 998244353;

ll add(ll a, ll b){
    return (a+b)%MOD;
}

ll mul(ll a, ll b){
    return (a*b)%MOD;
}

pair <ll, ll> a[200005];
ll dp[200005];
int seg[1000005];

void upd(int node, int l, int r, int x, ll val){
    if(l == r){
        seg[node] = val;
        return;
    }
    int mid = (l+r)/2;
    if(x <= mid) upd(node*2, l, mid, x, val);
    else upd(node*2+1, mid+1, r, x, val);
    seg[node] = max(seg[node*2], seg[node*2+1]);
}

ll getmax(int node, int l, int r, int tl, int tr){
    if(l > tr || tl > r) return 0;
    if(tl <= l && r <= tr) return seg[node];
    int mid = (l+r)/2;
    return max(getmax(node*2, l, mid, tl, tr), getmax(node*2+1, mid+1, r, tl, tr));
}

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

	int n;
	cin >> n;
	for(int i=1; i<=n; i++){
        cin >> a[i].first >> a[i].second;
        a[i].first += 1e9;
    }
    sort(a+1, a+1+n);
    a[n+1].first = 1e11;
    dp[n+1] = 1;
    for(int i=n-1; i>=1; i--){
        int l = i+1, r = n+1, j = n+1;
        while(l <= r){
            int mid = (l+r)/2;
            if(a[mid].first >= a[i].first+a[i].second){
                r = mid-1;
                j = mid;
            }
            else l = mid+1;
        }
        //a[j].second + a[j].first - a[i].first
        //cout << j << endl;
        a[i].second = max(a[i].second, (-a[i].first + getmax(1, 1, n, i, j-1))*(j>i+1));
        upd(1, 1, n, i, a[i].second + a[i].first);
    }
    for(int i=n; i>=1; i--){
        int l = i+1, r = n+1, j = n+1;
        while(l <= r){
            int mid = (l+r)/2;
            if(a[mid].first >= a[i].first+a[i].second){
                r = mid-1;
                j = mid;
            }
            else l = mid+1;
        }
        dp[i] = add(dp[i+1], dp[j]);
    }
    cout << dp[1] << "\n";
    return 0;
}


Measured memory_bytes: 8832
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	int i, j;
	int n, m;
	vector<int>list;


	cin >> n;

	for (i = 0; i < n; i++) {
		int num;
		cin >> num;
		list.push_back(num);
	}

	sort(list.begin(), list.end(), greater<int>());

	

	int sum = list[0] / 2;

	for (i = 1; i < n; i++) {
		int num;
		sum += list[i];
	}


	cout << sum << endl;














	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt
from functools import lru_cache, reduce
INF = 1 << 60
mod = 1000000007
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# ここから書き始める
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
# print("a =", a)
b = [0] * n
for i in range(n - 1):
    if x == 0:
        continue
    b[i] = min(x, a[i])
    x -= min(x, a[i])
b[-1] = x
ans = 0
for i in range(n):
    if a[i] == b[i]:
        ans += 1
print(ans)

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

using namespace std;

void printVector(vector<int> v) {
    for (int i=0;i<v.size();i++) {
        cout << v[i] << " ";
    }
    cout << endl;
}

int main() {
    int N; cin>>N;
    vector<int> hn(N+1);
    for (int i=1;i<=N;i++) cin>>hn[i];

    int cnt0=0;
    int ans=0;
    while (cnt0 != hn.size()-1) {
        // printVector(hn);
        cnt0 = 0;
        int last=0;
        for (int i=1;i<=N;i++) {
            if (hn[i] != 0) {
                if (last==0) ans++;
                last = hn[i];
                hn[i] -= 1;
            } else {
                last = hn[i];
                cnt0++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORTR(x) sort(ALLR(x))
#define SORT(x) sort(ALL(x))
#define SUM(x) accumulate(ALL(A), 0)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<string> VS;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}


void Main()
{
	long double R;
	long double length;
	cin>>R;
	length=2.0*(long double)M_PI*R;
	cout << length << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 3808
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

struct edge{
  int to,cost;
};

int A,B,C,N,W,H,ans,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	N = B *10 + C;
	if(N %4){
		cout << "NO\n";
	}else{
		cout << "YES\n";
	}
}

void debug(){

}

void answer(){
	// cout << ans << "\n";
}

int main(){
	cin >> A >> B >> C;
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	char c;
	string tag = "ABC";
	int res = 0;
	int len = 0;
	for (int i = 0; i < N; ++i) { 
		cin >> c;
		if (c == tag[len]) {
			++len;
			if (len == tag.length()) {
				++res;
				len = 0;
			}
		}
		else if (c == tag[0]) {
			len = 1;
		}
		else {
			len = 0;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int n;
    cin >> n;
    vector<int> a(1000010,0);
    For(i,0,n) {
        int x;
        cin>>x;
        a[x]++;
    }
    For(i,1,1000001){
        if(a[i]==0) continue;
        if(a[i]==1) ans++;
        for(int j=1;i*j<1000001;j++){
            a[i*j]=0;
        }
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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

int main(){
	vector<int> w(3);
    for(int i=0; i<3; i++){
        cin >> w.at(i);
    }
    sort(w.begin(), w.end());
    if(w.at(0)==5 && w.at(1)==5 && w.at(2)==7)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;    

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <sstream>
#include <iterator>
#include <sstream>
#include <iomanip>
#include <istream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

bool isGu(string s) {
    if(s.size()%2 != 0) return false;

    for(int i=0; i<s.size()/2; i++) {
        if(s[i] != s[i+s.size()/2]) return false;
    }
    return true;
}

int main()
{
    string s;
    cin >> s;
    s.erase( --s.end() );

    int size = s.size();
    for(int i=0; i<size; i++) {
        if(isGu(s)) {
            cout << s.size() << endl;
            break;
        }
        else {
            s.erase( --s.end() );
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;
	const int dx=tx-sx,dy=ty-sy;

	cout<<string(dy,'U')<<string(dx,'R');
	cout<<string(dy,'D')<<string(dx,'L');
	cout<<'L'<<string(dy+1,'U')<<string(dx+1,'R')<<'D';
	cout<<'R'<<string(dy+1,'D')<<string(dx+1,'L')<<'U';
	puts("");


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

ll a[220000];
int main(){
    ll n,ans=0;
    cin>>n;
    rep(i,0,n)cin>>a[i];
    sort(a,a+n,greater<ll>());
    ans=a[0];
    rep(i,1,n/2)ans+=a[i]*2;
    if(n%2==1)ans+=a[n/2];
    cout<<ans;
}




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

int main() {
  string s;
  cin >> s;
  vector <char> vec (s.size()) ;
  
  for (int i = 0;i<s.size(); i++) vec.at(i) = 'x';
  
  for (int i = 0; i < s.size(); i++) {
    if (i == s.size()-1) cout << vec.at(i) << endl;
    else cout << vec.at(i);
   }
  }

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

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

struct edge{
    LL to;
    LL state;
    LL cost;
};

struct vertex{
    LL id;
    LL state;
    LL cost;
    bool used;
    vector<edge> e;

    vertex(){}

    vertex(LL i, LL s):id(i),state(s){
        cost = INF;
        used = false;
    }
    
    bool operator >(const vertex& right)const{
        return cost > right.cost;
    }
};

struct usedv{
    LL id;
    LL state;

    bool operator <(const usedv& right)const{
        return (id==right.id)?(state<right.state):(id<right.id);
    }
};

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

    LL n,m;
    cin >> n >> m;

    vector<vertex> v;
    map<usedv,LL> mp;

    for(int i = 1; i <= n; i++){
        v.push_back(vertex(i,-1));
        mp[usedv{i,-1}] = v.size() - 1;
    }

    for(int i = 0; i < m; i++){
        LL a,b,c;
        cin >> a >> b >> c;
        auto itr = mp.find(usedv{a,c});
        if(itr == mp.end()){
            v.push_back(vertex(a,c));
            mp[usedv{a,c}] = v.size() - 1;
            v.back().e.push_back(edge{a,-1,0});
            v[mp[usedv{a,-1}]].e.push_back(edge{a,c,1});
        }
        auto itr2 = mp.find(usedv{b,c});
        if(itr2 == mp.end()){
            v.push_back(vertex(b,c));
            mp[usedv{b,c}] = v.size()-1;
            v.back().e.push_back(edge{b,-1,0});
            v[mp[usedv{b,-1}]].e.push_back(edge{b,c,1});
        }

        v[mp[usedv{a,c}]].e.push_back(edge{b,c,0});
        v[mp[usedv{b,c}]].e.push_back(edge{a,c,0});
    }

    priority_queue<vertex,vector<vertex>,greater<vertex>> pq;
    v[0].cost = 0;
    pq.push(v[0]);

    while(!pq.empty()){
        vertex tmp = pq.top();
        pq.pop();
        if(v[mp[usedv{tmp.id,tmp.state}]].used)continue;
        v[mp[usedv{tmp.id,tmp.state}]].used = true;

        for(int i = 0; i < tmp.e.size(); i++){
            if(v[mp[usedv{tmp.id,tmp.state}]].cost + tmp.e[i].cost < v[mp[usedv{tmp.e[i].to,tmp.e[i].state}]].cost){
                v[mp[usedv{tmp.e[i].to,tmp.e[i].state}]].cost = v[mp[usedv{tmp.id,tmp.state}]].cost + tmp.e[i].cost;
                pq.push(v[mp[usedv{tmp.e[i].to,tmp.e[i].state}]]);
            }
        }
    }

    if(v[n-1].cost == INF){
        cout << -1 << endl;
    }else{
        cout << v[n-1].cost << endl;
    }
    
    return 0;
}

Measured memory_bytes: 123588
N = int(input())
koma = list(map(int, input().split()))
M = int(input())
order = list(map(int, input().split()))
koma.append(0)

for i in range(M):
    koma[order[i]-1] += 1
    if koma[order[i]-1] == koma[order[i]] or koma[order[i]-1] == 2020:
        koma[order[i]-1] -= 1

del koma[-1]
for v in koma:
    print(v)


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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<vector<int>> s(4 * k + 1, vector<int>(4 * k + 1));

  for (int i = 0; i < n; i++) {
    int x, y;
    char c;
    cin >> x >> y >> c;
    if (c == 'W') {
      x += k;
    }
    x %= 2 * k;
    y %= 2 * k;
    s[x + 1][y + 1]++;
    s[x + 2 * k + 1][y + 1]++;
    s[x + 1][y + 2 * k + 1]++;
    s[x + 2 * k + 1][y + 2 * k + 1]++;
  }

  for (int i = 0; i + 1 < s.size(); i++) {
    for (int j = 0; j + 1 < s.size(); j++) {
      s[i + 1][j + 1] += s[i + 1][j] + s[i][j + 1] - s[i][j];
    }
  }

  auto sum = [&](int y, int x, int n) {
    return s[y + n][x + n] - s[y + n][x] - s[y][x + n] + s[y][x];
  };

  int ans = 0;
  for (int i = 0; i < 2 * k; i++) {
    for (int j = 0; j < 2 * k; j++) {
      int s1 = sum(i, j, k);
      int s2 = sum(i + k, j + k, k);
      ans = max(ans, s1 + s2);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 62976
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        String S =sc.nextLine();
        int w = sc.nextInt();
        char[] str = S.toCharArray();
        StringBuilder sb =new StringBuilder();
        for (int i=0;i<str.length;i=i+w) {
            sb.append(str[i]);
        }
        System.out.println(sb.toString());
    }

}


Measured memory_bytes: 22868
N = list(input())
#print(N)
ans = 'No'
count = 0
#f = N[0] 
pref =''
for i in N:
  if i == pref: 
    count +=1
  else:
    count = 0
  pref = i 
  if count>=2:
    ans = 'Yes'

  
print(ans)  

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;
#define rep(i, n) for (int i = 0; i < (n); i++)
 #define all(v) (v).begin(),(v).end()
 using ll = long long;
using Graph = vector<vector<int>>;

int main(){
ll a,b;
  cin>>a>>b;
  vector<double>pr(a);
  rep(i,a) cin>>pr.at(i);
  double sum[a+1];
  sum[0]=0;
 
  for(int i=1;i<a+1;i++) sum[i]=sum[i-1]+(pr[i-1]+1)/2;
  double ans=0;
  for(int i=0;i<a-b+1;i++)
  {
  ans=max(ans,sum[i+b]-sum[i]);
  
  }
  
  cout<< fixed << setprecision(12)<<ans;
  
  }
 




Measured memory_bytes: 3328
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC173
{
    class A
    {
        static void Main(string[] args)
        {
            //var CA = Enumerable.Repeat(0, (int)N).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            //var NMK = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = long.Parse(Console.ReadLine());

            while (1000 < N)
            {
                N -= 1000;
            }

            Console.WriteLine(1000 - N);
        }
    }
}


Measured memory_bytes: 27464
f = lambda: map(int, input().split())
n,m = f()
path = [[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    a,b = f()
    path[a-1][b-1]=path[b-1][a-1]=1

ans = 0


def dfs(pStack):
    global ans
    if len(pStack) == n:
        ans += 1
        pStack.pop()
        return
    cNode = pStack[-1]
    for nNode in range(n):
        if path[cNode][nNode] and not nNode in pStack:
            pStack.append(nNode)
            dfs(pStack)
    pStack.pop()


dfs([0])
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;

template<typename T>
using RQ = std::priority_queue<T, std::vector<T>, std::greater<T>>;

int main() {
   Int v, e, r;
   std::cin >> v >> e >> r;
   std::vector<Int> ss(e), ts(e), ds(e);
   rep(i, e) std::cin >> ss[i] >> ts[i] >> ds[i];
   std::vector<std::vector<Int>> edges(v);
   rep(i, e) edges[ss[i]].emplace_back(i);
   const Int inf = (Int)1 << 53;
   std::vector<Int> xs(v, inf);
   xs[r] = 0;
   std::vector<bool> ys(v, false);
   ys[r] = true;
   RQ<std::pair<Int,Int>> q;
   q.emplace(0, r);
   while( not q.empty() ) {
      Int x, s; std::tie(x, s) = q.top(); q.pop();
      for(Int k : edges[s]) {
         Int t = ts[k], d = ds[k];
         guard( x == xs[s] );
         guard( x + d < xs[t] );
         xs[t] = x + d;
         q.emplace(x + d, t);
      }
   }
   rep(i, v) {
      if( xs[i] >= inf / 2 ) {
         puts("INF");
      }
      else {
         printf("%ld\n", xs[i]);
      }
   }
}

Measured memory_bytes: 26032
#include <bits/stdc++.h>
using namespace std;
typedef long long Int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
int main() {
    int n, m; cin >> n >> m;
    vector<int> dp(n+1);
    vector<bool> is_safe(n+1, true);
    rep(i, m) {
        int tmp;
        cin >> tmp;
        is_safe[tmp] = false;
    }
    dp[0] = 1;
    if (is_safe[1]) dp[1] = 1;
    //if (is_safe[2]) dp[2] = 2;
    int j = 0;
    for (int i = 2; i < n+1; i++) {
        if (is_safe[i-2])
            dp[i] += dp[i-2];
        if (is_safe[i-1])
            dp[i] += dp[i-1];
        dp[i] = dp[i] % MOD;
    }
    cout << dp[n]% MOD  << endl;
}


Measured memory_bytes: 3724
#include <stdio.h>

int main() {
  int secondsIn;

  scanf("%d", &secondsIn);

  int hours = secondsIn / 3600;
  int minutes = (secondsIn - (hours * 3600)) / 60;
  int seconds = secondsIn % 60;


  printf("%d:%d:%d\n", hours, minutes, seconds);
  return 0;
}


Measured memory_bytes: 1848
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstdlib>
using namespace std;
typedef long long ll;
const int NN = 220000;

ll mod, k, n, a[NN], b[NN], ans, x;

int main(){
	//freopen("a.in", "r", stdin);

	scanf("%lld%lld", &k, &n);
	ll tmp = 0;
	for (int i=1; i<=n; i++) {
		scanf("%d", &a[i]);
	}
	tmp = k - (a[n] - a[1]);

	for (int i=2; i<=n; i++){
		tmp = max(tmp, a[i] - a[i-1]);
	}
	cout << k - tmp;
	
	return 0;
} 

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 100002;

int n, a;

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

    n %= 500;

    if (n <= a) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}


Measured memory_bytes: 256
import sys

K, N = map(int, sys.stdin.readline().rstrip().split())
A = list(map(int, sys.stdin.readline().rstrip().split()))

distances = [0] * N
for i in range(N):
    if i == 0:
        distances[i] = A[i] + K - A[-1]
    else:
        distances[i] = A[i] - A[i - 1]

minimum_distance = K - max(distances)
print(minimum_distance)


Measured memory_bytes: 26444
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  vi v(3);

  rep(i,3)
  {
    cin >> v[i];
  }

  vsort(v);

  bool b;
  b = (v[0] != v[1] && v[1] == v[2]) || (v[0] == v[1] && v[1] != v[2]);
  if(b) cout << "Yes";
  else cout << "No";



  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define int long long

using namespace std;

const int inf = (int)1e9 + 7  ;
const long long mod = 1e9 + 7;
const int N = (int)3007;

int n, m, dp[121];
main(){
      int n;
      cin >> n;
      dp[4] = 1;
      dp[7] = 1;
      for(int i = 8;i <= n; i++){
            if(dp[i - 4]){
                  dp[i] = 1;
            }
            if(dp[i - 7]){
                  dp[i] = 1;
            }
      }
      if(dp[n]){
            cout << "Yes";
            return 0;
      }
      cout << "No";
}


Measured memory_bytes: 256
#include <iostream>
//#include <stdio.h>
using namespace std;

int toNumber(char c){
	switch (c){
	case 'S':
		return 0;
	case 'H':
		return 1;
	case 'C':
		return 2;
	case 'D':
		return 3;
	default:
		return NULL;
		break;
	}
}
char toStr(int n){
	switch(n){
	case 0:
		return 'S';
	case 1:
		return 'H';
	case 2:
		return 'C';
	case 3:
		return 'D';
	default:
		return NULL;
		break;
	}
}

int main(){
	int room[5][4][11];
	int n, b, f, r, v; 
	//room???????????¢
	for (int i=1;i<=4;i++){
		for (int j=1;j<=3;j++){
			for (int k=1;k<=10;k++){
				room[i][j][k]=0;
			}
		}
	}
	cin >> n;
	for (int i = 0;i < n;i++){ 
		cin >> b >> f >> r >> v;
		room[b][f][r] = room[b][f][r] + v;
	}
	
	for (int i=1;i<=4;i++){
		for (int j=1;j<=3;j++){
			for (int k=1;k<=10;k++){
				cout << " " << room[i][j][k] ;
			}
			cout << endl;
		}
		if ( i!= 4 )cout << "####################" << endl;
	}
	
	//cout << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>

int map[15][15],table[15][15],X,Y;

int main(){
while(1){

scanf("%d%d",&X,&Y);
if(X==0&&Y==0) return 0;
memset(map,-1,sizeof(map));
memset(table,0,sizeof(table));
for(int i=0;i<Y;i++){
for(int j=0;j<X;j++){
scanf("%d",&map[i][j]);
if(i==0&&map[i][j]==0) table[i][j]=1;
else if(i!=0&&map[i][j]!=1){
if(j>0&&map[i-1][j-1]==0&&map[i][j]==0) table[i][j]+=table[i-1][j-1];
if(j<X-1&&map[i-1][j+1]==0&&map[i][j]==0) table[i][j]+=table[i-1][j+1];
if(map[i-1][j]==0)table[i][j]+=table[i-1][j];
if(i>2&&map[i-2][j]==2) table[i][j]+=table[i-2][j]; 
} 
}
}
int sum=0;
for(int i=0;i<X;i++){
sum+=table[Y-1][i];
if(map[Y-2][i]==2) sum+=table[Y-2][i];
}
printf("%d\n",sum);



}
}

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

int main(){
    int a,b,c,k,max;
    scanf("%d %d %d %d",&a,&b,&c,&k);

    max = a;
    if(b>max)
        max = b;
    else if(c>max)
        max = c;
    
    if(max==a)
        max = (pow(2,k)*a) + b + c;
    else if (max==b)
        max = (pow(2,k)*b) + a + c;
    else if (max==c)
        max = (pow(2,k)*c) + a + b;

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

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

class Main{
  public static void main(String... args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    StringBuilder sb = new StringBuilder(str);
    String str1 = sb.reverse().toString();
    if(str.equals(str1)) System.out.println("Yes"); else System.out.println("No");

  }
}


Measured memory_bytes: 21204
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	int b[n];
	for(int i=0;i<n;++i)
		cin>>a[i];
	for(int i=0;i<n;++i)
		cin>>b[i];
	int c[n];
	for(int i=0;i<n;++i)
		c[i]=i+1;
	int i=0,s1,s2;
	do{
		++i;
		bool flag=true;
		for(int j=0;j<n;++j)
			if(c[j]!=a[j]){
				flag=false;
				break;
			}
		if(flag)
			s1=i;
		else
			flag=true;
		for(int j=0;j<n;++j)
			if(c[j]!=b[j]){
				flag=false;
				break;
			}
		if(flag)
			s2=i;
	}while(next_permutation(c,c+n));
	if(s2<s1)
		swap(s2,s1);
	cout<<s2-s1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,a[105],flag=0;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]%2==0)
        {
            if(a[i]%3!=0&&a[i]%5!=0)
                flag=1;
        }
    }
    if(flag==1)cout<<"DENIED";
    else cout<<"APPROVED";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int n, m, i, j, k, c[1000005];
int f(int n){
	if(n & 1) return n * 3 + 1;
	else return n >> 1;
}
int main(){
	scanf("%d", &n);
	m = c[n] = 1;
	while(++c[n = f(n)] == 1) m++;
	printf("%d\n", m+1);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int ans = 1001001001;
    REP(c_cnt, max(x, y) * 2 + 1) {
        int a_cnt = max(0, (x * 2 - c_cnt + 2 - 1) / 2);
        int b_cnt = max(0, (y * 2 - c_cnt + 2 - 1) / 2);
        ans = min(ans, a_cnt * a + b_cnt * b + c_cnt * c);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra() {
  priority_queue<pair<int, int> > PQ;
  int color[MAX];
  int d[MAX];

  for (int i = 0; i < n; i++) {
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  PQ.push(make_pair(0, 0));
  color[0] = GRAY;

  while ( !PQ.empty() ) {
    pair<int, int> f = PQ.top(); PQ.pop();
    int u = f.second;
    color[u] = BLACK;

    if (d[u] < f.first * (-1)) continue;

    for (int j = 0; j < adj[u].size(); j++) {
      int v = adj[u][j].first;
      if (color[v] == BLACK) continue;
      if (d[v] > d[u] + adj[u][j].second) {
        d[v] = d[u] + adj[u][j].second;
        PQ.push(make_pair(d[v] * (-1), v));
        color[v] = GRAY;
      }
    }
  }

  for (int i = 0; i < n; i++) {
    cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
  }
}

int main() {
  int k, u, v, c;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v >> c;
      adj[u].push_back(make_pair(v, c));
    }
  }

  dijkstra();

  return 0;
}


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int x, y; cin >> x >> y;
  rep(i, x+1) {
    int j = x - i;

    if (i * 2 + j * 4 == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;

    vector<string> patterns{"SS", "SW", "WS", "WW"};
    for (string &pat : patterns) {
        for (int i = 1; i < n-1; i++) {
            if ((s[i] == 'o' && pat[i] == 'S') || (s[i] == 'x' && pat[i] == 'W')) {
                pat += pat[i - 1];
            } else {
                pat += (pat[i - 1] == 'S' ? 'W' : 'S');
            }
        }
        if (s[n-1] == 'o') {
            if (!((pat[n-1] == 'S' && pat[n-2] == pat[0]) || (pat[n-1] == 'W' && pat[n-2] != pat[0])))
                continue;
        } else {
            if (!((pat[n-1] == 'S' && pat[n-2] != pat[0]) || (pat[n-1] == 'W' && pat[n-2] == pat[0])))
                continue;
        }
        if (s[0] == 'o') {
            if (!((pat[0] == 'S' && pat[n-1] == pat[1]) || (pat[0] == 'W' && pat[n-1] != pat[1])))
                continue;
        } else {
            if (!((pat[0] == 'S' && pat[n-1] != pat[1]) || (pat[0] == 'W' && pat[n-1] == pat[1])))
                continue;
        }
        cout << pat << endl;
        return 0;    
    }
    puts("-1");
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int n,k;
  cin >> n >> k;
  vi h(n);
  rep(i,n) cin >> h[i];
  int cnt = 0;
  rep(i,n){
    if(h[i]>=k) cnt ++;
  }
  cout << cnt << endl;
  
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int h[200000];
int main(){
	int n;cin>>n;
	rep(i,n){
		scanf("%d",&h[i]);
	}
	for(int i=n-2;i>=0;i--){
		if(h[i]>h[i+1]){
			h[i]--;
		}
		if(h[i]>h[i+1]){
			puts("No");return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int x;
    cin >> x;
    int mini = -150;
    int maxi = 150;
    
    for (ll i = mini; i<maxi; ++i){
        for (ll j=mini; j<maxi; ++j){
            if (pow(i, 5) - pow(j, 5) == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }


}

Measured memory_bytes: 4012
#include<iostream>
#include<vector>
#include<algorithm>//sort,二分探査など
//#include<bitset>
//#include<cmath>//pow,logなど
//#include<deque>
//#include<functional>
//#include<iterator>
//#include<map>
#include<numeric>//gcd,lcm
//#include<queue>
//#include<set>
//#include<stack>
//#include<string>
//#include<utility>//pair

//QCFium法
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

//浮動小数点処理高速化
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using i64 = int64_t;
using f80 = __float80;
using u64 = uint_fast64_t;

constexpr i64 INF = 1010000000000000017LL;
constexpr u64 MOD = 1000000007LL;
constexpr f80 PI = 3.14159265358979323846;

#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(int i=(int)(start);i<(int)(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(int i=(int)(start);i>(int)(end);--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

#define v(T) vector<T>
#define vv(T) v(v(T))
#define vvv(T) v(v(v(T)))
typedef v(int) vi;

#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  int N;
  cin >> N;
  bool flagP = true;
  bool flagS = false;

  vector<int> A(N);
  cin >> A;

  if(A[0] == 1) {
    flagS = true;
  } else {
    int gcdx = A[0];
    rep(i, 1, N) {
      gcdx = __gcd(gcdx, A[i]);
      if(gcdx==1){
        flagS = true;
        break;
      }
    }
  }

  vector<bool> prime(1000001, true);
  for(int i = 2; i <= 1000; i++) {
    if(prime[i]) {
      int x = i * 2;
      while(x <= 1000000){
        prime[x] = false;
        x += i;
      }
    }
  }

  vector<bool> elatos(1000001, false);

  rep(i,N){
    if(A[i]==1) {
      continue;
    }
    if(elatos[A[i]]){
      flagP = false;
      break;
    }

    int Y = A[i];

    while(1<Y and !prime[Y]){
      rep(j,2,1001){
        if(prime[j] and (Y % j == 0)) {
          int x = j;
          while(x <= 1000000){
            elatos[x] = true;
            x += j;
          }
          while(Y % j == 0) {
            Y = Y / j;
          }
        }
      }
    }

    if(1<Y){
      int x = Y;
      while(x <= 1000000) {
        elatos[x] = true;
        x += Y;
      }
    }
  }

  if(flagP) {
    cout << "pairwise coprime\n";
    return;
  }

  if(flagS) {
    cout << "setwise coprime\n";
    return;
  }

  cout << "not coprime\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
//  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 7448
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std ;
template< class T > inl T read() {
	T x = 0 ; int f = 1 ; char k = getchar() ;
	for( ; k > '9' || k < '0'; k = getchar() ) if( k == '-' ) f = -1 ;
	for( ; k >= '0' && k <= '9'; k = getchar() ) x = x * 10 + k - '0' ;
	return x * f ;
}
template< class T > inl T read( T &x ) { return x = read<T>() ; }
int _num, _buf[20];
template< class T > il print( T x ) {
   	if( x == 0 ) return putchar( '0' ) ,void() ;
	if( x < 0 ) putchar( '-' ), x = -x ;
	while( x ) _buf[++_num] = x % 10, x /= 10 ;
	while( _num ) putchar( _buf[_num--] + '0' ) ;
}
ll mul( ll a, ll b, ll mod ) { long double c = 1. ; return ( a * b - (ll)( c * a * b / mod ) * mod ) % mod ; }
it qpow( int x, int m, int mod ) {
	int res = 1, bas = x ;
	while(m) {
		if( m & 1 ) res = ( 1ll * res * bas ) % mod ;
		bas = ( 1ll * bas * bas ) % mod, m >>= 1 ;
	}
	return res ;
}
const int N = 2e5 + 5 ;
int n, ans;
char s[N];
int main() {
//	freopen( ".in", "r", stdin ) ;
//	freopen( ".out", "w", stdout ) ;
	n = read<int>(), scanf( "%s", s + 1 ) ;
	int num = 0 ;
	for( ri i = 1; i <= n; ++i )
		num += s[i] == 'W' ;
	ans = std::min( num, n - num ) ;
	num = 0 ;
	for( ri L = 1, R = n; L < R; ) {
		while( s[L] == 'R' )
			L += 1 ;
		while( s[R] == 'W' )
			R -= 1 ;
		if( L >= R )
			break ;
		L += 1, R -= 1, num += 1 ;
	}
	ans = std::min( ans, num ) ;
	print( ans ), puts( "" ) ;
	cerr << 1. * clock() / CLOCKS_PER_SEC << "\n" ;
	return 0;
}

Measured memory_bytes: 3980