akhauriyash/Code-Regression huggingface dataset:
/*
  Author: Hamza Hasbi
*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define uld unsigned long double
#define ui unsigned int
#define ud unsigned double
#define uf unsigned float
#define pi 2*acos(0.0)
#define module cin.ignore()
#define rep(i,l,r) for(auto i=l;i<=r;i++)
#define range(x,y) for(auto x:y)
//inline long long lcm(ll a,ll b) {return a*b/__gcd(a,b);}
//inline long long gcd(ll a,ll b) {return 1LL*b == 0 ? a : gcd(1LL*b, a*1LL % b*1LL);}
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,x;
    cin >> n >> x;
    int current = n;
    vector <int> moto(n);
    for(int i = 0 ; i < n; i ++) {
      cin >> moto[i];
    }
    x -= (accumulate(moto.begin(), moto.end(), 0));
    current += floor(x/(*min_element(moto.begin(),moto.end())));
    cout << current << endl;
    return 0;
}


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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VC vector<char>
#define VS vector<string>
#define FOREACH(x,a) for(auto& (x) : (a) )
using namespace std;

int main() {
	int n;
	cin >> n;
	VS v(n);
	REP(i, n) {
		cin >> v[i];
	}
	bool a = true;
	REP(i, n - 1) {
		if (v[i][v[i].size() - 1] != v[i + 1][0]) a = false;
	}
	sort(ALL(v));
	REP(i, n - 1) {
		if (v[i] == v[i + 1]) a = false;
	}
	if (a) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    a = root(a);
    return -Parent[a];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(a < b) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }

  bool issame(int a, int b){
    return root(a) == root(b);
  }
};

int main(){
  int n; cin >> n;
  vl a(3*n); rep(i,3*n) cin >> a[i];
  sort(all(a));
  reverse(all(a));
  ll ans = 0LL;
  int j = 1;
  rep(i,n) {
    ans += a[j];
    j += 2;
  }
  cout << ans << endl;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(ll n,a,b;cin>>n>>a>>b&&n|a|b;){
		vl xs(n);
		for(auto& x:xs) cin>>x;
		ll res=0;
		rep(i,n-1)
			res+=min(a*(xs[i+1]-xs[i]),b);
		cout<<res<<endl;
	}
}


Measured memory_bytes: 1024
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var W = Number(inputs[0]);
    var H = Number(inputs[1]);
    var x = Number(inputs[2]);
    var y = Number(inputs[3]);
    var r = Number(inputs[4]);
  
    var x0 = W - x - r;
    var x1 = W - x + r;
    var y0 = H - y - r;
    var y1 = H - y + r;
  
    if ((x0 >= 0 && x1 <= W) && (y0 >= 0 && y1 <= H)) {
        console.log('Yes');
    } else {
        console.log('No');
    }
  
  
  
  
  
  
  
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15560
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

const int N = 17;
int ans[(1<<N)+3];
int cnt[(1<<N)+3];
int tmp[(1<<N)+3];
int n,A,B;

void solve(int x,int a,int ret[])
{
	if(x==0) {ret[0] = 0; return;}
	if(x==1) {ret[0] = 0; ret[1] = 1; return;}
	if(a&(1<<(x-1)))
	{
		solve(x-1,1,ret);
		solve(x-1,a^((1<<(x-1))+1),ret+(1<<(x-1)));
//		printf("Case 1\n");
//		printf("ret: "); for(int i=0; i<(1<<x); i++) printf("%d ",ret[i]); puts("");
		for(int i=(1<<(x-1)); i<(1<<x); i++) ret[i] = ret[i]^((1<<(x-1))+1);
//		printf("RET: "); for(int i=0; i<(1<<x); i++) printf("%d ",ret[i]); puts("");
	}
	else
	{
		solve(x-1,a,ret);
		solve(x-1,ret[1],ret+(1<<(x-1)));
//		printf("Case 2\n");
//		printf("ret: "); for(int i=0; i<(1<<x); i++) printf("%d ",ret[i]); puts("");
		for(int i=(1<<(x-1)); i<(1<<x); i++) ret[i] = ret[i]^(1<<(x-1));
//		printf("Ret: "); for(int i=0; i<(1<<x); i++) printf("%d ",ret[i]); puts("");
		tmp[0] = ret[0]; for(int i=0; i<(1<<(x-1)); i++) tmp[i+1] = ret[i+(1<<(x-1))];
		for(int i=((1<<(x-1))+1); i<(1<<x); i++) tmp[i] = ret[i-(1<<(x-1))];
		for(int i=0; i<(1<<x); i++) ret[i] = tmp[i];
//		printf("RET: "); for(int i=0; i<(1<<x); i++) printf("%d ",ret[i]); puts("");
	}
//	printf("solve(%d %d add=%d)\n",x,a,ret-ans);
}

int main()
{
	scanf("%d%d%d",&n,&A,&B); B^=A;
	for(int i=1; i<(1<<n); i++) cnt[i] = cnt[i>>1]+(i&1);
	if((cnt[B]&1)==0) {puts("NO"); return 0;}
	puts("YES");
	solve(n,B,ans);
//	puts("ansA: "); for(int i=0; i<(1<<n); i++) printf("%d ",ans[i]); puts("");
	for(int i=0; i<(1<<n); i++) ans[i]^=A;
	for(int i=0; i<(1<<n); i++) printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int count=0;

void MErge(int*,int,int,int,int);
void MErgeSort(int*,int,int,int);

int main(){
  int h,i,H[MAX];
  
  scanf("%d",&h);
  for( i = 0 ; i < h ; i++ ){
  scanf("%d",&H[i]);
  }

  MErgeSort(H,h,0,h);

  for( i = 0 ; i < h ; i++ ){
    if( i > 0 )printf(" ");
    printf("%d",H[i]);
  }

  printf("\n");
  printf("%d\n",count );

  return 0;
}
void MErge(int H[],int h,int l,int m,int r){
  int x1,x2,i,j,k;

  x1=m-l;
  x2=r-m;
  for(i=0;i<x1;i++){
    L[i]=H[l+i];
  }
  for(i=0;i<x2;i++){
    R[i]=H[m+i];
  }
  L[x1]=R[x2]=SENTINEL;

  i=0;
  j=0;
  for( k = l ; k < r ; k++ ){
    count++;
    if(L[i]<=R[j]){
      H[k]=L[i++];
    }
    else{
      H[k]= R[j++];
    }
  }
}

void MErgeSort(int H[],int h,int l,int r){
  int x;
  if(l+1<r){
    x=(l+r)/2;
      MErgeSort(H,h,l,x);
    MErgeSort(H,h,x,r);
    MErge(H,h,l,x,r);
  }
}
      
  



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

N = int(input())

A = [1]
i = 1
while 6 ** i <= 100000:
    A.append(6 ** i)
    i += 1
j = 1
while 9 ** j <= 100000:
    A.append(9 ** j)
    j += 1
A.sort()

table = [1000000 for _ in range(N + 1)]
table[0] = 0

for i in range(1, N+1):
    a = 0
    while 6 ** a <= i:
        table[i] = min(table[i], table[i - 6 ** a] + 1)
        a += 1
    b = 0
    while 9 ** b <= i:
        table[i] = min(table[i], table[i - 9 ** b] + 1)
        b += 1

print(table[N])


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

ll prime[MAXN];
ll vis[MAXN];
ll cnt;
ll n;
void isprime()
{
    cnt=0;
    for(int i=2; i<=MAXN; i++)
    {
        if(!vis[i])prime[cnt++]=i;
        for(int j=0; j<cnt && i*prime[j]<=MAXN; j++)
        {
            vis[i*prime[j]]=i;
            if(i%prime[j]==0)break;
        }
    }
}
ll qpow(ll a,ll b)
{
    ll ans=1,base=a;
    while(b!=0)
    {
        if(b&1!=0)ans*=base;
        base*=base;
        b>>=1;
    }
    return ans;
}
int main()
{
    ll n,p;
    isprime();
    //for(int i=0;i<cnt;i++)printf("%lld ",prime[i]);
    scanf("%lld%lld",&n,&p);
    ll sum=p;
    ll ans=1;
    for(int i=0; i<cnt && prime[i]<=sum; i++)
    {
        int k=0;
        while(sum%prime[i]==0)
        {
            sum/=prime[i];
            k++;
        }
        //printf("%lld\n",sum);
        if(k>=n)ans*=qpow(prime[i],k/n);

    }
    if(n==1 && sum>1)ans*=sum;//多出一个素数来
    printf("%lld\n",ans);

    return 0;
}


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

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<char>> S(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S.at(i).at(j);
    }
  }
  vector<vector<int>> ans(H, vector<int>(W));
  for (int i = 0, cnt = 1; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S.at(i).at(j) == '#') ans.at(i).at(j) = cnt++;
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0, tmp = 0; j < W; j++) {
      if (ans.at(i).at(j) != 0) tmp = ans.at(i).at(j);
      else ans.at(i).at(j) = tmp;
    }
    for (int j = W - 1, tmp = 0; j >= 0; j--) {
      if (ans.at(i).at(j) != 0) tmp = ans.at(i).at(j);
      else ans.at(i).at(j) = tmp;
    }
  }
  vector<int> tmp(W);
  for (int i = 0; i < H; i++) {
    if (*max_element(ans.at(i).begin(), ans.at(i).end()) == 0) {
      ans.at(i) = tmp;
    } else {
      tmp = ans.at(i);
    }
  }
  vector<int> tmp2(W);
  for (int i = H - 1; i >= 0; i--) {
    if (*max_element(ans.at(i).begin(), ans.at(i).end()) == 0) {
      ans.at(i) = tmp2;
    } else {
      tmp2 = ans.at(i);
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (j) cout << " ";
      cout << ans.at(i).at(j);
    }
    cout << "\n";
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A, B, x; cin >> A >> B;
  if((B - 1) % (A - 1) != 0)
   x = (B - 1) / (A - 1) + 1;
  else
    x = (B - 1) / (A - 1);
  cout << x << endl;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            double sum = 0;
            for (int i = 0; i < N; i++)
            {
                string[] input=Console.ReadLine().Split(' ');
                double price = double.Parse(input[0]);
                if (input[1]=="BTC")
                {
                    sum = sum + 380000 * price;
                }
                else
                {
                    sum = sum + price;
                }
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 11220
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y
from math import ceil

for _ in range(int(input()) if not True else 1):
    #n = int(input())
    s = input()
    if sum(int(k) for k in s) % 9 == 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 69392
#include <bits/stdc++.h>
using namespace std;
int a[200005], last[200005];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long n, k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		last[i]=-1;
	}
	int cur=1, mod;
	last[cur]=0;
	for(int i=1;i<500000;i++){
		if(last[a[cur]]!=-1){
			mod=i-last[a[cur]];
			break;
		}
		last[a[cur]]=i;
		cur=a[cur];
		if(k==i){
			cout<<cur;
			return 0;
		}
	}
	int reps=(k-500000+mod-1)/mod;
	reps=k-reps*mod;
	cur=1;
	for(int i=1;i<=reps;i++){
		cur=a[cur];
	}
	cout<<cur;

}

Measured memory_bytes: 5252
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

Int N, K;
Int A[100005];

int main() {
    ios::sync_with_stdio(false);
    // cin >> N >> K;
    // for (Int i = 0; i < N; i++) cin >> A[i];
    string s;
  cin >> s;
  Int a, b, c;
  a = b = c = 0;
  Int add = 1;
  for (Int i = 0; i < (Int)s.size(); i++) {
    if (s[i] == 'A') {
      a += add;
      //a %= mod;
    }
    else if (s[i] == 'B') {
      b += a;
      //b %= mod;
    }
    else if (s[i] == 'C') {
      c += b;
      //c %= mod;
    }
    else if (s[i] == '?') {
      c = (c * 3 + b) % mod; 
      b = (b * 3 + a) % mod; 
      a = (a * 3 + add) % mod;
       add = add * 3 % mod;
    }
   
  }
  cout << c % mod << '\n';
    return 0;
}

Measured memory_bytes: 512
import math
n,a,b = map(int, input().split())

m = [0] * n
for i in range(n):
  m[i] = int(input())
  

m.sort()


def enough(m,a,b,T):
  cnt = 0
  for hp in m:
    if hp > b*T:
      cnt += int(math.ceil((hp - b*T)/(a-b)))
      
  return True if  cnt <= T else False

r = 10**10
#r = 30
l = 0
mid = 0

while r - l > 1:
  mid = (r+l)//2
  if enough(m,a,b,mid) == True:
    r = mid
    #print("r:",r)
  else:
    l = mid
    #print("l:",l, " r:",r)

print(r)

Measured memory_bytes: 7472
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication26
{
    class Program
    {
        static void Main()
        { string s = Console.ReadLine();int i = 0;
            while (true)
            {
                string[] a = Console.ReadLine().Split();
                for(int b = 0; b < a.Length; b++)
                {
                    if (a[b] == "END_OF_TEXT") goto x;
                    if (s.Length != a[b].Length) continue;
                    for(int c = 0; c < a[b].Length; c++)
                    {
                        if (a[b][c] > 96)
                        {
                            if (a[b][c] != s[c] && a[b][c] != s[c] + 32) break;
                        }
                        else { if (a[b][c] != s[c] && a[b][c] != s[c] - 32) break; }
                        if (a[b].Length - 1 == c) i++;
                    }
                }
            }
        x:;Console.WriteLine(i);
        }
    }
}

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

using lint = long long;

int main() {
	lint N, X, M;
	cin >> N >> X >> M;

	vector<lint> beki(M, 0);
	for (int i = 0; i < M; i++) beki[i] = (lint)i * i % M;

	if (N <= 10000000) {
		lint ans = 0;
		lint now = X;
		for (int i = 0; i < N; i++) {
			ans += now;
			now = beki[now];
		}
		cout << ans << endl;
		return 0;
	}

	vector<int> visited(M, 0);
	lint now = X;
	while (1) {
		visited[now]++;
		if (visited[now] == 3) {
			int cnt1 = 0, cnt2 = 0, cnt3 = 0;
			for (int i = 0; i < M; i++) {
				if (visited[i] == 1) cnt1++;
				else if (visited[i] == 2) cnt2++;
				else if (visited[i] == 3) cnt3++;
			}
			lint ans = 0;
			N -= cnt1;
			for (int i = 0; i < M; i++) if (visited[i] == 1) ans += i;
			lint loop_sum = 0;
			for (int i = 0; i < M; i++) if (visited[i] == 2 || visited[i] == 3) loop_sum += i;
			ans += (lint)loop_sum * (N / (cnt3 + cnt2));
			for (int i = 0; i < N % (cnt3 + cnt2); i++) {
				ans += now;
				now = beki[now];
			}
			cout << ans << endl;
			return 0;
		}
		else {
			now = beki[now];
		}
	}

	
	return 0;
}

Measured memory_bytes: 4280
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>

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

struct Monoid {
  int64_t val;
  Monoid() {}
  Monoid(int64_t v) : val(v) {}
  static Monoid ident() { return Monoid((1LL << 31) - 1); }
  static Monoid multiply(Monoid l, Monoid r) {
    return Monoid(min(l.val, r.val));
  }
};

template <typename M>
struct SegmentTree {
  int n;
  M e;
  vector<M> dat;
  SegmentTree(int N, vector<M> a) {
    assert(N == (int)a.size());
    n = 1;
    e = M::ident();
    while (n < N) {
      n *= 2;
    }
    dat.resize(n * 2 - 1, e);
    rep(i, N) dat[i + n - 1] = a[i];
    for (int i = n - 2; i >= 0; i--) {
      dat[i] = M::multiply(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
  }
  M get(int i) { return dat[i + n - 1]; }
  void update(int i, M m) {
    auto k = i + n - 1;
    dat[k] = m;
    while (k) {
      k = (k - 1) / 2;
      dat[k] = M::multiply(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }
  M query(int ql, int qr) { return query(ql, qr, 0, 0, n); }
  M query(int ql, int qr, int i, int il, int ir) {
    if (ql <= il and ir <= qr) {
      return dat[i];
    } else if (qr <= il or ir <= ql) {
      return e;
    } else {
      auto m = (il + ir) / 2;
      return M::multiply(query(ql, qr, i * 2 + 1, il, m),
                         query(ql, qr, i * 2 + 2, m, ir));
    }
  }
};

int main() {

  int n, q;
  scanf("%d %d", &n, &q);
  vector<Monoid> a;
  SegmentTree<Monoid> seg(n, vector<Monoid>(n, Monoid((1LL << 31) - 1)));
  while (q--) {
    int t;
    scanf("%d", &t);
    if (t == 0) {
      int i, x;
      scanf("%d %d", &i, &x);
      seg.update(i, Monoid(x));
    } else {
      int l, r;
      scanf("%d %d", &l, &r);
      printf("%ld\n", seg.query(l, r + 1).val);
    }
  }

  return 0;
}



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

using namespace std;
typedef long long ll;

string S;
int num, ans;

int main ()
{
	cin >> S;

	for ( int i = 0; i < S.length() - 2; i++ )
	{
		num = 0;
		for ( int j = i; j < i + 3; j++ )
			num *= 10, num += (S[j] - '0');
		if ( i == 0 )
			ans = abs ( 753 - num );
		ans = min ( ans, abs ( 753 - num ) );
	}

	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();

        long diffA = Math.min(A, K);
        A -= diffA;
        K -= diffA;
        B -= Math.min(B, K);

        System.out.println(A+" "+B);
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793;
const long double DEL = 1e-10;
const int mod =  1000000007;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define vvpii vector<vector<pair<int,int>>>
#define ftt cin>>t;for(int tt=1;tt<=t;++tt)
#define Rev(v) reverse(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define mem(a,b) memset(a,b,sizeof(a))
#define forr(i,a,b) for(i=a;i<=b;i++)
#define umii unordered_map<int,int>
#define vpii vector<pair<int,int>>
#define all(a) a.begin() , a.end()
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define sqr(a) (((a) * (a)))
#define double long double
#define dbg cout<<"\nhi\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define vi vector<int>
#define int long long
#define nl cout<<"\n"
#define pb push_back
#define sp <<" "<<
#define ss second
#define ff first
inline void read(int &x)
{
      int c = getchar();
      x = 0;
      int neg = 0;
      for(; ((c<48 || c>57) && c != '-'); c = getchar());
      if(c=='-')
      {
            neg = 1;
            c = getchar();
      }
      for(; c>47 && c<58 ; c = getchar())
      {
            x = (x<<1) + (x<<3) + c - 48;
      }
      if(neg)
      {
            x = -x;
      }
}
int fpow(int x, int n)
{
    int res = 1;
    while(n){
          if(n&1){
                res = res * x % mod;
          }
          x = x * x % mod;
          n>>=1;
    }
    return res;
}
int gcd(int a,int b)
{
    if(b == 0)
    {
          return a;
    }
    return gcd(b,a % b);
}
void sieve(int n)
{
      bool prime[1000006];
      memset(prime, true, sizeof(prime));
      int rootn = (int)sqrt(n);
      for (int p = 2; p <= rootn; p++)
      {
            if (prime[p] == true)
            {
                  for (int i = p*p; i <= n; i += p)
                  {
                        prime[i] = false;
                  }
            }
      }
      prime[1] = 0;
}
const int N = 100050;
int cnt, sum, mid, mx, mn, ans, a[N], b[N];
int n, m, d, i, j, k, l, p, q, r, t, w, x, y, z;
bool f, f1, f2;
string s;

//******************************************* CHECK CONSTRAINTS **************************************************


int32_t main()
{     fio;
      cin>>n;
      vi likes(n+2);
      forr(i,1,n)
      {
            forr(j,0,n-1)
            {
                  cin>>x;
                  likes[i] |= ((1LL&x)<<j);
            }
      }
      vi dp(1LL<<n);
      dp[0] = 1;
      for(int mask = 1; mask < (1LL<<n) ; mask++)
      {
            x = __builtin_popcount(mask);
            forr(k,0,n-1)
            {
                  if(mask&(1LL<<k)&likes[x])
                  {
                        dp[mask] += dp[mask^(1LL<<k)];
                        dp[mask]%=mod;
                  }
            }
      }
      cout<<dp[(1LL<<n)-1];
     
}


Measured memory_bytes: 19552
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    a = list(map(int, input().split()))
    for i in range(5):
        if a[i] == 0:
            print(i+1)
            return
main()


Measured memory_bytes: 9460
// 2^n 全探索

#include  <iostream>
#include  <vector>
#include  <cstdlib>
#include  <cmath>

long long solve0(long long var); // bit全探索
long long solve1(long long var); // 再起全探索
long long solve11(long long p, int q); // 再起全探索(探索の実体)


int main(void)
{
	long long n;
	std::cin >> n;

	long long ans = 0;
	ans = solve0(n);
	//ans = solve0(n);

	std::cout << ans << std::endl;

	return EXIT_SUCCESS;
}

long long solve0(long long var)
{
	long long rtn = 0;
	int d = (int)std::log10(var) + 1;

	// 全パターン探索
	for(int bit = 0; bit < (1 << d-1); ++bit) {
		std::vector<long long> v;
		long long p = var, q = std::pow(10, d-1);

		for(int i = 0; i < d; ++i) {	
			if(bit & (1 << i)) {
				v.push_back(p / q);
				p = p % q;
			}
			q = q / 10;
		}

		v.push_back(p);

		for(std::vector<long long>::iterator it = v.begin(); it != v.end(); ++it)
			rtn += *it;
	}

	return rtn;
}

long long solve1(long long var)
{
	long long rtn = 0;
	int d = (int)std::log10(var) + 1;

	rtn = solve11(var, std::pow(10, d-1));

	return rtn;
}

long long solve11(long long p, int q)
{
	long long rtn = 0;

	if(q == 0)
		return p;
	else
		// (1) '+'を挿入する, (2) '+'を挿入しない
		rtn = solve11(p % q, q / 10) + solve11(p, q / 10);

	return rtn;
}



Measured memory_bytes: 4016
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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


MY_NAMESPACE(ABC169A)
int main()
{
	int a, b;
	cin >> a >> b;
	cout << a * b << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;
    
    vector<vector<pair<ll, ll>>> G(n);
    rep(i, n-1) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;  b--;
        G[a].pb(make_pair(b, c));
        G[b].pb(make_pair(a, c));
    }

    ll q, k;
    cin >> q >> k;
    k--;

    vl dist(n, -1);  // dist[i] : 頂点iの根からの距離
    queue<ll> Q;

    const ll root = k;  // 根は頂点k
    dist[root] = 0;
    Q.push(root);
    while(!Q.empty()) {
        ll v = Q.front();
        Q.pop();
        for(auto p : G[v]) {
            ll u = p.first;
            ll cost = p.second; 
            if(dist[u] != -1) {
                continue;
            }
            dist[u] = dist[v] + cost;
            Q.push(u);
        }
    }

    rep(i, q) {
        ll x, y;
        cin >> x >> y;
        x--;  y--;
        out(dist[x] + dist[y]);
    }
    
    re0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int arr[maxn], n;
int main(void) {
    while(~scanf("%d", &n)) {
        for(int i = 1; i <= n; ++i)
            scanf("%d", arr + i);
        int cnt = 0;
        for(int i = 1; i < n; ++i) {
            if(arr[i] == i) {
                swap(arr[i], arr[i + 1]);
                cnt++;
            }
        }
        if(arr[n] == n) ++cnt;
        printf("%d\n", cnt);
    }
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll n;
	vector<ll> v1, v2;

	cin >> n;

	REP(i, n) {
		ll a;
		cin >> a;
		v1.push_back(a);
		v2.push_back(a);
	}

	ll ans1 = 0;
	ll sum1 = 0;

	REP(i, n) {
		sum1 += v1[i];
		if (i % 2 == 0 && sum1 <= 0) {
			ans1 += abs(sum1) + 1;
			sum1 += abs(sum1) + 1;
		}
		else if (i % 2 == 1 && sum1 >= 0) {
			ans1 += sum1 + 1;
			sum1 -= sum1 + 1;
		}
	}

	ll ans2 = 0;
	ll sum2 = 0;

	REP(i, n) {
		sum2 += v2[i];
		if (i % 2 == 0 && sum2 >= 0) {
			ans2 += sum2 + 1;
			sum2 -= sum2 + 1;
		}
		else if (i % 2 == 1 && sum2 <= 0) {
			ans2 += abs(sum2) + 1;
			sum2 += abs(sum2) + 1;
		}
	}

	cout << min(ans1, ans2) << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

string solve(){
    int n; cin >> n;
    reps(i,1,9)reps(j,1,9){
            if(i*j==n) return "Yes";
    }
    return "No";
}

signed main(){
    cout << solve() << endl;
}

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

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n;
int len[100];
char word[100][100];
int memo[14][1 << 14];
int memo2[20][20];

int calc2(int next, int prev) {
  if (memo2[next][prev] != -1) { return memo2[next][prev]; }
  int ret = len[next];
  REP(i, len[prev]) {
    bool ok = true;
    FOR(j, i, len[prev]) {
      if (word[prev][j] != word[next][j - i]) { ok = false; break; }
    }
    if (ok) { ret = len[next] - (len[prev] - i); break; }
  }
  return memo2[next][prev] = ret;
}

int calc(int prev, int use) {
  if (use == (1 << n) - 1) { return 0; }
  if (memo[prev][use] != -1) { return memo[prev][use]; }
  int ret = 1 << 30;
  REP(i, n) {
    if (use & (1 << i)) { continue; }
    int nuse = use | (1 << i);
    int d = calc2(i, prev);
    ret = min(ret, calc(i, nuse) + d);
  }
  return memo[prev][use] = ret;
}

int main() {
  while (scanf("%d", &n), n) {
    MEMSET(memo, -1);
    MEMSET(memo2, -1);
    REP(i, n) {
      scanf("%s", word[i]);
      len[i] = strlen(word[i]);
    }
    int use = 0;
    REP(i, n) {
      REP(j, n) {
        if (i == j) { continue; }
        if (strstr(word[j], word[i]) == NULL) { continue; }
        use |= 1 << i;
      }
    }
    int ans = 1 << 30;
    REP(i, n) {
      if (use & (1 << i)) { continue; }
      ans = min(ans, calc(i, use | (1 << i)) + len[i]);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1800
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
	int n; cin >> n;
  vector<string>w(n);
  for(int i; i<n; i++) cin >> w[i];
  for(int i; i<n-1; i++){
    if ( w[i].back() != w[i+1].front() ) {
		cout << "No" << endl; exit(0);
    }
  }
  for(int i; i<n; i++){
    for(int j = i+1; j<n; j++){
      if(w[i]==w[j]){
        cout << "No" << endl;  exit(0);
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

void dfs(vector<vector<int>> &tree, int now, int bf, vector<int> &ans, int o, vector<int> &leaf, bool mode){
	bool flag = true;
	for(int i : tree.at(now)){
		if(i == bf) continue;
		ans.at(i) = ans.at(now) + 1;
		flag = false;
		if(i == o){
			leaf.push_back(i);
		}
		dfs(tree, i, now, ans, o, leaf, mode);
	}
	if(mode == true && flag == true) leaf.push_back(now);
}

int main(){
	int n, u, v;
	cin >> n >> u >> v;
	u--; v--;
	vector<vector<int>> tree(n, vector<int>());
	rep(i, n-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		tree.at(a).push_back(b);
		tree.at(b).push_back(a);
	}
	// cerr << "tst" << endl;
	vector<int> u_d(n, 1001001), v_d(n, 1001001), leaf;
	u_d.at(u) = 0;
	dfs(tree, u, -1, u_d, v, leaf, false);
	v_d.at(v) = 0;
	dfs(tree, v, -1, v_d, u, leaf, true);
	int ans = 0;
	for(int i : leaf){
		// cerr << i << ":" << u_d.at(i) << " " << v_d.at(i) << endl;
		if(u_d.at(i) < v_d.at(i)){
			ans = max(ans, v_d.at(i));
		}
	}
	ans--;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 16896
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long long C[60][60];
int main(){
	C[0][0]=1;
	for(int i=0;i<55;i++){
		for(int j=0;j<=i;j++){
			C[i+1][j]=C[i][j]+C[i+1][j];
			C[i+1][j+1]+=C[i][j];
		}
	}
	int s=0;
	int t=0;
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		int p;scanf("%d",&p);
		if(p%2)s++;
		else t++;
	}
	long long ret=0;
	for(int i=0;i<=s;i++){
		for(int j=0;j<=t;j++){
			if(i%2==b)ret+=C[s][i]*C[t][j];
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 128
#include <stdio.h>
#define MAX 100000+45
#define NIL -1

typedef struct node_ {
    int parent;
    int left;
    int right;
    
} Node;

Node T[MAX];

int arg(int v) {
    int f = 0;
    for (f=0;T[v].parent != NIL;f++) {
        v = T[v].parent;     
    }
    return f;
}




void print(int u) {
    int i;
    int mid;
    int c = T[u].left;
	printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("depth = %d, ", arg(u));
    if (T[u].parent == NIL) {
        printf("root, ");
    } else if (T[u].left == NIL) {
        printf("leaf, ");
    } else {
        printf("internal node, ");
    }
    printf("[");
    for (i = 0; c != NIL; i++) {
        if (i) printf(", ");printf("%d", c);
        c = T[c].right;
    }
    printf("]\n");
}

int main(void) {
    int i, j;
    int n;
	int c; 
	int key, k, left;
    scanf("%d", &n);
    i = 0;
	while (i < n) {
        T[i].parent = NIL;
        T[i].left = NIL;
        T[i].right = NIL;
          i++;
    }
    for (i = 0; i < n; i++) {
        scanf("%d %d", &key, &k);
        for (j = 0; j < k; j++) {
            
            scanf("%d", &c);
            if (j == 0) T[key].left = c;
            else T[left].right = c;
            left = c;
            T[c].parent = key;
        }
    }

    for (i = 0; i < n; i++) {
        print(i);
    }

    return 0;
}


Measured memory_bytes: 2892
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
 
#define INF (1<<26)
struct edge{int to,cost,key;};
struct state{
  int pos,pos2,S,cost;  
  bool operator < (const state &p)const{    return cost > p.cost;  }
};
 
vector<edge> g[200];
int N,M,E,Si,Ti,R;
int c[200];
vector<int> nodes;
int dp[105][105];
int d[105][205][300];
 
void solve(){
  for(int i=0;i<105;i++)
    for(int j=0;j<205;j++)
      for(int k=0;k<300;k++)
    d[i][j][k]=INF;
 
  priority_queue<state> Q;
  int a=0;
  if(c[Si]!=-1)a=(1<<c[Si]);
  Q.push((state){Si,0,a,0});
  d[Si][0][a]=0;
 
  while(!Q.empty()){
    state s=Q.top();Q.pop();
    if(d[s.pos][s.pos2][s.S]<s.cost)continue;
    if(s.pos==Ti){cout<<s.cost<<endl;return;}
    if(s.pos2>R)continue;
    if(d[Si][0][s.S]>s.cost+1){
      d[Si][0][s.S]=s.cost+1;
      Q.push((state){Si,0,s.S,s.cost+1});
    }
 
    for(int i=0;i<(int)nodes.size();i++){      
      int to=nodes[i];
      if(dp[s.pos][to]==INF)continue;
      int ncost=s.cost+dp[s.pos][to];
      int nS=s.S;
      int npos2=s.pos+dp[s.pos][to];
      if(c[to]!=-1)nS|=(1<<c[to]);
      if(d[to][npos2][nS]<=ncost)continue;
      d[to][npos2][nS]=ncost;
      Q.push((state){to,npos2,nS,ncost});
    }
     
    for(int i=0;i<(int)g[s.pos].size();i++){
      edge e=g[s.pos][i];
      if(!((s.S>>e.key)&1))continue;
      int to=e.to;
      int ncost=s.cost+e.cost;
      int nS=s.S;
      int npos2=s.pos+e.cost;
      if(c[to]!=-1)nS|=(1<<c[to]);
      if(d[to][npos2][nS]<=ncost)continue;
      d[to][npos2][nS]=ncost;
      Q.push((state){to,npos2,nS,ncost});
    }
  }
  cout<<-1<<endl;
}
 
int main(){
  for(int i=0;i<105;i++){
    c[i]=-1;
    for(int j=0;j<105;j++)dp[i][j]=(i==j?0:INF);
  }
 
  cin>>N>>M>>E>>Si>>Ti>>R;
  int x,y,z;
  for(int i=0;i<M;i++){
    cin>>x>>y;
    dp[x][y]=dp[y][x]=min(dp[x][y],1);
  }
 
  for(int i=0;i<E;i++){
    cin>>x>>y>>z;
    g[x].push_back((edge){y,1,i});
    g[y].push_back((edge){x,1,i});
    c[z]=i;
    nodes.push_back(x);
    nodes.push_back(y);
    nodes.push_back(z);
  }
  nodes.push_back(Si);  nodes.push_back(Ti);
  for(int k=0;k<N;k++)
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++)
    dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
 
  solve();
  return 0;
}

Measured memory_bytes: 28412
#include <stdio.h>

int main(){
  int n,q,i,key,lb,ub,mid;
  int S[100000],ans = 0;

  scanf("%d" ,&n);

  for(i = 0 ; i < n ; i++){
    scanf("%d" , S + i);
  }

  scanf("%d" ,&q);
  
  for(i = 0 ; i < q ; i++){
    
    scanf("%d" ,&key);
    lb = 0; ub = n;
    
    while(ub >= lb){
      mid = (lb + ub) / 2;

      if(S[mid] == key){
	ans++;
	break;
      }

      if(S[mid] < key){
	lb = mid+1;
      }
      else{
	ub = mid-1;
      }
    }
  }
  printf("%d\n" ,ans);

  return 0;
}



Measured memory_bytes: 2120
#include<iostream>
using namespace std;
 
int main(){
  
  int x,y;
  
  cin>>x>>y;
  
    int tmp = y - 2*x;
  
  if(tmp > 2*x){
    cout<<"No";
    return 0;
  
  }
  
  if(y%2 != 0){
    cout<<"No";
    return 0;
  }
  
  bool yes = false;
  
  if(x*2 > y){
    cout<<"No";
    return 0;
  }
  
    if(y/4 > x){
    cout<<"No";
    return 0;
  }
  

  
  for(int i = 0;i <= x;i++){
    int k = x-i;
    
    for(int j = 0;j <= k;j++){
      if(i*2 + j*4 == y){
        yes = true;
      }
    
    
    }
  
  }
  
  if(yes){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
  
  
  
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long


int main() {
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		string hoge = to_string(i);
		if (hoge.length()% 2 == 1)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int n,m,a[110000],r[110000];
priority_queue<int> que;
signed main(){
  cin>>n>>m;rep(i,n)cin>>a[i];
  sort(a,a+n,greater<int>());
  r[0] = a[0];
  repd(i,1,n)r[i] = a[i]+r[i-1];
  int ng = INF, ok = 0, ans = 0;
  while(abs(ng-ok) > 1){
    int mid = (ok+ng)/2;
    int cnt = 0, sum = 0;
    rep(i,n){
      auto itr = upper_bound(a, a+n, mid-a[i], greater<int>());
      if(itr != a){
        int ind = itr-a;
        cnt += ind;
        sum += r[ind-1]+a[i]*ind;
      }
    }
    if(cnt > m)sum -= (cnt-m)*mid;
    (cnt >= m ? ok : ng) = mid;
    ans = (cnt >= m ? sum : ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main(){
    int a[5];

    rep(i,4)cin>>a[i];

    int e=0,b=0,c=0,d=0;
    int f=0;
    rep(i,4){
        if(a[i]==1)++e;
        else if(a[i]==7)++b;
        else if(a[i]==9)++c;
        else if(a[i]==4)++d;
    }
    if(e==1){
        if(b==1){
            if(c==1){
                if(d==1)++f;
            }
        }
    }
    if(f==0)cout<<"NO";
    else cout<<"YES";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int n, m;
	cin >> n;
	cin >> m;
	int a[1000] = {};
	int b[1000] = {};
	int point[1000] = {};
	int selected;

	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < m; i++){
		cin >> b[i];
	}

	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			if(a[j] <= b[i]){
				point[j]++;
				break;
			}
		}
	}

	selected = 0;
	for(int i = 1; i < n; i++){
		
		if(point[selected] < point[i]){
			selected = i;
		}
	}

	cout << selected + 1 << endl;
	return 0;
}

Measured memory_bytes: 1172
# include "bits/stdc++.h"
 
using namespace std;
 
#define endl "\n"
typedef long long int ll;
#define f first
#define s second
 
inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}
 
//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
 
ll INF = 1e10;
int MOD = 1e9+7;

int main(){
    fastio();

    int n;
    cin >> n;
    cout << n * n * n;

    return 0;
}

/*

*/

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

vi v;

void dfs(int a){
    if(a>3234566667) return;
    else v.eb(a);
    string S=to_string(a);
    rep(i,10){
        if(abs(S[SZ(S)-1]-'0'-i)<=1){
            string T=S;
            T+=(char)('0'+i);
            int x=stoll(T);
            dfs(x);
        }
    }
}

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

    rep(j,9) dfs(j+1);
    sort(all(v));
    int N; cin >> N;
    cout << v[N-1] << endl;
}

Measured memory_bytes: 1400
#include<stdio.h>
int main(void)
{
	char S[100001];
	//for (int i = 0; i < 100000&&S[i]!='\0'; i++) {
	scanf("%s", S);
	int count[26] = { 0 };
	//for (int i = 0; i < 26; i++) count[i] = 0;
	for (int j = 0; S[j] != '\0'; j++) {
		for (int i = 0; i < 26; i++) {
			char c = 'a' + i;
			if (S[j] == c)
				count[i]++;
		}
	}
	//for (int i = 0; i < 26; i++) {
	//	printf("%c: %d\n", 'a' + i, count[i]);
	//}
	for (int i = 0; i < 26; i++) {
		char c = 'a' + i;
		if (count[i] == 0) {
			printf("%c", c);
			return 0;
		}
	}
	printf("None");

	/*for (char c = 'a'; c <= 'z'; c++) {
		if()*/
	

	return 0;


	

}

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl


const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	lli N, X;
	cin >> N >> X;
	vector<lli> v(N);

	for (int i = 0; i < N; i++) {
		cin >> v[i];
		v[i] = abs(v[i] - X);
	}

	if (N == 1) {
		cout << v[0] << endl;
		return 0;
	}
	lli ans = v[0];
	for (int i = 1; i < N; i++) {
		ans = __gcd(ans, v[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int main(){
    long long n;
    cin >> n;
    long long sum = 0;
    while(n){
        if(n % 3 != 0 && n % 5 != 0)
            sum +=n;
        n--;
    }
    cout << sum <<endl;
}


Measured memory_bytes: 3536