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

using namespace std;

#define LCM(a,b)                (a / __gcd(a,b) ) *b
#define GCD(a,b)                __gcd(a,b)
#define dist(x1,y1,x2,y2)       sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define distl(x1,y1,x2,y2)      sqrtl((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define fRead(x)                freopen(x,"r",stdin)
#define fWrite(x)               freopen (x,"w",stdout)
#define LL                      long long
#define ULL                     unsigned long long
#define pb                      push_back
#define tcase                   cout<<"Case "<<C++<<": ";
#define all(a)                  a.begin(),a.end()
#define Unique(a)               sort(all(a)),a.erase(unique(all(a)),a.end
#define ABS(x)                  ((x)<0?-(x):(x))
#define min3(a,b,c)             min(a,min(b,c))
#define min4(a,b,c,d)           min(a,min(b,min(c,d)))
#define max3(a,b,c)             max(a,max(b,c))
#define max4(a,b,c,d)           max(a,max(b,max(c,d)))
#define PI                      acos(-1.0)
#define ff                      first
#define ss                      second
#define SP(x,y)                 fixed<<setprecision((y))<<(x)
#define FastRead                ios_base::sync_with_stdio(0);cin.tie(NULL);
#define FOR(x, l, r)            for (int x = l; x<=r; ++x)
#define REP(x,r)               for (int x = 0; x <r; ++x)
#define NN                      cout<<"\n";
#define NNN                     cout<<"\n------------------------------\n";

//***********************************************************************//
//                      SHAHED AHMED, CSE'15, IUT                        //
//***********************************************************************//


int h[100010];
int cost[100010];
int main()
{
        int n;
        cin>>n;

        for(int i=1;i<=n;i++)
        {
                cin>>h[i];
        }

        cost[1]= 0;
        cost[2] = cost[1] + ABS(h[2]-h[1]);

        for(int i=3;i<=n;i++)
        {
                cost[i] = min(cost[i-1]+ABS(h[i]-h[i-1]) , cost[i-2]+ABS(h[i]-h[i-2]));
        }

        
        cout<< cost[n];







}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
signed main(){
  string a,b;
  int count=0;
  cin>>a>>b;
  for(int i=0;i<3;i++){
    if(a[i]==b[i]){
      count++;
    }
  }
  cout<<count<<"\n";
  return(0);
}


Measured memory_bytes: 256
x, y = map(int, input().split())
l1 = [1, 3, 5, 7, 8, 10, 12]
l2 = [4, 6, 9, 11]
if (x in l1 and y in l1) or (x in l2 and y in l2):
    print('Yes')
else:
    print('No')

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

using namespace std;

#define ll long long

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;

void init() {
  nil = new Node;
  nil->prev = nil;
  nil->next = nil;
}

void insert(int key) {
  Node *node = new Node;
  node->key = key;

  nil->next->prev = node;
  node->next = nil->next;
  node->prev = nil;
  nil->next = node;
}

void deleteKey(int key) {
  Node *node = nil->next;
  while(node != nil) {
    if(node->key == key) {
      node->next->prev = node->prev;
      node->prev->next = node->next;
      delete node;
      break;
    }
    else node = node->next;
  }
}

void deleteFirst() {
  Node *node = nil->next;
  if(node == nil) return;

  nil->next = node->next;
  node->next->prev = nil;
  delete node;
}

void deleteLast() {
  Node *node = nil->prev;
  if(node == nil) return;

  nil->prev = node->prev;
  node->prev->next = nil;
  delete node;
}

void show() {
  Node *node = nil->next;
  while(node != nil) {
    cout << node->key << (node->next == nil ? '\n' : ' ');
    node = node->next;
  }
}

void clear() {
  while(nil->next != nil) {
    deleteFirst();
  }
}

int main() {
  init();

  string o;
  int k;
  int n;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> o;
    if(o == "deleteFirst") {
      deleteFirst();
    }
    else if(o == "deleteLast") {
      deleteLast();
    }
    else if(o == "insert") {
      cin >> k;
      insert(k);
    }
    else {
      cin >> k;
      deleteKey(k);
    }
  }

  show();
  clear();
}

Measured memory_bytes: 34236
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000


int main()
{
    int N;
    cin >> N;
    vector<string> poll(N),win;
    string S;
    int cnt=1,mcnt=1;
    for (int i=0; i<N; i++) {
        cin >> poll[i];
    }
    sort(ALL(poll));
    for (int i=0; i<N; i++) {
        if(i > 0){
            if(poll[i-1] == poll[i]){
                cnt++;
                mcnt = max(mcnt, cnt);
            } else {
                cnt = 1;
            }
        }
    }
    cnt=1;
    for (int i=0; i<N; i++) {
        if(i > 0){
            if(poll[i-1] == poll[i]){
                cnt++;
            } else {
                cnt = 1;
            }

        }

        if (cnt == mcnt) {
            win.push_back(poll[i]);
        }
    }
//    cout << mcnt << " " << win.size() << endl;
    sort(ALL(win));
    for (int i=0; i < win.size(); i++) {
        cout << win[i] << endl;
    }
    
    
    
    return 0;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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


void Main()
{
    LL n,W;cin>>n>>W;

    vector<LL> w(n),v(n);
    REP(i,n){
        cin>>w[i]>>v[i];
    }

    vector<map<LL,LL>> dp(n);
    dp[0][0] = 0;
    dp[0][w[0]] = v[0];

    FOR(i,1,n){
        /*   
        for (const auto& [w0, v0] : dp[i-1]){
            dp[i][w0] = max(v0, dp[i][w0]);
            dp[i][w0+w[i]] = max(v0+v[i], dp[i][w0+w[i]]);
        }
        */
        for(auto itr = dp[i-1].begin(); itr != dp[i-1].end(); ++itr) {
            LL w0 = itr->first;
            LL v0 = itr->second;
            dp[i][w0] = max(v0, dp[i][w0]);
            dp[i][w0+w[i]] = max(v0+v[i], dp[i][w0+w[i]]);
        }
    }

    LL result = 0;
    for(auto itr = dp[n-1].begin(); itr != dp[n-1].end(); ++itr) {
        LL w0 = itr->first;
        LL v0 = itr->second;
        if(w0 <= W){
            result = max(result,v0);
        }
    }

    cout<<result<<endl;

	return;
}

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

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

int main() {
    ll a, b, x, ans = 1;
    cin >> a >> b >> x;
    for (int i = 0; x*i <= b; i++)
    {
        if (a <= x*i) {
            ans += (b - x*i) / x;
            cout << ans << endl;
            return 0;
        }
    }
    
    cout << 0 << endl;
}

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

using namespace std;

int main(){
	
	long long int N, A, B, C, D;
	
	cin >> N >> A >> B >> C >> D;
	
	bool flag = false;
	
	for(long long int i = 0; i <= N - 1; i++){
		if(B - A <= (N - 1 - i) * D - i * C && B - A >= (N - 1 - i) * C - i * D){
			flag = true;
		}
	}
	
	if(flag){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
const LL mod=998244353;
LL fac[500010],inv[500010];
void pre()
{
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(LL i=2;i<=500000;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(LL i=2;i<=500000;i++) fac[i]=fac[i-1]*i%mod,inv[i]=inv[i-1]*inv[i]%mod;
}
LL N,K;
LL C(LL m,LL n)
{
	if(m<n) return 0;
	return fac[m]*inv[m-n]%mod*inv[n]%mod;
}
int main()
{
	pre();
	scanf("%lld %lld",&N,&K);
	if(N>K) return puts("0"),0;
	LL ans=0;
	for(int i=N;i<=K;i++) (ans+=C(K-1,i-1))%=mod;
	printf("%lld",ans);
}

Measured memory_bytes: 8064
#include<iostream>
using namespace std;
#define maxx 100005
int a[maxx];
int kk;
int n;
void partition(int left,int right)
{
	int x=a[right-1];
	kk=left;//下一个待比较的数，即可能的界限位置 
	for(int i=left;i<right-1;i++)
	{
		if(a[i]<=x)
		{
		//	cout<<a[kk]<<" "<<a[i]<<endl;
			int tt=a[kk];
			a[kk]=a[i];
			a[i]=tt;
			kk++;
		}
	}
	
	int tt=a[kk];
	a[kk]=a[right-1];
	a[right-1]=tt;
}
int main()
{
	//int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	partition(0,n);
	for(int i=0;i<n;i++)
	{
		if(i==kk+1)
			cout<<"]";
		if(i>0)
			cout<<" ";
		if(i==kk)
			cout<<"[";
		cout<<a[i];
	}
	cout<<endl;
	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REP2(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<int> vec(n);

    rep(i, n) cin >> vec[i];
    sort(vec.begin(), vec.end());

    int m = vec[n / 2];
    int ans = 0;
    while(vec[n / 2 - 1] != m){
        ans++;
        m--;
    }
    OP(ans);
}


Measured memory_bytes: 640
from sys import stdin
import sys
import math

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

ASC = -1
DESC = 1

flag_asc_desc = 0
count = 1
prev = 0
for i in A:
    if prev == 0:
        prev = i
        flag_asc_desc = 0
        continue
    
    if flag_asc_desc == ASC and i >= prev:
        prev = i
        continue
    elif flag_asc_desc == ASC and i < prev:
        prev = i
        flag_asc_desc = 0
        count += 1
    elif flag_asc_desc == DESC and i <= prev:
        prev = i
        continue
    elif flag_asc_desc == DESC and i > prev:
        prev = i
        flag_asc_desc = 0
        count += 1
    elif i == prev:
        prev = i
        continue
    elif i < prev:
        flag_asc_desc = DESC
        prev = i
    elif i > prev:
        flag_asc_desc = ASC
        prev = i
    else:
        print("error")

print(count)


Measured memory_bytes: 15020
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int N;
    cin >> N;
    lint L[N];
    rep(i,N) cin >> L[i];
    lint ans=0;
    for(int i=0;i<N;i++) for(int j=i+1;j<N;j++) for(int k=j+1;k<N;k++){
        if(L[i]!=L[j] && L[j]!=L[k] && L[k]!=L[i]){
            int num[3];
            num[0]=L[i],num[1]=L[j],num[2]=L[k];
            sort(num,num+3);
            if(num[0]+num[1]>num[2]) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int tx, ty;
	int dx, dy;
	dx = x2 - x1;
	dy = y2 - y1;

	int nx, ny;
	nx = -dy;
	ny = dx;

	tx = x2 + nx;
	ty = y2 + ny;
	cout << tx << " " << ty << " ";
	//////
	swap(nx, ny);
	nx = -nx;

	tx = tx + nx;
	ty = ty + ny;
	cout << tx << " " << ty << endl;
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	m := make(map[int]int, M)
	var p, q int
	for i := 0; i < N; i++ {
		fmt.Scan(&p)
		for j := 0; j < p; j++ {
			fmt.Scan(&q)
			m[q]++
		}
	}
	cnt := 0
	for _, v := range m {
		if v == N {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
n = int(input())

w = 0

def make_div(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors = sorted(divisors)
    return divisors

min_div = make_div(n)

if len(min_div) == 2:
    print(n - 1)
else:
    w = min_div[len(min_div)//2] - 1
    h = n // min_div[len(min_div)//2] - 1
    print(w + h)

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

int main(void){
  int cnt[26] = {0};
  char c;
  int flg;
  
  for (int i=0; i<4; i++){
    cin >> c;
    cnt[c-'A']++;
  }
  flg = 1;
  for (int i=0; i<26; i++){
    if (cnt[i]!=0 && cnt[i]!=2) flg = 0;
  }
  cout << (flg?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<iterator>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    ll n,t,l,r;
    cin >> n >> t;
    std::vector<ll> list(t+1);
    REP(i,n){
        cin >> l >> r;
        list[l]++; list[r]--;
    }
    ll ans=list[0];
    REP(i,t){
        list[i+1] += list[i];
        if(ans < list[i+1]) ans=list[i+1];
    }
    //REP(i,t+1)cout << list[i] << " ";
    //cout << endl;
    cout << ans << endl;
}


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

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

	vector<int> h(n); for (int i = 0; i < n; i++) { cin >> h[i]; }

	int ans = 1;
	
	for (int i = 1; i < n; i++) {

		bool can = true;

		for (int j = 0; j <= i; j++) {
		
			if (h[j] > h[i]) can = false;
		
		}

		if (can) ans++;

	}

	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vii vector<int>
#define mii map<int,int>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pqmin priority_queue<int,vector<int>,greater<int>>
#define pqmax priority_queue<int>
using namespace std;
int32_t main()
{
    IOS;
string s;
     cin>>s;
     if(s=="Sunny")
     cout<<"Cloudy";
     else if(s=="Cloudy")
     cout<<"Rainy";
     else
     cout<<"Sunny";
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
mod = 10**9+7
ans = 0
for i in range(K, N+2):
	l = (i - 1) * i // 2
	r = (2 * N - i + 1) * i // 2
	ans += (r - l + 1) % mod
	ans %= mod

print(ans)

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

#define pb push_back
#define mp make_pair

typedef long long ll;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
  int n, k;
  cin >> n >> k;

  map<int, int> mp;
  int cnt = 0;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    if(mp[a] == 0) cnt++;
    mp[a]++;
  }

  vector<int> v;
  for(int i = 0; i <= n; i++){
    if(mp[i]){
      v.pb(mp[i]);
    }
  }
  
  sort(v.begin(), v.end());

  int ans = 0, i = 0;
  while(cnt > k){
    ans += v[i];
    i++;
    cnt--; 
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 10748
#include<bits/stdc++.h>
#include<unordered_map>
#include<math.h>
#define ll long long
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<int>
#define vll vector<long long>
#define print(vec) for(int i=0;i<vec.size();i++) cout<<vec[i]<<" ";
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define endl '\n'

using namespace std;

int main(){
    fast_cin();
    ll n;
    cin>>n;
    ll ans=1000;
    vi ar(n,0);
    rep(i,0,n)cin>>ar[i];
    ll min=ar[0],max=ar[0];
    rep(i,1,n){
        if(ar[i]<max){
            // cout<<"---";
            ll st = floor((double)ans/min);
            ans-= st*min;
            ans+= st*max;
            min = ar[i];
            max = ar[i];
        }
        else if(ar[i]>max){
            max = ar[i];
        }
        // cout<<min<<" "<<max<<" "<<ans<<endl;
    }
    if(max>min){
        // cout<<"----";
        ll st = floor((double)ans/min);
        ans-= st*min;
        ans+= st*max;
        // cout<<min<<" "<<max<<" "<<ans<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3732
S=input()
T=["KIHBR","KIHBRA","KIHBAR","KIHBARA",
  "KIHABR","KIHABRA","KIHABAR","KIHABARA",
  "AKIHBR","AKIHBRA","AKIHBAR","AKIHABRA",
  "AKIHABR","AKIHABRA","AKIHABAR","AKIHABARA"]
ans=0
for i in range(16):
  if(S==T[i]):
    ans=1
if(ans):
  print("YES")
else:
  print("NO")



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
 #define rep(i, n) for (int i = 0; i < (int)(n); i++)
 #define big 1000000007
int main(){
    string s;
    cin >> s;
    int n = s.length();
    vector<int> l(n+2);
    vector<int> r(n+2);
    vector<int> a(n+1);
    l[0]=r[0]=0;
    l[n+1]=r[n+1]=0;
    for(int i=1;i<=n;i++){
        if(s[i-1]=='<'){
            l[i]=l[i-1]+1;
        }
        else{
            l[i]=0;
        }
    }
    for(int i=n;i>=1;i--){
        if(s[i-1]=='>'){
            r[i]=r[i+1]+1;
        }
        else{
            r[i]=0;
        }
    }
    /*
    rep(i,n+2){
        cout<<l[i]<<" ";
    }
    cout<<endl;
    rep(i,n+2){
        cout<<r[i]<<" ";
    }
    cout<<endl;
    */
    for(int i=0;i<=n;i++){
        a[i]=max(l[i],r[i+1]);
    }
    int64_t sum=0;
    rep(i,n+1){
        sum += a[i];
        //cout<<a[i]<<" ";
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 6788
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1};
typedef pair<ll, ll> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, cnt = 0;
    cin >> n;
    vector<P> red(n);
    vector<P> blue(n);
    for (int i = 0; i < n; i++) {
        cin >> red[i].first >> red[i].second;
    }
    for (int i = 0; i < n; i++) {
        cin >> blue[i].first >> blue[i].second;
    }
    vector<bool> used(n);  // この添字のblueは使われている
    sort(red.begin(), red.end());
    sort(blue.begin(), blue.end());

    for (int i = 0; i < n; i++) {
        int maxy = -1,  // ペアとなるredの最大のy
            pos = -1;   //  ペアとなっていないredの添字
        for (int j = 0; j < n; j++) {
            if (red[j].first < blue[i].first &&
                red[j].second < blue[i].second) {
                // 最大のyがredのyよりも小さい and
                // j番目のredが使われていないとき
                if (maxy < red[j].second && !used[j]) {
                    maxy = red[j].second;  // maxyを更新
                    pos = j;               // redのposを更新
                }
            }
        }
        // posの値が初期値でない=更新されたとき
        if (pos >= 0) {
            used[pos] = true;  // posのredは使われたので
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}

ll div_floor(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll div_ceil(ll a, ll b) {
	return a / b + (((a ^ b) >= 0) and a % b);
}


int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

//#############################
const int MAXN = 1000005;
ll n, k, x;
vector<ll> a;
bool isNeg;
int neg, pos, zero;
vector<ll> poss, negs;

ll f(ll x) {
    ll count = 0;
    for(int i = 0; i < n; i++){
        if (a[i] == 0 && x >= 0){
                count += n-1;
        }
        else if(a[i] > 0) {
            // a[i] * z <= x ==> z <= x / a[i]
            ll z = int(upper_bound(a.begin(), a.end(), div_floor(x, a[i])) - a.begin());
            if (z > i)
                count += z - 1;
            else
                count += z;
        } else if (a[i] < 0) {
            // a[i] * z <= x ==> z >= x / a[i]

            ll z = int(lower_bound(a.begin(), a.end(), div_ceil(x, a[i])) - a.begin());

            if (z <= i)
                count += n - z -1;
            else
                count += n - z;
        }
    }


    return count / 2;
}

int main() {
    fastIO();
    cin >> n >> k;
    a = vector<ll>(n, 0);
    neg = pos = zero = 0;

    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    ll l(-1e18-1), r = (1e18+1);
    while (abs(r - l) >= 1) {
        ll mid = l + (r - l) / 2;
        ll guess = f(mid);
        if (guess >= k)
            r = mid;
        else
            l = mid+1;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1792
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 08/29/20 20:54:54
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int h,w; cin>>h>>w;

  map<int,int> etos;
  multiset<int> distset;
  for (int i = 0; i < w; i++) {
    etos[i] = i;
    distset.insert(0);
  }
  for (int i = 0; i < h; i++) {
    int a,b; cin>>a>>b; a--; b--;
    int max_s = -1;
    {
      auto bgn = etos.lower_bound(a);
      auto end = etos.upper_bound(b+1);
      for (auto it = bgn; it != end; ++it) {
        max_s = max(max_s, it->second);
        auto dist = it->first - it->second;
        assert(distset.count(dist)>0);
        distset.erase(distset.find(dist));
      }
      etos.erase(bgn, end);
    }
    if (max_s != -1 and b+1 < w) {
      auto min_dist = b+1 - max_s;
      distset.insert(min_dist);
      assert(etos.count(b+1) == 0);
      etos[b+1] = max_s;
    }
    if (!distset.empty()) {
      cout << i+1 + *distset.begin() << endl;
    } else {
      cout << -1 << endl;
    }
  }

  return 0;
}


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

using namespace std;

#define ll long long
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int N = 1e2+5;
const int maxN = 1e5+5;

ll w[N],val[N],dp[N][maxN];
ll n,tot_w;

ll f(int w_rem,int ind){
    if(w_rem<0)
        return LLONG_MAX;
    if(w_rem==0 || ind>=n)
        return 0LL;
    if(dp[ind][w_rem]!=-1)
        return dp[ind][w_rem];
    ll ans = 0LL;
    ans = max(ans,f(w_rem,ind+1));
    ans = max(ans,val[ind]+f(w_rem-w[ind],ind+1));
    //cout<<ans<<endl;
    return dp[ind][w_rem] = ans;

}


void solve(){
    cin>>n>>tot_w;
    for(int i=0;i<n;i++)
        cin>>w[i]>>val[i];
    ll k = -1;
    for(int i=0;i<n;i++)
        for(int j=0;j<=tot_w;j++)
            dp[i][j] = k;
    cout<<f(tot_w,0);
}

int main()
{
    FASTIO
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}




Measured memory_bytes: 81780
#!/usr/bin/env python3
import sys

def solve(N: int, A: "List[int]"):

    # ax+b
    xlist = [[1,0]]+[[] for _ in range(N)]
    for i in range(N):
        a = 0-xlist[i][0]
        b = A[i]*2-xlist[i][1]
        xlist[i+1]=[a,b]
    
    first = xlist[0]
    last = xlist[-1]
    a = first[0]-last[0]
    b = first[1]-last[1]
    x = -b//a

    answer = []
    for i in range(N):
        a = xlist[i][0]
        b = xlist[i][1]
        answer.append(a*x+b)
    
    print(*answer)

    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 35320
#include <iostream>
using namespace std;
int main(){
    int W,H,x,y,r,w,h;
    cin >> W >> H >> x >> y >> r;
    w = W-r;
    h = H-r;
    if (r <= x && w >= x && r <= y && h >= y){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
    return 0;
}



Measured memory_bytes: 3088
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        n:usize,
        d:usize,
        xn:[[i64;d];n],
    }
    let mut ans = 0;
    for i in 0..n {
        for j in i+1..n{
            let dist = xn[i].iter().zip(xn[j].iter())
                .fold(0 ,|y,x| {
                    let sub = x.0 - x.1;
                    y + sub * sub
                });
            let sq = (dist as f64).sqrt() as i64;
            if sq * sq == dist {
                ans += 1;
            }
        }
    }
    println!("{}",ans);
}


fn is_prime(x:i64) -> bool {
    if x == 2 {return true;}
    if x < 2 || x % 2 == 0 {return false;}
    let mut j = 3;
    while j <= (x as f64).sqrt() as i64 {
        if x % j == 0 {
            return false;
        }
        j += 2;
    }
    true
}


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

using namespace std;

#define fin cin
#define fout cout
//ifstream fin("x.in"); ofstream fout("x.out");

set< string > st;

int main() {
    fin.sync_with_stdio(false); fin.tie(); fout.tie();
    int n, k;
    string s;
    fin >> s >> k;

    n = (int)s.size();

    for (int i = 0; i < n; ++ i) {
        string aux;
        for (int j = i; j < n; ++ j) {
            aux += s[ j ];

            if (st.find(aux) != st.end())
                continue;

            st.insert(aux);

            if (st.size() > k)
                st.erase(prev(st.end()));
        }
    }

    fout << *prev(st.end()) << "\n";
    return 0;
}



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

int main() {
  Int N,M;
  cin >> N >> M;
  auto A = vector<Int>(N);
  for(auto& a : A) {
    cin >> a;
  }
  auto sum = accumulate(A.begin(), A.end(), Int(0));
  sort(A.begin(), A.end(), std::greater<Int>());
  cout << ((4*M*A[M-1] >= sum) ? "Yes" : "No") << endl;
   
  return 0;
}


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

int main(){
    ll n;
    cin>>n;
    int digit=log10(n)+1;
    ll sum=0,t=n;
    for(int i=0;i<digit;i++){
        sum+=t%10;
        t/=10;
    }
    if(n%sum==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

int main() {
    int a, b, c, d, p; cin >> a >> b >> c >> d >> p;
    int y;
    int tmp;

    y = b + max(p - c, 0) * d;
    cout << min(a * p, y) << endl;
}



Measured memory_bytes: 3088
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
LL MOD = 1000000007LL;
int pos[200000][26];
int dp[200001][26];
int main() {
	string A;
	cin >> A;
	int N = A.size();
	fill((int*)pos, (int*)(pos + N), -1);
	for (int i = N - 1; i >= 0; i--) {
		if (i + 1 < N) {
			for (int j = 0; j < 26; j++) pos[i][j] = pos[i + 1][j];
		}
		pos[i][A[i] - 'a'] = i;
	}
	fill((int*)dp, (int*)(dp + N + 1), 1 << 30);
	dp[N][0] = 1;
	for (int i = N - 1; i >= 0; i--) {
		for (int j = 0; j < 26; j++) {
			if (pos[i][j] == -1) {
				dp[i][j] = 1;
				continue;
			}
			int p = pos[i][j] + 1;
			for (int k = 0; k < 26; k++) {
				if (dp[p][k] == 1 << 30) continue;
				dp[i][j] = min(dp[i][j], dp[p][k] + 1);
			}
		}
	}
	string ans = "";
	int p = 0;
	while (1) {
		int idx = 0;
		for (int i = 0; i < 26; i++) {
			if (dp[p][i] < dp[p][idx]) idx = i;
		}
		ans.push_back('a' + idx);
		if (dp[p][idx] == 1) break;
		p = pos[p][idx] + 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 41220
#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>;

int main() {
  char s;

  cin >> s;
  cout << char(s+1) << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var H, W int
	fmt.Scan(&H, &W)

	board := make([][]string, H)
	for i := range board {
		board[i] = make([]string, W)
	}

	for i := 0; i < H; i++ {
		var s string
		fmt.Scan(&s)
		for j := 0; j < W; j++ {
			board[i][j] = string(s[j])
		}
	}

	flag := checkBorad(board, H, W)

	if flag {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func checkBorad(board [][]string, H int, W int) bool {
	dx := []int{-1, 0, 0, 1}
	dy := []int{0, 1, -1, 0}

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if board[i][j] == "#" {
				isOk := false
				for k := 0; k < 4; k++ {
					ni := i + dy[k]
					nj := j + dx[k]

					if nj == -1 || nj == W {
						continue
					}
					if ni == -1 || ni == H {
						continue
					}
					if board[ni][nj] == "#" {
						isOk = true
						break
					}
				}
				if !isOk {
					return false
				}
			}

		}
	}

	return true
}


Measured memory_bytes: 512
#
# File    : F.py
# Author  : Kazune Takahashi
# Created : 5/24/2020, 3:07:25 AM
# Powered by Visual Studio Code
#

dic = {
    1: 1,
    2: 1,
    3: 1,
    4: 7,
    5: 4,
    6: 1,
    7: 336,
    8: 384,
    9: 334,
    10: 220,
    11: 108,
    12: 36,
    13: 6,
    27: 976,
    28: 108,
    29: 4,
    60: 220,
    61: 1,
    124: 334,
    252: 384,
    508: 334,
    1020: 220,
    2044: 108,
    4092: 36,
    8188: 6,
    134217723: 976,
    268435451: 108,
    536870907: 4,
    1152921504606846970: 220,
    2305843009213693946: 1,
}

n = int(input())

if n in dic:
    print(dic[n])
else:
    print(-1)


Measured memory_bytes: 9108
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort()
ans=0
for i in range(n):
    if ab[i][1]<m:
        ans+=ab[i][0]*ab[i][1]
        m-=ab[i][1]
    elif ab[i][1]>=m:
        ans+=ab[i][0]*m
        break
print(ans)

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e18;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

const ll mod = 1000000007;

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
private:
	vector<ll> fac;
	vector<ll> ifac;
public:

	Factorial(ll N) {
		fac.push_back(1);
		for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
		ifac.resize(N + 1);
		ifac[N] = inv_mod(fac[N]);
		for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
	}

	ll fact(ll a) { return fac[a]; }
	ll ifact(ll a) { return ifac[a]; }

	ll cmb(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		ll tmp = ifact(a - b) * ifact(b) % mod;
		return tmp * fac[a] % mod;
	}
	ll per(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		return fac[a] * ifac[a - b] % mod;
	}
};


int main() {
	ll n;
	cin >> n;
	vector<ll> as(n+1);
	vector<vector<ll>> g(n + 1);
	rep(i, n + 1) {
		cin >> as[i];
		g[as[i] - 1].push_back(i);
	}	
	P range;
	rep(i, n + 1) {
		if (g[i].size() == 2) {
			range = { g[i][0], g[i][1] };
		}
	}
	Factorial f(n + 1);
	for (int i = 1; i <= n + 1;i++) {
		auto all = f.cmb(n + 1, i);
		auto cand = n + 1 - (range.second - range.first + 1);
		if (cand >= i - 1) {
			auto sub = f.cmb(cand, i - 1);
			all -= sub;
			all += mod;
			all %= mod;
		}
		cout << all << endl;
	}

	return 0;
}


Measured memory_bytes: 11260
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

#define LOOP(i,s,e) for(int i=s;i<e;i++)
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define MAX3(a,b,c) (a>b)?MAX(a,c):MAX(b,c)
#define MIN3(a,b,c) (a>b)?MIN(b,c):MIN(a,c)

int intcmp(const int *a,const int *b) {return (*a - *b);}

int intrcmp(const int *a,const int *b) {return (*b - *a);}

int dblcmp(const double *a,const double *b) { return (*a < *b) ? -1 : (*a == *b) ? 0 : 1; }

int stcmp(const char *a[],const char *b[]) { return(strcmp(*a, *b)); }

int main() {
	int a=0,b=0;
	scanf("%d %d",&a,&b);	
	if((a>9)||(b>9)||(a<1)||(b<1)){
		printf("-1\n");
	}
	else{
		printf("%d\n",(a*b));
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

struct UnionFind{
    vector<int> par;
    vector<int> rank;
    UnionFind(int n=1){
        init(n);
    }
    void init(int n=1){
        par.resize(n);
        rank.resize(n);
        for (int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
        }
    }
    int root(int x){
        if(par[x]==x)return x;
        else return par[x]=root(par[x]);
    }
    bool issame(int x,int y){
        return root(x)==root(y);
    }
    bool merge(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y)return false;
        if(rank[x]<rank[y])swap(x,y);
        if(rank[x]==rank[y])++rank[x];
        par[y]=x;
        return true;
    }
};

bool comp(pair<int,int> p,pair<int,int> q){
    pair<int,int> pp={p.second,p.first};
    pair<int,int> qq={q.second,q.first};
    return pp<qq;
}

int main(){
    int n,m;
    cin>>n>>m;
    if(n<2*(n-m-1)){
        cout<<"Impossible"<<endl;
        return 0;
    }
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    UnionFind uf(n);
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        uf.merge(x,y);
    }
    vector<pair<int,int>> v;
    for(int i=0;i<n;i++){
        v.push_back({a[i],uf.root(i)});
    }
    sort(v.begin(),v.end(),comp);
    bool flag[n]={};
    ll ans=0;
    if(m!=n-1){
        for(int i=0;i<n;i++){
            if(!flag[v[i].second]){
                flag[v[i].second]=true;
                ans+=v[i].first;
                v[i].first=2e9;
            }
        }
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n-m-2;i++){
        ans+=v[i].first;
    }
    cout<<ans<<endl;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

// ====================================================================

int main() {
  ll n, k;
  cin >> n >> k;
  vector<vector<ll>> v(64, vector<ll>(n));  // そこから2のn乗回進んだとこ
  for (ll i = 0; i < n; i++) {
    cin >> v[0][i];
    v[0][i]--;
  }

  for (ll i = 1; i < 64; i++) {
    for (ll j = 0; j < n; j++) {
      v[i][j] = v[i - 1][v[i - 1][j]];
    }
  }

  int now = 0;
  for (int i = 0; i < 64; i++) {
    if ((k >> i) & 1) now = v[i][now];
  }

  cout << now + 1 << endl;
}


Measured memory_bytes: 104884
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
//#define INF 1145141919
#define INF 2147483647
#define MOD 1000000007
#define MAX_N (1<<17) // 10^5

struct SegTree {
  int seg[MAX_N*2-1], lazy[MAX_N*2-1];
  SegTree() {
    for (int i=0; i<MAX_N*2-1; i++) seg[i] = INF, lazy[i] = INF;
  }
  inline void setLazy(int k, int v) {
    lazy[k] = v;
    seg[k] = v;
  }
  inline void fix(int k) {
    seg[k] = min(seg[k*2+1], seg[k*2+2]);
  }
  inline void push(int k) {
    if (lazy[k] == INF) return;
    setLazy(k*2+1, lazy[k]);
    setLazy(k*2+2, lazy[k]);
    lazy[k] = INF;
  }

  void fill(int a, int b, int x, int k=0, int l=0, int r=MAX_N) {
    if (r <= a || b <= l) return;
    if (a <= l && r <= b) {
      setLazy(k, x);
      return;
    }
    push(k);
    fill(a, b, x, k*2+1, l, (l+r)/2);
    fill(a, b, x, k*2+2, (l+r)/2, r);
    fix(k);
  }

  int query(int a, int b, int k=0, int l=0, int r=MAX_N) {
    if (r <= a || b <= l) return INF;
    if (a <= l && r <= b) return seg[k];
    push(k);
    return min(
      query(a, b, k*2+1, l, (l+r)/2),
      query(a, b, k*2+2, (l+r)/2, r)
    );
  }
};

int N, Q;
SegTree seg;

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> Q;
  rep(i, Q) {
    int t;
    cin >> t;
    if (t == 0) {
      int l, r, x;
      cin >> l >> r >> x;
      seg.fill(l, r+1, x);
    }
    else {
      int l, r;
      cin >> l >> r;
      cout << seg.query(l, r+1) << "\n";
    }
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int d;
  unordered_set <int> s;
  for (int i = 0; i < N; i++) {
    cin >> d;
    s.insert(d);
  }
  cout << s.size() << endl;
    
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var k, x int
	fmt.Scanf("%d %d", &k, &x)

	// var list []int
	for i := x - k + 1; i < x+k; i++ {

		// list = append(list, i)
		fmt.Printf("%d ", i)
	}

}

Measured memory_bytes: 512
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, t, e, x, i, j;

    n = sc.nextInt(); t = sc.nextInt(); e = sc.nextInt();
    for(i = 0;i < n;i++){
      x = sc.nextInt();
      for(j = 1;x * j <= t + e;j++)if(t - e <= x * j)break;
      if(t - e <= x * j && x * j <= t + e){
        out.println(i + 1); break;
      }
    }
    if(i == n)out.println("-1");

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

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

using namespace std;

void init_primes(vector<int>& v) {
	bool prime[1000001]; 
    for (int i = 0; i <= 1000000; i++) {
		prime[i] = true;
	}
  
    for (int p = 2; p * p <= 1000000; p++) { 
        if (prime[p]) { 
            for (int i = p * p; i <= 1000000; i += p) {
                prime[i] = false; 
			}
        } 
    } 
  
    for (int p=2; p <= 1000000; p++) {
		if (prime[p]) {
			v.push_back(p);
		}
	}
}

bool is_prime(long long x) {
	if (x == 1) {
		return false;
	}
	for (int i = 2; i <= sqrt(x); i++) {
		if (i * i == x) {
			return false;
		}
	}
	return true;
}

int main() {
	
	vector<int> primes;
	init_primes(primes);
	
	long long n;
	cin >> n;
	
	vector<int> counts;
	for (int i = 0; i < primes.size(); i++) {
		int count = 0;
		while (n % primes[i] == 0) {
			n /= primes[i];
			count++;
		}
		if (count) {
			counts.push_back(count);
		}
	}
	
	if (is_prime(n)) {
		counts.push_back(1);
	}
	
	int ans = 0;
	for (int i = 0; i < counts.size(); i++) {
		int x = 1;
		while (counts[i] - x >= 0) {
			ans++;
			counts[i] -= x++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
int a[100010];
int main()
{
    int n;
    int m;
    while(cin>>n>>m)
    {
        int ans=0;
        for(int i=0;i<n;i++)
            cin>>a[i];
        sort(a,a+n);
        for(int i=0;i<n;i++)
        {
            m-=a[i];
        }
        ans+=m/a[0];
        ans+=n;
        cout<<ans<<endl;
    }
}


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

int main(){
    int N;
    int res;
    cin >> N;
    for(int j = N ; j < 1000 ; j++){
        int temp = j;
        int box[11] = {0};
        int flag = 0;
        for (int k = 0; k < 3; k++){
            box [temp %10]++;
            temp = temp / 10;
        }
        for (int k = 0; k < 10; k++){
            if(box[k] != 0)flag++;
        }
        if(flag == 1){
            res = j;
            break;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

I, O, _, J, L, *_ = list(map(int, sys.stdin.buffer.readline().split()))
ans = 0

ans += O
# I, J, L は 3 つで 1 セット作れる
# 同じの 2 個でも 1 セット作れる
# 貪欲に 3 つのやつつくって、無駄があれば 2 つのほうに移す
if min(I, J, L) > 0:
    s = min(I, J, L)
    I -= s
    J -= s
    L -= s
    if I % 2 + J % 2 + L % 2 == 2:
        # あまりが 2 個出るなら同じので作ってもらったほうがいい
        s -= 1
        I += 1
        J += 1
        L += 1
    ans += s * 3
ans += (I // 2 + J // 2 + L // 2) * 2
print(ans)


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

using namespace std;

int main(){
    int64_t x;
    cin >> x;
    int64_t ans = x / 11 * 2;
    x -= 11 * (x / 11);
    if (x > 0){
        x -= 6;
        ans++;
    }
    if (x > 0){
        x -= 5;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256