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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;

void run_case()
{
    int n;
    cin >> n;
    cout << n * n * n << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3620
def main():
    N, A, B = map(int, input().split())
    if A > B:
        print(0)
        return
    if N == 1:
        if A == B:
            print(1)
        else:
            print(0)
        return
    ans = (N-2) * (B-A) + 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std ;
 
#define int long long

#define IOS ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vp vector<pii>
#define vs vector<string>
#define all(v) v.begin(),v.end()

#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define ff  first
#define ss  second
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
 
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
     
#define pi 3.14159265358979323846264338327950L
#define MOD 1000000007

 bool great(int a,int b)
 {
 	return a>b;
 }
int32_t main(){

     IOS
	int n,k,ans=0;
	cin>>n>>k;
	vi a(n,0);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(all(a),great);
	if(k<sz(a))
	{
		for(int i=k;i<n;i++)
			ans+=a[i];
	}
	else
	{
		ans=0;
	}
	cout<<ans;

	return 0;
}




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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int n = s.size(), m = t.size();
    vector<int> st;
    for(int i=0; i+m-1<n; i++) {
        int idx = i;
        bool valid = true;
        for(int j=0; j<m; j++) {
            if(s[idx] == t[j] || s[idx] == '?') {
                idx++;
            } else {
                valid = false;
                break;
            }
        }
        if(valid) {
            st.push_back(i);
        }
    }
    if((int)st.size() == 0) {
        cout<<"UNRESTORABLE\n";
        return 0;
    }
    string ans(100,'z');
    for(auto x : st) {
        string tmp = "";
        for(int i=0; i<n; i++) {
            if(i == x) {
                tmp += t;
                i+=m-1;
            } else {
                if(s[i] != '?') tmp += s[i];
                else tmp += 'a';
            }
        }
        ans = min(ans,tmp);
    }
    cout<<ans<<"\n";
    return 0;
}




Measured memory_bytes: 256
// Implementation of Andrew's monotone chain 2D convex hull algorithm.
// Asymptotic complexity: O(n log n).
// Practical performance: 0.5-1.0 seconds for n=1000000 on a 1GHz machine.
#include <algorithm>
#include <vector>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>

using namespace std;

typedef double coord_t;         // coordinate type
typedef double coord2_t;  // must be big enough to hold 2*max(|coordinate|)^2

struct Point {
	coord_t x, y;

	bool operator <(const Point &p) const {
		return x < p.x || (x == p.x && y < p.y);
	}
};

// 3D cross product of OA and OB vectors, (i.e z-component of their "2D" cross product, but remember that it is not defined in "2D").
// Returns a positive value, if OAB makes a counter-clockwise turn,
// negative for clockwise turn, and zero if the points are collinear.
coord2_t cross(const Point &O, const Point &A, const Point &B)
{
	return (A.x - O.x) * (B.y - O.y) - (A.y - O.y) * (B.x - O.x);
}

long dist(Point A, Point B){
  return abs(A.x - B.x) + abs(A.y - B.y);
}
// Returns a list of points on the convex hull in counter-clockwise order.
// Note: the last point in the returned list is the same as the first one.
vector<Point> convex_hull(vector<Point> P)
{
	size_t n = P.size(), k = 0;
	if (n <= 3) return P;
	vector<Point> H(2*n);

	// Sort points lexicographically
	sort(P.begin(), P.end());

	// Build lower hull
	for (size_t i = 0; i < n; ++i) {
		while (k >= 2 && cross(H[k-2], H[k-1], P[i]) <= 0) k--;
		H[k++] = P[i];
	}

	// Build upper hull
	for (size_t i = n-1, t = k+1; i > 0; --i) {
		while (k >= t && cross(H[k-2], H[k-1], P[i-1]) <= 0) k--;
		H[k++] = P[i-1];
	}

	H.resize(k-1);
	return H;
}

int main(void){
  int N;
  cin >> N;
  vector<Point> graph;
  for(int i = 0; i < N; i++){
    int x,y;
    cin >> x >> y;
    Point tmp;
    tmp.x = x;
    tmp.y = y;
    graph.push_back(tmp);
  }
  auto outline = convex_hull(graph);
  int max = 0;
  for(int i =0; i < outline.size(); i++){
    for(int j =0; j <= i; j++){
      if(max < dist(outline[i], outline[j])){
        max = dist(outline[i], outline[j]);
      }
    }
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 15868
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  bool b[k+1];
  memset(b,false,(k+1)*sizeof(b[0]));
  for(int i=0;i<n;i++){
  	cin>>a[i];
  }
  for(int i=1;i<=k;i++){
    for(int j=0;j<n;j++){
      if((i-a[j])>=0&&b[i-a[j]]==false){
        b[i]=true;
        break;
      }
    }
  }        
  if(b[k]==false){
    cout<<"Second"<<'\n';
  }
  else{
    cout<<"First"<<'\n';
  }
}

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

int main(){
    int n;
    string s;
    cin >> s;
    n = s.size();

    string t;
    for(int i = 0;i < n;i++){
        if(s[i] != 'x'){
            t.push_back(s[i]);
        }
    }

    for(int i = 0;i < t.size();i++){
        if(t[i] != t[t.size()-i-1]){
            cout << -1 << endl;
            return 0;
        }
    }

    int ans = 0;

    int st = 0;
    int en = n-1;

    while(en-st > 0){
        if(s[st] == s[en]){
            st++;
            en--;
        }else if(s[st] == 'x'){
            st++;
            ans++;
        }else{
            en--;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	int x, y;
	cin >> x >> y;
	vector<int>a = { 1,3,5,7,8,10,12 };
	vector<int>b = { 4,6,9,11 };
	vector<int>c = { 2 };
	int ans = 0;
	if (x == 2 && y == 2) {
		cout << "Yes";
		return 0;
	}
	for (int i = 0; i < a.size(); i++) {
		if (a[i] == x || a[i] == y) {
			ans++;
		}
		if (ans == 2) {
			cout << "Yes";
			return 0;
		}
	}
	ans = 0;
	for (int i = 0; i < b.size(); i++) {
		if (b[i] == x || b[i] == y) {
			ans++;
		}
		if (ans == 2) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n, l;
	cin >> n >> l;
	int m = 1000000, res = 0;
	for (int i = 0; i < n; i++) {
		res += l + i;
		if (abs(m) > abs(l + i))m = l + i;
	}
	cout << res - m << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll H,W,N; cin >> H >> W >> N;
    set<pair<int, int>> dic;
    rep(i,N) {
        int a,b; cin >> a >> b;
        a--; b--;
        dic.emplace(a,b);
    }

    vector<ll> cnt(10);
    for (auto v : dic) {
        int y,x;
        tie(y,x) = v;
        rep(i,3) {
            rep(j,3) {
                int oy = y - i;
                int ox = x - j;
                if (oy < 0 || ox < 0 || oy +2 >= H || ox+2 >= W) continue;
                int c = 0;
                rep(k,3) {
                    rep(l,3) {
                        if (dic.count(make_pair(oy+k,ox+l))) c++;
                    }
                }
                cnt[c]++;
            }
        }
    }

    cnt[0] = (H-2LL)*(W-2LL);
    for (int i = 1; i <= 9; i++) {
        cnt[i] /= i;
        cnt[0] -= cnt[i];
    }

    rep(i,10) cout << cnt[i] << endl;


}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define fastio  cin.sync_with_stdio(0); cin.tie(0);cin.exceptions(cin.failbit);
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
   
    fastio;
    int T=1;
    // cin>>T;
    while(T--){
        int n,k;cin>>n>>k;
        int p[n];rep(i,n)cin>>p[i];
        int ans=0;
        sort(p,p+n);
        rep(i,k)ans+=p[i];
        cout<<ans;
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

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)

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s;
    cin >> t;

    int res = s.size();
    rep(j, s.size()-t.size()+1) {
        int tmp = 0;
        rep(i, t.size()) {
            if (s[j+i] != t[i]) {
                tmp++;
            }
        }
        res = min(res, tmp);
    }

    cout << res << "\n";
}

Measured memory_bytes: 3656
from math import sin,cos,radians, sqrt
a,b,C = map(float, input().split())
#面積
C = radians(C)
print('{:.08f}'.format(0.5*a*b*sin(C)))
#辺の長さ
L = a + b + sqrt(a**2 + b**2 -2*a*b*cos(C))
print('{:.08f}'.format(L))
#高さ
print('{:.08f}'.format(b*sin(C)))


Measured memory_bytes: 5692
#include<cstdio>

int main(){
	int A, B, C, X, Y;
	scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);
	if(C*2 >= A + B){
		printf("%d\n", A*X + B*Y);
		return 0;
	}
	if(X >= Y){
		if(C*2 >= A){
			printf("%d\n", C*Y*2 + A*(X - Y));
			return 0;
		}
		printf("%d\n", C*X*2);
		return 0;
	}
 	if(C*2 >= B){
		printf("%d\n", C*X*2 + B*(Y - X));
		return 0;
	}
	printf("%d\n", C*Y*2);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>   
using namespace std;   
typedef long long ll;
int main()  
{   
    cin.tie(0); ios::sync_with_stdio(false);  
	//freopen("input.txt", "rt", stdin);
	int n, a; cin >> n >> a;
	cout << n*n-a << "\n";
	

	return 0;   
}  

Measured memory_bytes: 256
N=int(input())
x=list(map(int,input().split()))
min_x=min(x)
max_x=max(x)
m1=(min_x+max_x)//2
m2=(min_x+max_x+1)//2
print(min([max(max_x-m1,m1-min_x),max(max_x-m2,m2-min_x)]))


Measured memory_bytes: 5608
module StringMap = Map.Make (String)

let () = Scanf.scanf "%d\n" @@ fun n ->
  let ss = Array.init n @@ fun _ -> Scanf.scanf "%s\n" @@ fun s -> s in
  List.iter print_endline @@
  List.rev @@
  fst @@
  List.fold_left (fun (ss, n) (s, m) ->
    if n < m
    then ([s], m)
    else if n = m then (s :: ss, n)
    else (ss, n)) ([], 0) @@
  StringMap.bindings @@
  Array.fold_left (fun m s ->
    StringMap.add s (1 + try StringMap.find s m with Not_found -> 0) m) StringMap.empty ss

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

int main(){
    int H,W;
    cin >> H >> W;
    string s[H];
    for(int i=0;i<H;i++){
        cin >> s[i];
    }
    cout << endl;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int tmp = 0;
            if(s[i][j] == '#') continue;
            for(int k=-1;k<=1;k++){
                for(int l=-1;l<=1;l++){
                    if(i+k<0||i+k>=H) continue;
                    if(j+l<0||j+l>=W) continue;
                    if(s[i+k][j+l]=='#') tmp++;
                }
                s[i][j] = tmp +'0';
            }
        }
    }

    for(int i=0;i<H;i++){
        cout<<s[i]<<endl;
    }
}

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

namespace AtCoderExamCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string tmp = Console.ReadLine();
            string[] tmpSplit = tmp.Split();
            int A = int.Parse(tmpSplit[0]);
            int B = int.Parse(tmpSplit[1]);
            int C = int.Parse(tmpSplit[2]);
            int K = int.Parse(tmpSplit[3]);

            if (K < A)
            {
                Console.WriteLine(K);
            }
            else if (K <= A + B)
            {
                Console.WriteLine(A);
            }
            else
            {
                Console.WriteLine(A - (K - (A + B)));
            }
        }
    }
}


Measured memory_bytes: 27380
use proconio::input;
use std::collections::HashSet;

fn main() {
    input! {
        k: usize,
    }

    println!("{}", sevens(k as i64));
}

fn sevens(k: i64) -> i64 {
    let (mut sevens, mut modulo) = (HashSet::new(), 7 % k);
    for i in 1.. {
        if modulo == 0 {
            return i;
        } else if sevens.contains(&modulo) {
            break;
        }
        sevens.insert(modulo);
        modulo = (modulo * 10 + 7) % k;
    }
    -1
}


Measured memory_bytes: 29636
#include <cmath>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <iostream>
#include <algorithm>


using namespace std;


int main() {
	int n = 0;
	cin >> n;
	if(n == 5) {
		printf("YES\n");
	}
	else if(n == 3){
		printf("YES\n");
	}
	else if(n == 7) {
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const ll INF=1e17;
const long double PI=acos(-1);



void solve(int T){
    int n;
    cin>>n;
    int c=0;
    for(int i=1;i*i<n;i++){
        for(int j=i;j*i<n;j++){
            if(j!=i)c+=2;
            else c++;
        }
    }
    cout<<c;
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}
/*

for(int i=1;i<n;i++){
        for(int j=1;j<n;j++){
            cout<<i<<" "<<j<<" "<<n-(i*j)<<"\n";
        }
    }
    */


Measured memory_bytes: 3592
import math
from functools import reduce
ans = []
a = []

def gcd(*numbers):
    return reduce(math.gcd, numbers)
    
n = int(input())

for i in range(1, n+1):
    for j in range(1, n+1):
        ans.append(3*(math.gcd(i,j)))
        
for i in range(1,n+1):
    a.append(i)
mainas = sum(a)*2

for i in range(1, n-1):
    for j in range(i+1, n):
        for z in range(j+1, n+1):
            ans.append(6*(gcd(i,j,z)))
answer = sum(ans)-mainas
print(answer)

Measured memory_bytes: 19880
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int,int>;

int main(){
	int n, m;
	cin>>n>>m;
	vector<int> a(n), b(m);
	rep(i, n) cin>>a[i];
	rep(i, m) cin>>b[i];

	auto c=convolution(a, b);

	rep(i, n+m-1) cout<<c[i]<<" ";
	cout<<endl;
	return 0;
}


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

using namespace std;

int main()
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    bool ans = true;

    if (x - r < 0 || y - r < 0 || x + r > W || y + r > H)
    {
        ans = false;
    }

    if (ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3112
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e3 + 10;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b, c;
	cin >> a >> b >> c;
	if (c >= a && c <= b) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)

ll n;
ll t[200001];
ll dp[200001][4];
ll calc(ll i, ll extra) {
	if(i<0) return (extra==0?0:-1LL<<60);
	if(dp[i][extra]!=-1LL<<60) return dp[i][extra];
	ll ans=-1LL<<60;
	for(int j=0;j<=extra;++j) {
		ans=max(ans,calc(i-j-2,extra-j)+t[i]);
	}
	return dp[i][extra]=ans;
}
int main() {
	IO;
	for(int i=0;i<200001;++i) for(int j=0;j<4;++j) dp[i][j]=-1LL<<60;
	cin>>n;
	for(int i=0;i<n;++i) cin>>t[i];
	if(n%2==0) cout<<max(calc(n-2,0),calc(n-1,1))<<"\n";
	else cout<<max(calc(n-1,2),calc(n-2,1))<<"\n";
	return 0;
}


Measured memory_bytes: 17644
import math 
N,D=map(int,input().split())
XY = [input().split() for i  in range(N)]

ans =0

for i in range(N):
  if math.sqrt((int(XY[i][0])**2) + (int(XY[i][1])**2))<= D:
    ans +=1

print(ans)

Measured memory_bytes: 67684
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int h = Integer.parseInt(strlist[0]);
		int w = Integer.parseInt(strlist[1]);
		String[][] list = new String[h][w];

		for(int i=0; i<h; i++){
			str = input.readLine();
			list[i] = str.split("");
		}

		StringBuffer buf = new StringBuffer();
		for(int i=0; i<w+2; i++){
			buf.append("#");
		}

		System.out.println(buf.toString());

		for(int i=0; i<h; i++){
			System.out.print("#");
			for(int j=0; j<w; j++){
				System.out.print(list[i][j]);
			}
			System.out.println("#");
		}

		System.out.println(buf.toString());
	}


}


Measured memory_bytes: 25556
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
graph = [[] for _ in range(n)]
for a, b, cost in LIR(n-1):
    graph[a-1] += [(b-1, cost)]
    graph[b-1] += [(a-1, cost)]



color = [0] * n
color[0] = 0
dist = [-1] * n
dist[0] = 0
que = deque([0])
while que:
    cur = que.pop()
    for nxt, cost in graph[cur]:
        if dist[nxt] == -1:
            dist[nxt] = dist[cur] + cost
            color[nxt] = dist[nxt] % 2
            que += [nxt]


for i in range(n):
    print(color[i])

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD=998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=100005;

int dp[101][N];int pre[N+1];

void solve()
{
int n,k;
cin>>n>>k;
int a[n+1];
for(int i=1;i<=n;i++)
cin>>a[i];
dp[0][0]=1;
for(int i=1;i<=n;i++)
{
    pre[0]=dp[i-1][0];
    for(int j=1;j<=k;j++)
    pre[j]=(pre[j-1]+dp[i-1][j])%hell;
    for(int j=0;j<=k;j++)
    {
        int l=max((int)0,j-a[i]),r=j;
        dp[i][j]=pre[r]-((l>=1)?pre[l-1]:0);
        dp[i][j]=(dp[i][j]+hell)%hell;
        //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
    }
}
//cout<<dp[1][1]<<endl;
cout<<dp[n][k]<<endl;




}




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

Measured memory_bytes: 82524
w1, w2, s1, s2, s_max, b_max = map(int, input().split())
waters = [0]
waters_base = [0]
while len(waters_base) > 0:
    base = waters_base.pop()
    water1 = base + 100 * w1
    water2 = base + 100 * w2
    if water1 not in waters and water1 <= b_max:
        waters.append(water1)
        waters_base.append(water1)
    if water2 not in waters and water2 <= b_max:
        waters.append(water2)
        waters_base.append(water2)
waters.pop(0)
sugars = [0]
sugars_base = [0]
while len(sugars_base) > 0:
    base = sugars_base.pop()
    sugar1 = base + s1
    sugar2 = base + s2
    if sugar1 not in sugars and sugar1 <= b_max:
        sugars.append(sugar1)
        sugars_base.append(sugar1)
    if sugar2 not in sugars and sugar2 <= b_max:
        sugars.append(sugar2)
        sugars_base.append(sugar2)
max_radio = -1
result = (-1, -1)
for water in waters:
    for sugar in sugars:
        if b_max < water + sugar:
            continue
        if water // 100 * s_max < sugar:
            continue
        ratio = sugar / (water + sugar)
        if max_radio < ratio:
            max_radio = ratio
            result = (water + sugar, sugar)
print(*result)


Measured memory_bytes: 3064
d = list(map(int, input().split()))

tmp = 0
if (d[0] == 0 and d[1] >= 100):
     tmp = d[1] / 100
if (d[0] == 1 and d[1] == 100):
     tmp = 100
if (d[0] == 2 and d[1] == 100):
    tmp = 10000

print(int(pow(100, d[0]) * d[1] + tmp));


Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]", Q: int, K: int, x: "List[int]", y: "List[int]"):

    """graph.input.linkedlist_with_weight
        input: u[]:start, v[]:end, w[]:weight
        output:g[][]
    """
    g = [[] for i in range(N+1)]
    for i in range(N-1):
        g[a[i]].append([b[i], c[i]])
        g[b[i]].append([a[i], c[i]])

    def dikstra(nodes: int, graph: "List[List[int, int]]", start: int):
        """dikstra
        
        Arguments:
            nodes {int} -- Nodes in graph
            graph {List["List[int, int]"]} -- graph (adjancency matrix)
            start {int} -- start point
        
        Returns:
            [type] -- great distances from start point to each nodes in graph
        """
        INF = 1<<48
        from heapq import heapify, heappop, heappush
        hq = []
        heapify(hq)
        # i-indexed
        colors = ['W'] * (nodes+1)
        d = [INF] * (nodes+1)
        d[start] = 0
    
        heappush(hq, [start, start])
        colors[start] = 'G'
    
        while hq:
            f = hq.pop()
            u = f[1]
            colors[u]= 'B'
            
            if d[u] < -f[0]:
                continue
    
            for adj_i in graph[u]:
                v = adj_i[0]
                if colors[v] == 'B':
                    continue
                if d[v] > d[u] + adj_i[1]:
                    d[v] = d[u] + adj_i[1]
                    heappush(hq, [-d[v], v])
                    colors[v] = 'G'
        return d
    
    d = dikstra(N, g, K)

    for i in range(Q):
        print(d[x[i]]+d[y[i]])

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    c = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    Q = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [int()] * (Q)  # type: "List[int]"
    y = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, a, b, c, Q, K, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 69428
#import<bits/stdc++.h>
#define L long
#define t first
#define u second
#define M push_back(make_pair(c(
using namespace std;L R,C,N,a[9<<14],b,i;vector<pair<L,L>> p;L s(L x,L y){return!(x^0&&x^R&&y^0&&y^C);}L c(L x,L y){return L(atan2(x-R/2,y-C/2)*(1<<30));}main(){for(cin>>R>>C>>N;i<N;++i){cin>>*a>>a[1]>>a[2]>>a[3];if(s(*a,a[1])&&s(a[2],a[3]))p.M*a,a[1]),i)),p.M a[2],a[3]),i));}sort(p.begin(),p.end());fill(a,a+N,0);stack<L>s;for(auto P:p)if(s.empty()||s.top()^P.u)s.push(P.u);else s.pop();puts(s.size()?"NO":"YES");}

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

long long n,a,m,k,q,b,c=1;
string ss,s1,s2;
int main(){
    cin>>a>>b;
    if (a<b){
        cout<<0<<endl;
    }
    else{
        cout<<10<<endl;
    }
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z int
var mod int = pow(10, 9) + 7
var pi float64 = math.Pi
var ans, cnt int

func main() {
	var s string
	fmt.Scan(&s)

	var b, cnt_bef, cnt_aft int
	for i := 0; i < len(s); i++ {
		if string(s[i]) == "B" {
			cnt_bef += i
			b++
		}
	}
	for i := len(s) - 1; (len(s)-1)-(b-1) <= i; i-- {
		cnt_aft += i
	}
	fmt.Println(cnt_aft - cnt_bef)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] > a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 2048
import java.util.*;
import java.io.*;

class Main {

	void solve () {

		int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
		out.println(Math.max(0,c-(a-b)));
		
	}

	public static PrintWriter out = new PrintWriter(System.out);
	public static Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using tll = tuple<ll,ll,ll>;
using vtll = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

// https://www.hamayanhamayan.com/entry/2019/02/03/234144

// k以下の任意の数を決めて、数列aとのxorの和の最大値を求める問題
// 各桁について独立に考える(k<=10^12 なので、40bit程度まで見る)

ll dp[100][2]; // ibit目まで確定していて、k以下であるかがjという状態であるときの、f(X) の最大値

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  
  vll a(n);
  rep(i,n) cin>>a[i];
  
  memset(dp,-1,sizeof(dp));
  dp[0][0]=0;
  
  rep(i,40) rep(j,2){
    if(dp[i][j]<0) continue;
    ll d=40-i-1;
    ll mask=1LL<<d;
    
    // 数列aにおいて、maskに対応するbitが1であるものと0であるものの個数を数える
    ll zero=0, one=0;
    rep(i,n){
      if(a[i]&mask) one++;
      else zero++;
    }
    
    ll nj=j;
    // kのmaskに対応するbitが1であり、今見ている数のmaskに対応するbitが0であるとき、その数はk未満であることが確定する
    if(k&mask) nj=1;
    // 今見ている桁を0とした場合
    // 今見ている桁が0であるなら、上でカウントしたoneの数*maskだけ加算される
    chmax(dp[i+1][nj],dp[i][j]+one*mask);
    
    // 今見ている桁を1とした場合
    // 今見ている桁が1であるなら、上でカウントしたzeroの数*maskだけ加算される
    // NOTE: (k&mask) or j==1) の意味
    // (k&mask) or j==1) を反転すると、(k&mask==0) && j==0 である
    // kの対応する桁は0でありj==0つまりk未満であることが未確定の状態であるなら、
    // 今見ている桁が1とすると、その数はkより大きい数であることが確定するので、その数は対象から外す必要がある
    if((k&mask) or j==1) chmax(dp[i+1][j],dp[i][j]+zero*mask);
  }
  
  cout<<max(dp[40][0],dp[40][1])<<endl;
}

Measured memory_bytes: 1024
N, C = map(int, input().split())
x = [0]
v = [0]
for _ in range(N):
    a, b = map(int, input().split())
    x.append(a)
    v.append(b)
opt_l = [0]
acc_v = 0
for i in range(1, N + 1):
    opt_l.append(max(opt_l[-1], v[i] + acc_v - x[i]))
    acc_v += v[i]
opt_r = [0]
acc_v = 0
for i in range(1, N + 1):
    opt_r.append(max(opt_r[-1], v[-i] + acc_v - (C - x[-i])))
    acc_v += v[-i]
ans = 0
acc_v = 0
for i in range(N + 1):
    ans = max(
        ans,
        acc_v + v[i] - x[i],
        acc_v + v[i] - 2 * x[i] + opt_r[N - i]
    )
    acc_v += v[i]
acc_v = 0
for i in range(N + 1):
    ans = max(
        ans,
        acc_v + v[-i] - (C - x[-i]),
        acc_v + v[-i] - 2 * (C - x[-i]) + opt_l[N - i]
    )
    acc_v += v[-i]
print(ans)

Measured memory_bytes: 18912
def bubbleSort(a,n)
	$count = 0
	flag = true
	while flag
		flag = false
		(n-1).downto(1){|i|
			if a[i]<a[i-1]
				$count += 1
				tmp=a[i];a[i]=a[i-1];a[i-1]=tmp
				flag = true
			end
		}
	end

end


n = gets.to_i
a=gets.split.collect{|f|f.to_i}

bubbleSort a,n
puts a*' '
puts $count

Measured memory_bytes: 8688
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, k; cin >> n >> k;
    vector<ll> h(n);
    REP(i, n) cin >> h[i];
    sort(ALL(h));
    ll min_num = INF;
    REP(i, n - k + 1) {
        ll num = h[i+k-1] - h[i];
        min_num = min(min_num, num);
    }
    cout << min_num << endl;
    return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())

AB = [0]*N
for i in range(N):
    AB[i] = tuple(map(int, input().split()))
AB.sort()

money = 0 
for A, B in AB: 
    if B <= M:
        money += A*B 
    else:
        money += A*M 
        break
    M -= B                                                                                                     

print(money)

Measured memory_bytes: 16948
N,K,S = list(map(int, input().split()))

## 1,2,3,...,N
## 1<= A <= 1e9
## sum=S, pairs=K
# K<N//2, S,MAX,S,MAX,...
# K>N//2, 

adv = 10**9 if S < 10**9 else 10**9 - 1

ans = [S] * K + [adv] * (N-K)
print(" ".join(map(str, ans)))

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

int main()
{
	int n, m = 0;
	int a[20], b[20], c[19];

	cin >> n;

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

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

	for (int i = 0; i < n - 1; i++)
		cin >> c[i];

	for (int i = 0; i < n; i++) {
		m += b[a[i] - 1];
		if (i > 0 && a[i] == a[i - 1] + 1)
			m += c[a[i - 1] - 1];
	}

	cout << m << endl;

	return 0;
}

Measured memory_bytes: 256
def f(s, t):
    res = 0
    for i in set(s):
        for j in set(t):
            if i == j:
                res += 1
    return res

N = int(input())
S = input()
ans = 0
for i in range(N):
    ans = max(ans, f(S[:i], S[i:]))
print(ans)

Measured memory_bytes: 3060
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int dfs(int n, int sum, int k, int sn) {
	int ret = 0;
	if (k == 0) {
		if (sn == sum) {
			return 1;
		}
		else {
			return 0;
		}
	}
	if (sn > sum || n == 0) {
		return 0;
	}

	ret += dfs(n-1, sum, k-1, sn+n);
	ret += dfs(n-1, sum, k, sn);
	
	return ret;
}

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

	while ( n != 0 || k != 0 || s!= 0 ) {
		int count = dfs(n,s,k,0);
		cout << count << endl;

		cin >> n;
		cin >> k;
		cin >> s;
	}

	return 0;
}

Measured memory_bytes: 2988
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
  char s[10];
  scanf("%s",s);
  if(s[0] ==s[1] &&s[1] !=s[2] &&s[2] ==s[3])
    printf("Yes\n");
  else if(s[0] ==s[2] &&s[2] !=s[1] &&s[1] ==s[3])
    printf("Yes\n");
  else if(s[0] ==s[3] &&s[3] !=s[1] &&s[1] ==s[2])
    printf("Yes\n");
  else printf("No\n");
}

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

struct Point
{
  int32_t x, y;
  
  Point(int32_t x, int32_t y) : x(x), y(y) {}
  
  bool operator<(const Point &p) const {
    return (y == p.y) ? x < p.x : y < p.y;
  }
};

std::ostream& operator<<(std::ostream &os, const Point &p)
{
  os << p.y << ' ' << p.x;
  return os;
}

struct Pair
{
  Point src, dst;
  
  Pair(const Point &src, const Point &dst) : src(src), dst(dst) {}
};

std::ostream& operator<<(std::ostream &os, const Pair &p)
{
  os << p.src << ' ' << p.dst;
  return os;
}

int main()
{
  uint32_t H, W;
  std::cin >> H >> W;
  
  std::vector< std::vector<uint32_t> > a(H);
  for (uint32_t h = 0; h < H; ++h) {
    a[h] = std::vector<uint32_t>(W);
    for (uint32_t w = 0; w < W; ++w) {
      std::cin >> a[h][w];
    }
  }
  
  uint32_t da = 0;
  Point prev(1, 1);
  std::list<Pair> list;
  for (uint32_t h = 0; h < H; ++h) {
    if (h % 2 == 0) {
      for (int32_t w = 0; w < W; ++w) {
        if (w == 0 && h == 0) {
          da = a[h][w] % 2;
          
          prev = Point(1, 1);
          
          continue;
        }
        
        if (da == 1) {
          list.emplace_back(prev, Point(w + 1, h + 1));
        }
        
        if ((a[h][w] + da) % 2 == 1) {
          da = 1;
        } else {
          da = 0;
        }
        
        prev = Point(w + 1, h + 1);
      }
    } else {
      for (int32_t w = W - 1; w >= 0; --w) {
        if (da == 1) {
          list.emplace_back(prev, Point(w + 1, h + 1));
        }
        
        if ((a[h][w] + da) % 2 == 1) {
          da = 1;
        } else {
          da = 0;
        }
        
        prev = Point(w + 1, h + 1);
      }
    }
  }
  
  std::cout << list.size() << std::endl;
  for (const Pair &pair : list) {
    std::cout << pair << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 8960
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = in.readLine().toInt
    val as = in.readLine().split("\\s+").map(_.toInt).sorted

    @tailrec
    def solve(acc: Long, t: Int, k: Int, as: List[Int]): Int = {
      as match {
        case ak :: aip1 :: rest =>
          val new_acc = acc + 2L * ak
          if (new_acc < aip1) {
            solve(new_acc, k, k + 1, aip1 :: rest)
          } else {
            solve(new_acc, t, k + 1, aip1 :: rest)
          }
        case _ =>
          t
      }
    }

    out.println(n - solve(0L, -1, 0, as.toList) - 1)
    out.flush()
  }
}


Measured memory_bytes: 53356
#coding: UTF-8
N=int(input())
lis=list(map(int, input().split()))
kind_dict={}
for i in lis:
    if i in kind_dict:
        kind_dict[i]+=1
    else:
        kind_dict[i]=1
kindn=len(kind_dict)
out=0
for i in kind_dict:
    if kind_dict[i]%2==0:
        out+=1
if out%2==0:
    print(kindn)
else:
    print(kindn-1)

Measured memory_bytes: 17400
fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map { it.toInt() }
    val s = mutableListOf<CharArray>()
    (1..H).forEach {
        s.add(readLine()!!.map { it }.toCharArray())
    }

    fun continuesAreaSize(h: Int, w: Int) : Int {
        val arePramsValid = 0 <= w && w < W && 0 <= h && h < H
        if (!arePramsValid) {
            return 0
        }

        if (s[h][w] == '.') {
            return 0
        }

        // Mark as visited
        s[h][w] = '.'
        return 1 + continuesAreaSize(h + 1, w) + continuesAreaSize(h - 1, w) + continuesAreaSize(h, w + 1) + continuesAreaSize(h, w - 1)
    }

    (0..(H-1)).forEach {h ->
        (0..(W-1)).forEach {w ->
            if (s[h][w] != '.') {
                if (continuesAreaSize(h, w) == 1) {
                    println("No")
                    return
                }
            }
        }
    }
    println("Yes")
}


Measured memory_bytes: 37996