akhauriyash/Code-Regression huggingface dataset:
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl            '\n'
#define mem(a, n)       memset(a, n, sizeof(a))
#define repeat(n)       for(int i=0; i<n; i++)
#define Unique(n)       (n).erase(unique(all(n)), (n).end())
#define isPowerOfTwo(n) (n && !(n & (n - 1)))
#define NumofDigits(n)  ((int)log10(n)+1)
#define all(a)          a.begin(), a.end()

unsigned long long pow(long long base, long long power);

long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a*b/gcd(a, b); }

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

/*
    Special functions:
        find_by_order(k) --> returns iterator to the kth largest element counting from 0
        order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

int main(){
    quicken();

    int c=0, n;
    string str; cin >> str;
    n = str.length();
    repeat(n/2)
        if(str[i]!=str[n-i-1]) c++;

    cout << c;
    return 0;
}

unsigned long long pow(long long base, long long power){
    if(power==0) return 1;
    if(power==1) return base;

    unsigned long long ans = pow(base, power/2);
    ans *= ans; /// ans = (ans%mod)*(ans%mod);

    if(power&1) return ans*base; /// (ans%mod)*(base%mod);
    return ans;
}


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

#define print cout <<
#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;

const ll modseed = pow(10,9) + 7;

template <typename T>
vector<T> getValues(int num){
    vector<T> values(num);
    for(int i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

int main(){
    int N;
    string S;
    cin >> N >> S;
    int ans = 0; 
    rep(i,N-2){
      if((S.at(i)=='A') && (S.at(i+1)=='B') && (S.at(i+2)=='C')){
        ans++;
      }
    }
    printl(ans);
}


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

struct Edge {
  ll from;
  ll to;
  ll cost;
  Edge(ll from, ll to, ll cost) : from(from), to(to), cost(cost) {}
};

using Edges = vector<Edge>;
const ll INF = 1LL << 60;

bool bellman_ford(const Edges &Es, int V, int s, vector<ll> &dis) {
  dis.resize(V, INF);
  dis[s] = 0;
  int cnt = 0;
  while (cnt < V) {
    bool end = true;
    for (auto e : Es) {
      if (dis[e.from] != INF && dis[e.from] + e.cost < dis[e.to]) {
        dis[e.to] = dis[e.from] + e.cost;
        end = false;
      }
    }
    if (end) break;
    cnt++;
  }
  return (cnt == V);
}

int main() {
  int v, e, r;
  cin >> v >> e >> r;
  Edges edges;
  rep(i, e) {
    int s, t, d;
    cin >> s >> t >> d;
    Edge edge(s, t, d);
    edges.push_back(edge);
  }
  vector<ll> dist;
  bool negative = bellman_ford(edges, v, r, dist);

  if (negative) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    rep(i, v) {
      if (dist[i] == INF) {
        cout << "INF" << endl;
      } else {
        cout << dist[i] << endl;
      }
    }
  }
}


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

int main()
{
  int64_t N, ans;
  cin >> N;
  for (int64_t i = 1; i <= 100000; i++)
  {
    int64_t n = i * i;
    if (n > N)
    {
      cout << ans << endl;
      return 0;
    }
    ans = n;
  }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
	
    int N; cin >> N;
	ves S(N+1); rep(i,N) cin >> S[i];


	map<string,int> v;
    int ma = 0;
	rep(i,N) {
        v[S[i]]++;
        chmax(ma,v[S[i]]);
    }

    sort(all(S));
    S.erase(unique(S.begin(),S.end()),S.end());

    rep(i,S.size()) {
        if(v[S[i]] == ma) cout << S[i] << endl;
    }
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A, B; cin >> A >> B;
    if(A >= 13) cout << B << endl;
    else if(A >= 6) cout << B/2 << endl;
    else cout << 0 << endl;
    return 0;
}

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

int main(){
  int64_t a,b;
  cin >> a >> b;
  if(a==1||b==1){
    cout << 1 << endl;
  }else{
  int64_t ans=(a*b%2==0?a*b/2:a*b/2+1);
  cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
const int maxn = 200200;
const int mod = 1e9 + 7;
const int N = 2010;
typedef long long ll;
int n;
int a[maxn];
int main() {
	std::ios::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for(int i = 1;i <= n;++i) std::cin >> a[i];
	std::sort(a + 1, a + n + 1, std::greater<int>());
	for(int i = 1;i <= n;++i) 
		if(i + 1 > a[i + 1]) {
			if((std::count(a + i + 1, a + n + 1, i) | a[i] - i) & 1) {
				puts("First");
			} else {
				puts("Second");
			}
			return 0;
		}
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <cstdint>

class Duration {
private:
	using Self = Duration;

	const uint16_t hour;
	const uint8_t  min;
	const uint8_t  sec;

	Duration(const uint16_t _hour, const uint8_t _min, const uint8_t _sec) :
		hour(_hour),
		min(_min),
		sec(_sec)
	{ }

public:
	/**
	 * Create a Time instance from seconds
	 */
	static auto from_seconds(const uint32_t time) -> Self {
		const uint8_t  sec  = time % 60;
		const uint8_t  min  = time / 60 % 60;
		const uint16_t hour = time / 60 / 60;

		return Self { hour, min, sec };
	}

	auto format() const -> std::string {
		std::ostringstream ss {};
		ss
			<< (uint32_t) this->hour
			<< ":"
			<< (uint32_t) this->min
			<< ":"
			<< (uint32_t) this->sec;

		return ss.str();
	}
};

auto main() -> int {
	uint32_t time;

	std::cin >> time;

	if (not std::cin.good()) {
		return 1;
	}

	std::cout << Duration::from_seconds(time).format() << std::endl;
}

Measured memory_bytes: 3176
import numpy as np
N,K = map(int,input().split())
H = np.array(list(map(int,input().split())))

dp = np.zeros(N, dtype=int)

for i in range(1,N):
  s = max(i-K,0)
  dp[i] = np.min(dp[s:i]+np.abs(H[s:i]-H[i]))

print(dp[-1])


Measured memory_bytes: 23044
#include <vector>
#include <iostream>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

vector<P> prime_factirize(ll n) {
    vector<P> res;

    for (ll a = 2; a * a <= n; ++a) {
        if (n % a != 0) continue;

        ll ex = 0;
        while (n % a == 0) {
            ++ex;
            n /= a;
        }

        res.emplace_back(a, ex);
    }
    if (n != 1) res.emplace_back(n, 1);

    return res;
}


int main() {
    ll a, b; cin >> a >> b;
    ll g = gcd(a, b);
    vector<P> res = prime_factirize(g);
    cout << (res.size() + 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int nunmern,worth;
  vector<int> vdata(22);
  vector<int> cdata(22);
  int judge = 0;
  
  
    cin >> nunmern;
  
  for (int i = 0; i < nunmern; i++) {
    cin >> vdata.at(i);
  }
  
  for (int h = 0; h < nunmern; h++) {
    cin >> cdata.at(h);
  }
  
  
  
  for(int k = 0; k< nunmern ; k++){
    worth=vdata.at(k)-cdata.at(k);
    if(worth > 0){
      judge+=worth;
    }
    
  }
  
      cout << judge << endl;
  
  
  
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
const int MAXN=100000+10;
int n,h;
int a[MAXN],b[MAXN];
int ans;
int main(){
	scanf("%d%d",&n,&h);
	for(int i=0;i<n;i++)
		scanf("%d%d",&a[i],&b[i]);
	int x=*std::max_element(a,a+n);
	std::sort(b,b+n);
	std::reverse(b,b+n);
	ans=(h+x-1)/x;
	for(int i=0;i<n;i++){
		h-=b[i];
		int tmp;
		if(h<=0) tmp=0;
		else tmp=(h+x-1)/x;
		if(ans>i+1+tmp) ans=i+1+tmp;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#define maxn 100005
using namespace std;
typedef long long ll;
ll a[maxn] = { 0 };
int main() {
    ll n, i;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    ll sum1 = 0;  ll sum2 = 0;
    ll ans1 = 0; ll ans2 = 0;
    for (int i = 1;i <= n; ++i) {
        sum1 += a[i];
        if (i % 2 == 0 && sum1 >= 0) {
            ans1 += sum1 + 1;
            sum1 = -1;
        }
        else if (i % 2 != 0 && sum1 <= 0) {
            ans1 += abs(sum1) + 1;
            sum1 = 1;
        }
    }
    for (int i = 1; i <= n; ++i) {
        sum2 += a[i];
        if (i % 2 == 0 && sum2 <= 0) {
            ans2 += abs(sum2) + 1;
            sum2 = 1;
        }
        else if (i % 2 != 0 && sum2 >= 0) {
            ans2 += abs(sum2) + 1;
            sum2 = -1;
        }
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    string s;
    cin >> s;

    int N = sz(s);

    if(N%2){
        cout << "No" << endl;
    }else{
        rep(i,N){
            if(s[i] != (i%2?'i':'h')){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
}

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

int main(){
  string masu;
  int i=0;
  cin >> masu;
  if(masu[0] == '1')i++;
  if(masu[1] == '1')i++;
  if(masu[2] == '1')i++;
  cout << i << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
edge = [ [] for i in range(N) ]
rst = 0
for i in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(N):
    is_peak = True
    for j in edge[i]:
        if H_ls[i] <= H_ls[j]:
            is_peak = False
    if is_peak:
        rst += 1
print(rst)

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

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(s == u)
    {
        cout << a - 1 << " " << b;
    }
    else
    {
        cout << a << " " << b - 1;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

ll mod_pow(ll a,ll b,ll p){ //(a^b)%p
	ll res=1;
	a%=p;

	while(b>0){
		if(b&1==1) res=((res%p)*(a%p))%p;
		a=(a%p*a%p)%p;
		b>>=1;
	}
	return res;
}

//mod_inv=mod_pow(denominator,MOD-2,MOD);

int32_t main(){
	fastio();
	int n , k;
	cin >> n >> k;
	int mini = 0;
	for(int i = 0; i < k; i++){
		mini += i;
	}
	int maxi = 0;
	int j = 0;
	int p = n;
	for( p = n; j < k; p--,j++){
		maxi += p;
	}

	int ans = maxi  - mini + 1;
	ans %= mod;
	//cout << ans << " ";
	for(int i = k; i <= n; i++){
		maxi += p;
		p--;
		mini += i;
		
		ans += (maxi - mini + 1);
		ans %= mod;
	}

	cout << ans;

}

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

int N,M;
map<string,int> s;

int main()
{
    cin>>N;
    for (int i = 0; i < N; i++)
    {
        string x;
        cin>>x;
        s[x]++;
    }

    cin>>M;
    for (int i = 0; i < M; i++)
    {
        string x;
        cin>>x;
        s[x]--;
    }

    int ans = 0;
    for (auto itr=s.begin(); itr!=s.end(); itr++)
    {
        ans = max(ans, itr->second);
    }
    
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n ; cin >> n ;
  int x = n/1.08 ;
  for(int i=x-10; i<x+10; i++){
    if(int(i*1.08)==n){
      cout << i << endl ;
      return 0 ;
    }
  }
  cout << ":(" << endl ;
}

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

#define pi 3.1415926535
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define tc int test_case; cin >> test_case; while(test_case--)
#define f(i,a,n) for(int i = a ; i < n ; i++)
#define rf(i,n,a) for(int i = n-1 ; i >= a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) cout << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cout<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

const int inf = 1e9;
const ll inf64 = 1e18;
const int mod = inf + 7;
const int N = 2e5 + 10;

int main()
{
    fast;
    int n;
    cin >> n;
    ll ans = 0;

    f(i,1,n+1)
    {
        ll x = (n/i)*i;

        ll cnt = x/i; /// count of no.s
        ans += 1ll*i*cnt*(cnt+1)/2;
    }

    cout << ans;
}


Measured memory_bytes: 3616
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int sum = 0;
		int N = in.nextInt();
		for(int i=0; i<N; i++) {
			int l = in.nextInt();
			int r = in.nextInt();
			sum += (r - l + 1);
		}
		System.out.println(sum);
		
		in.close();
	}
}


Measured memory_bytes: 25712
#include <stdio.h>

char ans[100000007];

int main(void)
{
	int m, n;
	int i, j, k;
	int f;
	char lb[12000];
	char la[12000];
	char c;
	
	while (scanf("%d", &n), n != 0){
		
		for (i = 0; i < n; i++){
			scanf(" %c %c", &lb[i], &la[i]);
		}
		scanf("%d", &m);
		k = 0;
		for (i = 0; i < m; i++){
			scanf(" %c", &c);
			f = 0;
			for (j = 0; j < n; j++){
				if (lb[j] == c){
					ans[k] = la[j];
					k++;
					f = 1;
				}
			}
			if (f == 0){
				ans[k] = c;
				k++;
			}
		}
		ans[k] = '\0';
		
		printf("%s\n", ans);
	}
	return (0);
}

Measured memory_bytes: 1124
N,K=[int(x) for x in input().split()]

a_list=[0] * (10**5)
for i in range(N):
    a,b=[int(x) for x in input().split()]
    a_list[a-1]+=b

k=0
for i in range(len(a_list)):
    k+=a_list[i]
    if k >=K:
        break
print(i+1)

Measured memory_bytes: 5744
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;

bool check(string tail) {
    return tail.find("AGC") == string::npos &&
           tail.find("GAC") == string::npos &&
           tail.find("ACG") == string::npos &&
           tail.find("AGGC") == string::npos &&
           tail.find("ATGC") == string::npos &&
           tail.find("AGTC") == string::npos;
}

int solve(map<pair<int, string>, int>& hist, int n, string tail) {
    auto key = make_pair(n, tail);
    if (hist.count(key)) {
        return hist[key];
    } else if (n == 0) {
        return 1;
    } else {
        int ret = 0;
        string alph = "ACGT";
        for (int i = 0; i < 4; i++) {
            char c = alph[i];
            if (check(tail + c)) {
                ret = (ret + solve(hist, n - 1, tail.substr(1, 2) + c)) %
                      1000000007;
            }
        }
        hist[key] = ret;
        return ret;
    }
}

int main() {
    int n;
    std::cin >> n;
    map<pair<int, string>, int> hist;
    cout << solve(hist, n, "xxx") << endl;
}

Measured memory_bytes: 896
#include<map>
#include<cstdio>
using namespace std;
int main(){for(int T,n,k,c,d,C;scanf("%d",&T),T;puts("")){
	map<pair<int,int>,int>m;
	for(;T--&&scanf("%s%d",&C,&n);){
		if(C=='D'){
			for(auto it=m.begin();it!=m.end();)if(it->second==n)m.erase(it++);else ++it;
		}else if(C=='R'){
			auto it=m.lower_bound(make_pair(n,2000000000));
			printf("%d\n",it==m.begin()||n<(--it)->first.first||it->first.second<n?-1:it->second);
		}else if(C=='W'){
			c=!scanf("%d",&k);
			for(auto it=m.begin();k&&it!=m.end();++it){
				d=it->first.first-c;
				if(d>k)d=k;
				if(d)m.insert({{c,c+d-1},n});
				k-=d;
				c=it->first.second+1;
			}
			if(k)m.insert({{c,c+k-1},n});
		}
	}
}}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
int main(){
long long n,k,l;
cin >> n;
if (n%2==0){
	cout << n << ' ' << n << ' ' << n/2;
	return 0;
}
if (n%3==0){
	cout << n << ' ' << n/3*2 << ' ' << n/3*2;
	return 0;
}
if ((n-3)%4==0){
	cout << (n+1)/4 <<' ' << (n+1)/4*(n+1)<<' ' <<(n+1)/4*(n+1)*n;
	return 0;
}
if ((n-1)%4==0){
for (long long i=1;i<=3500;i++){
	for (long long j=1;j<=3500;j++){
		  k=n*i*j,l=4*i*j-n*i-n*j;//数学 
        if (l>0&&k%l==0){
        	cout << i << ' ' << j << ' ' << k/l << endl;
        	return 0;
        }
	}
} 
}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

int main(void){
  int n;
  std::vector<int> v;
  std::cin >> n;
  for(int i=0; i<n; i++){
    int k;
    std::cin >> k;
    v.push_back(k);
  }

  int min_cost = 100000000;
  for(int number=-100; number<=100; number++){
    int temp_cost = 0;
    for(auto it = v.begin(); it!=v.end(); it++){
      int temp = number-*it;
      temp_cost += temp*temp;
    }
    if (min_cost > temp_cost)
      min_cost = temp_cost;
  }	
  
  std::cout << min_cost << std::endl;
}

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

namespace AtCoder.Abc
{
    public class EijC
    {
        public static void Main(string[] args)
        {
            var c = new ConsoleInput(Console.In);
            int N = c.ReadInt;
            int n = (int)Math.Sqrt(N) + 1;
            int[] ary = new int[10000*10000];
            for (int x = 1; x <= n; x++)
            {
                for (int y = 1; y <= n; y++)
                {
                    for (long z = 1; z <= n; z++)
                    {
                        ary[x * x + y * y + z * z + x * y + y * z + z * x]++;
                    }
                }
            }

            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(ary[i + 1]);
            }
        }
        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }

    }
}

Measured memory_bytes: 28784
N = int(input())
d = []
for i in range(0,N):
  d += [int(input())]

d.sort(reverse=True)

ans = 0

x = max(d)+1
for i in range(0,N):
  
  if d[i] < x:
    ans += 1
    x = d[i]

print(ans)

Measured memory_bytes: 9020
#include "bits/stdc++.h"
#define REP(i,n,N) for(ll i=n; i<N; i++)
#define p(s) cout<<(s)<<endl
#define p2(a,b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;

vector<int> hurui_v(int n){
	vector<int> v;
	bool *isPrime_v;
	isPrime_v=new bool[n+1];

	isPrime_v[0]=isPrime_v[1]= false;
	for(int i=2;i<n+1;i++) isPrime_v[i]=true;

	for (int i = 2; i*i <= n ; ++i) {
		for(int j=i*2;j<n+1;j+=i){
			isPrime_v[j]= false;
		}
	}
	for(int i=0;i<n+1;i++){
		if(isPrime_v[i])v.push_back(i);
	}
	delete[] isPrime_v;
	return v;
}



int main(){
	vector<int> primes = hurui_v(10000000);

	while(1){
		int n,p;
		cin >> n >> p;
		if(n==-1){
			break;
		}

		vector<int> selected;
		vector<int> last;

		int count=0;

		for(auto prime:primes){
			if(n<prime){
				count++;
				selected.push_back(prime);
			}
			if(count==100)break;
		}
		/**
		REP(i,0,100){
			cout << selected[i] << " ";
		}
		cout << endl;
		 **/

		REP(i,0,selected.size()){
			REP(j,i,selected.size()){

				last.push_back(selected[i]+selected[j]);
			}
		}

		sort(last.begin(),last.end());

		count=1;
		int ans;
		for(auto l:last){
			if(count==p) ans=l;
			count++;
		}
		p(ans);

	}

	return 0;
}


Measured memory_bytes: 16444
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	string A, B, C; cin >> A >> B >> C;
	cout << (A[A.size()-1]==B[0]&&B[B.size()-1]==C[0]?"YES":"NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    string s;
    cin >> s;

    if(s.size() == 2){
        if(s[0] == s[1]){
            cout << 1 << " " << 2 << endl;
            return 0;
        }
    }

    rep(i, 0, s.size() - 2){
        if(s[i] == s[i + 1] || s[i] == s[i + 2]){
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <atcoder/maxflow>

using namespace std;

int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };

int N,M;
vector<string> S;
inline void input(){
    fast_io();
    cin >> N >> M;
    for (int i = 0; i < N; i++)
    {
        string s; cin >> s;
        S.push_back(s);
    }
}

#define WALL '#'
#define PATH '.'

inline int solve(){
    atcoder::mf_graph<int> MF(N*M+10);
    int source = N*M , sink = N*M+1;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            if(S[i][j]==WALL) continue;
            if((i+j)%2==0){
                MF.add_edge(source, i*M+j, 1);
                for (int k = 0; k < 4; k++)
                {
                    int x = i + dx[k];
                    int y = j + dy[k];
                    if(x < 0|| x>=N) continue;
                    if(y < 0|| y>=M) continue;
                    if(S[x][y]==WALL) continue;
                    MF.add_edge(i*M+j, x*M+y, 1);
                }
                
            }
            else{
                MF.add_edge(i*M+j, sink, 1);
            }
        }
    }
    int ans = MF.flow(source, sink);
    vector<string> Fields = S;
    for(auto e:MF.edges()){
        if(e.from != source && e.to != sink && e.flow==1){
            int fi = e.from / M, fj = e.from % M;
            int ti = e.to / M, tj = e.to % M;
            if(fi==ti){
                Fields[fi][min(fj,tj)] = '>';
                Fields[fi][max(fj,tj)] = '<';
            }
            else{
                Fields[min(fi,ti)][fj] = 'v';
                Fields[max(fi,ti)][fj] = '^';
            }
        }
    }

    // output
    cout << ans << "\n";
    for(auto f:Fields){
        cout << f << "\n";
    }
      
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 5584
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<iostream>
using namespace std;

int k;
double r;
int t;

int first;
int y,n;

int cal(){
	int fb=first;
	if(k==0){
		int p=0;
		for(int i=0;i<y;i++){
			p+=(int)(fb*r);
			fb-=t;
		}
		fb+=p;
	}
	else{
		for(int i=0;i<y;i++){
			fb+=((int)(fb*r)-t);
		}
	}
	return fb;
}

int i_max(int p,int q){
	if(p>q) return p;
	return q;
}

int main(){
	int nn;
	int i;
	int ans;
	int size;
	cin>>size;
	for(nn=0;nn<size;nn++){
		cin>>first>>y>>n;
		ans=0.0;
		for(i=0;i<n;i++){
			cin>>k>>r>>t;
			ans=i_max(ans,cal());
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N;
vector<vector<int>> G;
vector<int> d;

void dfs(int v,int p=-1){
	if(p!=-1) d[v] = d[p]+1;
	for(int u:G[v]) if(u!=p) dfs(u,v);
}
vector<int> calcdist(int r){
	d = vector<int>(N);
	dfs(r);
	return d;
}
int main(){
	cin>>N;
	G.resize(N);
	rep(i,N-1){
		int x,y;
		cin>>x>>y;
		x--,y--;
		G[x].pb(y);
		G[y].pb(x);
	}
	vector<int> d = calcdist(0);
	int a = 0;
	rep(i,N) if(d[i]>d[a]) a = i;
	d = calcdist(a);
	int b = 0;
	rep(i,N) if(d[i]>d[b]) b = i;

	vector<int> vs;
	{
		vs.pb(b);
		int v = b;
		while(v!=a){
			for(int u:G[v]) if(d[u]+1 == d[v]){
				v = u;
				break;
			}
			vs.pb(v);
		}
	}
	int L = vs.size();
	vector<int> c(L);
	rep1(i,L-2){
		int v = vs[i];
		for(int u:G[v]) if(u!=vs[i-1] && u!=vs[i+1]){
			if(G[u].size()!=1){
				puts("-1");
				return 0;
			}
			c[i]++;
		}
	}
	vector<int> rc = c;
	reverse(all(rc));
	if(c>rc) c = rc;

	int v = 1;
	rep(i,L){
		int ov = v;
		v++;
		rep(k,c[i]) cout<<v++<<" ";
		cout<<ov<<" ";
	}
	cout<<endl;
}


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

using namespace ::std;

typedef long long ll;
typedef unsigned long long ull;


int px[] = {0, 1, 0, -1, 1, -1, -1, 1};
int py[] = {1, 0, -1, 0, 1, 1, -1, -1};

int main()
{
    int test, n, m, a, b;

    //scanf("%d", &test);


    scanf("%d%d", &n, &m);

    bool in[222]{};
    for(int i = 0; i<m; ++i) scanf("%d", &a), in[a] = 1;
    
    if(m == 0) 
    {
        cout << n << endl;

        return 0;
    }

    a = -1;

    for(int i = 0; i<=112; ++i)
    {
        if(a == -1 and !in[i]) a = i;

        if(!in[i] and abs(n - a) > abs(n - i)) a = i;
    }

    cout << a << endl;
}

Measured memory_bytes: 3760
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  int n, m, k; cin >> n >> m >> k;
  int black = 0;
  char g[n][m];
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) {
      cin >> g[i][j];
      if(g[i][j] == '#') black++;
    }
  }
  int ans = 0;
  for(int i = 0; i < (1 << n); i++) {
    for(int j = 0; j < (1 << m); j++) {
      bool used[n][m];
      memset(used, 0, sizeof used);
      int have = black;
      for(int k = 0; k < n; k++) {
        if(((i >> k) & 1) == 0) continue;
        for(int u = 0; u < m; u++) {
          if(used[k][u] == 1) continue;
          if(g[k][u] == '#') {
            used[k][u] = 1;
            have--;
          }
        }
      }
      for(int k = 0; k < m; k++) {
        if(((j >> k) & 1) == 0) continue;
        for(int u = 0; u < n; u++) {
          if(used[u][k] == 1) continue;
          if(g[u][k] == '#') {
            used[u][k] = 1;
            have--;
          }
        }
      }
      if(have == k) ans++;
    }
  }
  print(ans);
}

int main() {
  int t; t = 1;
  while(t--) solve();
}




Measured memory_bytes: 3588
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
template<typename Monoid, typename F>
struct SegmentTree{
	//using F=function<Monoid(Monoid, Monoid)>;
	int sz;
	vector<Monoid> seg;
	const F f;
	const Monoid e;

	SegmentTree(int n, const F f, const Monoid &e): f(f), e(e){
		sz=1;
		while(sz<n) sz<<=1;
		seg.resize(2*sz, e);
	}

	SegmentTree(int n, const F f, const Monoid &e, vector<Monoid> v): f(f), e(e){
		sz=1;
		while(sz<n) sz<<=1;
		seg.resize(2*sz, e);
		for(int i=0; i<n; i++) seg[i+sz]=v[i];
		for(int i=sz-1; i>=1; i--){
			seg[i]=f(seg[2*i], seg[2*i+1]);
		}
	}

	void update(int k, const Monoid &x){
		k+=sz;
		seg[k]=x;
		while(k>1){
			k>>=1;
			seg[k]=f(seg[2*k], seg[2*k+1]);
		}
	}

	Monoid query(int a, int b){
		a+=sz, b+=sz;
		Monoid ret=e;
		for(;a<b; a>>=1, b>>=1){
			if(b&1) ret=f(ret, seg[--b]);
			if(a&1) ret=f(ret, seg[a++]);
		}
		return ret;
	}
	
	template<typename C>
	int binarysearch(int st, C &check){//[st,ret):false, [st, ret+1):true (check(e):false)
		Monoid s=e;
        int k=st+sz;
        while(1){
            if(!check(f(s, seg[k]))){
                if(((k+1)&-(k+1))==k+1) return -1;
                s=f(s, seg[k++]);
                if(~k&1) k>>=1;
            }else{
                if(k>=sz) return k-sz;
                k<<=1;
            }
        }
        return -1;
	}

	Monoid operator[](const int &k) const{
		return seg[k+sz];
	}
};
int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    vector<int> a(n);
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
	auto f=[](int x, int y){ return max(x, y);};
    SegmentTree<int, decltype(f)> seg(n, f, -1, a);
    while(q--){
        int t;
        scanf("%d", &t);
        if(t==1){
            int x, v;
            scanf("%d %d", &x, &v);
            x--;
            seg.update(x, v);
        }else if(t==2){
            int l, r;
            scanf("%d %d", &l, &r);
            l--;
            printf("%d\n", seg.query(l, r));
        }else{
            int x, v;
            scanf("%d %d", &x, &v);
            x--;
            auto check=[&](int a){ return a>=v;};
            int r=seg.binarysearch(x, check);
            if(r!=-1) printf("%d\n", r+1);
            else printf("%d\n", n+1);
        }
    }
    return 0;
}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;

const int N = 1e5 + 5;

vector<ii> graph[N];

int n, m;

map<int, int> d[N];

struct State{
    int dist, f, c;
};

deque<State> q;

void lmao() {
    q.push_front({0, 1, 0});
    d[1][0] = 0;
    while(!q.empty()) {
        State frt = q.front();
        q.pop_front();
        if(frt.dist > d[frt.f][frt.c]) continue;
        int u = frt.f, c = frt.c;
        if(!d[u].count(0) || (d[u].count(0) && d[u][c] < d[u][0])) {
            d[u][0] = d[u][c];
            q.push_front({d[u][0], u, 0});
        }
        if(c) {
            int pos = lower_bound(graph[u].begin(), graph[u].end(), mp(c, 0)) - graph[u].begin();
            while(pos < graph[u].size() && graph[u][pos].fi == c) {
                ii v = graph[u][pos];
                if(!d[v.se].count(v.fi) || (d[v.se].count(v.fi) && d[v.se][v.fi] > d[u][c])) {
                    d[v.se][v.fi] = d[u][c];
                    q.push_front({d[v.se][v.fi], v.se, v.fi});
                }
                pos++;
            }
        }
        else {
            for(int i = 0; i < graph[u].size(); i++) {
                ii v = graph[u][i];
                if(!d[v.se].count(v.fi) || (d[v.se].count(v.fi) && d[v.se][v.fi] > d[u][c] + 1)) {
                    d[v.se][v.fi] = d[u][c] + 1;
                    q.push_back({d[v.se][v.fi], v.se, v.fi});
                }
            }
        }
    }
}

int main() {
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; i++) {
        int u, v, c;
        scanf("%d%d%d", &u, &v, &c);
        graph[u].pb({c, v});
        graph[v].pb({c, u});
    }
    for(int i = 1; i <= n; i++)
        sort(graph[i].begin(), graph[i].end());
    lmao();
    if(!d[n].count(0))
        printf("-1");
    else
        printf("%d", d[n][0]);
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;
typedef unsigned int i64;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define bye(x) return void (cout <<(x) << endl);
#define all(e) (e).begin(), (e).end()
#define pb push_back

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

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


template <typename T>
void printV(vector<T> A) {
  if (A.empty()) cerr << "EMTPY\n";
  else { 
    cerr << "[";
    for (int i = 0; i < A.size() -1 ; ++i) {
      cerr << A[i] << ", ";
    }
    if (A.size()) cerr << A.back() << "]\n";
  }
}


template <typename T>
void printVV(vector<vector<T>> A) {
  cerr << "[";
  for (auto v : A) {
    printV<T>(v);
  }
  cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

int main(int argc, char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a; cin >> a;
  cout << a + a * a + a * a * a << endl;
  return 0;
}



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

using namespace std;

#define llint long long int
#define REP(i,s,l) for(llint i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main() {

    int makeTime, cps, totalTime ;
    cin >> makeTime >> cps >> totalTime;

    cout << cps * (totalTime / makeTime) << endl;
    /* code */
    return 0;
}

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

int main() {
    ll N, K;
    cin >> N >> K;

    map<ll, ll> a;
    for (int i = 0; i < N; i++) {
        ll tmp_a, tmp_b;
        cin >> tmp_a >> tmp_b;
        a[tmp_a] += tmp_b;
    }

    for (auto num : a) {
        K -= num.second;
        if (K <= 0) {
            cout << num.first << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 7336
#include<bits/stdc++.h>
#define ll long long
ll read() {ll x = 0;char f = 1, ch = getchar();while(ch < '0' || ch > '9') {if(ch == '-')f = -1;
ch = getchar();}while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0';ch = getchar();}return x * f;}
void write(ll x) {if(x < 0) x = -x, putchar('-');if(x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(ll x) {write(x);puts("");}
using namespace std;
ll a, b, c, k;

int main() {
	a = read(), b = read(),c = read(), k = read();
	if(k & 1)
		writeln(b - a);
	else
		writeln(a - b);
	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++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 100000000;
const int MOD = 1000000007;
int main(){
  int n;
  std::cin >> n;
  std::vector<int> w(n),su(n);
  rep(i,n)std::cin >> w[i];
  //sort(all(w));
  su[0]=w[0];
  for (int i = 1; i < n; i++) {
    /* code */
    su[i]=su[i-1]+w[i];
  }
  int mi=su[n-1];
  for (int i = 0; i < n; i++) {
    int dum;
    dum=abs(su[n-1]-su[i]-su[i]);
    if(dum<mi)mi=dum;
    /* code */
    
  }
 // rep(i,n)std::cout << su[i] << std::endl;
  std::cout << mi << std::endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Console;

namespace a {
static class Extensions {
   public static int ToInt(this string str) {
      return int.Parse(str);
   }

   public static int[] readIntArr() {
      return ReadLine().Split(' ').Select(int.Parse).ToArray();
   }
}

class Program {
   public static void Main(string[] args) {
      var tmp = Extensions.readIntArr();
      var n = tmp[0];
      var k = tmp[1];
      var s = ReadLine();

      var sb = new System.Text.StringBuilder();
      for (var i = 0; i < n; i++) {
         if (i == k - 1) {
            sb.Append(s[i].ToString().ToLower());
         } else {
            sb.Append(s[i]);
         }
      }

      WriteLine(sb.ToString());
   }
}

}


Measured memory_bytes: 13268
#include<iostream>
using namespace std; // 575

int main() {
	int H, W, N;
	cin >> N >> H >> W;
	cout << (N - H + 1) * (N - W + 1);
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

縦横で独立に考えることができて、それぞれ候補がN-H+1, N-W+1より答えは(N-H+1)(N-W+1)
*/

Measured memory_bytes: 256
a, b, k = map(int,input().split())
ans = []
if 2*k >= b-a+1:
    ans = list(range(a,b+1))

else:
    for i in range(k):
        ans.append(a+i)
    for i in range(k):
        ans.append(b-k+i+1)

for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void ng() {
    cout << -1 << endl;
    exit(0);
}

int N, A[100005];

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

    cin >> N;
    rep(i, N) {
        cin >> A[i];
    }

    ll L = A[N-1], R = A[N-1]*2-1;
    if (L != 2)ng();

    for (int i = N - 2; i >= 0; --i) {
        L = (L + A[i] - 1) / A[i] * A[i];
        R = R / A[i] * A[i];

        if (L > R)ng();
        R += A[i] - 1;
    }
    cout << L << ' ' << R << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    double T, A;
    cin >> N >> T >> A;

    vector<int> H(N);

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

    double tmp = T - H[0] * 0.006;;
    int answer = 0;

    for (int i = 1; i < N; i++){
        double t = T - H[i] * 0.006;

        if(abs(A - t) < abs(A - tmp)){
            tmp = t;
            answer = i;
        }
    }

    cout << answer + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define endl '\n'
#define pi 3.14159265
ll p(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b%2!=0)

            res*=a;
        a*=a;
        b/=2;
    }
    return res;
}
int main()
{           
    IOS;
    ll a,b,q;
    cin>>a>>b>>q;
    vector<ll> s(a),t(b);
    for(ll i=0;i<a;i++)
        cin>>s[i];
    for(ll j=0;j<b;j++)
        cin>>t[j];
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    while(q--)
    {
        ll x;
        cin>>x;
        ll ans=1e18;
        auto it1=lower_bound(s.begin(),s.end(),x);
        auto it2=lower_bound(t.begin(),t.end(),x);
        auto it3=lower_bound(s.begin(),s.end(),x);
        auto it4=lower_bound(t.begin(),t.end(),x);
        if(it1!=s.end()&&it2!=t.end())
            ans=min(ans,max(*it1,*it2)-x);
        if((*it1!=x&&it1==s.begin())||(*it2!=x&&it2==t.begin()))
        {
            ;
        }
        else
        {
            if(*it1!=x)
                it1--;
            if(*it2!=x)
                it2--;
            ans=min(ans,x-min(*it1,*it2));
        }
        if(it3!=s.end())
        {
            if(*it4!=x&&it4==t.begin())
            {
                ;
            }
            else
            {
                if(*it4!=x)
                    it4--;
                ans=min(ans,min(abs(x-*it4),abs(x-*it3))*2+max(abs(x-*it4),abs(x-*it3)));
                it4=lower_bound(t.begin(),t.end(),x);;
            }
        }
        if(it4!=t.end())
        {
            if(*it3!=x&&it3==s.begin())
            {
                ;
            }
            else
            {
                if(*it3!=x)
                    it3--;
                ans=min(ans,min(abs(x-*it4),abs(x-*it3))*2+max(abs(x-*it4),abs(x-*it3)));
            }    
        }
        cout<<ans<<endl;
    }
}       

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

#define int long long
#define w cout
#define e '\n'
#define sz(x) (int)x.size()
template<class T, class U> inline istream& operator>>(istream& str, pair<T, U> &p) { return str >> p.first >> p.second; }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

const int N = 1e6 + 10 , mod = 998244353;

signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int h , n;cin >> h >> n;
	vector<int> v(n);
	int sum =0 ;
	for(int i = 0; i < n ;i ++) {
		int x;cin >> x;
		sum += x;
	}
	if(sum >= h) {
		w << "Yes";
	}else w << "No";
}	



Measured memory_bytes: 1024