akhauriyash/Code-Regression huggingface dataset:
import sys
import numpy as np
import numba
from numba import njit
i8 = numba.int64

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 998_244_353

@njit((i8[:], ), cache=True)
def build(raw_data):
    bit = raw_data.copy()
    for i in range(len(bit)):
        j = i + (i & (-i))
        if j < len(bit):
            bit[j] += bit[i]
    return bit


@njit((i8[:], i8), cache=True)
def get_sum(bit, i):
    s = 0
    while i:
        s += bit[i]
        i -= i & -i
    return s


@njit((i8[:], i8, i8), cache=True)
def add(bit, i, x):
    while i < len(bit):
        bit[i] += x
        i += i & -i


@njit((i8[:], i8), cache=True)
def find_kth_element(bit, k):
    N = len(bit)
    x, sx = 0, 0
    dx = 1
    while 2 * dx < N:
        dx *= 2
    while dx:
        y = x + dx
        if y < N:
            sy = sx + bit[y]
            if sy < k:
                x, sx = y, sy
        dx //= 2
    return x + 1

@njit((i8[:], ), cache=True)
def main(XY):
    X, Y = XY[::2], XY[1::2]
    N = len(Y)
    ind = X.argsort()
    X, Y = X[ind], Y[ind]
    # 座圧
    Y_sort = Y.copy()
    Y_sort.sort()
    Y = np.searchsorted(Y_sort, Y, 'right')
    bit = np.zeros(N + 10, np.int64)

    pow2 = np.ones(N + 10, np.int64)
    for n in range(1, N + 10):
        pow2[n] = 2 * pow2[n - 1] % MOD

    ret = 0
    for i in range(N):
        y = Y[i]
        L = i
        R = N - 1 - i
        LD = get_sum(bit, y)
        add(bit, y, 1)
        LU = L - LD
        D = y - 1
        U = N - 1 - D
        RD = D - LD
        RU = R - RD

        x = pow2[N] - 1
        x -= pow2[L] + pow2[R] + pow2[D] + pow2[U]
        x += pow2[LD] + pow2[LU] + pow2[RD] + pow2[RU]
        ret += x
    return ret % MOD

N = int(readline())
XY = np.array(read().split(), np.int64)

print(main(XY))

Measured memory_bytes: 133768
import collections
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
set_a = set(a)
count_a = collections.Counter(a).most_common()[::-1]
if len(set_a)-k > 0:
    for i in range(len(set_a)-k):
        ans += count_a[i][1]
print(ans)

Measured memory_bytes: 50528
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iterator>
#include <string>
#include <cmath>

# define PI 3.14159265358979323846

using namespace std;

int main(void) {
    long long n, k;
    cin >> n >> k;
    long long m = n % k;
    if (abs(m - k) < m)
        m = abs(m-k);
    cout << m << endl;
}

Measured memory_bytes: 3616
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val items = (0 until h).map {
        readLine()!!.toCharArray().map {
            when (it) {
                '.' -> true
                '#' -> false
                else -> throw IllegalStateException()
            }
        }
    }

    val map = mutableMapOf<String, Int>()
    for (i in (h - 1) downTo 0) {
        for (j in (w - 1) downTo 0) {
            val isGood = items[i][j]

            if (i == (h - 1) && j == (w - 1)) {
                map["$i-$j"] = if (isGood) 0 else 1
                continue
            }

            val fromDown = if (i != (h - 1)) {
                map["${i + 1}-$j"]!! + if (isGood != items[i + 1][j]) 1 else 0
            } else {
                5000
            }
            val fromEnd = if (j != (w - 1)) {
                map["$i-${j + 1}"]!! + if (isGood != items[i][j + 1]) 1 else 0
            } else {
                5000
            }
            map["$i-$j"] = Math.min(fromDown, fromEnd)
        }
    }

    val result = (map["0-0"]!! + 1) / 2
    println(result)
}

Measured memory_bytes: 40532
#include<stdio.h>
#include<stdlib.h>
int main()
{
  long long n;
  scanf("%lld",&n);
  
  long long a,b,c;
  int i,j,k;
  
  for(i=1;i<=3500;i++)
  {
    for(j=1;j<=3500;j++)
    {
        if(4*i*j-n*i-n*j>00&&(i*j*n)%(4*i*j-n*i-n*j)==0)
        {
        a=i;
        b=j;
        c=a*b*n/(4*a*b-n*a-n*b);
           printf("%lld %lld %lld\n",a,b,c);
          return 0;     
      }
    }
  }
}

Measured memory_bytes: 128
import sys
X,N = map(int,input().split())
if N == 0:
    print(X)
    sys.exit()    
else:
    P = list(map(int,input().split()))
flaga = 0
flagb = 0

for i in range(100):
    a = X - i
    b = X + i
    if (a in P)== 0:
        flaga = 1
    if (b in P)== 0:
        flagb = 1
    if flaga ==1 or flagb ==1:
        break

if flaga ==1 and flagb ==1:
    print(min(a,b))
elif flaga ==1 and flagb ==0:
    print(a)
else:
    print(b)

Measured memory_bytes: 9220
#include <stdio.h>
#include <iostream>
#include<algorithm>
using namespace std;
// int count=1;
// int A,B;
// void f(int a,int b){
//     if(a>=b) return;
//     if(a<b){
//         f(a+A-1,b);
//         count++;
//     }
// }
// int main(){
//     scanf("%d%d",&A,&B);
//     if(B==1){
//         printf("%d",0);
//     }else{
//         f(A,B);
//         printf("%d",count); 
//     } 
// }
int a[100001];
int main(){
    int N;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
    {
        scanf("%d",&a[i]);
    }
    int ansv=0;
    int count=0;
    for(int k=0;k<N-1;k++){
        if(a[k]>=a[k+1]){
            count++;
        }else
        {
            ansv=max(ansv,count);count=0;
        }
    }  
    ansv=max(ansv,count);         
    printf("%d",ansv);  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vll;
     
int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  if (n == m) cout << "Yes\n";
  else cout << "No\n";
  return (0);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
long long f(int c){
    long long ret=1;
    int i;
    for(i=0;i<c;i++)
        ret*=2;
    return ret;
}
int main(void){
    char s[150];
    long long a[20],ans[2];
    int c,i;
    while(1){
        scanf("%s",s);
        if(s[0]=='#')
            break;
        ans[0]=ans[1]=0;
        for(i=0,c=0;i<strlen(s);c++){
            if(strstr(s+i,"north")==s+i){
                a[c]=-90;
                i+=5;
            }
            else if(strstr(s+i,"west")==s+i){
                a[c]=90;
                i+=4;
            }
        }
        if(a[c-1]==-90)
            a[c-1]=0;
        ans[1]=f(c-1);
        for(i=c-1;i>=0;i--){
            ans[0]+=a[i]*f(i);
        }
        while(ans[0]%2==0&&ans[1]!=1){
            ans[0]/=2;
            ans[1]/=2;
        }
        if(ans[1]==1)
            printf("%lld\n",ans[0]);
        else
            printf("%lld/%lld\n",ans[0],ans[1]);
    }
    return 0;
}

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

#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int) (x).size())


int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	if (a >= 1 && a <= 9 && b >= 1 && b <= 9) cout << a * b << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
// D - Water Bottle
#include <bits/stdc++.h>
using namespace std;
using dbl = double;

int main(){
	dbl a,b,x; cin>>a>>b>>x;
	dbl s = x/a;
	printf("%.10f\n", atan( s < a*b/2? b/(s/b*2): (b-s/a)*2/a ) *180/M_PI);
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    string s;
    cin >> s;

    map<char, int> a;
    rep(i, 4){
        a[s[i]]++;
    }

    if(SZ(a) != 2){
        cout << "No" << endl;
        return 0;
    }

    for(P p : a){
        if(p.second != 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int l;
  cin >> l;
  vector<vector<P>> to(21); // 1-index
  to[1].emplace_back(2, 0);
  to[1].emplace_back(2, 1);
  vi task;
  while (2 < l) {
    if (l % 2 == 1) {
      task.push_back(1); // +1
      l--;
    } else {
      task.push_back(0); // *2
      l /= 2;
    }
  }
  reverse(task.begin(), task.end());
  dump(task);
  int len = 2;
  int now = 1;
  rep(i, task.size()) {
    if (task[i]) {
      to[1].emplace_back(now + 1, len);
      len++;
    } else {
      for (auto& v : to) for (auto& p : v) p.second *= 2;
      to[now + 1].emplace_back(now + 2, 0);
      to[now + 1].emplace_back(now + 2, 1);
      len *= 2;
      now++;
    }
  }
  dump(now);
  int cnt = 0;
  rep(i, 21) cnt += to[i].size();
  cout << now + 1 << " " << cnt << endl;
  rep(i, 21) {
    for (auto u : to[i]) {
      cout << i << " " << u.first << " " << u.second << endl;
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("d.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    if (A > 8 || B > 8) {
        cout << ":(" << endl;
    } else
        cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Hello
{
    public static void Main()
    {
        int K = NextInt();
        long[] A = LineLong();
        long min = 2, max = 2;
        for (int i = K - 1; i >= 0; i--)
        {
            min = (long)Math.Ceiling(min / (A[i] + .0)) * A[i];
            max = (max / A[i]) * A[i] + A[i] - 1;
        }
        Console.WriteLine((min > max ? "-1" : min + " " + max));
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 27484
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = 0, B = 0;
		if (N == 2) {
			A = sc.nextInt();
			B = sc.nextInt();
		}
		sc.close();

		if (N == 1)
			System.out.println("Hello World");
		else
			System.out.println(A + B);
	}
}


Measured memory_bytes: 22484
require 'prime'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

def f(sum,a,count)
  repl 1,a.size-1 do |i|
    sum << a[i]+sum[i-1]
    if sum[i-1] > 0
      if sum[i] >= 0
        count += sum[i]+1
        sum[i] = -1
      end
    elsif sum[i-1] < 0
      if sum[i] <= 0
        count += 1-sum[i]
        sum[i] = 1
      end
    end
  end
  return count
end

n = gif
a = gi
sum2 = []
sum3 = []
ans2 = nil
ans3 = nil
if a[0]>0
  sum2 << a[0]
  ans2 = f sum2,a,0
  sum3 << -1
  ans3 = f sum3,a,(1+a[0]).abs
elsif a[0]<0
  sum2 << 1
  ans2 = f sum2,a,1-a[0]
  sum3 << a[0]
  ans3 = f sum3,a,0
else
  sum2 << 1
  ans2 = f sum2,a,1
  sum3 << -1
  ans3 = f sum3,a,1
end

puts min ans2,ans3


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


int main() {
    ll x;
    cin >> x;
    ll n=0;
    ll tmp;
    do{
        n++;
        tmp=5*pow(n,4)+10*pow(n,3)+10*pow(n,2)+5*n+1;
    }while(tmp<=x);


    bool flag=true;
    bool pm=true;
    ll a=0;
    ll b=0;
    while(flag){
        for(ll i=1;i<=n+1;i++) {
            ll tmp = pow(a,5);
            if (tmp - pow((a + i), 5) == x) {
                b = a+i;
                flag = false;
                break;
            }else if (tmp - pow((a - i), 5) == x){
                b=a-i;
                flag = false;
                break;
            }
        }
        a++;
    }
    cout<< a-1 <<" "<< b<<endl;

    return 0;
}


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

int main(){
	long long N;
	cin >> N;
	map<long long,long long> prime;
	for(long long i=2;i*i<=N;i++){
		while(N%i==0){
			prime[i]++;
			N/=i;
		}
	}
	if(N>1)prime[N]++;
	
	long long ans=0;
	
	for(auto p:prime){
		auto x=p.second;
		for(long long i=1;x>=i;i++){
			ans++;
			x-=i;
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(long long &a, long long b) { if (a > b) a = b; }

int main(){
  ll i = 0, j;
  ll n, a, b;
  cin >> n >> a >> b;
  cout << min(a, b) spa max(a + b - n, i) << endl;

  return 0;
}

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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

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




ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int ans = 0;
int N, M, Q;

template<typename T>
void showall(vector<T> v){
  rep(i, 0, v.size()){
    cout << v[i] << " ";
  }
  cout << endl;
}

template<typename T>
ll com(T n, T m, T mod){
  ll a = 1, b = 1, ans;
  if(n == m || m == 0){
    ans = 1;
  }else{
    for(ll i = 0;i < m; i++){
      a *= n-i;
      a %= mod;
      b *= i+1;
      b %= mod;
    }
    ans = (a * powmod(b, mod-2, mod)) % mod;
  }
  
  return ans;
}



 
int main() {
  int A, B;
  cin >> A >> B;

  cout << A * B << endl;
  

}



Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  string a;
  cin >> a;
  cout << a.substr(0, a.size() - 8) << endl;
  return 0;
}


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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;

int main(){
    ll d, n;
    cin >> n >> d;
    int ans = 0;
    REP(i,n){
        ll x,y;
        cin >> x >> y;
        if(x*x+y*y<=d*d) ans ++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(void)
{
	int a, b, flag = 1;
	char op;
	
	while (flag) {
		scanf("%d %c %d", &a, &op, &b);
		
		switch (op) {
		case '+':
			printf("%d\n", a + b);
			break;
		case '-':
			printf("%d\n", a - b);
			break;
		case '*':
			printf("%d\n", a * b);
			break;
		case '/':
			printf("%d\n", a / b);
			break;
		case '?':
			flag = 0;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 600
import itertools
N = int(input())
P = tuple([int(i) for i in input().split()])
Q = tuple([int(i) for i in input().split()])


n = N - 1
num_list = [i+1 for i in range(N)]

num_list_set = list(itertools.permutations(num_list))
a = num_list_set.index(P)
b = num_list_set.index(Q)

print(abs(a-b))


Measured memory_bytes: 8052
/**

       Author : sea_26

    **/


    #pragma GCC optimize("03")
    #include <bits/stdc++.h>

    using namespace std;

    const int M = 1000000007;
    const double PI = acos(-1.0);

    // const double pi = atan2(0, -1);
    // const double PI = 4 * atan(1);
    // const double pi = 2*cos(0.0);

    typedef long long ll;
    typedef long double ld;

    const int iinf = 0x3f3f3f3f;
    const ll linf = 0x3f3f3f3f3f3f3f3f;

    #define mp make_pair
    #define pb push_back
    #define f first
    #define s second
    #define ln(x) (int)x.size()

    #define bp(n)  __builtin_popcount(n)
    #define bclz(n) __builtin_clzll(n)
    #define bctz(n) __builtin_ctzll(n)
    #define bip(n) __builtin_parity(n)

    #define vsort(v) sort(v.begin(),v.end())
    #define rvsort(v) sort(v.begin(),v.end(),greater<int>())

    #define rep(n) for(int i=0; i<n; i++)
    #define rrep(n) for(int i=n-1; i>=0; i--)
    #define lrep(p,q) for(int i=p; i<=q; i++)
    #define prep(n) for(int i=1; i*i<=n; i++)
    #define it(a, x)  for(auto &a : x)
    #define yes cout << "YES" << endl
    #define no cout << "NO" << endl

    priority_queue<int> pq;

    #define fs   ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

    template< typename T> inline T lcm(T a, T b){ return (a / gcd(a,b)) * b; }
    template< typename T> inline T MAX(T a, T b){ return a ^ ((a ^ b) & -(a < b)); }
    template< typename T> inline T MIN(T a, T b){ return b ^ ((a ^ b) & -(a < b)); }
    template< typename T> void tpns(T n){ rrep(30){ if(n & (1 << i)) pq.push(1 << i); } }
    template< typename T> void SWAP(T &a, T &b){ a = ((a) ^= (b)),  b = ((b) ^= (a)),  a = ((a) ^= (b)); }
    template< typename T> inline T ABS(T a){ int x = a >> sizeof(int) * CHAR_BIT - 1; return (a + x) ^ x; }
    template< typename T> inline T mod(T a, T b){ return a >= b ? a % b : a; }
    template< typename T> inline T gcd(T a, T b){ while (b) b ^= a ^= b ^= a %= b; return a; }

    ll gcdextd(ll a, ll b, ll& x, ll& y) {
        if (!a) { x = 0; y = 1; return b; }
        ll y1,d;
        d = gcdextd(b % a, a, y, y1);
        x = y1 - (b / a) * y;
        return d;
    }



    double WT() {
    	return double(clock()) / CLOCKS_PER_SEC;
    }

    void ReT(){

    	cout << "\nTime = " << fixed << setprecision(3) << WT()  << " Sec"<< endl;

    exit(0);
    }


    int n,cnt;
    int main(){

            fs;
            cin >> n;
            vector<int> v(n);

            rep(n)
                cin >> v[i];
            rep(n){
                bool flag = true;
                for(int j=0; j<i; j++){
                    if(v[j] > v[i]){
                        flag = false;
                        break;
                    }
                }
                if(flag) cnt++;
            }
        cout << cnt << endl;
         //   ReT();

    }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <time.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  string s;
  cin >> s;
  int c = 0;
  rep(i, 0, s.length()) {
    if(s[i] == 'o') c++;
  }
  c += 15 - s.length();
  if(c >= 8) {
    cout << "YES" << endl;
  }else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    string str;
    cin>>str;
    int n=str.length();
    char ch;
    ch='s';
    if(str[n-1]==ch)
    {
        cout<<str<<"es";
    }
    else
    {
        cout<<str<<"s";
    }
    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll       long long
#define DS       pair<ll, ll>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 2e5 + 5;
const int MOD = 1e9 + 7;;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    ll x;
    cin >> x;
    ll ans = (x / 500) * 1000;
    ans += (((x % 500) / 5) * 5);
    cout << ans << '\n';
    return 0;
}


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

int main() {
  string str;
  while(cin >> str) {
    int joi, ioi;
    joi = ioi = 0;
    for(int i = 0; i < str.size() - 2; ++i) {
      if(str.substr(i, 3) == "JOI") ++joi;
      if(str.substr(i, 3) == "IOI") ++ioi;
    }
    cout << joi << endl << ioi << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define pf push_front
#define fd(n)       fixed<<setprecision(n)
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);   
	cin.tie(NULL);
	cout.tie(NULL);
	
	long double n;
	cin>>n;
	cout<<fd(8)<<pow(n/3,3)<<endl;
}


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  string s;
  cin >> s;
  cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
}


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

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

#define fr first
#define sc second

const ll INF = 1000000000000000000;

vector<P> f(vector<P> vec){
	sort(vec.begin(),vec.end());
	vector<P> ret;
	ll mi = INF;
	for(int i = 0 ; i < vec.size() ; i ++){
		if(mi > vec[i].sc){
			mi = vec[i].sc;
			ret.push_back(vec[i]);
		}
	}
	return ret;
}

static int N;
static int a[131100];
static ll v[131100];
static vector<ll> ch[131100];
static vector<P> dp[131100];

int main(){
	scanf("%d",&N);
	for(int i = 1 ; i <= N-1 ; i ++){
		scanf("%d%lld",&a[i],&v[i]);
		ch[a[i]].push_back(i+1);
	}
	
	ll l = 0, r = 1LL<<34;
	while(l < r){
		ll m = (l+r)/2;
		//cout << l << " " << r << " " << m << endl;
		for(int i = 1 ; i <= N ; i ++)dp[i].clear();
		for(int i = N ; i >= 1 ; i --){
			if(ch[i].size() == 0){
				dp[i].push_back(P(0,0));
			}
			else {
				ll s = ch[i][0];
				ll t = ch[i][1];
				for(int j = 0 ; j < dp[s].size() ; j ++){
					P p = dp[s][j];
					P q = P( m-dp[s][j].sc-v[s-1]-v[t-1] , INF );
					vector<P>::iterator itr = lower_bound(dp[t].begin(),dp[t].end(),q);
					if(itr == dp[t].begin())continue;
					else {
						p.sc = (--itr)->sc;
						p.fr += v[s-1];
						p.sc += v[t-1];
						dp[i].push_back(p);
					}
				}
				swap(s,t);
				for(int j = 0 ; j < dp[s].size() ; j ++){
					P p = dp[s][j];
					P q = P( m-dp[s][j].sc-v[s-1]-v[t-1] , INF );
					vector<P>::iterator itr = lower_bound(dp[t].begin(),dp[t].end(),q);
					if(itr == dp[t].begin())continue;
					else {
						p.sc = (--itr)->sc;
						p.fr += v[s-1];
						p.sc += v[t-1];
						dp[i].push_back(p);
					}
				}
				dp[i] = f(dp[i]);
			}
		}
		if(dp[1].size() > 0)r = m;
		else l = m+1;
	}
	cout << l << endl;
}



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

const int N=100005;
const int INF=0x3f3f3f3f;
int n,m,q,a[N],b[N];
int mina=INF,minb=INF,ans;

int main()
{
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),mina=min(mina,a[i]);
	for(int i=1;i<=m;i++) scanf("%d",&b[i]),minb=min(minb,b[i]);
	ans=mina+minb;
	while(q--)
	{
		int x,y,c;
		scanf("%d%d%d",&x,&y,&c);
		ans=min(ans,a[x]+b[y]-c);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1024
import java.io.*;
import java.nio.CharBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        ArrayList<String> x = new ArrayList<>(n);
        for (int i = 0; i < n; ++i) {
            char[] s = scanner.next().toCharArray();
            Arrays.sort(s);
            x.add(new String(s));
        }
        x.sort(Comparator.naturalOrder());
        long ans = 0;
        for (int i = 0; i < n; ) {
            int j = i;
            while (j < n && x.get(j).equals(x.get(i)))
                ++j;
            long cnt = j - i;
            ans += cnt * (cnt - 1) / 2;
            i = j;
        }
        writer.println(ans);
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        private void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        private char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        private String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        private int nextInt() {
            return Integer.valueOf(next());
        }

        private long nextLong() {
            return Long.valueOf(next());
        }

        private double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 45676
N = int(input())
b = list(map(int, input().split()))
bb = [0 for _ in range(N+1)]
ans = []

for num, val in list(enumerate(b))[::-1]:
    if not sum(bb[::num+1]) % 2 == val:
        bb[num+1] = 1
        ans.append(str(num+1))
print(len(ans))
if len(ans):
    print(' '.join(ans))

Measured memory_bytes: 35832
from sys import exit
N, u, v = map(int, input().split())

if u == v:
    print(0)
    exit()

edges = [[] for _ in range(N+1)]

for _ in range(N-1):
    A, B = map(int, input().split())
    edges[A].append(B)
    edges[B].append(A)

def calDist(start, edges):
    dest = [-1] * (N + 1)
    dest[start] = 0
    q = [start]
    while len(q) != 0:
        current = q.pop()
        for n in edges[current]:
            if dest[n] != -1:
                continue
            dest[n] = dest[current] + 1
            q.append(n)
    return dest

T = calDist(u, edges)
A = calDist(v, edges)

result = 0
for i in range(1, N+1):
    A_i = A[i]
    if T[i] >= A_i:
        continue
    if A_i > result:
        result = A_i

print(result-1)



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


template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    bool update = true;
    ll ans = 0;
    while (update) {
        int l = -1, r = 0;
        bool flag=false;
        for (int i=0; i<n; ++i) {
            if (!flag and h[i]>0) {
                flag = true;
                l = r = i;
            }
            else if (flag and h[i]>0) {
                r=i;
            }
            else if (flag and h[i]==0) {
                break;
            }
        }
        if (l<0) break;
        for (int t=l;t<=r;++t) h[t]--;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int main() {
int N;
long long ans = 0;
cin >> N;
vector<long long> a(3 * N); 
for (int i = 0; i < 3 * N; ++i) cin >> a[i];
sort(a.begin(), a.end(), greater<long long>());
for (int i = 1; i < 2*N + 1; i += 2) ans += a[i];
cout << ans << endl;
}

Measured memory_bytes: 2560
fn main() {
    let stdin = std::io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut out = String::with_capacity(2 * 10_000);

    let mut r_cnt = 0;
    let mut l_cnt = 0;

    let mut taking_r = true;
    for c in buf.trim_right().bytes() {
        if c == b'L' {
            l_cnt += 1;
            taking_r = false;
        } else { // c == b'R'
            if taking_r {
                r_cnt += 1;
            } else {
                for _ in 0..r_cnt-1 {
                    out += "0 ";
                }
                let r = (r_cnt + 1) / 2 + l_cnt / 2;
                out += &(r.to_string() + " ");
                let l = r_cnt / 2 + (l_cnt + 1) / 2;
                out += &(l.to_string() + " ");
                for _ in 1..l_cnt {
                    out += "0 ";
                }
                l_cnt = 0;
                r_cnt = 1;
                taking_r = true;
            }
        }
    }

    for _ in 0..r_cnt-1 {
        out += "0 ";
    }
    let r = (r_cnt + 1) / 2 + l_cnt / 2;
    out += &(r.to_string() + " ");
    let l = r_cnt / 2 + (l_cnt + 1) / 2;
    out += &l.to_string();
    for _ in 1..l_cnt {
        out += " 0";
    }
    println!("{}", out);
}


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

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

const long long INF = 1LL << 60;

int main() {
    int N; cin >> N;
    vector<int> A_1(N), A_2(N);
    for (int i = 0; i < N; i++) cin >> A_1[i];
    for (int i = 0; i < N; i++) cin >> A_2[i];

    int sum = 0;

    for (int i = 0; i < N; i++) {
        int S = 0;
        for (int j = 0; j <= i; j++) S += A_1[j];
        for (int j = i; j < N ; j++) S += A_2[j];

        chmax(sum, S);
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D) {
    cout << "Left" << endl;
  } else if (A + B < C + D) {
    cout << "Right" << endl;
  } else {
  	cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M, K;
  cin>>N>>M>>K;
  bool can = false;
  for(int i=0;i<=N;++i) {
    for(int j=0;j<=M;++j) {
      if(K==N*M-i*j-(N-i)*(M-j)) can = true;
    }
  }
  if(can) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3636
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

const INF: usize = 1 << 24;

fn solve() {
    let n = get();
    let m = get();
    let mut far = vec![INF; n];
    for _ in 0 .. m {
        let a = get::<usize>() - 1;
        let b = get::<usize>() - 1;
        far[a] = min(far[a], b);
    }
    let mut ans = 0;
    let mut pos = n;
    for i in (0 .. n).rev() {
        if far[i] >= INF {
            continue;
        }
        if far[i] > pos {
            continue;
        }
        ans += 1;
        pos = i;
    }
    println!("{}", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#tiソート
#
import sys,bisect
input = sys.stdin.readline
n,c,k = map(int, input().split( ))
t = []
for i in range(n):
    ti = int(input())
    t.append(ti)

t.sort()
cnt = 0
fin = 0
while fin <n:
    fin2 = bisect.bisect_right(t,t[fin]+k)
    fin = min(fin+c,fin2)
    #print(t[fin:fin3],fin,fin3)
    #fin = fin3
    cnt+=1
print(cnt)

Measured memory_bytes: 44380
#include <bits/stdc++.h>
using namespace std;
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}





int main(){

ios::sync_with_stdio(false);
cin.tie(0);

string s;
cin>>s;
int flag=0;
for(int i=0;i<(int)s.size();i++){
if(s[i]=='7')flag=1;
}

if(flag==1){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;

}

}

//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;



Measured memory_bytes: 3660
// ~/Remember,remember the 6th of March

#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-9;
const ll MOD = 1e9 + 7;
using namespace std;
int main()
{
    int n;
    cin>>n;
    cout<<3*(n*n)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1e18
#define gap " "
#define pi 2 * acos (0.0)

int main()
{
    
    int n;
    cin>> n;
    int ac=0,wa=0,tle=0,re=0;
    while(n--){
        string s;
        cin>> s;
        if(s=="AC") ac++;
        if(s=="WA") wa++;
        if(s=="TLE") tle++;
        if(s=="RE") re++;

    }
    cout<< "AC x "<<ac<<endl;
    cout<< "WA x "<<wa<<endl;
    cout<< "TLE x "<<tle<<endl;
    cout<< "RE x "<<re<<endl;

}


Measured memory_bytes: 3548
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>
constexpr long long int MOD = 998244353;
static int sum;
std::vector<std::vector<std::vector<long long int>>> memo;
long long int pattern(const std::vector<int>& run_length, const int current_pos, const int current_use, const int k) {
	if (k < 0) return 0LL;
	if (run_length.size() <= current_pos) return current_use == sum ? 1LL : 0LL;
	if (current_use == sum) return 1LL;
	if (memo[current_pos][current_use][k] >= 0) return memo[current_pos][current_use][k];
	long long int result{ 0 };
	for (auto use = 0; current_use + use <= sum; ++use) {
		result += pattern(run_length, current_pos + 1, current_use + use, k - std::max(0, use - run_length[current_pos]));
	}
	return memo[current_pos][current_use][k] = result % MOD;
}
int main() {
	std::string str; int k; std::cin >> str >> k;
	std::vector<int> run_length{ 0 };
	for (const auto c: str) {
		if (c == '1') {
			run_length.back()++;
		}
		else {
			run_length.push_back(0);
		}
	}
	const auto all_one = std::count(str.begin(), str.end(), '1');
	sum = all_one;
	memo = std::vector<std::vector<std::vector<long long int>>>(run_length.size(), std::vector<std::vector<long long int>>(all_one + 1, std::vector<long long int>(std::min<int>(k, all_one) + 1, -1)));
	int prev{ 0 };
	for (auto i = 0; i < run_length.size(); ++i) {
		for (auto j = 0; j < prev; ++j) {
			std::fill(memo[i][j].begin(), memo[i][j].end(), 0);
		}
		prev += run_length[i];
	}
	std::cout << pattern(run_length, 0, 0, std::min<int>(k, all_one));
}

Measured memory_bytes: 30940
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m;
    cin >> n;
    vector<string> s(n);
    for(int i=0;i<n;i++) cin >> s[i];
    cin >> m;
    vector<string> t(m);
    for(int i=0;i<m;i++) cin >> t[i];
    
    int ans =0;
    for(int i=0;i<n;i++){
        int count=0;
        string moji = s[i];
        for(int j=i;j<n;j++){
            if(moji==s[j]) count++;
        }
        for(int j=0;j<m;j++){
            if(moji==t[j]) count--;
        }
        ans = max(ans, count);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <unordered_set>

int main() {
  int n;
  scanf("%d", &n);
  int xor_sum = 0;
  std::unordered_set<int> s;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    xor_sum ^= a;
    a = a ^ (a - 1);
    s.insert(a);
  }

  int ans = 0;
  for (int bit = 29; bit >= 0; bit--) {
    if (((1 << bit) & xor_sum) == 0) {
      continue;
    }
    int x = (1 << (bit + 1)) - 1;

    if (s.find(x) != s.end()) {
      xor_sum ^= x;
      ans += 1;
    }
  }

  if (xor_sum != 0) {
    printf("-1\n");
  } else {
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,a,b) for(int i= (int)(a); i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define what_is(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
const int N = 1e6+7 ;
string s ;

int main(){fast ;
	int m,k ;
	cin >> m >> k ;
	if(m==0){
		if(k == 0){
			cout << "0 0" << endl ;
		}
		else
			cout << -1 << endl ;
		return 0 ;
	}
	if(m==1){
		if(k == 0){
			cout << "0 0 1 1" << endl ;
		}
		else
			cout << -1 << endl ;
		return 0 ;
	}
	if(k >= (1<<m))
		return cout << -1 , 0 ;
	
	for(int i = 1 ; i < (1<<m) ; i++){
		int z = i^k ;
		cout << z << ' ' ;
	}
	cout << k << ' ' ;	
	
	for(int i = (1<<m)-1 ; i > 0 ; i--){
		int z = i^k ;
		cout << z << ' ' ;
	}
	cout << k << endl ;
	
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N;
  cin >> N;

  map<ll, ll> m;
  ll ans = 0;
  rep(i, N) {
    ll a;
    cin >> a;
    m[a]++;
    ans += a;
  }

  ll Q;
  cin >> Q;
  rep(i, Q) {
    ll b, c;
    cin >> b >> c;
    ll kosu = m[b];
    m.erase(b);
    ans -= kosu * b;
    ans += kosu * c;
    m[c] += kosu;
    COUT(ans);
  }

  return 0;
}

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


int main() {
    int x;
    cin>>x;
    if(x>=30){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;

int power(int x,int b){
    return x*x*x*x*x;
}

void solve()
{
    int x ;
    cin>>x;
    int a = 0, b = 0;
    for(int a=-1000;a<=1000;a++){
        for(int b = -1000; b <= 1000; b++){
            if(power(a,5) - power(b,5) == x){
                cout<<a<<" "<<b;
                return;
            }
        }
    }
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3604