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

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

    int Q;
    cin >> Q;

    bool reversed = false;
    deque<char> D;
    for (int i = 0; i < S.size(); i++) {
        D.push_back(S[i]);
    }

    while (Q--) {
        int q;
        cin >> q;

        if (q == 1) {
            reversed = !reversed;
        } else if (q == 2) {
            int F;
            char C;
            cin >> F >> C;

            if ((F == 1 && !reversed) || (F == 2 && reversed)) {
                D.push_front(C);
            } else {
                D.push_back(C);
            }
        }
    }

    for (int i = 0; i < D.size(); i++) {
        if (reversed) {
            cout << D[D.size() - i - 1];
        } else {
            cout << D[i];
        }
    }

    cout << "\n";
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PRINT(s) cout << s << endl;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR((i), 0, (n))

int main() {
    int x, n;
    cin >> x >> n;
    if (n == 0) {
        PRINT(x);
        return 0;
    }
    vector<int> p(n);
    REP(i, n) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int nearIndex = 0;
    REP(i, p.size()) {
        if (p[i] == x || p[i] > x) {
            nearIndex = i; 
            break;
        }
    }
    int counter = 0;
    
    while(true) {
        int lowerIndex = nearIndex - counter;
        int upperIndex = nearIndex + counter;
        int lowerX = x - counter;
        int upperX = x + counter;

        if (lowerIndex > -1 &&
            p[lowerIndex] != lowerX) {
            PRINT(lowerX);
            break;
        }
        if (lowerIndex < 0) {
            PRINT(lowerX);
            break;
        }
        if (upperIndex < p.size() &&
            p[upperIndex] != upperX) {
            PRINT(upperX);
            break;
        }
        if (upperIndex >= p.size()) {
            PRINT(upperX);
            break;
        }       
        counter++;
        
    }
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

#define INF 1 << 10

int f(int n, int low, int up) {
	return n < low ? 0 : n > up ? up - low : n - low;
}

int main() {
	int w;
	while (cin >> w, w != -1) {
		int price =
			  1150
			+ f(w, 10, 20) * 125
			+ f(w, 20, 30) * 140
			+ f(w, 30, INF) * 160
			;
		cout << (4280 - price) << endl;
	}
}

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


  int a;cin>>a;
  if(a==25){
    puts("Christmas");
  }else if (a == 24){
    puts("Christmas Eve");
  }else if (a == 23){
    puts("Christmas Eve Eve");
  }else if (a == 22){
        puts("Christmas Eve Eve Eve");

  }

  return 0;
}


Measured memory_bytes: 3568
#include <iostream>

using namespace std;

int main()
{
    string S;
    cin >> S;
    if(S=="SUN")
        cout << 7;
    else if(S=="MON")
        cout << 6;
    else if(S=="TUE")
        cout << 5;
    else if(S=="WED")
        cout << 4;
    else if(S=="THU")
        cout << 3;
    else if(S=="FRI")
        cout << 2;
    else
        cout << 1;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,k;
vi a;

int main(){
	cin>>n>>k;
	a=vi(n);
	for(auto &i:a) cin>>i;
	sort(a.begin(),a.end());
	int t=0;
	for(int i=0;i<k;i++) t+=a[i];
	cout<<t<<endl;
}

Measured memory_bytes: 3644
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int S = Integer.parseInt(sc.next());
    int W = Integer.parseInt(sc.next());
    if(S<=W){      
    System.out.println("unsafe");
    return;
    }else{
      System.out.println("safe");
      return;  
    }

  }
}



Measured memory_bytes: 35704
#include <iostream>
#include <string>

using namespace std;

int main() {
    int N, X;
    int L[100];

    cin >> N >> X;
    for (int i = 0; i < N; ++i) cin >> L[i];

    int sum, i, count;
    while (sum <= X) {
        count++;
        sum += L[i];
        i++;
        if (count == N+1) {
            break;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def abc158d(s_init, n, query):
    head = ""
    tail = ""
    reverse = 0
    for i in range(n):
        tgt = query[i]
        if tgt[0] == "1":
            reverse = (reverse + 1) % 2
        elif tgt[0] == "2":
            if tgt[1] == "1":
                if reverse == 0:
                    head += tgt[2]
                else:
                    tail += tgt[2]
            elif tgt[1] == "2":
                if reverse == 0:
                    tail += tgt[2]
                else:
                    head += tgt[2]
            else:
                print("invalid query!!:" + str(tgt[0]) + str(tgt[1]))
        else:
            print("invalid query!!:" + str(tgt[0]))
    if reverse == 0:
        return head[::-1] + s_init + tail
    else:
        return tail[::-1] + s_init[::-1] + head

###
# main
if(__name__ == '__main__'):
    # input
    s_init = input()
    n = int(input())
    query = []
    for i in range(n):
        query.append(input().split(" "))
    
    accomplishment = abc158d(s_init, n, query)
    
    # output
    print(accomplishment)
# else:
    # do nothing


Measured memory_bytes: 40272
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int n;
  cin >> n;
  map<string,int> m;
  REP(i,n) {
    string s;
    cin >> s;
    m[s]++;
  }
  cout << "AC x " << m["AC"] << endl;
  cout << "WA x " << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x " << m["RE"] << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
signed gcd(long long x, long long y) {if (y == 0)return x;long long z=gcd(y, x % y);return z;}
int main(){
  long long a,b,c,d; cin>>a>>b>>c>>d;
  cout<<b-a+1-(b/c-(a-1)/c+b/d-(a-1)/d-b/(c/gcd(c,d)*d)+(a-1)/(c/gcd(c,d)*d))<<endl;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int ans = 1;
    int total = a;
    if(b == 1){
        cout << 0 << endl;
        return 0;
    }
    while(total < b){
        total -= 1;
        total += a;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#define ll long long
#define INF 0x7f7f7f7f
const double E=exp(1);
const int maxn=1e6+10;
const int mod=1e9+7;
using namespace std;
int a[maxn];
int vis[maxn];
bool check(int n){
	while(n){
		if (vis[n%10]) return false;
		n/=10;
	}
	return true;
}
int n,k,x;
int main(){
	cin>>n>>k;
	for (int i=0; i<k; i++){
		cin>>x;
		vis[x]=1;
	}
	for (int i=n; ; i++)
		if(check(i)){
			cout<<i<<endl;
			return 0;
		}
	return 0;
}

Measured memory_bytes: 3164
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

int h, w;
char a[1010][1010];
int dp[1010][1010];

int main() {
    cin >> h >> w;
    rep(i, h) rep(j, w) {
        cin >> a[i][j];
    }
    dp[1][1] = 1;
    rep(i, h) rep(j, w) {
        if (i == 0 && j == 0) continue;
        if (a[i][j] == '#')
            dp[i+1][j+1] = 0;
        else
            dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % 1000000007;
    }
    cout << dp[h][w] << endl;
    return 0;
}


Measured memory_bytes: 5248
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main(){
  ll n;
  cin>>n;
  vector<ll> v;
  Rep(i,n+1) v.push_back(i);
  vector<vector<ll>> ans;
    do{
      ans.push_back(v);
        
    }while(next_permutation(ALL(v)));
  vector<ll> a(n),b(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  ll ans1,ans2;
  ll tmp=0;
  rep(i,ans.size()){
    if(ans[i]==a){
      break;
    }else{
      tmp++;
    }
  }
  ans1=tmp;
  tmp=0;
  rep(i,ans.size()){
    if(ans[i]==b){
      break;
    }else{
      tmp++;
    }
  }
  ans2=tmp;
  cout<<abs(ans1-ans2)<<endl;
}

Measured memory_bytes: 4404
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a>b)swap(a,b);
	if(b>c)swap(b,c);
	if(a>b)swap(a,b);
	cout<<a<<" "<<b<<" "<<c<<endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<long long> a(n+1);
  for(int i = 0; i <= n; i++){
    cin >> a.at(i);
  }
  
  vector<pair<long long, long long>> floor(n+1);
  for(int i = n; i >= 0; i--){
    long long ma = a.at(i), mi = a.at(i);
    if(i < n) ma += floor.at(i+1).first, mi += (floor.at(i+1).second + 1)/2;
    floor.at(i) = {ma, mi};
  }
  
  long long ans = 0;
  long long next = 1;
  for(long long i = 0; i <= n; i++){
    long long now = a.at(i), ma = floor.at(i).first, mi = floor.at(i).second;
    
    if(mi > next){
      ans = -1;
      break;
    }
    ans += min(next, ma);
    next = (min(next, ma) - now) * 2;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 5572
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.*;
public class Main {
    public static void main(String []args){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver=new Task();
        solver.solve(1,in,out);
        out.close();
    }
    static class Task{
        public void solve(int testnumber,InputReader in,PrintWriter out){
            int n = in.nextInt();
            int k = in.nextInt();
            int [] a = new int[k];
            for(int i=0;i<k;i++){
                a[i]=in.nextInt();
            }
            for(int i=n;i<=10*n;i++){
                if(is_ok(i,a)){
                    out.println(i);
                    break;
                }
            }
        }

        private boolean is_ok(int i,int [] a) {
            while(i != 0){
                int t = i % 10;
                for(int j=0;j<a.length;j++){
                    if(t == a[j]){
                        return false;
                    }
                }
                i /= 10;
            }
            return true;
        }
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


Measured memory_bytes: 21460
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k, tmp int
	fmt.Scan(&n, &k)

	m := make(map[int]int)
	for i := 0; i < n; i++ {
		fmt.Scan(&tmp)
		m[tmp]++
	}

	l := List{}
	for key, val := range m {
		l = append(l, Entry{key, val})
	}
	sort.Sort(l)

	count := 0
	for i := 0; i < len(m)-k; i++ {
		count += l[i].value
	}

	fmt.Println(count)
}

type Entry struct {
	name  int
	value int
}

type List []Entry

func (l List) Len() int {
	return len(l)
}

func (l List) Swap(i, j int) {
	l[i], l[j] = l[j], l[i]
}

func (l List) Less(i, j int) bool {
	if l[i].value == l[j].value {
		return l[i].name < l[j].name
	}
	return l[i].value < l[j].value
}


Measured memory_bytes: 22400
#include<bits/stdc++.h>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0;i < (ll)(n);i++)
#define INF (1e9 + 1)
#define MAXN 100001
#define MAXM 11
int main()
{
    int N;
    unsigned long long int rec = 0,m = 0,a = 0,r = 0,c = 0,h = 0;
    char s[MAXN][MAXM];
    cin >> N;
    REP(i,N){
        cin >> s[i];
    }
    /*REP(i,N - 2){
        if(s[i][0] == 'M' || s[i][0] == 'A' || s[i][0] == 'R' || s[i][0] == 'C' || s[i][0] == 'H'){
            for(int j = i + 1;j < N - 1;j++){
                if(s[j][0] == 'M' || s[j][0] == 'A' || s[j][0] == 'R' || s[j][0] == 'C' || s[j][0] == 'H'){
                    if(s[j][0] != s[i][0]){
                        for(int k = j + 1;k < N;k++){
                            if(s[k][0] == 'M' || s[k][0] == 'A' || s[k][0] == 'R' || s[k][0] == 'C' || s[k][0] == 'H'){
                                if(s[k][0] != s[i][0] && s[k][0] != s[j][0]){
                                    rec++;
                                    //cout << s[i]  << endl << s[j]  << endl << s[k] << endl << endl;
                                }
                            }
                        }
                    }
                }
            }
        }
    }*/
    REP(i,N){
        if(s[i][0] == 'M'){
            m++;
        }
        else if(s[i][0] == 'A'){
            a++;
        }
        else if(s[i][0] == 'R'){
            r++;
        }
        else if(s[i][0] == 'C'){
            c++;
        }
        else if(s[i][0] == 'H'){
            h++;
        }
    }
    rec = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h;

    cout << rec << endl;




    return 0;
}
/*
    REP(i,a){
        REP(j,b){

        }
    }
    */


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define md 1000000007
#define ll long long 
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fastmap mp.reserve(1024);mp.max_load_factor(0.25);
#define fastset st.reserve(1024);st.max_load_factor(0.25);

ll int mpw(ll int a,ll int b,ll int m)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans=(ans*a)%m;
		}
		a=(a*a)%m;
		b>>=1;
	}
	return ans;
}
 
ll int pw(ll int a,ll int b)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans*=a;
		}
		a*=a;
		b>>=1;
	}
	return ans;
}
 
ll int mn(ll int a,ll int b)
{
	if(a<=b)
	{
		return a;
	}
	return b;
}
 
ll int mx(ll int a,ll int b)
{
	if(a>=b)
	{
		return a;
	}
	return b;
}

int main()
{
	fio
	int n;
	cin>>n;
	vector<vector<ll int>>nm(n,vector<ll int>(n,0));
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<n;++j)
		{
			cin>>nm[i][j];
		}
	}
	int mx1=pw(2,n);
	vector<ll int>cst(mx1,0);
	for(int i=1;i<mx1;++i)
	{
		ll int cnt=0;
		int tmp=i;
		int p1=0;
		while(tmp)
		{
			if(tmp&1)
			{
				int p2=0;
				int tmp1=tmp>>1;
				while(tmp1)
				{
					if(tmp1&1)
					{
						cnt=(cnt+nm[p1][p1+p2+1]);
					}
					tmp1>>=1;
					++p2;
				}
			}
			tmp>>=1;
			++p1;
		}
		cst[i]=cnt;
	}
	vector<ll int>D(mx1,0);
	for(int i=1;i<mx1;++i)
	{
		int m=i;
		int s=m;
		while(s>0)
		{
			D[i]=mx(D[i],D[i^s]+cst[s]);
			s=(s-1)&m;
		}
	}
	
	cout<<D[mx1-1]<<"\n";
	return 0;
}

Measured memory_bytes: 4256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

int powmod(int a, int p, int m){
  int res = 1, tmp = a;
  while(p != 0){
    if(p % 2)
      res = (res*tmp) % m;
    tmp = (tmp*tmp) % m;
    p /= 2;
  }
  return res;
}

int fact[2000], invfact[2000];

int invmod(int a, int p){ // a^-1 mod p
  int b = p, u = 1, v = 0;
  while(b){
    int t = a / b;
    a -= t*b; swap(a, b);
    u -= t*v; swap(u, v);
  }
  u %= p;
  if(u < 0) u += p;
  return u;
}

void factmod(int m){
  fact[0] = invfact[0] = 1;
  for(int i = 1; i < 2000; i++){
    fact[i] = (fact[i-1] * i) % m;
    invfact[i] = (invfact[i-1] * invmod(i, m)) % m;
  }
}

int nCrmod(int n, int r, int m){
  return (((fact[n] * invfact[r]) % m) * invfact[n-r]) % m;
}

signed main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  int N, K; cin >> N >> K;
  factmod(MOD);
  int ans = 0;
  for(int emp = 1; emp < K; emp++){
    int num = nCrmod(K, emp, MOD) * powmod(K-emp, N, MOD);
    num %= MOD;
    if(emp & 1){
      ans += num; ans %= MOD;
    } else {
      ans += MOD;
      ans -= num; ans %= MOD;
    }
  }
  ans = powmod(K, N, MOD) + MOD - ans;
  ans %= MOD;
  cout << ans << endl;
}



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

bool ok(string s){
    if(s=="Vacant") return true;
    else return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<string> s(n);
    cout<<0<<endl;
    cin>>s[0];
    if(ok(s[0])) return 0;  
    cout<<n-1<<endl;
    cin>>s[n-1];
    if(ok(s[n-1])) return 0;
    int lb =0,ub=n-1;
    while(ub-lb>1){
        int mid = (ub+lb)/2;
        cout<<mid<<endl;
        cin>>s[mid];
        if(ok(s[mid])) return 0;
        if((mid-lb)%2)s[mid]!=s[lb]? lb = mid:ub = mid; 
        else s[mid]==s[lb]?lb = mid:ub=mid;
    }
    cout << ub << endl;
    cin >> s[ub];
    if(ok(s[ub])) return 0;
    cout << lb << endl;
    cin >> s[lb];
    return 0;
}

Measured memory_bytes: 1620
using System;
using System.Linq;

namespace _0018
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine(WriteAr(ReadIntAr().OrderByDescending(x => x).ToArray()));
        }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 18288
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

int main(int argc, char const *argv[]) {
	int a = 10000;
	int b = 5000;
	int c = 1000;
	int n,y;
	std::cin >> n >> y;
	if (y > n * a || c * n > y) {
		std::cout << "-1 -1 -1" << '\n';
		return 0;
	}

	y = y - c * n;
	for (int i = y / (a-c); i >= 0; i--) {
		int amari = y - i * (a-c);
		if (amari % (b-c) == 0) {
			int ansb = amari / (b-c);
			int ansc = n - i - ansb;
			if (ansc >= 0) {
				std::cout << i << ' ' << ansb << ' ' << ansc << '\n';
				return 0;
			}
		}
	}

	std::cout << "-1 -1 -1" << '\n';
	return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    n = input().strip()
    if len(set(n)) == 1:
        print(n)
    elif int(n) < int(n[0] * 3):
        print(int(n[0] * 3))
    else:
        print(str(int(n[0]) + 1) * 3)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
using System;

class Program
{
	static void Main()
	{
		bool[] A = new bool[52];
		int D = int.Parse(Console.ReadLine());
		for (int i = 0; i < D; i++)
		{
			string[] sD = Console.ReadLine().Split(' ');
			if (sD[0] == "S")
			{
				A[int.Parse(sD[1]) - 1] = true;
			}
			if (sD[0] == "H")
			{
				A[int.Parse(sD[1]) + 12] = true;
			}
			if (sD[0] == "C")
			{
				A[int.Parse(sD[1]) + 25] = true;
			}
			if (sD[0] == "D")
			{
				A[int.Parse(sD[1]) + 38] = true;
			}
		}
		for (int i = 0; i < A.Length; i++)
		{
			if (!A[i])
			{
				if (i < 13)
				{
					Console.WriteLine("{0} {1}", "S", i + 1);
				}
				if (i < 26 && i >= 13)
				{
					Console.WriteLine("{0} {1}", "H", i - 12);
				}
				if (i < 39 && i >= 26)
				{
					Console.WriteLine("{0} {1}", "C", i - 25);
				}
				if (i < 52 && i >= 39)
				{
					Console.WriteLine("{0} {1}", "D", i - 38);
				}
			}
		}
	}
}

Measured memory_bytes: 15876
import sys
sys.setrecursionlimit(1000000)
readline = sys.stdin.readline
from collections import deque


def solve_beam():
    D = int(readline())
    C = list(map(int, readline().split()))
    S = [list(map(int, readline().split())) for i in range(D)]
    N = 26

    lasts = [0] * N

    ans = [None] * D

    W, DEPTH = 4, 5

    def rec(day, rem):
        if rem == 0 or day > D:
            return 0, 0
        gains = [(S[day - 1][t] + (day - lasts[t]) * C[t], t) for t in range(N)]
        gains.sort(reverse=True)
        max_gain = -1e10
        max_gain_t = 0
        for i in range(W):
            gain, t = gains[i]
            _t = lasts[t]
            lasts[t] = day
            f_gain, _ = rec(day + 1, rem - 1)
            lasts[t] = _t
            gain += f_gain
            if gain > max_gain:
                max_gain = gain
                max_gain_t = t

        return max_gain, max_gain_t

    _total = 0
    for day in range(D):
        _, t = rec(day, DEPTH)
        lasts[t] = day
        ans[day - 1] = t
        _total += _
    
    #print(_total)
    for a in ans:
        print(a + 1)


solve_beam()

Measured memory_bytes: 9836
#include<bits/stdc++.h>
using namespace std;
#define MAXN	200005
#define P	1000000007
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
vector <int> a[MAXN], b[MAXN];
int n, cnt, p[MAXN], cnte, x, y, size[MAXN], pr[MAXN];
bool visited[MAXN], father[MAXN];
long long fac[MAXN], inv[MAXN], met[MAXN];
long long power(long long x, long long y) {
	if (y == 0) return 1;
	long long tmp = power(x, y / 2);
	if (y % 2 == 0) return tmp * tmp % P;
	else return tmp * tmp % P * x % P;
}
long long getc(long long x, long long y) {
	return fac[x] * inv[y] % P * inv[x - y] % P;
}
void init(int N) {
	fac[0] = 1;
	for (int i = 1; i <= N; i++)
		fac[i] = fac[i - 1] * i % P;
	inv[N] = power(fac[N], P - 2);
	for (int i = N - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1) % P;
}
void dfs(int pos, int fa) {
	visited[pos] = true;
	p[++cnt] = pos; cnte += a[pos].size();
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (!visited[a[pos][i]]) dfs(a[pos][i], pos);
		else if (a[pos][i] != fa) x = pos, y = a[pos][i]; 
}
void work(int pos) {
	visited[pos] = true;
	for (unsigned i = 0; i < a[pos].size(); i++) {
		if (a[pos][i] == pr[pos]) continue;
		if (a[pos][i] < pr[pos]) {
			b[pos].push_back(a[pos][i]);
			father[a[pos][i]] = true;
		}
		if (!visited[a[pos][i]]) {
			pr[a[pos][i]] = pos;
			work(a[pos][i]);
		}
	}
}
long long dp(int pos) {
	size[pos] = 0;
	long long ans = 1;
	for (unsigned i = 0; i < b[pos].size(); i++) {
		ans = ans * dp(b[pos][i]) % P;
		size[pos] += size[b[pos][i]];
		ans = ans * getc(size[pos], size[b[pos][i]]) % P;
	}
	size[pos]++;
	return ans;
}
int main() {
	read(n); init(n * 2);
	for (int i = 1; i <= 2 * n; i++) {
		int x, y;
		read(x), read(y);
		a[x].push_back(y + n);
		a[y + n].push_back(x); 
	}
	long long ans = 1, all = 0;
	for (int i = 1; i <= 2 * n; i++)
		if (!visited[i]) {
			cnt = cnte = 0; dfs(i, 0);
			if (cnt * 2 != cnte) {
				cout << 0 << endl;
				return 0;
			}
			long long tans = 0;
			b[0].clear();
			for (int i = 1; i <= cnt; i++) {
				b[p[i]].clear(); pr[p[i]] = 0;
				father[p[i]] = false;
				visited[p[i]] = false;
			}
			pr[x] = y;
			work(x);
			for (int i = 1; i <= cnt; i++)
				if (!father[p[i]]) b[0].push_back(p[i]);
			tans += dp(0);
			b[0].clear();
			for (int i = 1; i <= cnt; i++) {
				b[p[i]].clear(); pr[p[i]] = 0;
				father[p[i]] = false;
				visited[p[i]] = false;
			}
			pr[y] = x;
			work(y);
			for (int i = 1; i <= cnt; i++)
				if (!father[p[i]]) b[0].push_back(p[i]);
			tans += dp(0);
			all += cnt;
			ans = ans * tans % P * getc(all, cnt) % P;
		}
	cout << ans << endl;
	return 0;
}

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

int main() {
int n;
cin>>n;
vector <int> x(n);
for (int i = 0; i < n; i++) {
    cin >> x.at(i);
  }

int minzahyo=0;
int shuukaicost=1e9;//i=集会の座標
for (int i = 1; i <= 100; i++) {
    int nowcost=0;
    for (size_t k = 0; k < n ; k++)
    {
      nowcost+=pow(x.at(k)-i, 2);
    }
    

    if (shuukaicost>nowcost)
    {
      shuukaicost=nowcost;
 
    }
    
  }

  cout << shuukaicost << endl;
}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	string a = "maerd", b = "remaerd", c = "esare", d = "resare";
	string s;
	cin >> s;
	rep(i, s.size() / 2) swap(s[i], s[s.size() - i - 1]);
	int now = 0;
	while (now < s.size()) {
		if (now + 7 <= s.size()) {
			if (b == s.substr(now, 7)) {
				now += 7;
				continue;
			}
		}
		if (now + 6 <= s.size()) {
			if (d == s.substr(now, 6)) {
				now += 6;
				continue;
			}
		}
		if (now + 5 <= s.size()) {
			if (a == s.substr(now, 5)) {
				now += 5;
				continue;
			}
			if (c == s.substr(now, 5)) {
				now += 5;
				continue;
			}
		}
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;

	return 0;
}

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

int main(){
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<vector<int> > mp(N+1, vector<int>(N+1,0));
  for (int i=0; i<M; i++){
    int l, r;
    cin >> l >> r;
    mp[l][r]++;
  }
  for (int i=1; i<N+1; i++){
    for (int j=1; j<N+1; j++){
      mp[i][j] += mp[i][j-1]+mp[i-1][j]-mp[i-1][j-1];
    }
  }
  for (int i=0; i<Q; i++){
    int p, q;
    cin >> p >> q;
    cout << mp[q][q]-mp[q][p-1]-mp[p-1][q]+mp[p-1][p-1] << endl;
  }
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD (int)1e9 + 7
#define atoi(x) ((x)-'0')
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

ll n, m, sum, t, a, b, cnt[100010];

int main() {
	cin >> n;
	FOR(i, n) {
		cin >> t;
		cnt[t]++;
		sum += t;
	}
	cin >> m;
	FOR(i, m) {
		cin >> a >> b;
		t = cnt[a];
		cnt[a] = 0;
		cnt[b] += t;
		sum += (b - a) * t;
		cout << sum << endl;
	}
}

Measured memory_bytes: 4412
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>

int main(){
  
  char S[100001];
  scanf("%s", S);
  //printf("%s", S);
  
  int N = strlen(S);
  
  std::cerr << "The length of S : " << N << std::endl;
  
  // solve problem
  std::vector<int> RL;
  for(int i = 1; i < N; i++){
    if(S[i]=='L' && S[i-1]=='R'){
      RL.push_back(i-1);
    }
  }
  
  /*std::cerr << "RL: " << std::endl;
  for(int i = 0; i < RL.size(); i++){
    std::cout << RL[i] << " ";
  }std::cout << std::endl << std::endl;*/
  
  std::vector<int> children_num;
  for(int i = 0; i < N; i++){
    children_num.push_back(0);
  }
  
  int RL_index, tmp;

  for(int i = 0; i < N; i++){
    if(S[i] == 'L'){
      std::cerr << "L" << S[i] << std::endl;
      tmp = std::distance(RL.begin(), std::lower_bound(RL.begin(), RL.end(), i))-1;
      std::cerr << "tmp ="  << tmp << std::endl;
      RL_index = RL[tmp];
      std::cerr << "RLindex ="  << RL_index << std::endl;

      
      if(((i - RL_index) & 1) == 1){
        children_num[RL_index+1]++;
      }
      else children_num[RL_index]++;
    }
    
    else if(S[i] == 'R'){ // if(S[i] == 'R')
      std::cerr << "R" << S[i] << std::endl;
      tmp = std::distance(RL.begin(), std::lower_bound(RL.begin(), RL.end(), i));
      std::cerr << "tmp ="  << tmp << std::endl;
      RL_index = RL[tmp];
      std::cerr << "RLindex ="  << RL_index << std::endl;
      if(((RL_index - i) & 1) == 1){
        children_num[RL_index+1]++;
      }
      else children_num[RL_index]++;
    }
    
    std::cerr << "i: " << i << std::endl;
    std::cerr << "tmp: " << tmp << std::endl;
    std::cerr << "RL_index: " << RL_index << std::endl;
    /*for(int j = 0; j < N; j++){
      std::cerr << children_num[j] << " ";
    }std::cerr << std::endl << std::endl;*/
  }

  
  for(int i = 0; i < N; i++){
    std::cout << children_num[i] << " ";
  }std::cout << std::endl;
  
  return 0;
}


Measured memory_bytes: 1272
#encoding:utf-8

# encoding:utf-8
import copy
import numpy as np
import random

d,g = map(int, input().split())
P = []
C = []
for i in range(d):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)

completed = []
for i in range(d):
    score = P[i]*(i+1)*100+C[i]
    completed.append(score)

def to_digital(num):
    dig = [0]*d
    for i in range(d):
        dig[i]=num%2
        num //= 2
    return dig

ans = 10**9
for i in range(2**d):
    digital = to_digital(i)
    score = 0
    count = 0
    for j in range(d):
        if digital[j]:
            score += completed[j]
            count += P[j]

    for j in range(d)[::-1]:
        if digital[j]==0:
            for k in range(P[j]-1):
                if g<=score:
                    break
                else:
                    count += 1
                    score += 100*(j+1)
        if g<=score:
            ans = min(ans,count)

print(ans)


Measured memory_bytes: 21652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
const double eps = 1e-8;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    cin >> a;
    
    auto bin = [&](double ok, double ng) {
        auto check = [&](double x) {
            ll sum = 0;
            rep(i, n) {
                sum += max(ceil(a[i] / x) - 1, 0.0);
            }
            // cerr << x << " " << sum << endl;
            if (sum <= k) return 1;
            return 0;
        };
        int cnt = 0;
        while (++cnt < 100) {
            double mid = (ok + ng) / 2;
            if (check(mid)) ok = mid;
            else ng = mid;
        }
        cout << (int)ceil(ok) << endl;
    };
    bin(inf, 0);
}


Measured memory_bytes: 3956
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = [0] * (n + 1)
for _ in range(m):
    x, y = map(int, input().split())
    a[x] = (a[x] + 1) & 1
    a[y] = (a[y] + 1) & 1
print("YES" if sum(a) == 0 else "NO")


Measured memory_bytes: 74704
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll n,now=1,cnt=0;
	map<ll,ll> mp;
	mp[1]=1;
	cin >> n;
	vll a(n+1);
	rep(i,n) cin >> a[i+1];
	while(1){
		now=a[now];
		cnt++;
		if(now==2){
			cout << cnt << endl;
			break;
		}
		mp[now]++;
		if(mp[now]>1){
			cout << -1 << endl;
			break;
		}
	}
    return 0;
}


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


Measured memory_bytes: 26296
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

int n;
int L[2100];

int main() {
    while (cin >> n) {
        for (int i = 0; i < n*2; ++i) cin >> L[i];
        sort(L, L + n*2);
        int res = 0;
        for (int i = 0; i < n; ++i) {
            res += L[i*2];
        }
        cout << res << endl;
    }
}





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

using namespace std;

int main() {
    int N, mx=0, sum=0;
    cin >> N;
    for(int n=0; n<N; n++) {
        int L;
        cin >> L;
        
        sum += L;
        mx = max(mx, L);
    }

    if(sum-mx>mx) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    vector <int> quin;
    vector <int> dou;
    vector <int> normal;
    for(int i=0;i<n;i++){
        int a; cin>>a;
        if(a%4==0) quin.push_back(a);
        else if(a%2==0) dou.push_back(a);
        else normal.push_back(a);
    }
    if(dou.size() ==0){
        if(normal.size() <= quin.size() +1){
            cout<<"Yes"<<endl;
            return 0;
        }
    }else{
        if(normal.size() <= quin.size()){
           cout<<"Yes"<<endl;
            return 0; 
        }
    }
    cout<<"No"<<endl;
}

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef long double ld;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

/*
task from atcoder: https://atcoder.jp/contests/cf16-tournament-round2-open/tasks/asaporo_e
*/

void solve(){
  int x, p;
  cin >> x >> p;
  cout << fixed << setprecision(30) <<((ld)(x + x % 2) * 100.0) / ((ld)p * 2.0) << '\n';
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}


Measured memory_bytes: 3796
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
a_list = [0]
b_list = [0]
for i in range(n):
    a_list.append(a[i] + a_list[i])
for i in range(m):
    b_list.append(b[i] + b_list[i])

ans = 0
num = m
for i in range(n+1):
    if a_list[i] > k:
        break
    while b_list[num] > k - a_list[i]:
        num -= 1
    ans = max(ans,i + num)
print(ans)


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

#define MOD 1000000007
#define MOD2 998244353
#define SIZE_1 2000005
#define SIZE_2 1000000
#define INT_BITS 32
typedef long long int ll;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;

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

    int x,a;
    cin >> x >> a;
    if(x < a)
        cout << "0";
    else
        cout << "10";

    return 0;
}


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

int main(){

    long long n, a, b;
    cin >> n >> a >> b;

    if(a > b){
        cout << 0 << endl;
    }
    else if(n == 1){
        if(a == b){
            cout << 1 << endl;
        }
        else{
            cout << 0 << endl;
        }
    }
    else{
        cout << (n - 1) * b + a - ((n - 1) * a + b) + 1<< endl;
    }




}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#define fi first
#define se second
#define pb push_back
#define last(s) (s)[(s).length()-1]
#define all(a) (a).begin(),(a).end()
#define elif else if
#define left asdasd
#define next zaza
#define prev azaz
#define cclear cout<<flush;
#define x0 kerker
#define y0 lolik
#define kchay ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
using namespace std;
 
using llong = long long;
using ld = long double;
using ii = pair<int,int>;
using ull = unsigned long long;
using pll = pair<llong, llong>;
 
const llong over999 = 1e12;
const llong md = 1e9+7;
const ld eps = 1e-9;
const ld Pi = acos(-1);
 
/*watch the sunlight*/

//q - 0.25, h - 0.5, s - 1, d - 2

llong q, h, s, d;
llong n, ans;

int32_t main()
{
    kchay;
    
    cin >> q >> h >> s >> d;
    
    cin >> n;
    
    ans = n/2 * min({q*8, h*4, s*2, d});
    
    n&=1;
    
    if(n)ans+= min({q*4, h*2, s});
    
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 764
#include <iostream>

int main() {
  using namespace std;

  int x, y;

  cin >> x;
  cin >> y;

  if (y % 2 != 0) {
    cout << "No";
  }
  else if (y > x * 4) {
    cout << "No";
  }
  else if (y < x * 2) {
    cout << "No";
  }
  else {
    cout << "Yes";
  }

  return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    String answer = "";
    if (x >= 1800) {
      answer = "1";
    } else if (x >= 1600) {
      answer = "2";
    } else if (x >= 1400) {
      answer = "3";
    } else if (x >= 1200) {
      answer = "4";
    } else if (x >= 1000) {
      answer = "5";
    } else if (x >= 800) {
      answer = "6";
    } else if (x >= 600) {
      answer = "7";
    } else if (x >= 400) {
      answer = "8";
    }
    System.out.print(answer);
  }
}

Measured memory_bytes: 35652