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

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


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  if(n==3){
    cout<<2<<" "<<5<<" "<<63<<endl;
    return 0;
  }
  if(n==6){
    cout<<2<<" "<<4<<" "<<6<<" "<<12<<" "<<3<<" "<<9<<endl;
    return 0;
  }
  vector<int> v,w;
  int u;
  for(int i=8;;i+=8){
    if(i>=n){
      u=i;
      break;
    }
  }
  for(int i=2;i<=(3*u)/2;i+=2)v.push_back(i);
  for(int i=3;i<=(u/4)*6-3;i+=6)w.push_back(i);
  if(n%8==1)v.erase(v.end()-7,v.end());
  if(n%8==2)v.erase(v.end()-6,v.end());
  if(n%8==3){
    v.erase(v.end()-3,v.end());
    w.erase(w.end()-2,w.end());
  }
  if(n%8==4)v.erase(v.end()-4,v.end());
  if(n%8==5)v.erase(v.end()-3,v.end());
  if(n%8==6)w.erase(w.end()-2,w.end());
  if(n%8==7)v.erase(v.end()-1,v.end());
  for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
  for(int i=0;i<w.size();i++)cout<<w[i]<<" ";
  cout<<endl;
}

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

    // 入力
    int h, w;
    cin >> h >> w;
    vector<string> vec(h);
    rep(i, h) { cin >> vec[i]; }

    // 処理
    vector<bool> row(h, false);
    vector<bool> colum(h, false);
    rep(i, h) {
        rep(j, w) {
            if (vec[i][j] == '#') {
                row[i]   = true;
                colum[j] = true;
            }
        }
    }

    // 出力
    rep(i, h) {
        if (row[i]) {
            rep(j, w) {
                if (colum[j]) {
                    cout << vec[i][j];
                }
            }
            cout << endl;
        }
    }

    return 0;
}


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

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

typedef long long llong;
typedef pair<int, int> pii;

void solve(){

	int fives = 0, sevens = 0;

	for(int i = 0; i < 3; i++){
		int val;
		cin >> val;
		if(val == 5) fives++;
		else if(val == 7) sevens++;
	}

	cout << (fives == 2 && sevens == 1 ? "YES" : "NO");

}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }

}

use std::cmp::{max, min};

fn main() {
    let n: i64 = read();
    let mut cnt: f64 = 0.0;

    for i in 1..n + 1 {
        if i % 2 == 1 {
            cnt += 1.0;
        }
    }

    // println!("{}", n);
    // println!("{}", cnt);

    println!("{}", cnt / n as f64);

}


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

using namespace std;

#define ll long long
#define nn '\n'
#define db(x) cout << "(DB)-> " << x << nn

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n, d;
  cin >> n >> d;
  ll p[n][2];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 2; j++)
      cin >> p[i][j];

  int count = 0;
  for (int i = 0; i < n; i++) {
    ll a = p[i][0] * p[i][0];
    ll b = p[i][1] * p[i][1];
    if ((a + b) <= (d * d)) count++;
  }
  cout << count;
  return 0;
}


Measured memory_bytes: 6768
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

K,N = LI()
A = LI()

A.sort()

x = 0
for i in range(1,N):
    if A[i]-A[i-1] > x:
        x = A[i]-A[i-1]

if K-(A[N-1]-A[0]) > x:
    x = K-(A[N-1]-A[0])

print(K-x)

Measured memory_bytes: 73588
#include <iostream>

int main()
{
	int K = 0, X = 0, ans = 0, ans_init = 0;
	std::cin >> K >> X;

	ans_init = X - (K - 1);
	for (int i = 0; i < 2 * K - 1; i++){
		ans = ans_init + i;
		std::cout << ans << " ";
	}
	return 0;
}



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

int main(){
  int n;
  cin >> n;
  map<string, int> freebies;
  string s;
  rep(i,n){
    cin >> s;
    freebies[s]++;
  }
  cout << freebies.size() << endl;
  return 0;
}

Measured memory_bytes: 19260
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>

using namespace std;

const double EPS=(1e-10);
typedef long long ll;
typedef pair<int,int> pii;
typedef complex<double> P;
bool EQ(double a,double b){
  return abs((a)-(b))<EPS;
}
void fast_stream(){
  std::ios_base::sync_with_stdio(0);
}

const int MAX_V = 300;
const double INF=1000000000;
int n,m;
P troops[101];
P bases[101];
double vs[101];
// troopÆbaseÔÌÚ®Ô
double times[101][101];
// OtÌXg\»
vector<int> G[MAX_V];
// }b`OÌyA
int match[MAX_V];
// dfsÅ·ÅÉ²×½©Ç¤©ÌtO
bool used[MAX_V];

// uÆvðÔÓðOtÉÇÁ
void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

// ÁpXðdfsÅT·
bool dfs(int v){
  used[v] = true;
  for(int i = 0; i < G[v].size(); i++){
    int u = G[v][i],w = match[u];
    if(w < 0 || !used[w] && dfs(w)){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

// ñOtÌÅå}b`Oðßé
int bipartite_matching(int V){
  int res = 0;
  memset(match,-1,sizeof(match));
  for(int v = 0; v < V; v++){
    if(match[v] < 0){
      memset(used,0,sizeof(used));
      if(dfs(v))res++;
    }
  }
  return res;
}

// ÔtÅðð½¹é©
bool check(double t){
  for(int i=0;i<MAX_V;i++)G[i].clear();
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      // ÔÉÔÉ¤ÈçÎAÔ
      if(EQ(t,times[i][j])||t>times[i][j])
	add_edge(i,n+j);
    }
  }
  return bipartite_matching(n+m)==m;
}

int main(){

  while(cin>>n>>m&&(n|m)){
    for(int i=0;i<n;i++){
      int x,y;
      cin>>x>>y>>vs[i];
      troops[i]=P(x,y);
    }
    for(int i=0;i<m;i++){
      int x,y;
      cin>>x>>y;
      bases[i]=P(x,y);
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	double d=abs(troops[i]-bases[j]);
	times[i][j]=d/vs[i];
      }
    }
    double ub=INF;
    double lb=0;
    int cnt=100;
    while(cnt--){
      double mid=(ub+lb)/2;
      if(check(mid))ub=mid;
      else lb=mid;
    }
    printf("%.10f\n",ub);
  }

  return 0;
}

Measured memory_bytes: 1188
#include <iostream>

using namespace std;
string S, T, U;
int A, B;
int main()
{
    cin >> S >> T >> A >> B >> U;
    if (U == S)
        cout << A - 1 << "  " << B << endl;
    else if(U==T)
        cout << A<< " " << B-1 << endl;
   
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
    int k;
    cin>>k;
    int n=1<<k;
    ll a[n];
    rep(i,n)cin>>a[i];
    //rep(i,n)a[i]=i;
    ll ma[n],se[n];
    rep(i,n)ma[i]=se[i]=0;
    rep(i,n){
        ma[i]=a[i];
        rep(j,k){
            if(i&(1<<j))ma[i]=max(ma[i],ma[i^(1<<j)]);
        }
    }
    rep(mask,n){
        int cnt=0;
        for(int i=mask;i>=0;i--){
            i&=mask;
            if(a[i]==ma[mask])cnt++;
            else se[mask]=max(a[i],se[mask]);
        }
        if(cnt>=2)se[mask]=ma[mask];
    }
    ll ans[n];
    rep(i,n)ans[i]=ma[i]+se[i];
    rep(i,n-1)ans[i+1]=max(ans[i],ans[i+1]);
    rep(i,n-1)cout<<ans[i+1]<<"\n";
    return 0;
}


Measured memory_bytes: 11264
X=[input() for _ in range(int(input()))]
a,b,e,s=0,0,0,0
for x in X:
	a += x.count("AB")
	if x.endswith("A") and x.startswith("B"):
		b += 1
	elif x.endswith("A"):
		e += 1
	elif x.startswith("B"):
		s += 1
if b > 0:
	a += b-1
	if e > 0:
		e -= 1
		a += 1
	if s > 0:
		s -= 1
		a += 1
a += min(e,s)
print(a)


Measured memory_bytes: 3700
n = int(input())
l = [0, 0, 0, 0]


for i in range(n):
  s = input()
  if s == 'AC':
    l[0] += 1
  elif s == 'WA':
    l[1] += 1
  elif s == 'TLE':
    l[2] += 1
  else:
    l[3] += 1

print('AC x', l[0])
print('WA x', l[1])
print('TLE x', l[2])
print('RE x', l[3])
  
  

Measured memory_bytes: 69832
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int z = 0; z < n; z++) {
			String m = sc.next();
			String str = sc.next();
			for (int i = m.length() - 1; i >= 0; i--) {
				switch (m.charAt(i)) {
				case 'J':
					String f = str.substring(0, str.length() - 1);
					String e = str.substring(str.length() - 1);
					str = e + f;
					break;
				case 'C':
					f = str.substring(0, 1);
					e = str.substring(1);
					str = e + f;
					break;
				case 'E':
					if (str.length() % 2 == 0) {
						f = str.substring(0, str.length() / 2);
						e = str.substring(str.length() / 2);
						str = e + f;
					} else {
						f = str.substring(0, str.length() / 2);
						String c = str.substring(str.length() / 2,
								str.length() / 2 + 1);
						e = str.substring(str.length() / 2 + 1);
						str = e + c + f;
					}
					break;
				case 'A':
					char[] a = str.toCharArray();
					char[] b = new char[str.length()];
					for (int j = 0; j < str.length(); j++)
						b[str.length() - 1 - j] = a[j];
					str = String.valueOf(b);
					break;
				case 'P':
					a = str.toCharArray();
					for (int j = 0; j < str.length(); j++) {
						switch (a[j]) {
						case '0':
							a[j] = '9';
							break;
						case '1':
						case '2':
						case '3':
						case '4':
						case '5':
						case '6':
						case '7':
						case '8':
						case '9':
							a[j]--;
							break;
						}
					}
					str = String.valueOf(a);
					break;
				case 'M':
					a = str.toCharArray();
					for (int j = 0; j < str.length(); j++) {
						switch (a[j]) {
						case '0':
						case '1':
						case '2':
						case '3':
						case '4':
						case '5':
						case '6':
						case '7':
						case '8':
							a[j]++;
							break;
						case '9':
							a[j] = '0';
							break;
						}
					}
					str = String.valueOf(a);
					break;
				}
			}
			System.out.println(str);
		}
		sc.close();
	}
}

Measured memory_bytes: 17204
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

signed main(){
    string S;
  	int tmp;
    cin >> tmp;
    cin >> S;
    int cnt = 1;
    REP(i,S.size()-1){
        if(S[i] != S[i+1]) cnt++;
        if(i == S.size()-1 && S[i] != S[i+1]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 512
n, m = gets.split.map(&:to_i)

segments = Array.new()

(1..m).each do |index|
  a, b = gets.split.map(&:to_i)
  segment = [a + 1, b]
  segments.push(segment)
end

segments.sort_by! {|a, b| b}

last = -1
many = 0

segments.each do |segment|
  if last < segment[0]
    last = segment[1]
    many += 1
  end
end

puts many

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

int main() {
	string W;
	cin >> W;
	if (W[5] == '1' || W[6] >= '5')
		cout << "TBD" << endl;
	else
		cout << "Heisei" << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    long long int a,b,k;
    scanf("%lld%lld%lld",&k,&a,&b);
    if(k<=a)
    return puts("1"),0; //按思路特判
    else if(a<=b)
    return puts("-1"),0;   //按思路特判
    else 
    printf("%lld\n",((k-a)/(a-b)+bool((k-a)%(a-b)))<<1|1);
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i,s.length()) {
    int t = s[i] - 'A';
    t = (t + n) % 26;
    s[i] = 'A' + t;
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

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



int main(){
    string s,t;
    cin >> s >> t;

    int ans  = 0;
    rep(i,0,sz(s))if(s[i] != t[i])ans++;
    P(ans);
    
    return  0;
}


Measured memory_bytes: 3832
// author-Shivam gupta

#include <bits/stdc++.h>


using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))

#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define IN(A, B, C) assert( B <= A && A <= C)

#define MP make_pair
#define FOR(i,a) for(int i=0;i<a;i++)

#define FOR1(i,j,a) for(int i=j;i<a;i++)

#define EB emplace_back

#define INF (int)1e9

#define EPS 1e-9

#define PI 3.1415926535897932384626433832795

#define MOD 1000000007

#define read(type) readInt<type>()
#define max1 1000008
#define out(x) cout<<x<<'\n'
#define out1(x) cout<<x<<" "
#define END cout<<'\n'
typedef long int li;

typedef unsigned long int uli;

typedef long long int ll;

typedef unsigned long long int  ull;


void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}


int main() {
string s;
cin>>s;
string ans="";
if(s.length()==1){out(s);}
else{
        string p="";
        int cnt=0;
        int j=0;
    for(int i=s.length()-1;i>=0;i--){
            if(s[i]=='B'){cnt++;}
       else if(s[i]!='B'){if(cnt==0){p+=s[i];}
        else{cnt--;}}
    }
reverse(p.begin(),p.end());
out(p);
}

}



Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i=1,num=1;
    while(i>0){
        scanf("%d",&num);
        if(num==0){
            break;
        }
        printf("Case %d: %d\n",i,num);
        i++;
    }
    return 0;
}

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

template<typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b%a, a);
}

template<typename T>
T lcm(T a, T b) {
  return (a*b)/gcd(b%a, a);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);
  int r, d, x;
  cin >> r >> d >> x;
  ll ans = r * x - d;
  rep(i, 10) {
    cout << ans << endl; 
    ans = r * ans - d;
  }
  return 0;
}


Measured memory_bytes: 256
n, m, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
here = 0
if x < a[0] or a[m-1] < x:
  ans = 0
else:
  for i in range(m-1):
    if a[i] < x < a[i+1]:
      here = i
      ans = min(len(a[:here+1]),len(a[here+1:]))
print(ans)

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main() {
  string s;cin>>s;
  int n=s.size();
  int k;cin>>k;
  vector<int> num(26,-1);

  rep(i,0,n){
    char c=s[i];
    if(num[int(c-'a')]==-1)num[int(c-'a')]=i;
  }

  rep(i,0,26){
    if(num[i]==-1)continue;

    if(n-num[i]>=k){
      vector<string> tmp;
      rep(j,num[i],n-k+1){
        if(s[j]==char('a'+i))tmp.push_back(s.substr(j,k));
      }
      sort(tmp.begin(),tmp.end());
      out(tmp[0]);
      return 0;
    }else{
      k-=n-num[i];
    }
  }

  return 0;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline

n,m,q= map(int, input().split())
a= [list(map(int, input().split())) for i in range(m)]
b= [list(map(int, input().split())) for i in range(q)]


# ２次元累積和
c=[[0]*(n+1) for i in range(n+1)]
for i,j in a:
    c[i][j]+=1

for i in range(1,n+1):
    for j in range(1,n+1):
        c[i][j] += c[i - 1][j]+c[i][j - 1]-c[i-1][j-1]

for i,j in b:
    ans=c[j][j]-c[i-1][j]-c[j][i-1]+c[i-1][i-1]
    print(ans)

Measured memory_bytes: 97500
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
ll dp[2005];
ll solve(ll n)
{
	if(n==0)return 1;
	if(n==1 || n==2)return 0;
	if(dp[n]!=-1)return dp[n];
	ll res=0;
	for(int i=3;i<=n;i++){
		res+=solve(n-i);
		res%=mod;
	}
	return dp[n]=res;
}

int main()
{
	ll n;
	memset(dp,-1,sizeof(dp));
	cin>>n;
	ll res=solve(n);
	res=(res)%mod;
	cout<<res<<endl;
}
	
	


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

typedef long long ll;
#define INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
const double pi = acos(-1.0);

// 分成两组
//  max(max(0,min(r1)-max(l1)+1) + max(0,min(r2)-max(l2)))

// 1----------------------1000
//                  999-------------------------5000
// 1 2 3 4 5 6 7 8
//       x x x x
// x x x x
//         x x x x
//   x x x x

//  max(max(0,min(R)-?L+1) + max(0,min(r2)-max(l2)))

// pick L O(N),
//          if(L > R) ans = max(len single)
//          if(L <= L(R)) 必选
//          if(L(R)<=L <= R) , L 从大到小， 另一个逐个 变小


ll n;
vector<pair<ll,ll>> lr;

int main(){
  cin>>n;
  rep(i,0,n){
    ll l,r;
    scanf("%lld %lld",&l,&r);
    lr.pb({l,r});
  }
  sort(lr.begin(),lr.end());
  ll maxsingle = 0;
  ll minr = lr[0].second;
  rep(i,0,n){
    maxsingle=max(maxsingle,lr[i].second-lr[i].first+1);
    minr = min(minr,lr[i].second);
  }
  ll minrl = 1'000'000'001;
  rep(i,0,n){ // 最小左端点 [minrl,minr]
    if(lr[i].second == minr){
      minrl = min(minrl,lr[i].first);
    }
  }
  pair<ll,ll>right = {0,1'000'000'001};
  ll ans = maxsingle;
  int maxsinglel = 0,maxsingler = 0;
  rep(i,0,n){
    if(lr[i].second-lr[i].first+1 == maxsingle){
      maxsinglel = lr[i].first;
      maxsingler = lr[i].first;
    }
  }
  rep(i,0,n){
    if(lr[i].first == maxsinglel && lr[i].second == maxsingler)continue;
    right.first = max(right.first,lr[i].first);
    right.second = min(right.second,lr[i].second);
  }
  if(right.first <= right.second){
    ans=max(ans,maxsingle+(right.second-right.first+1));
  }

  right = {0,1'000'000'000};

  per(i,1,n){ // 最左边的一定包裹
    if(lr[i].first == minrl)break; // 剩余的全是包裹[minrl,minr]的
    // 第i个移动到右侧
    right.first = max(right.first,lr[i].first);
    right.second = min(right.second,lr[i].second);
    if(right.second < right.first)break; // 右侧为0
    if(lr[i-1].first > minr)continue; // 左侧为0
    ans = max(ans,(minr-lr[i-1].first+1)+(right.second-right.first+1));
  }
  if(right.first == 0){ // 全部包裹了最小段
    cout<<max(ans,maxsingle+(minr-minrl+1))<<endl;
    return 0;
  }
  cout<<ans<<endl;
  // [              ]
  //   [     ]
  //     [     ]
  //-----------------------
  //    [              ]
  //   [     ]
  //     [     ]
  return 0;
}


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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll x; cin >> x;
    ll ans = ((x+10)/11) * 2;
    if(x<=6) ans = 1;
    else if(x<=11) ans = 2;
    else if(x%11<=6&&x%11!=0) ans--;
    cout << ans << endl;
}

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

nums = list(map(int, input().split()))

isApl = True

for num in nums:
    if num%2 == 0:
        if num%3 == 0:
            pass
        elif num%5 == 0:
            pass
        else:
            isApl = False
            break

if isApl:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
from collections import deque
n,m=map(int,input().split())
l=[]
for i in range(m):
  bridge=list(map(int,input().split()))
  l.append(bridge)
road=[[] for i in range(n)]
for i in range(m):
  road[l[i][0]-1].append(l[i][1])
  road[l[i][1]-1].append(l[i][0])                            
count=0
for i in range(m):
  b=l[i]
  d=[False for j in range(n)]
  d[0]=True
  q=deque([1])
  while q:
    a=q.popleft()
    for j in road[a-1]:
      if (a==b[0] and j==b[1]) or (a==b[1] and j==b[0]):
        pass
      else:
        if d[j-1]==False:
          q.append(j)
          d[j-1]=True
  boolian=True
  for i in d:
    if i==False:
      boolian=False
  if boolian:
    pass
  else:
    count+=1
print(count)

Measured memory_bytes: 3316
#include <iostream>
#include <queue>

int main() {
  int n, q;
  std::cin >> n>> q ;
  std::priority_queue<int> s[n];

  for (int i = 0; i < q; ++i) {
    int c, t;
    std::cin >> c >> t;
    switch (c) {
    case 0:
      int x;
      std::cin >> x;
      s[t].push(x);
      break;
    case 1:
      if (!s[t].empty())
        std::cout << s[t].top() << std::endl;
      break;
    case 2:
      if (!s[t].empty())
        s[t].pop();
      break;
    }
  }
}



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

int dfs(int v,vector<vector<int>> &to, vector<bool> &visited, vector<int> &c){
    if(c[v] != -1) return c[v];
    if(visited[v]) return -1;
    visited[v] = true;
    c[v] = -1;
    for(auto e:to[v]){
        int tmpres = dfs(e,to,visited,c);
        if(tmpres == -1) return -1;
        c[v] = max(c[v],tmpres+1);
    }
    if(c[v] == -1) c[v] = 1;
    return c[v];
}

int main() {
    int N;
    cin >> N;
    vector<vector<int>> ids(N,vector<int>());
    int maxid = 1;
    map<pair<int,int>,int> mp;
    auto addId = [&](int i,int vs){
        int k = i;
        if(i>vs) swap(i,vs);
        if(mp[{i,vs}] == 0){
            mp[{i,vs}] = maxid;
            ++maxid;
        }
        ids[k].push_back(mp[{i,vs}]-1);
    };
    rep(i,N)rep(j,N-1){
        int vs;
        cin >> vs;
        --vs;
        addId(i,vs);
    }
    vector<vector<int>> to(maxid,vector<int>());
    rep(i,N)rep(j,N-2){
        to[ids[i][j+1]].push_back(ids[i][j]);
    }
    vector<int> calculated(maxid,-1);
    vector<bool> visited(maxid,false);
    int ans = 0;
    rep(i,maxid-1){
        int tmpans = dfs(i,to,visited,calculated);
        if(tmpans == -1) {
            cout << -1 << endl;
            return 0;
        }
        ans = max(ans,tmpans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 65024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll
//#define endl '\n'

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    while(cin >> n) {
        vi d(n);
        int sum = 0;
        REP(i, n) {
            cin >> d[i];
            sum ^= d[i];
        }
        REP(i, n) {
            cout << (sum ^ d[i]) << " \n"[i + 1 == n];
        }
    }
}


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

using namespace std;

int main() {
  int n, p;
  cin >> n >> p;
  string s;
  cin >> s;
  if (p == 2) {
  	long long ans = 0;
    for (int i = n -1; ~i; --i) {
    	if (s[i] & 1) continue;
      	ans += i + 1;
    }
    cout << ans << '\n';
    return 0;
  }
  if (p == 5) {
    long long ans = 0;
    for (int i = n - 1; ~i; --i) {
      if (s[i] == '0' || s[i] == '5')
        ans += i + 1;
    }
    cout << ans << '\n';
    return 0;
  }
  vector<int> cnt(10000);
  int pw = 1, val = 0;
  for (int i = n - 1; ~i; --i) {
  	val += pw * (s[i] - '0');
    val %= p;
    ++cnt[val];
    pw *= 10;
    pw %= p;
  }
  pw = 1; val = 0;
  long long ans = cnt[0];
  for (int i = n - 1; ~i; --i) {
    val += pw * (s[i] - '0');
    val %= p;
  	ans += --cnt[val];
    pw *= 10;
    pw %= p;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
n, m = map(int, input().split())
ans = [-1] * n
exist = True
for i in range(m):
    s, c = map(int, input().split())
    if (n != 1 and (s, c) == (1, 0)) or (ans[s - 1] != -1 and ans[s - 1] != c):
        exist = False
        break
    else:
        ans[s - 1] = c

for i in range(n):
    if n != 1 and i == 0:
        if ans[i] == -1:
            ans[i] = 1
    else:
        if ans[i] == -1:
            ans[i] = 0
if exist:
    print(*ans, sep='')
else:
    print(-1)

Measured memory_bytes: 9120
import sys
def input():
	return sys.stdin.readline().strip()

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort(reverse=True)
F.sort()

right = F[-1]*A[0]
left = 0

while left < right:
	mid = (left + right) // 2

	total = 0
	for i in range(N):
		if F[i]*A[i] > mid:
			add = F[i]*A[i] - mid
			if add % F[i] == 0:
				total += add//F[i]
			else:
				total += add//F[i] + 1
	#print(mid, left, right)
	if total <= K:
		judge = 1
	else:
		judge = 0

	if judge == 1: #左の区間に限定する条件
		right = mid
	else: #右の区間に限定される場合
		left = mid + 1
		mid += 1


print(mid)





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

using namespace std;

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

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> p(n);
    rep (i, n) cin >> p[i];
    int mini = p[0];
    int res = 1;
    FOR (i, 1, n) {
        if (mini >= p[i]) {
            mini = p[i];
            res++;
        }
    }
    cout << res << endl;
    
    return 0;
}



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


int main(){
string S;
string T;
cin >> S>>T;
int count = 0;
rep(i,3){
    if(S.at(i)==T.at(i))count++;

}
cout<<count<<endl;
}

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

int main(){
    int N, X, i, j, temp;
    int m[1000];
    int ans = 0;

    cin >> N >> X;

    for (i=0; i < N; i++){
        cin >> m[i] ;
        X = X - m[i];
        ans = ans + 1;
    }

    for (i=0; i<N; ++i) {
    
    int tmp;
    
    for (j=i+1; j<N; ++j) {
        if (m[i] > m[j]) {
            tmp =  m[i];
            m[i] = m[j];
            m[j] = tmp;
        }
    }   
    }

    for (i=0; i < N; i++){
        while (m[i] <= X){
            X = X - m[i];
            ans = ans + 1;
        }
    }
    
    
    cout << ans << '\n';

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define pb push_back
#define tam 520004
#define offset 320000
#define se second
#define fi first
#define pitem item*
#define ptr tre*
#define forr(i,p,n) for(int i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000007 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
int n;
int arr[tam];
ll f(vector<int> v)
{
    ll totsum=0;
    ll val=0;
    forr(i,0,n)
    {
        totsum+=arr[i];
        if (v[i]==1)
        {
            if (totsum<=0)
            {
                val+=abs(1-totsum);
                totsum=1;
            }
        }
        else
        {
            if (totsum>=0)
            {
                val+=abs(-1-totsum);
                totsum=-1;
            }
        }
    }
    return val;

}
int main()
{

    cin>>n;
    vector<int> v1,v2;
    forr(i,0,n)
    {
        cin>>arr[i];
        v1.pb(i%2);
        v2.pb((i+1)%2);
    }
    cout<<min(f(v1),f(v2))<<endl;
}


Measured memory_bytes: 2420
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <bitset> 

using namespace std;

const int INF=1e9+7,mod=1e9+7;
const double eps=1e-8;
const int MAXN=110000;

int s[100001],v[100001];

int main()
{
   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
    int cas=0,T;
  //  cin>>T;
    //while(++cas<=T)
  // 	while(scanf("%d%d",&nn,&mm)!=EOF)
    {
    	int n,m,x,y;
    	cin>>n>>m;
    	for(int i=1;i<=n;i++)
    		s[i]=1;
    	v[1]=1;
    	for(int i=1;i<=m;i++)
    	{
    		cin>>x>>y;
    		s[x]--;
    		s[y]++;
    		if(v[x]==1)
    			v[y]=1;
    		if(s[x]==0)
    			v[x]=0;
		}
		int ans=0;
		for(int i=1;i<=n;i++)
			ans+=v[i];
		cout<<ans<<endl; 
    }
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define  vi vector<long long int>
#define  set1 set<long long int>
#define  pb push_back
#define  map1 map<long long int,long long int>
#define  ll    long long int
#define  mp make_pair
#define  inf 1e17
#define  minf INT_MIN
#define  setbits(x) __builtin_popcountll(x)
#define  pres(x,y) fixed<<setprecision(y)<<x
#define  pair1 pair<long long int,long long int>
#define  mk(arr,n,type) type *arr=new type[n];
#define  mod 1000000007
#define  pi  3.1415926535897932384626433832
#define  ins insert
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//find_by_order() --> returns an iterator to the k-th largest element (counting from zero)
//order_of_key()  --> the number of items in a set that are strictly smaller than our item.
#define  w(t) long long int t;t=1;while(t--)

void solve() {

	ll r, c;
	cin >> r >> c;
	ll a[r][c];
	ll dp[r][c];
	memset(dp, 0, sizeof(dp));
	for (ll i = 0; i < r; i++) {
		for (ll j = 0; j < c; j++) {
			char x;
			cin >> x;
			if (x == '.') {
				a[i][j] = 1;
			}
			else {
				a[i][j] = 0;
			}
		}
	}


	for (ll i = 0; i < r; i++) {
		if (a[i][0] == 0) {
			break;
		}
		dp[i][0] = 1;
	}

	for (ll i = 0; i < c; i++) {
		if (a[0][i] == 0) {
			break;
		}
		dp[0][i] = 1;
	}

	for (ll i = 1; i < r; i++) {
		for (ll j = 1; j < c; j++) {
			if (a[i - 1][j] != 0)
				dp[i][j] = dp[i - 1][j]%mod;
			if (a[i][j - 1] != 0)
				dp[i][j] =((dp[i][j]%mod)+(dp[i][j - 1]%mod))%mod;
		}
	}

	cout << dp[r - 1][c - 1]%mod << "\n";


}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	w(t) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 19152
#include <iostream>
    #include <iomanip>
    #include <cstring>
    #include <algorithm> 
    #include <math.h>
    #include <queue>
    #include <functional>
    #include <map>
    #include <vector>
    #include <string>
    using namespace std;
     
    typedef long long ll;
    typedef pair<int, int> P;
    int dx[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
    int dy[] = { -1, -1, 0, 1, 1, 1, 0, -1 };
    const ll MOD = 1000000007;
    const ll INF = 1000000000;
    const int MAX = 10000000;
     
     
    int main() {
        ll n, m;
        cin >> n >> m;
        if (n == 1 && m == 1) cout << 1 << endl;
        else if (n == 1 || m == 1) cout << n*m - 2;
        else cout << n*m - 2 * n - 2 * m + 4 << endl;
        
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

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

    vector<int> dp(N);
    for(int i=0; i<N; i++){
        dp[i] = INT_MAX;
    }

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i=2; i<N; i++){
        dp[i] = dp[i-1] + abs(h[i] - h[i-1]) < dp[i-2] + abs(h[i] - h[i-2]) ? dp[i-1] + abs(h[i] - h[i-1]) : dp[i-2] + abs(h[i] - h[i-2]);
    }

    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {

            //入力読取。
            string strDice = Console.ReadLine();
            string strDice2 = Console.ReadLine();
            
            //サイコロのクラスにて処理。
            Dice insD = new Dice(strDice, strDice2);
            string strAnsewr = insD.GetAnswer();

            //出力
            Console.WriteLine(strAnsewr);
            
        }
        
    }
    
    class Dice{
        
        private string strDice;
        private string strDice2;
        private int[] dice;
        private int[] dice2;
        private string strAnsewr;
        
        public Dice(string strDice, string strDice2){
            this.strDice = strDice;
            this.strDice2 = strDice2;
            SetDice();
        }
        
        private void SetDice(){
        
            //サイコロ生成。
            this.dice = MakeDice(strDice);
            this.dice2 = MakeDice(strDice2);
            
            //サイコロを転がす。
            string strOrder = "NNNNWNNNWNNNENNNENNNWNNN";
            char[] chOrder = strOrder.ToCharArray();
            this.strAnsewr = "No";
            for(int order = 0; order < chOrder.Length; order++){
                Roll(chOrder[order]);
                if(dice.SequenceEqual(dice2)){
                    this.strAnsewr = "Yes";
                    break;
                }
            }
            
        }
        
        private int[] MakeDice(string strDiceTemp){
            
            string[] strDiceArray = strDiceTemp.Split(' ');
            int[] diceTemp = new int[6];
            for(int index = 0; index < 6; index++){
                diceTemp[index] = int.Parse(strDiceArray[index]);
            }
            return diceTemp;
            
        }
        
        private void Roll(char chDirection){
            if(chDirection == 'N'){
                int intTemp = dice[0];
                dice[0] = dice[1];
                dice[1] = dice[5];
                dice[5] = dice[4];
                dice[4] = intTemp;
            }else if(chDirection == 'W'){
                int intTemp = dice[0];
                dice[0] = dice[2];
                dice[2] = dice[5];
                dice[5] = dice[3];
                dice[3] = intTemp;
            }else if(chDirection == 'E'){
                int intTemp = dice[0];
                dice[0] = dice[3];
                dice[3] = dice[5];
                dice[5] = dice[2];
                dice[2] = intTemp;
            }else{
                int intTemp = dice[0];
                dice[0] = dice[4];
                dice[4] = dice[5];
                dice[5] = dice[1];
                dice[1] = intTemp;
            }
        }
        
        public string GetAnswer(){
            return strAnsewr;
        }
        
    }

}



Measured memory_bytes: 18152
import java.io.*;
public class Main {
    public static void main(String[] args)throws IOException {
        int m = 0,f=0,r=0;
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String str = br.readLine();
            String[] i=str.split(" ");
                m=Integer.parseInt(i[0]);
                f=Integer.parseInt(i[1]);
                r=Integer.parseInt(i[2]);
                if(m==(-1)&&f==(-1)&&r==(-1)){break;}
                if(m==(-1)||f==(-1)){System.out.println("F");}
                else if(m+f>=80){System.out.println("A");}
                else if(m+f>=65){System.out.println("B");}
                else if(m+f>=50){System.out.println("C");}
                else if(m+f>=30){if(r>=50){System.out.println("C");}
                                 else{System.out.println("D");}}
                else {System.out.println("F");}
        }
    }
}
/*import java.io.*;
public class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader mBufferedReader=new BufferedReader(new InputStreamReader(System.in));
    int m=0;
    int f=0;
    int r=0;
    while(true){
      String str=mBufferedReader.readLine();
      String[]arr=str.split(" ");   
      m=Integer.parseInt(arr[0]);
      f=Integer.parseInt(arr[1]);    
      r=Integer.parseInt(arr[2]);
      if(m==( - 1)&&f==( - 1)&&r==( - 1)){
        break;
      }else if(m+f>=80){
        System.out.println("A");
      }else if(m+f>=65){
        System.out.println("B");
      }else if((m+f>=50)||r>=50){
        System.out.println("C");
      }else if(m+f>=30){
        System.out.println("D");    
      }else if(30>m+f){
        System.out.println("F");
      }else if(m==-1||f==-1){
        System.out.println("F");
      }
    }
  }
}*/


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

int main(){
    int n;
    ll k;
    cin>>n>>k;
    ll a[n],f[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>f[i];
    }
    sort(a,a+n);
    sort(f,f+n);
    ll ok=1e12,ng=-1;
    while(ok-ng>1){
        ll mid=(ok+ng)/2;
        ll sum=0;
        for(int i=0;i<n;i++){
            ll s=a[i]*f[n-1-i];
            if(s>mid){
                sum+=a[i]-mid/f[n-1-i];
            }
        }
        if(sum<=k)ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define sec second
#define pii pair<int, int>
ll n, m, k, x, y, sum, ans, l, a[100005];
int main () {
	scanf("%d %lld", &n, &l);
	for (int i=1; i<=n; i++) scanf("%d", &a[i]);
	for (int i=1; i<n; i++) {
		if (a[i]+a[i+1]>=l) {
			y++;
			ans=i;
			break;
		}
	}
	if (y==0) {
		printf("Impossible\n");
		return 0;
	}
	printf("Possible\n");
	vector<int>v;
	for (int i=1; i<ans; i++) v.push_back(i);
	for (int i=n-1; i>ans; i--) v.push_back(i);
	v.push_back(ans);
	for (int i=0; i<v.size(); i++) printf("%d\n", v[i]);
	return 0;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}


int main(){
  int i,j,N,M,K;
  cin>>N>>M>>K;
  cout<<max(M+K-N,0)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;




int main()
{
    int n;
    cin >> n;
    vector<pair<ll, pll>> dish(n);
    rep(i,n){
        ll a, b;
        cin >> a >> b;
        dish[i] = mp(a + b, mp(a, b));
    }
    ll ans = 0;
    sort(all(dish));
    rep(i,n){
        if (i%2==0)
            ans += dish[n-1-i].S.F;
        else
            ans -= dish[n-1-i].S.S;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    int n;
    int ans = 0;
    cin >> n;
    vector<int> a;
    map<int, int> b;
    for (int loop = 0, tmp = 0; loop < n; loop++){
        cin >> tmp;
        if (b[tmp]){
            b[tmp]++;
        } else {
            b[tmp] = 1;
            a.push_back(tmp);
        }
    }
    for (int loop = 0; loop < (int)a.size(); loop++){
        if (a[loop] > b[a[loop]]){
            ans += b[a[loop]];
        } else if(a[loop] < b[a[loop]]){
            ans += b[a[loop]]-a[loop];
        } else {
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5112