akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
string s1, s2;
int main(void) {
    std:ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    while(cin >> s1 >> s2) {
        reverse(s1.begin(), s1.end());
        cout << (s1 == s2 ? "YES" : "NO") << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll q;cin>>q;
  ll a,b,ans,temp;
  rep(i,q){
  	cin>>a>>b;
  	ans=0;
  	temp=ll(sqrt((long double)(a*b-1)));
  	if(temp*(temp+1)>(a*b-1)){
  		ans+=(temp-1)*2;
  		ans++;
  	}else{
  		ans+=temp*2;
  	}
  	if(1<=min(a,b)&&min(a,b)<=temp){
  		ans--;
  	}
  	cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000000;

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n + 1);
	ff(i, 0, n + 1)cin >> a[i];
	vector<int> b(n);
	ff(i, 0, n)cin >> b[i];
	i64 ans = 0;
	int ac,an,bc;
	ac = a[0];
	ff(i, 0, n) {
		an = a[i + 1];
		bc = b[i];
		if (ac > 0&&bc>0) {
			int c = min(ac, bc);
			ac -= c;
			bc -= c;
			ans += c;
		}
		if (an > 0 && bc > 0) {
			int c = min(an, bc);
			an -= c;
			bc -= c;
			ans += c;
		}
		ac = an;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int N; cin >> N;
    vector<int> a(N, 0);
    int crushNo = 1;
    int crushCnt = 0;
    int no;
    for (int i=0; i<N; i++) {
        cin >> no;
        if (no == crushNo) {
            crushNo += 1;
        }
        else {
            crushCnt++;
        }
    }
    if (crushCnt == N) {
        crushCnt = -1;
    }
    cout << crushCnt << endl;
    return 0;
}


Measured memory_bytes: 1024
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<bits/stdc++.h>
#define int long long
using namespace std;
long long n,m,v,p,mn,a[101010],ps[101010];
pair<int,int>b[101010];
bool ck(int x)
{
	b[x].first+=m;
	ps[b[x].second]=m;
	long long now=v,kk=b[x].first;
	for(int i=1;i<=n;i++)
	{
		if(b[i].first<kk)
		{
			int x=min(min(kk-b[i].first,m),now);
			now-=x;
			b[i].first+=x;
			ps[b[i].second]=x;
		}
	}
	sort(b+1,b+n+1);
	int cnt=0;
	for(int i=n;i>=1;i--)
	{
		if(!now)
		{
			break;
		}
		if(ps[b[i].second]<m)
		{
			int x=min(m-ps[b[i].second],now);
			b[i].first+=x;
			now-=x;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i].first>kk)
		{
			cnt++;
		}
	}
	return cnt<p;
}
signed main()
{
	cin>>n>>m>>v>>p;
	v*=m;
	v-=m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		b[i].first=a[i];
		b[i].second=i;
		ps[i]=0;
	}
	int l=1,r=n,ans=n;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(ck(mid))
		{
			ans=mid;
            r=mid-1;
		}
		else
		{
			l=mid+1;
		}
		for(int i=1;i<=n;i++)
		{
			b[i].first=a[i];
			b[i].second=i;
			ps[i]=0;
		}
	}
	cout<<n-ans+1<<endl;
	return 0;
}

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

#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
#define nrep(i,a,b) for(int i=int(a);i>=int(b);--i)
#define trv(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define watch(x) cout<<"\n"<<#x<<" is "<<x<<"\n"
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define ZERO(box) memset(box, 0, sizeof(box));
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define chkbit(s, b) (s & (1<<b))
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1e9+7;


void solve(){
	ll n,k,x,y;
	cin>>n>>k>>x>>y;
	if(n<k) cout<<n*x;
	else cout<<k*x + (n-k)*y;
}


int main(){
	int t=1;
	//cin>>t;
	while(t--){
		solve();	
	}	
}
/*input
2
3
10000
9000
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int nx[4]={0,1,-1,0};
int ny[4]={1,0,0,-1};
int main(){
  ll n,m;
  cin>>n>>m;
  vll a(n);
  rep(i,n) cin>>a[i];
  vector<pll> p(m);
  rep(i,m){
    ll b,c;
    cin>>b>>c;
    p[i]=mp(c,b);
  }
  sort(rall(p));
  sort(all(a));
  ll ans=0;
  rep(i,n){
    ans+=a[i];
  }
  ll j=0;
  rep(i,n){
    if(p[j].S==0) j++;
    if(a[i]<p[j].F){
      ans-=a[i];
      ans+=p[j].F;
      p[j].S--;
    }
    else{
      break;
    }
  }
  COUT(ans);
}


Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <ctime>
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;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
	int n, m;
	cin >> n >> m;
	VI a(n);
	REP(i,n) cin >> a[i];
	ll ans = 0;
	VI x(n);
	int p = 0;
	while (1){
		x[p] = 1;
		int mi = 100, ma = 0;
		REP(i,m){
			mi = min(mi, a[(p+i)%n]);
			ma = max(ma, a[(p+i)%n]);
		}
		ans += ma - mi;
		p = (p+m) % n;
		if (x[p]) break;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3044
//20190707
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(void){

    int n,a,b;

    cin >> n >> a >> b;

    if(n*a >= b) cout << b << endl;
    else cout << n*a << endl;


    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    
    double x1, y1, x2, y2;
    cin>>x1>>y1>>x2>>y2;
    cout<<hypot(x2-x1, y2-y1)<<'\n';
    return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int dp[maxn], rev[maxn];
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	string s; cin >> s;
	string t = s;
	for (int i = 0; i < t.length(); ++i)
		t[i] = '0' + (9 - (s[i] - '0'));
	int carry = 1;
	reverse(t.begin(), t.end());
	for (int i = 0; i < t.length(); ++i) {
		int cur = t[i] - '0' + carry;
		carry = cur / 10;
		t[i] = '0' + (cur % 10);
	}
	if (carry) t.push_back('0' + carry);
	reverse(t.begin(), t.end());
	for (int i = s.length() - 1; i >= 0; --i) {
		dp[i] = dp[i + 1] + min(s[i] - '0', 11 - s[i] + '0');
		dp[i] = min(dp[i], 1 + (s[i] - '0') + rev[i + 1]);
		rev[i] = rev[i + 1] + min(t[i] - '0', 11 - t[i] + '0');
		rev[i] = min(rev[i], 1 + (t[i] - '0') + dp[i + 1]);
	}
	cout << min(dp[0], 1 + rev[0]) << '\n';
	return 0;
}

Measured memory_bytes: 10140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int max_n = 10000;
const int max_q = 100000;

int parent[max_n];
int Rank[max_n];

void init(int n){
    REP(i,n){
        parent[i] = i;
        Rank[i] = 0;
    }
}

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

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    
    if(Rank[x] < Rank[y]){
        parent[x] = y;
    }
    else{
        parent[y] = x;
        if(Rank[x] == Rank[y]) Rank[x]++;
    }
}

bool same(int x,int y){
    return find(x) == find(y);
}

int N,Q;

int main(){
    cin >> N >> Q;
    int com[Q], X[Q], Y[Q];
    REP(i,Q){
        cin >> com[i] >> X[i] >> Y[i];
    }
    int ans = 0;
    init(N);
    REP(i,Q){
        int c = com[i];
        int x = X[i];
        int y = Y[i];
        if(c == 0){
            unite(x,y);
        }
        else{
            cout << (same(x,y) ? "1" : "0") << endl;
        }
    }
}


Measured memory_bytes: 4332
#!/usr/bin/env python3
import sys
import numpy as np

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, K: int, Q: int, A: "List[int]"):
    human = np.full(N, K)
    score = np.zeros(N)
    #print(human)
    for i in range(Q):
        #print("i =", i)
        # ind = np.ones(N, dtype=bool)
        # ind[A[i]-1] = False
        # human[ind] = human[ind] - 1
        # ind[A[i]-1] = True
        #human[A[i]-1] += 1
        #print('human =', human)
        score[A[i]-1] += 1

    human = human - Q + score

    #print(human)
    human2 = list(map(lambda x: YES if x > 0 else NO, human))
    print('\n'.join(human2))
    '''
    for j in range(N):
        #print(j, human[j])
        if human[j] > 0:
            print(YES)
        else:
            print(NO)
    '''
    return
    

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(Q)]  # type: "List[int]"
    solve(N, K, Q, A)

if __name__ == '__main__':
    main()


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

using namespace std;

struct w{
	int num;
	bool flag;
};

int q_sort(w d[],int left,int right){
	if(left >= right) return 0;
	int l = left, r = right;
	w pipot = d[(left+right)/2];
	w tmp;
	while(l<r){
		while(d[l].num < pipot.num) l++;
		while(d[r].num > pipot.num) r--;
		if( l <=  r){
			tmp = d[l];
			d[l] = d[r];
			d[r] = tmp;
			l++;
			r--;
		}
	}
	q_sort(d,left,r);
	q_sort(d,l,right);
}

int main(void)
{
	int n; cin>>n;
	w k[n]; 
	for(int i = 0; i < n; i++){
		int a;
		cin>>a;
		k[i].num = a;
		if(i%2 == 0) k[i].flag = false;
		else k[i].flag = true;
	}
	
	q_sort(k,0,n-1);
	
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(i%2 == 0 && k[i].flag == true) ans++;
	}
	
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 1152
import java.util.Scanner;
 
public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            if(m == -1 && f == -1 && r == -1) break;
            if(m == -1 || f == -1) { System.out.println('F'); continue; }
            if(m + f >= 80) { System.out.println('A'); continue; }
                if(m + f >= 65) { System.out.println('B'); continue; }
                if(m + f >= 50) { System.out.println('C'); continue; }
            if(m + f >= 30) {
                    if(r >= 50) System.out.println('C');
                else System.out.println('D');
                continue;
            }
            System.out.println('F');
             
        }
    }
}


Measured memory_bytes: 26316
from operator import itemgetter
import bisect
N, D, A = map(int, input().split())
enemies = sorted([list(map(int, input().split())) for i in range(N)], key=itemgetter(0))
d_enemy = [enemy[0] for enemy in enemies]
b_left = bisect.bisect_left
logs = []
logs_S = [0, ]
ans = 0
for i, enemy in enumerate(enemies):
    X, hp = enemy

    start_i = b_left(logs, X-2*D)
    count = logs_S[-1] - logs_S[start_i]

    hp -= count * A
    if hp > 0:
        attack_num = (hp + A-1) // A
        logs.append(X)
        logs_S.append(logs_S[-1]+attack_num)
        ans += attack_num
print(ans)






Measured memory_bytes: 113880
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
int n;
int a[300010];
int num[100010]; 
int mx;
int ans;
int ans2;
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		num[a[i]]++;
		if(num[a[i]]==1)ans++;
		mx=max(a[i],mx);
	}
	for(int i=0;i<=mx;i++){
		if(num[i]!=0 && num[i]%2==0){
			ans2++;
		}
	}
	cout<<ans-ans2%2<<endl;
    return 0; 
}

Measured memory_bytes: 1024
#include <iostream>
#include <set>
#include <vector>

using namespace std;

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

set< vector<int> > prev;
vector< vector<int> > cur, next; 
int x[8], y[8], u[100], v[100], n, k, X, Y, ans;

int abs(int x){return x>0?x:-x;}

void move(int step, int pos){
	if(ans != 20) return;
	if(pos >= n) {
		for(int i=0;i<n;i++)
			for(int j=i+2;j<n;j++)
				for(int k=0;k<6;k++)
					if(x[i]+dx[k]==x[j]&&y[i]+dy[k]==y[j]) return;
		vector<int> v;
		for(int i=0;i<n;i++) v.push_back(x[i]), v.push_back(y[i]);
		if(x[0]==X&&y[0]==Y) ans = step;
		if(!prev.count(v)){
			prev.insert(v);
			next.push_back(v);
		}
		return;
	}
	int px = x[pos], py = y[pos];
	for(int i=0;i<6;i++){
		int nx = x[pos]+dx[i], ny = y[pos]+dy[i];
		bool check = false, flagF = false, flagB = false;
		if(pos == 0 && step+max(abs(X-nx),abs(Y-ny)) > 19) continue;
		if(pos == 1 && step+max(abs(X-x[0]),abs(Y-y[0]))+abs(max(abs(X-nx),abs(Y-ny))-1) > 19) continue;
		for(int j=0;j<min(pos+1,n);j++){
			if(j==pos) continue;
			if(x[j]==nx&&y[j]==ny) check = true;
		}
		if(check) continue;
		if(pos>0){
			for(int k=0;k<6;k++)
				if(x[pos-1]+dx[k] == nx && y[pos-1]+dy[k] == ny) flagF = true;
			if(!flagF) continue;
		}
		if(pos<n-1){
			for(int k=0;k<6;k++)
				if(x[pos+1]+dx[k] == nx && y[pos+1]+dy[k] == ny) flagB = true;
			if(!flagB) continue;
		}
		for(int j=0;j<k&&!check;j++)
			if(u[j] == nx && v[j] == ny) check = true;
		if(check) continue;

		x[pos] = nx, y[pos] = ny;
		move(step, pos+2);
		x[pos] = px, y[pos] = py;
	}
	move(step, pos+1);
}

int main(){
	set< vector<int> >::iterator it;
	while(cin >> n, n){
		for(int i=0;i<n;i++) cin >> x[i] >> y[i];
		cin >> k;
		for(int i=0;i<k;i++) cin >> u[i] >> v[i];
		cin >> X >> Y;
		ans = 20;
		vector<int> v;
		for(int i=0;i<n;i++) v.push_back(x[i]), v.push_back(y[i]);
		prev.clear();   cur.clear();
		prev.insert(v); cur.push_back(v);
		for(int i=1;ans==20&&i<=19;i++){
			next.clear();
			for(int k=0;k<cur.size();k++){
				for(int j=0;j<n;j++) x[j] = cur[k][2*j], y[j] = cur[k][2*j+1];
				move(i, 0);
			}
			cur = next;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 5560
import java.util.ArrayList

fun main(args: Array<String>) {
    val A = readLine()!!.toInt()
    val B = readLine()!!.toInt()
    var n = ArrayList<Int>()
    n.add(1);n.add(2);n.add(3)
    n.remove(A)
    n.remove(B)
    for(i in n){
        println(i)
    }
}

Measured memory_bytes: 29852
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

void solve() {
    string s;
    cin >> s;
    ll n = (ll)s.size();
    vector<ll> cnt(26);
    for (char c : s) {
        cnt.at(c-'a')++;
    }
    ll res = n * (n-1) / 2 + 1;
    for (int i=0; i<26; i++) {
        res -= cnt.at(i) * (cnt.at(i) - 1) / 2;
    }
    cout << res << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

int c[10][10], r[200][200];

int main() {
    int H, W, t = 0, i, j, k;
    scanf("%d %d", &H, &W);
    for (i = 0; i < 10; ++i) for (j = 0; j < 10; ++j) scanf("%d", &c[i][j]);
    for (i = 0; i < 10; ++i) c[i][i] = 0;
    for (k = 0; k < 10; ++k) for (i = 0; i < 10; ++i) for (j = 0; j < 10; ++j) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    for (i = 0; i < H; ++i) for (j = 0; j < W; ++j) scanf("%d", &k), t += (k > -1 ? c[k][1] : 0);
    printf("%d\n", t);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <bits/stdc++.h>
static const int MAX = 100000;

struct bc
{
  long b, c;
  bc(long inputted_b, long inputted_c)
  {
    b = inputted_b;
    c = inputted_c;
  }
};

bool cmp(const bc &x, const bc &y)
{
  return x.c > y.c;
}

int main()
{
  int n, m;
  long a[MAX], b, c;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++)
  {
    scanf("%ld", &a[i]);
  }
  std::sort(a, a + n);

  std::vector<bc> change;
  for (int i = 0; i < m; i++)
  {
    scanf("%ld %ld", &b, &c);
    change.push_back(bc(b, c));
  }
  std::sort(change.begin(), change.end(), cmp);

  int count = 0;
  for (int i = 0; i < change.size(); ++i)
  {
    for (int j = 0; j < change[i].b; j++)
    {
      if (a[count] < change[i].c)
      {
        a[count] = change[i].c;
      }
      else
      {
        i = change.size();
        break;
      }
      count++;
    }
  }
  long sum;
  for (int i = 0; i < n; i++)
  {
    sum += a[i];
  }
  printf("%ld\n", sum);
  return 0;
}

Measured memory_bytes: 3188
a,b,c,d=map(int,input().split())

acount=0
ccount=0

while 0<a:
    acount+=1
    a-=d


while 0<c:
    ccount+=1
    c-=b

#print(acount,ccount)

if acount<ccount:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9184
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

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

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a, bool g){
	if(g){
		if(a[index]<key){
			return true;
		}
	}
	else{
		if(a[index]>key){
			return true;
		}
	}
	return false;
}

ll bin_search(ll key, vector<ll> &a, bool g){
	
	ll l=-1;
	ll r=a.size();

	if(g){
		l=a.size();
		r=-1;
	}

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a, g)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

ll ans=0;
ll n,m;

//深さ優先探索
void dfs(vector<vector<ll>> &gra, ll v, vector<ll> seen){

	seen.push_back(v);

	if(seen.size()==n){
		ans++;
		return;
	}

	for(auto next: gra[v]){
		bool flag=false;
		for(auto i : seen){
			if(next==i){
				flag=true;
			}
		}
		if(flag){
			continue;
		}
		dfs(gra,next,seen);
	}
}


void solve(){
	
	cin>>n>>m;

	vector<vector<ll>> gra(n);
	for(ll j=0;j<m;j++){
		ll a,b;
		cin>>a>>b;
		a--;
		b--;

		gra[a].push_back(b);
		gra[b].push_back(a);
	}

	vector<ll> seen;

	dfs(gra,0,seen);

	cout<<ans<<endl;
	
}

int main(){
	
	solve();
	
    return 0;
}


Measured memory_bytes: 256
#define taskname ""

#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;
#define long long long

const int N = 3e3 + 10;
const int MOD = 1e9 + 7;

int n, f[N][N], sum[N];
char s[N];

int main()
{
//    freopen(taskname".INP", "r", stdin);
//    freopen(taskname".OUT", "w", stdout);
    cin.tie(nullptr); ios_base::sync_with_stdio(false);

    cin >> n >> s + 1;
    for (int i = 1; i <= n; ++i) f[1][i] = 1, sum[i] = i;
    for (int i = 2; i <= n; ++i) {
        if (s[i - 1] == '<') {
            for (int id = 2; id <= n - i + 2; ++id)
//                for (int j = id - 1; j > 0; --j)
//                    f[i][id - 1] = (f[i][id - 1] + f[i - 1][j]) % MOD;
                f[i][id - 1] = sum[id - 1];
        }

        if (s[i - 1] == '>') {
            for (int id = 1; id < n - i + 2; ++id)
//              for (int j = id + 1; j <= n - i + 2; ++j)
//                  f[i][id] = (f[i][id] + f[i - 1][j]) % MOD;
                f[i][id] = (sum[n - i + 2] - sum[id] + MOD) % MOD;
        }

        for (int id = 1; id <= n - i + 1; ++id) sum[id] = (sum[id - 1] + f[i][id]) % MOD;
    }

    cout << f[n][1];

    return 0;
}


Measured memory_bytes: 35200
import math
a, b, x = map(int, input().split())
if 2*x/(a**2)-b <= 0:
    y = a*b**2/(2*x)
    ans = math.degrees(math.atan(y))
else:
    y = (2*a**2*b-2*x)/(a**3)
    ans = math.degrees(math.atan(y))
print(ans)

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll A, B;
  char op;
  cin >> A >> op >> B;

  if(op == '+'){
    cout << A + B << endl;
  }else{
    cout << A - B << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(cont) cont.begin(), cont.end()
#define pb push_back
#define fi first
#define se second
#define DEBUG(x) cerr << (#x) << ": " << (x) << '\n'
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
 
template<class T> bool uin(T &a, T b) {return (a < b ? false : (a = b, true));}
template<class T> bool uax(T &a, T b) {return (a > b ? false : (a = b, true));}
 
//~ ifstream f(".in");
//~ ofstream g(".out");
 
const int NMAX = 1e4 + 5;
const int MOD = 1e9 + 7;
 
int n, d;
char k[NMAX];

int main() {    
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL_DEFINE
  freopen(".in", "r", stdin);
#endif
 
  cin.getline(k + 1, NMAX);
  cin >> d; 
 
  n = strlen(k + 1);
  
  vector<vector<int>> dp(d, vector<int>(2));
  // dp[sum][0] = if no smaller digit so far and sum of digits % d == sum
  // dp[sum][1] = if already smaller and sum of digits % d == sum
  dp[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    vector<vector<int>> new_dp(d, vector<int>(2));
    for (int sum = 0; sum < d; ++sum) {
      for (int j : {0, 1}) {
        for (int dig = 0; dig < 10; ++dig) {
          if (j == 0 && dig > k[i] - '0') {
            break;
          }
          if (j == 0 && dig == k[i] - '0') {
            (new_dp[(sum + dig) % d][0] += dp[sum][j]) %= MOD;
          } else {
            (new_dp[(sum + dig) % d][1] += dp[sum][j]) %= MOD;
          }
        }
      }
    }
    dp = new_dp;
  }
  
  cout << ((dp[0][0] + dp[0][1]) % MOD + MOD - 1) % MOD << '\n';
 
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


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

ll MOD = 1000000007;

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<ll>> com(W, vector<ll>(W));
  for (int bit = 0; bit < (1 << (W - 1)); bit++) {
    int prev = 0;
    bool valid = true;
    for (int i = 0; i < W - 1; i++) {
      if (prev == 1 && ((bit >> i) & 1)) valid = false;
      prev = ((bit >> i) & 1);
    }
    if (!valid) continue;

    for (int i = 0; i < W; i++) {
      int left = ((bit >> (i - 1)) & 1) ? i > 0 : 0;
      int right = ((bit >> i) & 1) ? i < W - 1 : 0;
      if (left == 0 && right == 0) com[i][i]++;
      if (left == 0 && right == 1) com[i][i + 1]++, com[i + 1][i]++;
      // if (left == 1 && right == 0) com[i][i - 1]++, com[i - 1][i]++;
    }
  }

  vector<vector<ll>> dp(H + 1, vector<ll>(W, 0));
  dp[0][0] = 1;
  for (int h = 1; h <= H; h++) {
    for (int w = 0; w < W; w++) {
      if (w < W - 1) {
        dp[h][w] += (dp[h - 1][w + 1] * com[w][w + 1]) % MOD;
      }
      if (w > 0) {
        dp[h][w] += (dp[h - 1][w - 1] * com[w][w - 1]) % MOD;
      }
      dp[h][w] += (dp[h - 1][w] * com[w][w]) % MOD;
      dp[h][w] %= MOD;
    }
  }
  cout << dp[H][K - 1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<P,int>P2;
#define fi first
#define se second
 
 
void END(){
  cout<<":("<<endl;
  exit(0);
}
 
signed main(){
  int n;
  cin>>n;
  int a[n];
  vector<P>ve;
  r(i,n){
    cin>>a[i];
    ve.push_back(P(a[i],i+1));
  }
 
  sort(ve.begin(),ve.end());
 
  r(i,n){
    a[i]=ve[i].second;
  }
 
  stack<P>st1;
  stack<P>st2;
 
  int del=1;
 
  string s;
 
  r(i,n){
 
    s+="(";
 
    ///st1.push(P(a[i],i+1));
    st2.push(P(a[i],i+1));
 
    while(!st2.empty()){
      if(st2.top().first!=del)break;
      s+=")";
      st2.pop();
      del++;
    }
 
    //cout<<st1.size()<<' '<<st2.size()<<endl;
  }
 
  if(!st1.empty()) END();
  if(!st2.empty()) END();
 
  cout<<s<<endl;
 
}


Measured memory_bytes: 6892
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double x = sc.nextDouble();
        int year = 0;
        double money = 100;
        sc.close();
        while(true){
            money = Math.floor(money * 1.01);
            year++;
            if(x <= money){
                System.out.println(year);
                return;
            }
        }
    }
}

Measured memory_bytes: 37412
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main(){
    string s;
    cin >> s;
    ll n=s.length();
    ll cnt=0;
    ll len=n;
    ll left=0;
    ll ans=0;
    rep(i,n){
        if(s[i]=='0' && cnt%2==0){
            continue;
        }
        if(s[i]=='1' && cnt%2==1){
            continue;
        }
        else{
            ans=max(ans,min(i,len));
            len=n-i;
            cnt++;
        }
    }
    ans=max(ans,min(n,len));
    cout << ans << endl;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;


int main() {
int a, b, c, k;
 cin >> a >> b >> c >> k;
 if(k <= a) cout << k << endl;
 else if(k <= a + b) cout << a << endl;
 else cout << a - (k - a - b) << endl;
 return 0;
}

Measured memory_bytes: 3596
n=int(input())
a=list(map(int,input().split()))
a.sort()
mod=10**9+7
if n%2==0:
  for i in range(n):
    if a[i]!=(i//2)*2+1:
      print(0)
      exit()
  print(pow(2,n//2,mod))
else:
  for i in range(n):
    if a[i]!=((i+1)//2)*2:
      print(0)
      exit()
  print(pow(2,n//2,mod))


Measured memory_bytes: 13880
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N;
    string A, B, C;
    cin >> N >> A >> B >> C;
    int ans = 0;
    rep(i, N) {
        set<char> S = {A[i], B[i], C[i]};
        ans += S.size() - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ll                  long long int
#define ull                 unsigned long long int
#define ld                  long double
#define fi                  first
#define se                  second
#define pb                  push_back
#define pbb                 pop_back
#define mp                  make_pair
#define pii     	        pair<int,int>
#define all(x)              x.begin(), x.end()
#define uniq(x)             x.erase(unique(x.begin(),x.end()),x.end())
#define mem(array, value)   memset(array, value, sizeof(array))
#define lcm(a,b)            (abs(a)/gcd(a,b))*abs(b)
#define PI      	        2*acos(0.0)
#define INF     	        1e9
#define EPS     	        1e-8
#define line                cout << "\n==========\n"
#define fastRead 	        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet; 

const int N = 1e5+9;
int ara[N];
int dp[N];

int main ()
{
    #ifdef Lollipop
    //freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
    #endif
    
    int n, k;
    cin >> n >> k;
    for (int i = 0; i<n; i++){
        cin >> ara[i];
    }
    dp[0] = 0;
    dp[1] = abs(ara[0] - ara[1]);
    for (int i = 2; i<n; i++){
        int temp = dp[i-1] + abs(ara[i-1] - ara[i]);
        for (int j = i-2, l = 1; j>= 0 && l < k; j--, l++){
            temp = min(temp, dp[j] + abs(ara[j] - ara[i]));
        }
        dp[i] = temp;
    }
    cout << dp[n-1] << endl;
    return 0;
}



Measured memory_bytes: 1024
import sys
import math
input = sys.stdin.readline
 
N = int(input())
a = int(math.sqrt(N))
 
A = 0
B = 0
for i in reversed(range(1, a + 1)):
  if not N % i:
    A = i
    B = N // A
    break
 
print(max(len(str(A)), len(str(B))))

Measured memory_bytes: 3060
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >>=  putStrLn . which "Yes" "No" . ( == [ 2, 2 ] ) . map length . group . sort

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef vector<pi> vp;

#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define INF 1e9
#define modulo 1000000007
#define forn(i, n) for(int i = 0; i < (n); i++)
#define FAST ios::sync_with_stdio(false); cin.tie(NULL);
#define end1 "\n" 
#define print(x) cout << x << end1



int main(){ 
FAST;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif

int n; cin >> n;
ll ans = 0;
for(int i = 0; i <= n; i++){
    if(i%3 != 0 && i%5 != 0) ans += i;
}
cout << ans;

}

Measured memory_bytes: 3652
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var A = [intShift(),intShift(),intShift(),intShift(),intShift()];
  var o = [];
  for(var i = 0 ; i < 3125 ; i++){
  	var a = i.toString(5);
    while(a.length!=5)a="0"+a;
    if(a.indexOf("0")==-1)continue;
    if(a.indexOf("1")==-1)continue;
    if(a.indexOf("2")==-1)continue;
    if(a.indexOf("3")==-1)continue;
    if(a.indexOf("4")==-1)continue;
    a = a.split(NOSP).map(a=>~~a);
    var sum = 0;
    for(var j = 0; j < 5; j++){
    	sum += A[a[j]];
    	if(sum % 10 && j < 4)sum = sum + 10 - (sum % 10);
    }
    o.push(sum);
  }
  return ~~Math.min(...o);
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
123
123
123
123
123
`);

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
int n,w;
const int N = 1e5 + 5;
int weights[N];
int benefit[N];
long long mem[100][N];
void init() {
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < N; j++) {
            mem[i][j] = -1;
        }
    }
}
long long maxBenefit(int i , int r) {
   if (i < 0 || r < 0)
    return 0;
   if (mem[i][r] != -1)
    return mem[i][r];
   if (weights[i] > r)
        return maxBenefit(i - 1 , r);
    else {
        return mem[i][r] = max(maxBenefit(i-1 , r - weights[i]) + benefit[i] , maxBenefit(i - 1 , r));
    }
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> w;
    for (int i = 0; i < n; i++) {
        cin >> weights[i] >> benefit[i];
    }
    init();
    cout << maxBenefit(n - 1 , w) << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define IREP(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define IMAX INT_MAX
#define IMIN INT_MIN
#define LMAX LLONG_MAX
#define LMIN LLONG_MIN
template<typename T> inline void chmin(T &a, T b){ if(a > b) a = b; }
template<typename T> inline void chmax(T &a, T b){ if(a < b) a = b; }
template<typename T> inline void xch(T &a, T &b){ T w = a; a = b; b = w; }



int main() {
    int X;
    cin >> X;
    int LEN = (int)1e6 + 1;
    bool p[LEN];
    REP(i, LEN){
        p[i] = true;
    }
    p[0] = false; p[1] = false;
    for(int i = 2; i * i < LEN; i++){
        if(p[i]){
            for(int j = i * 2; j < LEN; j += i){
                p[j] = false;
            }
        }
    }
    for(int i = X; i < LEN; i++){
        if(p[i]){
            cout << i << endl;
            return 0;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 1280
/* ****Shrey97**** */

#include <bits/stdc++.h>

#define hell 1000000007
#define N 100005

using namespace std;


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n;
    cin >> n;
    long long a[n], b[n], c[n];
    long long ans=  0;
    for(long long i=0;i<n;i++)
    {
        cin >> a[i];
    }   
    for(long long i=0;i<n;i++)
    {
        cin >> b[i];
        ans += b[i];
    }
    for(long long i=0;i<n-1;i++){
        cin >> c[i];
    }
    for(long long i=0;i<n-1;i++)
    {
        if(a[i]+1==a[i+1])
        {
            ans += c[a[i]-1];
        }
    }
    cout << ans;
    return 0;
}

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

namespace AC {
#define ll long long
#define PLL pair<ll, ll>
#define PDD pair<double, double>
#define PDPLL pair<double, PLL>
#define PLPLL pair<ll, PLL>
#define pb push_back
#define fi first
#define se second
#define ls rt << 1
#define rs rt << 1 | 1

    const ll N = 2e5 + 66;

    ll BUGS = 1;

    inline ll read(){
        ll x = 0;    bool flag = 1;   char ch = getchar();
        while(ch < '0' || ch > '9') { if(ch == '-') flag = 0; ch = getchar(); }
        while(ch >= '0' && ch <= '9') { x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); }
        if(flag) return x;  return (~(x - 1));
    }

    inline void read(ll arr[], ll s, ll e) { for(ll i = s; i <= e; ++i) arr[i] = read(); }

    inline void write(ll x){
        if(x < 0) { x = ~(x - 1); putchar('-'); }
        if(x > 9) write(x / 10); putchar(x % 10 + '0');
    }

    inline void print(ll x) { write(x); puts(""); }

    inline void print(ll arr[], ll s, ll e) {
        for(ll i = s; i <= e - 1; ++i) write(arr[i]), putchar(' ');
        write(arr[e]); puts("");
    }

    inline ll max3(ll a, ll b, ll c) { return max(a, max(b, c)); }

    inline ll min3(ll a, ll b, ll c) { return min(a, min(b, c)); }

    inline void debugNum(ll num, string ss) { cout << "BUGS" << BUGS++ << " : " << ss << " : " << num << endl; }

    inline void debugArr(ll arr[], ll s, ll e, string ss) {
        cout << "BUGS" << BUGS++ << " : " << ss << " : " << endl;
        for(ll i = s; i <= e; ++i) cout << "i : " << i << " val : " << arr[i] << endl;
    }

    inline void IO() {
        //ios::sync_with_stdio(false), cout.tie(0), cin.tie(0);
        //cout << setiosflags(ios::fixed) << setprecision(1); //保留小数点后1位
        //cout << setprecision(1); //保留1位有效数字
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    }
}using namespace AC;

ll n, k, arr[N];

int main() {
    //IO();
    while(~scanf("%lld", &n)) {
        k = read(), read(arr, 1, n);
        for(ll i = 1; i <= n; ++i) {
            ll j = i + k;
            if(j > n) break;
            if(arr[j] > arr[i]) puts("Yes");
            else puts("No");
        }
    }
    return 0;
}



Measured memory_bytes: 5316
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <cmath>

#define MY_PI 3.14159265358979323846

#define pb push_back
     
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
     
bool debug = false;
     

struct state
{
    ll a,b,c;

    state(ll a, ll b, ll c) : a(a), b(b), c(c)
    {

    }

  bool operator==(const state &other) const
  { return (a == other.a
            && b == other.b
            && c == other.c);
  }
};


struct KeyHasher
{
    size_t operator()(const state& k) const
  {
    //using std::size_t;
    //using std::hash;
    //using std::string;

    return ((hash<ll>()(k.a)
               ^ (hash<ll>()(k.b) << 1)) >> 1)
               ^ (hash<ll>()(k.c) << 1);
  }
};  

vector<ll> graph[100005];

void bfs(int i, vector<bool> &visited, vector<ll> &parent)
{
    queue<ll> q;
    visited[i] = true;
    parent[i] = i;

    q.push(i);

    while(!q.empty())
    {
        int node = q.front();
        q.pop();
        for (auto x : graph[node])
        {
            if (!visited[x])
            {
                visited[x] = true;
                //cout << "parent of " << x << " is " << node << endl;
                parent[x] = node;
                q.push(x);
            }
        }
    }
}

void solve()
{
    ll n,m;
    cin >> n >> m;

    vector<bool> visited(n+1, false);
    vector<ll> parent(n+1, -1);

    for (int i = 0; i < m; i++)
    {
        ll a,b;
        cin >> a >> b;
        graph[a].pb(b);
        graph[b].pb(a);
    }

    //
    for (int i = 1; i <= n; i++)
    {
        if (!visited[i])
        {
            if (i != 1)
            {
                cout << "No" << endl;
                return;
            }

            bfs(i, visited, parent);
        }
    }

    cout << "Yes" << endl;
    for (int i = 2; i <= n; i++)
    {
        cout << parent[i] << endl;
    }

}

int main()
{
    // $ g++ -std=c++14 -Wshadow -Wall -o c C.cpp

    // !!! Here, unordered map was too slow!!!
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);

    solve();
    

    return 0;
}

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

#ifdef DEBUG
    #include "debug.h"
    #define DEB
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define DEB if (false)
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//////////////////

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)



void solve(){
    string s;
    cin >> s;
    int N = s.size();


    for(int i=0; i<s.size(); i++){
        if(s[i]=='?'){
            s[i]='D';
        }
    }
    cout << s << endl;
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 3760
N,M=map(int,input().split())

S=[]
C=[]

for i in range(M):
    s,c=map(int,input().split())
    S.append(s-1)
    C.append(c)

for n in range(1000):
    ns=str(n)
    nl=list(ns)
    if len(ns)!=N:
        continue
    f=True
    for m in range(M):
        if nl[int(S[m])]!=str(C[m]):
            f=False
            break
    if f==True:
        print(n)
        exit()
print(-1)





Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int A,B,Q;
int a[100005],b[100005];
pair<int,int>binary_searchA(int x){
	int l=-1,r=A;
	while(r-l>1){
		int mid=l+r>>1;
		if(a[mid]<x)l=mid;
		else r=mid;
	}
	if(l==-1)return make_pair(-1e18,a[0]);
	return make_pair(a[l],a[r]);
}
pair<int,int>binary_searchB(int x){
	int l=-1,r=B;
	while(r-l>1){
		int mid=l+r>>1;
		if(b[mid]<x)l=mid;
		else r=mid;
	}
	if(l==-1)return make_pair(-1e18,b[0]);
	return make_pair(b[l],b[r]);
}
signed main(){
	cin>>A>>B>>Q;
	for(int i=0;i<A;i++)cin>>a[i];
	for(int i=0;i<B;i++)cin>>b[i];
	sort(a,a+A);a[A]=1e18;
	sort(b,b+B);b[B]=1e18;
	while(Q--){
		int x;cin>>x;
		int la,ra,lb,rb;
		tie(la,ra)=binary_searchA(x),tie(lb,rb)=binary_searchB(x);
		int ans=1e18;
		//(la,lb)
		ans=min(ans,x-min(la,lb));
		//(ra,rb)
		ans=min(ans,max(ra,rb)-x);
		//(la,rb)
		ans=min(ans,min(rb-x,x-la)+rb-la);
		//(lb,ra)
		ans=min(ans,min(ra-x,x-lb)+ra-lb);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define endl "\n"
#define PI acos(-1)
#define BMW_GTR ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef long long ll;
using namespace std;

//ll const n = 50005;

ll fact(ll N)
{
    ll ans = 1;
    for(int i = 1; i <= N; i++)
    {
        ans *= i;
    }

    return ans;
}

int main()
{
    BMW_GTR;

    int N;
    cin >> N;

    vector<pair<long double, long double>> arr;
    long double ans = 0.00;

    for(int i = 0; i < N; i++)
    {
        long double x, y;
        cin >> x >> y;

        arr.push_back(make_pair(x, y));
    }

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

    do
    {
        for(int i = 0; i < N - 1; i++)
            {
                ans += sqrt((arr[i].first - arr[i + 1].first) * (arr[i].first - arr[i + 1].first) + (arr[i].second - arr[i + 1].second) * (arr[i].second - arr[i + 1].second));
            }
    }while(next_permutation(arr.begin(), arr.end()));

    cout << fixed << setprecision(10) << ans / (fact(N) * 1.00);

    return 0;
}


Measured memory_bytes: 3804
package main

import "fmt"

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_D&lang=jp>
 */

func init() {
}

func main() {
	var n int
	fmt.Scanf("%d",&n)
	for i:= 1; i <= n;i++{
		x := i
		if i%3 == 0{
			fmt.Printf(" %d",i)
			continue
		}
		for x > 0 {
			if x%10==3 {
				fmt.Printf(" %d", i)
				break
			}
			x/=10
		}
	}
	fmt.Println("")
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair 
#define f(i,n) for(int i=0;i<n;i++) 
#define F first 
#define S second 
#define pb push_back 

using namespace std;

void test(){
	ll n;
	cin>>n;
	ll a[n];
	f(i,n)cin>>a[i];
	ll x = 0;
	ll p = a[0];
	f(i,n){
		p = max(p,a[i]);
		x = x + (p-a[i]);
	}
	cout<<x<<"\n";
}

int main(){
	int tests=1;
	// cin>>tests;
	while(tests--){
		test();
	}
}


Measured memory_bytes: 5196